diff --git a/rocclr/runtime/device/device.cpp b/rocclr/runtime/device/device.cpp index d4df1d28fc..daa8726d27 100644 --- a/rocclr/runtime/device/device.cpp +++ b/rocclr/runtime/device/device.cpp @@ -198,18 +198,14 @@ void Device::tearDown() { #endif // WITH_PAL_DEVICE } -Device::Device(Device* parent) +Device::Device() : settings_(NULL), online_(true), blitProgram_(NULL), hwDebugMgr_(NULL), - parent_(parent), vaCacheAccess_(nullptr), vaCacheMap_(nullptr) { memset(&info_, '\0', sizeof(info_)); - if (parent_ != NULL) { - parent_->retain(); - } } Device::~Device() { @@ -223,12 +219,8 @@ Device::~Device() { delete settings_; } - if (parent_ != NULL) { - parent_->release(); - } else { - if (info_.extensions_ != NULL) { - delete[] info_.extensions_; - } + if (info_.extensions_ != NULL) { + delete[] info_.extensions_; } } @@ -244,15 +236,6 @@ bool Device::create() { return true; } -bool Device::isAncestor(const Device* sub) const { - for (const Device* d = sub->parent_; d != NULL; d = d->parent_) { - if (d == this) { - return true; - } - } - return false; -} - void Device::registerDevice() { assert(Runtime::singleThreaded() && "this is not thread-safe"); diff --git a/rocclr/runtime/device/device.hpp b/rocclr/runtime/device/device.hpp index b3683bed81..a9fa1635a6 100644 --- a/rocclr/runtime/device/device.hpp +++ b/rocclr/runtime/device/device.hpp @@ -1411,24 +1411,12 @@ class Device : public RuntimeObject { virtual Compiler* compiler() const = 0; - Device(Device* parent = NULL); + Device(); virtual ~Device(); //! Initializes abstraction layer device object bool create(); - //! Increment the reference count - uint retain() { - // Only increment the reference count of sub-devices - return !isRootDevice() ? RuntimeObject::retain() : 0u; - } - - //! Decrement the reference count - uint release() { - // Only decrement the reference count of sub-devices - return !isRootDevice() ? RuntimeObject::release() : 0u; - } - //! Register a device as available void registerDevice(); @@ -1561,30 +1549,6 @@ class Device : public RuntimeObject { //! Returns TRUE if the device is available for computations bool isOnline() const { return online_; } - //! Returns TRUE if the device is a root device (as opposed to sub-device) - bool isRootDevice() const { return parent_ == NULL; } - //! Returns TRUE if 'this' is an ancestor of the given sub-device. - bool isAncestor(const Device* sub) const; - - //! Return the parent device. - Device* parent() const { return parent_; } - - //! Return the root device for this instance; - Device& rootDevice() { - Device* root = this; - while (!root->isRootDevice()) { - root = root->parent_; - } - return *root; - } - - const Device& rootDevice() const { - const Device* root = this; - while (!root->isRootDevice()) { - root = root->parent_; - } - return *root; - } //! Returns device settings const device::Settings& settings() const { return *settings_; } @@ -1643,7 +1607,6 @@ class Device : public RuntimeObject { static std::vector* devices_; //!< All known devices - Device* parent_; //!< This device's parent Monitor* vaCacheAccess_; //!< Lock to serialize VA caching access std::map* vaCacheMap_; //!< VA cache map }; diff --git a/rocclr/runtime/device/gpu/gpudevice.cpp b/rocclr/runtime/device/gpu/gpudevice.cpp index 76b9aec392..2033f7bc99 100644 --- a/rocclr/runtime/device/gpu/gpudevice.cpp +++ b/rocclr/runtime/device/gpu/gpudevice.cpp @@ -63,7 +63,7 @@ aclCompiler* NullDevice::hsaCompiler_; AppProfile Device::appProfile_; NullDevice::NullDevice() - : amd::Device(NULL), calTarget_(static_cast(0)), hwInfo_(NULL) {} + : amd::Device(), calTarget_(static_cast(0)), hwInfo_(NULL) {} bool NullDevice::init() { std::vector devices; diff --git a/rocclr/runtime/device/pal/paldevice.cpp b/rocclr/runtime/device/pal/paldevice.cpp index e0663d7cdc..1a37e2c2d7 100644 --- a/rocclr/runtime/device/pal/paldevice.cpp +++ b/rocclr/runtime/device/pal/paldevice.cpp @@ -62,7 +62,7 @@ NullDevice::Compiler* NullDevice::compiler_; AppProfile Device::appProfile_; NullDevice::NullDevice() - : amd::Device(nullptr), ipLevel_(Pal::GfxIpLevel::None), hwInfo_(nullptr) {} + : amd::Device(), ipLevel_(Pal::GfxIpLevel::None), hwInfo_(nullptr) {} bool NullDevice::init() { std::vector devices; diff --git a/rocclr/runtime/platform/context.cpp b/rocclr/runtime/platform/context.cpp index 661558db61..71dfc28fac 100644 --- a/rocclr/runtime/platform/context.cpp +++ b/rocclr/runtime/platform/context.cpp @@ -315,9 +315,8 @@ void Context::svmFree(void* ptr) const { } bool Context::containsDevice(const Device* device) const { - for (const auto& it : devices_) { - if (device == it || it->isAncestor(device)) { + if (device == it) { return true; } } diff --git a/rocclr/runtime/platform/program.cpp b/rocclr/runtime/platform/program.cpp index 8515cf3ada..055c351b07 100644 --- a/rocclr/runtime/platform/program.cpp +++ b/rocclr/runtime/platform/program.cpp @@ -62,7 +62,7 @@ cl_int Program::addDeviceProgram(Device& device, const void* image, size_t lengt return CL_INVALID_VALUE; } - Device& rootDev = device.rootDevice(); + Device& rootDev = device; // if the rootDev is already associated with a program if (devicePrograms_[&rootDev] != NULL) { @@ -150,7 +150,7 @@ cl_int Program::addDeviceProgram(Device& device, const void* image, size_t lengt } device::Program* Program::getDeviceProgram(const Device& device) const { - const auto it = devicePrograms_.find(&device.rootDevice()); + const auto it = devicePrograms_.find(&device); if (it == devicePrograms_.cend()) { return NULL; } @@ -613,20 +613,11 @@ bool Symbol::setDeviceKernel(const Device& device, const device::Kernel* func) { } const device::Kernel* Symbol::getDeviceKernel(const Device& device) const { - const devicekernels_t* devKernels = &deviceKernels_; - const auto itEnd = devKernels->cend(); - auto it = devKernels->find(&device); - if (it != itEnd) { + auto it = deviceKernels_.find(&device); + if (it != deviceKernels_.cend()) { return it->second; } - - for (it = devKernels->cbegin(); it != itEnd; ++it) { - if (it->first->isAncestor(&device)) { - return it->second; - } - } - - return NULL; + return nullptr; } } // namespace amd diff --git a/rocclr/runtime/platform/program.hpp b/rocclr/runtime/platform/program.hpp index b5b99aa181..dda488c90c 100644 --- a/rocclr/runtime/platform/program.hpp +++ b/rocclr/runtime/platform/program.hpp @@ -149,7 +149,7 @@ class Program : public RuntimeObject { const Symbol* findSymbol(const char* name) const; //! Return the binary image. - const binary_t& binary(const Device& device) { return binary_[&device.rootDevice()]; } + const binary_t& binary(const Device& device) { return binary_[&device]; } //! Return the program kernel names const std::string& kernelNames() const { return kernelNames_; }