diff --git a/src/umpire/strategy/ResourceAwarePool.cpp b/src/umpire/strategy/ResourceAwarePool.cpp index 58978c4e2..3b7ddc044 100644 --- a/src/umpire/strategy/ResourceAwarePool.cpp +++ b/src/umpire/strategy/ResourceAwarePool.cpp @@ -216,6 +216,7 @@ void ResourceAwarePool::do_deallocate(Chunk* chunk, void* ptr) noexcept UMPIRE_LOG(Debug, "Merging with prev" << prev << " and " << chunk); UMPIRE_LOG(Debug, "New size: " << prev->size); + chunk->~Chunk(); //manually call destructor m_chunk_pool.deallocate(chunk); chunk = prev; } @@ -225,7 +226,6 @@ void ResourceAwarePool::do_deallocate(Chunk* chunk, void* ptr) noexcept chunk->size += next->size; chunk->next = next->next; - // TODO: Double check this chunk->m_event = next->m_event; chunk->m_resource = next->m_resource; @@ -238,6 +238,7 @@ void ResourceAwarePool::do_deallocate(Chunk* chunk, void* ptr) noexcept UMPIRE_LOG(Debug, "Removing chunk" << next << " from size map"); m_free_map.erase(next->size_map_it); + next->~Chunk(); //manually call destructor m_chunk_pool.deallocate(next); } @@ -340,6 +341,7 @@ void ResourceAwarePool::release() } } + chunk->~Chunk(); //manually call destructor m_chunk_pool.deallocate(chunk); pair = m_free_map.erase(pair); } else { diff --git a/tests/integration/resource_aware_pool_tests.cpp b/tests/integration/resource_aware_pool_tests.cpp index f44f44986..41aaf19c5 100644 --- a/tests/integration/resource_aware_pool_tests.cpp +++ b/tests/integration/resource_aware_pool_tests.cpp @@ -34,31 +34,29 @@ TEST(ResourceAwarePool_Host_Test, Check_States_Host) auto& rm = umpire::ResourceManager::getInstance(); auto pool = rm.makeAllocator("rap-pool-host", rm.getAllocator("HOST")); - Host h1, h2; - Resource r1{h1}, r2{h2}; + Resource r1{Host{}}, r2{Host{}}; int* ptr = static_cast(pool.allocate(r1, 1024)); - // int* compare_ptr1 = ptr; + int* compare_ptr1 = ptr; - // EXPECT_EQ(getResource(pool, ptr), r1); - // EXPECT_EQ(getPendingSize(pool), 0); + EXPECT_EQ(getResource(pool, ptr), r1); + EXPECT_EQ(getPendingSize(pool), 0); - // host_sleep(ptr); + host_sleep(ptr); pool.deallocate(r1, ptr); - // EXPECT_EQ(getPendingSize(pool), 0); // When only using host, there will be no pending chunks + EXPECT_EQ(getPendingSize(pool), 0); // When only using host, there will be no pending chunks - /* - ptr = static_cast(pool.allocate(r2, 2048)); - int* compare_ptr2 = ptr; + + ptr = static_cast(pool.allocate(r2, 2048)); + int* compare_ptr2 = ptr; - EXPECT_TRUE(r1 == r2); - EXPECT_EQ(compare_ptr1, compare_ptr2); // only 1 host resource available, no possible data race + EXPECT_TRUE(r1 == r2); + EXPECT_EQ(compare_ptr1, compare_ptr2); // only 1 host resource available, no possible data race - pool.deallocate(r2, ptr); - pool.release(); - */ + pool.deallocate(r2, ptr); + } -/* + #if defined(UMPIRE_ENABLE_CUDA) || defined(UMPIRE_ENABLE_HIP) using clock_value_t = long long; @@ -158,4 +156,3 @@ TEST_P(ResourceAwarePoolTest, Check_States) INSTANTIATE_TEST_SUITE_P(ResourceAwarePoolTests, ResourceAwarePoolTest, ::testing::ValuesIn(get_allocator_strings())); #endif -*/