( + pool_name + , rm.getAllocator(m_resource_name) + , initial_pool_size + , min_pool_growth_size + , alignment + , Pool::percent_releasable(percentage) + ) + ); + } +}; + +TYPED_TEST_SUITE(PrimaryPoolTimingsTest, PoolTestTypes, ); + +TYPED_TEST(PrimaryPoolTimingsTest, TestCoalesceHeuristicTiming) +{ + // + // Make sure that the time taken to run with the percent_releaseable(100) + // heuristic is close to the same as the time taken to run + // with the percent_releaseable(0) heuristic + // + int64_t ms_h_100{0}; + int64_t ms_h_0{0}; + + this->run_test(this->m_allocator, ms_h_100); + this->run_test(this->m_allocator_no_coalesce, ms_h_0); + + int64_t delta{ std::abs(ms_h_100 - ms_h_0) }; + + const int64_t max_delta{ std::max((ms_h_100/4), INT64_C(25)) }; + + if (delta >= max_delta) { + std::cerr << "Difference between heuristic durations exceed maximum of: " + << max_delta << std::endl + << "Heuristic(100) Duration: " << ms_h_100 + << ", Heuristic(0) Duration: " << ms_h_0 << std::endl; + } + ASSERT_LT(delta, max_delta); +} diff --git a/tests/integration/reallocate_tests.cpp b/tests/integration/reallocate_tests.cpp new file mode 100644 index 000000000..d12391a92 --- /dev/null +++ b/tests/integration/reallocate_tests.cpp @@ -0,0 +1,20 @@ +#include "umpire/ResourceManager.hpp" + +#include "gtest/gtest.h" + +// Needs to be in separate file so that resources are not initialized prior to +// reallocate call +TEST(Reallocate, Nullptr) +{ + auto& rm = umpire::ResourceManager::getInstance(); + constexpr std::size_t size = 1024; + + void* ptr{nullptr}; + EXPECT_NO_THROW({ + ptr = rm.reallocate(ptr, size); + }); + + ASSERT_NE(nullptr, ptr); + + rm.deallocate(ptr); +}