diff --git a/rocclr/runtime/device/rocm/rocmemory.cpp b/rocclr/runtime/device/rocm/rocmemory.cpp index 2b68d53143..48bbfee444 100644 --- a/rocclr/runtime/device/rocm/rocmemory.cpp +++ b/rocclr/runtime/device/rocm/rocmemory.cpp @@ -708,7 +708,7 @@ bool Buffer::create() { // data transfer to the view of the buffer. amd::Buffer* bufferView = new (owner()->getContext()) amd::Buffer(*owner(), 0, owner()->getOrigin(), owner()->getSize()); - bufferView->create(); + bufferView->create(nullptr, false, true); roc::Buffer* devBufferView = new roc::Buffer(dev_, *bufferView); devBufferView->deviceMemory_ = deviceMemory_; diff --git a/rocclr/runtime/platform/memory.cpp b/rocclr/runtime/platform/memory.cpp index b17f4032c2..2f00dd8f08 100644 --- a/rocclr/runtime/platform/memory.cpp +++ b/rocclr/runtime/platform/memory.cpp @@ -205,7 +205,7 @@ bool Memory::allocHostMemory(void* initFrom, bool allocHostMem, bool forceCopy) return true; } -bool Memory::create(void* initFrom, bool sysMemAlloc) { +bool Memory::create(void* initFrom, bool sysMemAlloc, bool skipAlloc) { static const bool forceAllocHostMem = false; initDeviceMemory(); @@ -238,7 +238,7 @@ bool Memory::create(void* initFrom, bool sysMemAlloc) { deviceMemories_[i].ref_ = devices[i]; deviceMemories_[i].value_ = NULL; - if ((devices.size() == 1) || DISABLE_DEFERRED_ALLOC) { + if (!skipAlloc && ((devices.size() == 1) || DISABLE_DEFERRED_ALLOC)) { device::Memory* mem = getDeviceMemory(*devices[i]); if (NULL == mem) { LogPrintfError("Can't allocate memory size - 0x%08X bytes!", getSize()); @@ -436,7 +436,7 @@ void Buffer::initDeviceMemory() { memset(deviceMemories_, 0, context_().devices().size() * sizeof(DeviceMemory)); } -bool Buffer::create(void* initFrom, bool sysMemAlloc) { +bool Buffer::create(void* initFrom, bool sysMemAlloc, bool skipAlloc) { if ((getMemFlags() & CL_MEM_EXTERNAL_PHYSICAL_AMD) && (initFrom != NULL)) { busAddress_ = *(reinterpret_cast(initFrom)); initFrom = NULL; @@ -444,7 +444,7 @@ bool Buffer::create(void* initFrom, bool sysMemAlloc) { busAddress_.surface_bus_address = 0; busAddress_.marker_bus_address = 0; } - return Memory::create(initFrom, sysMemAlloc); + return Memory::create(initFrom, sysMemAlloc, skipAlloc); } bool Buffer::isEntirelyCovered(const Coord3D& origin, const Coord3D& region) const { diff --git a/rocclr/runtime/platform/memory.hpp b/rocclr/runtime/platform/memory.hpp index 53714d58b2..ec31e4eebe 100644 --- a/rocclr/runtime/platform/memory.hpp +++ b/rocclr/runtime/platform/memory.hpp @@ -228,7 +228,8 @@ class Memory : public amd::RuntimeObject { //! Creates and initializes device (cache) memory for all devices virtual bool create(void* initFrom = NULL, //!< Pointer to the initialization data - bool sysMemAlloc = false //!< Allocate device memory in system memory + bool sysMemAlloc = false, //!< Allocate device memory in system memory + bool skipAlloc = false //!< Skip device memory allocation ); //! Allocates device (cache) memory for a specific device @@ -338,7 +339,8 @@ class Buffer : public Memory { : Memory(parent, flags, origin, size) {} bool create(void* initFrom = NULL, //!< Pointer to the initialization data - bool sysMemAlloc = false //!< Allocate device memory in system memory + bool sysMemAlloc = false, //!< Allocate device memory in system memory + bool skipAlloc = false //!< Skip device memory allocation ); //! static_cast to Buffer with sanity check