diff --git a/projects/clr/rocclr/platform/command.cpp b/projects/clr/rocclr/platform/command.cpp index b61159b99d..a4133bb957 100644 --- a/projects/clr/rocclr/platform/command.cpp +++ b/projects/clr/rocclr/platform/command.cpp @@ -318,16 +318,15 @@ Command::Command(HostQueue& queue, cl_command_type type, const EventWaitList& ev } } -SysmemPool Command::command_pool_ ROCCLR_INIT_PRIORITY(101); - +SysmemPool* Command::command_pool_ = new SysmemPool; // ================================================================================================ void Command::operator delete(void* ptr) { - command_pool_.Free(ptr); + return command_pool_->Free(ptr); } // ================================================================================================ void* Command::operator new(size_t size) { - return command_pool_.Alloc(size); + return command_pool_->Alloc(size); } // ================================================================================================ diff --git a/projects/clr/rocclr/platform/command.hpp b/projects/clr/rocclr/platform/command.hpp index 2ed4d212e0..1a98349172 100644 --- a/projects/clr/rocclr/platform/command.hpp +++ b/projects/clr/rocclr/platform/command.hpp @@ -260,7 +260,7 @@ class GraphKernelArgManager { */ class Command : public Event { private: - static SysmemPool command_pool_; //!< Pool of active commands + static SysmemPool *command_pool_; //!< Pool of active commands HostQueue* queue_; //!< The command queue this command is enqueue into Command* next_; //!< Next GPU command in the queue list Command* batch_head_ = nullptr; //!< The head of the batch commands @@ -310,6 +310,12 @@ class Command : public Event { public: //! Returns AQL buffer state + static void ReleaseSysmemPool() { + if (command_pool_ != nullptr) { + delete command_pool_; + command_pool_ = nullptr; + } + } bool getCapturingState() const { return capturing_; } //! Sets AQL capture state, aql packet to capture and where to copy kernArgs diff --git a/projects/clr/rocclr/platform/runtime.cpp b/projects/clr/rocclr/platform/runtime.cpp index 8efcdab216..c170b11259 100644 --- a/projects/clr/rocclr/platform/runtime.cpp +++ b/projects/clr/rocclr/platform/runtime.cpp @@ -97,6 +97,7 @@ void Runtime::tearDown() { if (outFile != stderr && outFile != nullptr) { fclose(outFile); } + Command::ReleaseSysmemPool(); initialized_ = false; }