From 6bb7d1afdc776be5edcc9a02dda20a0297046eff Mon Sep 17 00:00:00 2001 From: German Andryeyev Date: Fri, 18 Oct 2024 09:46:24 -0400 Subject: [PATCH] SWDEV-486602 - Fix Windows 32 bit build Windows alings fields to 8 bytes even with 32bit builds. Add BUG_CLR_SYSMEM_POOL to cotnrol sysmempool. Change-Id: I8622aabc9f7391ed7dd8583b252ce9eb41d62293 --- rocclr/platform/command.cpp | 12 ++++++++++-- rocclr/platform/object.hpp | 10 ++++++---- rocclr/utils/flags.hpp | 2 ++ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/rocclr/platform/command.cpp b/rocclr/platform/command.cpp index 6ad49c43e4..363012e607 100644 --- a/rocclr/platform/command.cpp +++ b/rocclr/platform/command.cpp @@ -321,12 +321,20 @@ Command::Command(HostQueue& queue, cl_command_type type, const EventWaitList& ev SysmemPool* Command::command_pool_ = new SysmemPool; // ================================================================================================ void Command::operator delete(void* ptr) { - return command_pool_->Free(ptr); + if (DEBUG_CLR_SYSMEM_POOL) { + command_pool_->Free(ptr); + } else { + ::operator delete (ptr); + } } // ================================================================================================ void* Command::operator new(size_t size) { - return command_pool_->Alloc(size); + if (DEBUG_CLR_SYSMEM_POOL) { + return command_pool_->Alloc(size); + } else { + return ::operator new (size); + } } // ================================================================================================ diff --git a/rocclr/platform/object.hpp b/rocclr/platform/object.hpp index dece674ea5..f6f5f1a99f 100644 --- a/rocclr/platform/object.hpp +++ b/rocclr/platform/object.hpp @@ -256,14 +256,17 @@ public: // Save the chunk allocation obj->base_ = active_allocs_[chunk_idx]->base_; obj->base_->busy_++; - assert((reinterpret_cast
(&obj->object_) - - reinterpret_cast
(obj)) == sizeof(AllocChunk*) && "Incorrect mem obj offset!"); return &obj->object_; } void Free(void* ptr) { +#if IS_WINDOWS auto obj = reinterpret_cast( - reinterpret_cast
(ptr) - sizeof(MemoryObject*)); + reinterpret_cast
(ptr) - offsetof(MemoryObject, object_)); +#else + auto obj = reinterpret_cast( + reinterpret_cast
(ptr) - sizeof(AllocChunk*)); +#endif auto freed = --obj->base_->free_; // If it's the last slot in the chunk, then release memory if (freed == 0) { @@ -300,7 +303,6 @@ private: ~AllocChunk() { delete [] allocs_; } }; - std::atomic current_alloc_ = 0; //!< Current allocation, global index std::atomic max_chunk_idx_ = 0; //!< Current max chunk index size_t free_chunk_num_ = 0; //!< The number of freed chunks diff --git a/rocclr/utils/flags.hpp b/rocclr/utils/flags.hpp index 5d39181b8f..9fc958809d 100644 --- a/rocclr/utils/flags.hpp +++ b/rocclr/utils/flags.hpp @@ -261,6 +261,8 @@ release(uint, DEBUG_HIP_BLOCK_SYNC, 50, \ "Blocks synchronization on CPU until the callback processing is done")\ release(uint, DEBUG_CLR_MAX_BATCH_SIZE, 1000, \ "Forces the callback to clean-up CPU submission queue") \ +release(bool, DEBUG_CLR_SYSMEM_POOL, true, \ + "Use sysmem pool implementation in runtime for amd commands") \ release(bool, DEBUG_HIP_KERNARG_COPY_OPT, true, \ "Enable/Disable multiple kern arg copies") \ release(bool, DEBUG_CLR_USE_STDMUTEX_IN_AMD_MONITOR, false, \