Skip to content

Commit

Permalink
Limit benchmark iterations using environment variable (NVIDIA#10060)
Browse files Browse the repository at this point in the history
To address part of rapidsai/cudf#5773
This allows to run benchmarks for only specific iterations using environment variable `CUDF_BENCHMARK_ITERATIONS`.
except when benchmark definition  itself specifies iteration count.

Also, makes pool as static to allocate pool memory resource only once per binary.

Authors:
  - Karthikeyan (https://github.com/karthikeyann)

Approvers:
  - Conor Hoekstra (https://github.com/codereport)
  - Vukasin Milovanovic (https://github.com/vuule)
  - Nghia Truong (https://github.com/ttnghia)

URL: rapidsai/cudf#10060
  • Loading branch information
karthikeyann authored Jan 25, 2022
1 parent b8d2969 commit a552afb
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions cpp/benchmarks/fixture/benchmark_fixture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ namespace {
// memory resource factory helpers
inline auto make_cuda() { return std::make_shared<rmm::mr::cuda_memory_resource>(); }

inline auto make_pool()
inline auto make_pool_instance()
{
return rmm::mr::make_owning_wrapper<rmm::mr::pool_memory_resource>(make_cuda());
static rmm::mr::cuda_memory_resource cuda_mr;
static rmm::mr::pool_memory_resource pool_mr{&cuda_mr};
return std::shared_ptr<rmm::mr::device_memory_resource>(&pool_mr);
}
} // namespace

Expand Down Expand Up @@ -68,9 +70,15 @@ inline auto make_pool()
*/
class benchmark : public ::benchmark::Fixture {
public:
benchmark() : ::benchmark::Fixture()
{
const char* env_iterations = std::getenv("CUDF_BENCHMARK_ITERATIONS");
if (env_iterations != nullptr) { this->Iterations(std::max(0L, atol(env_iterations))); }
}

void SetUp(const ::benchmark::State& state) override
{
mr = make_pool();
mr = make_pool_instance();
rmm::mr::set_current_device_resource(mr.get()); // set default resource to pool
}

Expand Down

0 comments on commit a552afb

Please sign in to comment.