diff --git a/rocclr/runtime/platform/memory.cpp b/rocclr/runtime/platform/memory.cpp index c8fa903a15..c792d3eb64 100644 --- a/rocclr/runtime/platform/memory.cpp +++ b/rocclr/runtime/platform/memory.cpp @@ -227,9 +227,12 @@ bool Memory::allocHostMemory(void* initFrom, bool allocHostMem, bool forceCopy) return true; } -bool Memory::create(void* initFrom, bool sysMemAlloc, bool skipAlloc) { +bool Memory::create(void* initFrom, bool sysMemAlloc, bool skipAlloc, bool forceAlloc) { static const bool forceAllocHostMem = false; + // Sanity checks (can't defer and force allocations at the same time) + assert(!(skipAlloc && forceAlloc)); + initDeviceMemory(); // Check if it's a subbuffer allocation @@ -260,7 +263,9 @@ bool Memory::create(void* initFrom, bool sysMemAlloc, bool skipAlloc) { deviceMemories_[i].ref_ = devices[i]; deviceMemories_[i].value_ = NULL; - if (!skipAlloc && ((devices.size() == 1) || DISABLE_DEFERRED_ALLOC)) { + if (forceAlloc || + (!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()); diff --git a/rocclr/runtime/platform/memory.hpp b/rocclr/runtime/platform/memory.hpp index 7711c19afa..ffd5a3f5ec 100644 --- a/rocclr/runtime/platform/memory.hpp +++ b/rocclr/runtime/platform/memory.hpp @@ -239,7 +239,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 skipAlloc = false //!< Skip device memory allocation + bool skipAlloc = false, //!< Skip device memory allocation + bool forceAlloc = false //!< Force device memory allocation ); //! Allocates device (cache) memory for a specific device