Skip to content

Commit

Permalink
Merge branch 'branch-23.08' into feat/streams_copying
Browse files Browse the repository at this point in the history
  • Loading branch information
vyasr authored Jul 11, 2023
2 parents a772066 + dec6d08 commit 4f4d28f
Show file tree
Hide file tree
Showing 46 changed files with 1,442 additions and 1,237 deletions.
94 changes: 94 additions & 0 deletions cpp/benchmarks/fixture/nvbench_fixture.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/*
* Copyright (c) 2021-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once

#include <cudf/utilities/error.hpp>

#include <rmm/mr/device/arena_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>
#include <rmm/mr/device/per_device_resource.hpp>
#include <rmm/mr/device/pool_memory_resource.hpp>

#include <string>

namespace cudf {
namespace detail {
static std::string rmm_mode_param{"--rmm_mode"}; ///< RMM mode command-line parameter name
} // namespace detail

/**
* Base fixture for cudf benchmarks using nvbench.
*
* Initializes the default memory resource to use the RMM pool device resource.
*/
struct nvbench_base_fixture {
inline auto make_cuda() { return std::make_shared<rmm::mr::cuda_memory_resource>(); }

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

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_arena()
{
return rmm::mr::make_owning_wrapper<rmm::mr::arena_memory_resource>(make_cuda());
}

inline auto make_managed_pool()
{
return rmm::mr::make_owning_wrapper<rmm::mr::pool_memory_resource>(make_managed());
}

inline std::shared_ptr<rmm::mr::device_memory_resource> create_memory_resource(
std::string const& mode)
{
if (mode == "cuda") return make_cuda();
if (mode == "pool") return make_pool();
if (mode == "async") return make_async();
if (mode == "arena") return make_arena();
if (mode == "managed") return make_managed();
if (mode == "managed_pool") return make_managed_pool();
CUDF_FAIL("Unknown rmm_mode parameter: " + mode +
"\nExpecting: cuda, pool, async, arena, managed, or managed_pool");
}

nvbench_base_fixture(int argc, char const* const* argv)
{
for (int i = 1; i < argc - 1; ++i) {
std::string arg = argv[i];
if (arg == detail::rmm_mode_param) {
i++;
rmm_mode = argv[i];
}
}

mr = create_memory_resource(rmm_mode);
rmm::mr::set_current_device_resource(mr.get());
std::cout << "RMM memory resource = " << rmm_mode << "\n";
}

std::shared_ptr<rmm::mr::device_memory_resource> mr;
std::string rmm_mode{"pool"};
};

} // namespace cudf
21 changes: 20 additions & 1 deletion cpp/benchmarks/fixture/nvbench_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,28 @@
* limitations under the License.
*/

#include <benchmarks/fixture/rmm_pool_raii.hpp>
#include <benchmarks/fixture/nvbench_fixture.hpp>
#define NVBENCH_ENVIRONMENT cudf::nvbench_base_fixture

#include <nvbench/main.cuh>

#include <vector>

// strip off the rmm_mode parameter before passing the
// remaining arguments to nvbench::option_parser
#undef NVBENCH_MAIN_PARSE
#define NVBENCH_MAIN_PARSE(argc, argv) \
nvbench::option_parser parser; \
std::vector<std::string> m_args; \
for (int i = 0; i < argc; ++i) { \
std::string arg = argv[i]; \
if (arg == cudf::detail::rmm_mode_param) { \
i += 2; \
} else { \
m_args.push_back(arg); \
} \
} \
parser.parse(m_args)

// this declares/defines the main() function using the definitions above
NVBENCH_MAIN
81 changes: 0 additions & 81 deletions cpp/benchmarks/fixture/rmm_pool_raii.hpp

This file was deleted.

1 change: 0 additions & 1 deletion cpp/benchmarks/groupby/group_max.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/

#include <benchmarks/common/generate_input.hpp>
#include <benchmarks/fixture/rmm_pool_raii.hpp>

#include <cudf/groupby.hpp>

Expand Down
1 change: 0 additions & 1 deletion cpp/benchmarks/groupby/group_nunique.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/

#include <benchmarks/common/generate_input.hpp>
#include <benchmarks/fixture/rmm_pool_raii.hpp>

#include <cudf/groupby.hpp>

Expand Down
1 change: 0 additions & 1 deletion cpp/benchmarks/groupby/group_rank.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* limitations under the License.
*/
#include <benchmarks/common/generate_input.hpp>
#include <benchmarks/fixture/rmm_pool_raii.hpp>
#include <benchmarks/synchronization/synchronization.hpp>

#include <cudf/groupby.hpp>
Expand Down
1 change: 0 additions & 1 deletion cpp/benchmarks/groupby/group_struct_keys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/

#include <benchmarks/common/generate_input.hpp>
#include <benchmarks/fixture/rmm_pool_raii.hpp>

#include <cudf_test/column_wrapper.hpp>

Expand Down
1 change: 0 additions & 1 deletion cpp/benchmarks/io/csv/csv_reader_input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

#include <benchmarks/common/generate_input.hpp>
#include <benchmarks/fixture/benchmark_fixture.hpp>
#include <benchmarks/fixture/rmm_pool_raii.hpp>
#include <benchmarks/io/cuio_common.hpp>
#include <benchmarks/io/nvbench_helpers.hpp>

Expand Down
1 change: 0 additions & 1 deletion cpp/benchmarks/io/csv/csv_reader_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

#include <benchmarks/common/generate_input.hpp>
#include <benchmarks/fixture/benchmark_fixture.hpp>
#include <benchmarks/fixture/rmm_pool_raii.hpp>
#include <benchmarks/io/cuio_common.hpp>
#include <benchmarks/io/nvbench_helpers.hpp>

Expand Down
4 changes: 2 additions & 2 deletions cpp/benchmarks/io/fst.cu
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
*/

#include <benchmarks/common/generate_input.hpp>
#include <benchmarks/fixture/rmm_pool_raii.hpp>
#include <nvbench/nvbench.cuh>

#include <io/fst/lookup_tables.cuh>
#include <io/utilities/hostdevice_vector.hpp> //TODO find better replacement
Expand All @@ -35,6 +33,8 @@

#include <thrust/iterator/discard_iterator.h>

#include <nvbench/nvbench.cuh>

#include <cstdlib>

namespace {
Expand Down
5 changes: 2 additions & 3 deletions cpp/benchmarks/io/json/nested_json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@

#include <benchmarks/common/generate_input.hpp>
#include <benchmarks/fixture/benchmark_fixture.hpp>
#include <benchmarks/fixture/rmm_pool_raii.hpp>

#include <nvbench/nvbench.cuh>

#include <io/json/nested_json.hpp>

Expand All @@ -28,6 +25,8 @@
#include <cudf/strings/repeat_strings.hpp>
#include <cudf/types.hpp>

#include <nvbench/nvbench.cuh>

#include <string>
#include <vector>

Expand Down
1 change: 0 additions & 1 deletion cpp/benchmarks/io/orc/orc_reader_input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

#include <benchmarks/common/generate_input.hpp>
#include <benchmarks/fixture/benchmark_fixture.hpp>
#include <benchmarks/fixture/rmm_pool_raii.hpp>
#include <benchmarks/io/cuio_common.hpp>
#include <benchmarks/io/nvbench_helpers.hpp>

Expand Down
1 change: 0 additions & 1 deletion cpp/benchmarks/io/orc/orc_reader_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

#include <benchmarks/common/generate_input.hpp>
#include <benchmarks/fixture/benchmark_fixture.hpp>
#include <benchmarks/fixture/rmm_pool_raii.hpp>
#include <benchmarks/io/cuio_common.hpp>
#include <benchmarks/io/nvbench_helpers.hpp>

Expand Down
1 change: 0 additions & 1 deletion cpp/benchmarks/io/orc/orc_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

#include <benchmarks/common/generate_input.hpp>
#include <benchmarks/fixture/benchmark_fixture.hpp>
#include <benchmarks/fixture/rmm_pool_raii.hpp>
#include <benchmarks/io/cuio_common.hpp>
#include <benchmarks/io/nvbench_helpers.hpp>

Expand Down
1 change: 0 additions & 1 deletion cpp/benchmarks/io/orc/orc_writer_chunks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

#include <benchmarks/common/generate_input.hpp>
#include <benchmarks/fixture/benchmark_fixture.hpp>
#include <benchmarks/fixture/rmm_pool_raii.hpp>
#include <benchmarks/io/cuio_common.hpp>
#include <benchmarks/io/nvbench_helpers.hpp>

Expand Down
1 change: 0 additions & 1 deletion cpp/benchmarks/io/parquet/parquet_reader_input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

#include <benchmarks/common/generate_input.hpp>
#include <benchmarks/fixture/benchmark_fixture.hpp>
#include <benchmarks/fixture/rmm_pool_raii.hpp>
#include <benchmarks/io/cuio_common.hpp>
#include <benchmarks/io/nvbench_helpers.hpp>

Expand Down
1 change: 0 additions & 1 deletion cpp/benchmarks/io/parquet/parquet_reader_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

#include <benchmarks/common/generate_input.hpp>
#include <benchmarks/fixture/benchmark_fixture.hpp>
#include <benchmarks/fixture/rmm_pool_raii.hpp>
#include <benchmarks/io/cuio_common.hpp>
#include <benchmarks/io/nvbench_helpers.hpp>

Expand Down
1 change: 0 additions & 1 deletion cpp/benchmarks/io/parquet/parquet_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

#include <benchmarks/common/generate_input.hpp>
#include <benchmarks/fixture/benchmark_fixture.hpp>
#include <benchmarks/fixture/rmm_pool_raii.hpp>
#include <benchmarks/io/cuio_common.hpp>
#include <benchmarks/io/nvbench_helpers.hpp>

Expand Down
1 change: 0 additions & 1 deletion cpp/benchmarks/io/parquet/parquet_writer_chunks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

#include <benchmarks/common/generate_input.hpp>
#include <benchmarks/fixture/benchmark_fixture.hpp>
#include <benchmarks/fixture/rmm_pool_raii.hpp>
#include <benchmarks/io/cuio_common.hpp>
#include <benchmarks/io/nvbench_helpers.hpp>

Expand Down
1 change: 0 additions & 1 deletion cpp/benchmarks/io/text/multibyte_split.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

#include <benchmarks/common/generate_input.hpp>
#include <benchmarks/fixture/benchmark_fixture.hpp>
#include <benchmarks/fixture/rmm_pool_raii.hpp>
#include <benchmarks/io/cuio_common.hpp>
#include <benchmarks/synchronization/synchronization.hpp>

Expand Down
1 change: 0 additions & 1 deletion cpp/benchmarks/join/join.cu
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* limitations under the License.
*/

#include <benchmarks/fixture/rmm_pool_raii.hpp>
#include <benchmarks/join/join_common.hpp>

template <typename key_type, typename payload_type, bool Nullable>
Expand Down
1 change: 0 additions & 1 deletion cpp/benchmarks/join/mixed_join.cu
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* limitations under the License.
*/

#include <benchmarks/fixture/rmm_pool_raii.hpp>
#include <benchmarks/join/join_common.hpp>

template <typename key_type, typename payload_type, bool Nullable>
Expand Down
1 change: 0 additions & 1 deletion cpp/benchmarks/lists/set_operations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/

#include <benchmarks/common/generate_input.hpp>
#include <benchmarks/fixture/rmm_pool_raii.hpp>

#include <cudf/lists/set_operations.hpp>

Expand Down
1 change: 0 additions & 1 deletion cpp/benchmarks/reduction/rank.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/

#include <benchmarks/common/generate_input.hpp>
#include <benchmarks/fixture/rmm_pool_raii.hpp>

#include <cudf/detail/scan.hpp>
#include <cudf/filling.hpp>
Expand Down
Loading

0 comments on commit 4f4d28f

Please sign in to comment.