Fix a deadlock in ROCr backend

When OCL ROCr backend performs CL_MEM_COPY_HOST_PTR it may attempt
to have access to amd::Memory object it's currently creating,
but it's not ready yet. The logic creates a temporary dummy object
to perform a copy transfer. The new change will make sure runtime
skips allocation of the same device::Memory object second time.

Change-Id: I14c6a00a3941fdcaa6aea299e9f096e4c3f5cadf
This commit is contained in:
German Andryeyev
2020-12-07 23:01:12 -05:00
parent f403b1c079
commit 1fde842703
2 changed files with 18 additions and 10 deletions
+11 -4
View File
@@ -1167,10 +1167,10 @@ Image* Image::createView(const Context& context, const Format& format, device::V
// Find the image dimensions and create a corresponding object
view = new (context) Image(format, *this, baseMipLevel, flags);
// Set GPU virtual device for this view
view->setVirtualDevice(vDev);
if (view != nullptr) {
// Set GPU virtual device for this view
view->setVirtualDevice(vDev);
view->resetAllocationState();
// Initialize array of the device memory pointers
@@ -1178,7 +1178,14 @@ Image* Image::createView(const Context& context, const Format& format, device::V
// Check if runtime has to allocate memory
if ((context.devices().size() == 1) || DISABLE_DEFERRED_ALLOC) {
device::Memory* mem = view->getDeviceMemory(*context.devices()[0]);
for (uint i = 0; i < numDevices_; ++i) {
// Make sure the parent's device memory is avaialbe
if ((deviceMemories_[i].ref_ == context.devices()[i]) &&
(deviceMemories_[i].value_ != nullptr)) {
device::Memory* mem = view->getDeviceMemory(*context.devices()[i]);
break;
}
}
}
}