Skip to content

Commit

Permalink
Enable running tests using RMM arena and async memory resources (#9506)
Browse files Browse the repository at this point in the history
Since Spark uses both the arena and the cuda async allocators, it is useful to run the c++ tests using these allocators.

Authors:
  - Rong Ou (https://github.com/rongou)

Approvers:
  - Jake Hemstad (https://github.com/jrhemstad)
  - Mark Harris (https://github.com/harrism)

URL: #9506
  • Loading branch information
rongou authored Oct 26, 2021
1 parent ca40e18 commit 5cd3003
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cpp/include/cudf_test/base_fixture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
#include <cudf_test/cxxopts.hpp>
#include <cudf_test/file_utilities.hpp>

#include <rmm/mr/device/arena_memory_resource.hpp>
#include <rmm/mr/device/binning_memory_resource.hpp>
#include <rmm/mr/device/cuda_async_memory_resource.hpp>
#include <rmm/mr/device/cuda_memory_resource.hpp>
#include <rmm/mr/device/managed_memory_resource.hpp>
#include <rmm/mr/device/owning_wrapper.hpp>
Expand Down Expand Up @@ -217,13 +219,20 @@ class TempDirTestEnvironment : public ::testing::Environment {
/// MR factory functions
inline auto make_cuda() { return std::make_shared<rmm::mr::cuda_memory_resource>(); }

inline auto make_async() { return std::make_shared<rmm::mr::cuda_async_memory_resource>(); }

inline auto make_managed() { return std::make_shared<rmm::mr::managed_memory_resource>(); }

inline auto make_pool()
{
return rmm::mr::make_owning_wrapper<rmm::mr::pool_memory_resource>(make_cuda());
}

inline auto make_arena()
{
return rmm::mr::make_owning_wrapper<rmm::mr::arena_memory_resource>(make_cuda());
}

inline auto make_binning()
{
auto pool = make_pool();
Expand Down Expand Up @@ -253,7 +262,9 @@ inline std::shared_ptr<rmm::mr::device_memory_resource> create_memory_resource(
{
if (allocation_mode == "binning") return make_binning();
if (allocation_mode == "cuda") return make_cuda();
if (allocation_mode == "async") return make_async();
if (allocation_mode == "pool") return make_pool();
if (allocation_mode == "arena") return make_arena();
if (allocation_mode == "managed") return make_managed();
CUDF_FAIL("Invalid RMM allocation mode: " + allocation_mode);
}
Expand Down

0 comments on commit 5cd3003

Please sign in to comment.