From 322b50e683027eb7f3d963b01b55266b23aef7cc Mon Sep 17 00:00:00 2001 From: foreman Date: Tue, 4 Jun 2019 15:50:38 -0400 Subject: [PATCH] P4 to Git Change 1791677 by vsytchen@vsytchen-remote-ocl-win10 on 2019/06/04 13:42:04 SWDEV-79445 - OCL generic changes and code clean-up 1. Add a flag to amd::memory::create() to force the allocation on all available devices. ReviewBoardURL = http://ocltc.amd.com/reviews/r/17466/diff/ Affected files ... ... //depot/stg/opencl/drivers/opencl/runtime/platform/memory.cpp#137 edit ... //depot/stg/opencl/drivers/opencl/runtime/platform/memory.hpp#110 edit --- rocclr/runtime/platform/memory.cpp | 9 +++++++-- rocclr/runtime/platform/memory.hpp | 3 ++- 2 files changed, 9 insertions(+), 3 deletions(-) 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