@@ -233,19 +233,20 @@ void MemAllocatorTy::MemPoolTy::printUsage() {
233233}
234234
235235// / Release resources used in the pool.
236- MemAllocatorTy::MemPoolTy::~MemPoolTy () {
236+ Error MemAllocatorTy::MemPoolTy::deinit () {
237237 const int DebugLevel = getDebugLevel ();
238238 if (DebugLevel > 0 )
239239 printUsage ();
240240 for (auto &Bucket : Buckets) {
241241 for (auto *Block : Bucket) {
242242 if (DebugLevel > 0 )
243243 Allocator->log (0 , Block->Size , AllocKind);
244- CALL_ZE_RET_VOID (zeMemFree, Allocator->L0Context ->getZeContext (),
245- reinterpret_cast <void *>(Block->Base ));
244+ CALL_ZE_RET_ERROR (zeMemFree, Allocator->L0Context ->getZeContext (),
245+ reinterpret_cast <void *>(Block->Base ));
246246 delete Block;
247247 }
248248 }
249+ return Plugin::success ();
249250}
250251
251252// / Allocate the requested size of memory from this pool.
@@ -419,8 +420,23 @@ Error MemAllocatorTy::deinit() {
419420 if (Err)
420421 return Err;
421422 }
422- ReductionPool.reset (nullptr );
423- CounterPool.reset (nullptr );
423+ for (auto &Pool : Pools) {
424+ if (Pool) {
425+ if (auto Err = Pool->deinit ())
426+ return Err;
427+ Pool.reset (nullptr );
428+ }
429+ }
430+ if (ReductionPool) {
431+ if (auto Err = ReductionPool->deinit ())
432+ return Err;
433+ ReductionPool.reset (nullptr );
434+ }
435+ if (CounterPool) {
436+ if (auto Err = CounterPool->deinit ())
437+ return Err;
438+ CounterPool.reset (nullptr );
439+ }
424440 // Report memory usage if requested
425441 if (getDebugLevel () > 0 ) {
426442 for (auto &Stat : Stats) {
0 commit comments