Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add libcudf wrappers around current_device_resource functions. #16679

Merged
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
1153bfb
Add memory_resource.hpp
harrism Aug 28, 2024
160864d
Use cudf wrappers around current memory resource
harrism Aug 28, 2024
a6f4a1e
Use cudf::set_current_device_resource
harrism Aug 28, 2024
1e5ff7f
Remove includes of RMM per_device_resource.hpp
harrism Aug 28, 2024
54cf784
More copyrights
harrism Aug 28, 2024
06409d8
Complete ref aliases (and docs)
harrism Aug 28, 2024
e6743da
Use cudf::host*_ref aliases
harrism Aug 28, 2024
19c72f5
Update DEVELOPER_GUIDE
harrism Aug 28, 2024
69ef75f
Whitespace (style)
harrism Aug 28, 2024
f27f962
Comment out cudf::[re]set_current_device_resource_ref until they are …
harrism Aug 28, 2024
2b814dc
Fix search-replace-o
harrism Aug 28, 2024
6f57d6d
Fix interop.pxd
harrism Aug 28, 2024
c101c0d
Enable [re]set_current_device_resource_ref now that they are merged i…
harrism Aug 28, 2024
173c125
Remove unneeded header.
harrism Sep 3, 2024
d5d79ee
Remove unneeded header.
harrism Sep 3, 2024
2e4e9ca
Drop cudf resource_ref aliases (aliases of aliases)
harrism Sep 3, 2024
94704d1
Add missing include.
harrism Sep 4, 2024
fb863dc
Merge branch 'branch-24.10' into fea/cudf_current_resource_wrappers
harrism Sep 4, 2024
71347e0
More missed includes.
harrism Sep 4, 2024
a5cd494
Update docs.
harrism Sep 4, 2024
36cb4e7
style
harrism Sep 4, 2024
4050f3d
Revert some changes to developer guide.
harrism Sep 4, 2024
f83b64d
A few new calls after merge.
harrism Sep 4, 2024
02aaff4
Fix up includes.
harrism Sep 9, 2024
4db5be2
Merge branch 'branch-24.10' into fea/cudf_current_resource_wrappers
harrism Sep 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
14 changes: 7 additions & 7 deletions cpp/benchmarks/common/generate_input.cu
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
#include <cudf/types.hpp>
#include <cudf/utilities/default_stream.hpp>
#include <cudf/utilities/error.hpp>
#include <cudf/utilities/memory_resource.hpp>

#include <rmm/device_buffer.hpp>
#include <rmm/device_uvector.hpp>
#include <rmm/mr/device/per_device_resource.hpp>

#include <cuda/functional>
#include <thrust/binary_search.h>
Expand Down Expand Up @@ -507,7 +507,7 @@ std::unique_ptr<cudf::column> create_random_column(data_profile const& profile,
null_mask.end(),
thrust::identity<bool>{},
cudf::get_default_stream(),
rmm::mr::get_current_device_resource());
cudf::get_current_device_resource_ref());

return std::make_unique<cudf::column>(
dtype,
Expand Down Expand Up @@ -591,7 +591,7 @@ std::unique_ptr<cudf::column> create_random_utf8_string_column(data_profile cons
null_mask.end() - 1,
thrust::identity<bool>{},
cudf::get_default_stream(),
rmm::mr::get_current_device_resource());
cudf::get_current_device_resource_ref());
return cudf::make_strings_column(
num_rows,
std::make_unique<cudf::column>(std::move(offsets), rmm::device_buffer{}, 0),
Expand Down Expand Up @@ -626,7 +626,7 @@ std::unique_ptr<cudf::column> create_random_column<cudf::string_view>(data_profi
cudf::out_of_bounds_policy::DONT_CHECK,
cudf::detail::negative_index_policy::NOT_ALLOWED,
cudf::get_default_stream(),
rmm::mr::get_current_device_resource());
cudf::get_current_device_resource_ref());
return std::move(str_table->release()[0]);
}

Expand Down Expand Up @@ -688,7 +688,7 @@ std::unique_ptr<cudf::column> create_random_column<cudf::struct_view>(data_profi
valids.end(),
thrust::identity<bool>{},
cudf::get_default_stream(),
rmm::mr::get_current_device_resource());
cudf::get_current_device_resource_ref());
}
return std::pair<rmm::device_buffer, cudf::size_type>{};
}();
Expand Down Expand Up @@ -782,7 +782,7 @@ std::unique_ptr<cudf::column> create_random_column<cudf::list_view>(data_profile
valids.end(),
thrust::identity<bool>{},
cudf::get_default_stream(),
rmm::mr::get_current_device_resource());
cudf::get_current_device_resource_ref());
list_column = cudf::make_lists_column(
current_num_rows,
std::move(offsets_column),
Expand Down Expand Up @@ -933,7 +933,7 @@ std::pair<rmm::device_buffer, cudf::size_type> create_random_null_mask(
thrust::make_counting_iterator<cudf::size_type>(size),
bool_generator{seed, 1.0 - *null_probability},
cudf::get_default_stream(),
rmm::mr::get_current_device_resource());
cudf::get_current_device_resource_ref());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#pragma once

#include <cudf/column/column.hpp>
#include <cudf/utilities/default_stream.hpp>
#include <cudf/utilities/memory_resource.hpp>

#include <string>

Expand All @@ -36,7 +38,7 @@ std::unique_ptr<cudf::column> generate_random_string_column(
cudf::size_type upper,
cudf::size_type num_rows,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = rmm::mr::get_current_device_resource());
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/**
* @brief Generate a column of random numbers
Expand All @@ -61,7 +63,7 @@ std::unique_ptr<cudf::column> generate_random_numeric_column(
T upper,
cudf::size_type num_rows,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = rmm::mr::get_current_device_resource());
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/**
* @brief Generate a primary key column
Expand All @@ -81,7 +83,7 @@ std::unique_ptr<cudf::column> generate_primary_key_column(
cudf::scalar const& start,
cudf::size_type num_rows,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = rmm::mr::get_current_device_resource());
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/**
* @brief Generate a column where all the rows have the same string value
Expand All @@ -101,7 +103,7 @@ std::unique_ptr<cudf::column> generate_repeat_string_column(
std::string const& value,
cudf::size_type num_rows,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = rmm::mr::get_current_device_resource());
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/**
* @brief Generate a column by randomly choosing from set of strings
Expand All @@ -121,7 +123,7 @@ std::unique_ptr<cudf::column> generate_random_string_column_from_set(
cudf::host_span<const char* const> set,
cudf::size_type num_rows,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = rmm::mr::get_current_device_resource());
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/**
* @brief Generate a column consisting of a repeating sequence of integers
Expand All @@ -145,6 +147,6 @@ std::unique_ptr<cudf::column> generate_repeat_sequence_column(
bool zero_indexed,
cudf::size_type num_rows,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = rmm::mr::get_current_device_resource());
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

} // namespace cudf::datagen
20 changes: 11 additions & 9 deletions cpp/benchmarks/common/tpch_data_generator/table_helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#include <cudf/column/column_view.hpp>
#include <cudf/table/table.hpp>
#include <cudf/table/table_view.hpp>
#include <cudf/utilities/default_stream.hpp>
#include <cudf/utilities/memory_resource.hpp>

#include <vector>

Expand All @@ -37,7 +39,7 @@ std::unique_ptr<cudf::column> add_calendrical_days(
cudf::column_view const& timestamp_days,
cudf::column_view const& days,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = rmm::mr::get_current_device_resource());
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/**
* @brief Perform a left join operation between two tables
Expand All @@ -56,7 +58,7 @@ std::unique_ptr<cudf::table> perform_left_join(
std::vector<cudf::size_type> const& left_on,
std::vector<cudf::size_type> const& right_on,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = rmm::mr::get_current_device_resource());
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/**
* @brief Generate the `p_retailprice` column of the `part` table
Expand All @@ -68,7 +70,7 @@ std::unique_ptr<cudf::table> perform_left_join(
[[nodiscard]] std::unique_ptr<cudf::column> calculate_p_retailprice(
cudf::column_view const& p_partkey,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = rmm::mr::get_current_device_resource());
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/**
* @brief Generate the `l_suppkey` column of the `lineitem` table
Expand All @@ -84,7 +86,7 @@ std::unique_ptr<cudf::table> perform_left_join(
cudf::size_type scale_factor,
cudf::size_type num_rows,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = rmm::mr::get_current_device_resource());
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/**
* @brief Generate the `ps_suppkey` column of the `partsupp` table
Expand All @@ -100,7 +102,7 @@ std::unique_ptr<cudf::table> perform_left_join(
cudf::size_type scale_factor,
cudf::size_type num_rows,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = rmm::mr::get_current_device_resource());
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());
/**
* @brief Calculate the cardinality of the `lineitem` table
*
Expand All @@ -111,7 +113,7 @@ std::unique_ptr<cudf::table> perform_left_join(
[[nodiscard]] cudf::size_type calculate_l_cardinality(
cudf::column_view const& o_rep_freqs,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = rmm::mr::get_current_device_resource());
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());
/**
* @brief Calculate the charge column for the `lineitem` table
*
Expand All @@ -126,7 +128,7 @@ std::unique_ptr<cudf::table> perform_left_join(
cudf::column_view const& tax,
cudf::column_view const& discount,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = rmm::mr::get_current_device_resource());
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/**
* @brief Generate a column of random addresses according to TPC-H specification clause 4.2.2.7
Expand All @@ -138,7 +140,7 @@ std::unique_ptr<cudf::table> perform_left_join(
[[nodiscard]] std::unique_ptr<cudf::column> generate_address_column(
cudf::size_type num_rows,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = rmm::mr::get_current_device_resource());
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/**
* @brief Generate a phone number column according to TPC-H specification clause 4.2.2.9
Expand All @@ -150,6 +152,6 @@ std::unique_ptr<cudf::table> perform_left_join(
[[nodiscard]] std::unique_ptr<cudf::column> generate_phone_column(
cudf::size_type num_rows,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = rmm::mr::get_current_device_resource());
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

} // namespace cudf::datagen
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#pragma once

#include <cudf/table/table.hpp>
#include <cudf/utilities/default_stream.hpp>
#include <cudf/utilities/memory_resource.hpp>

namespace CUDF_EXPORT cudf {
namespace datagen {
Expand All @@ -32,7 +34,7 @@ std::tuple<std::unique_ptr<cudf::table>, std::unique_ptr<cudf::table>, std::uniq
generate_orders_lineitem_part(
double scale_factor,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = rmm::mr::get_current_device_resource());
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/**
* @brief Generate the `partsupp` table
Expand All @@ -44,7 +46,7 @@ generate_orders_lineitem_part(
std::unique_ptr<cudf::table> generate_partsupp(
double scale_factor,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = rmm::mr::get_current_device_resource());
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/**
* @brief Generate the `supplier` table
Expand All @@ -56,7 +58,7 @@ std::unique_ptr<cudf::table> generate_partsupp(
std::unique_ptr<cudf::table> generate_supplier(
double scale_factor,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = rmm::mr::get_current_device_resource());
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/**
* @brief Generate the `customer` table
Expand All @@ -68,7 +70,7 @@ std::unique_ptr<cudf::table> generate_supplier(
std::unique_ptr<cudf::table> generate_customer(
double scale_factor,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = rmm::mr::get_current_device_resource());
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/**
* @brief Generate the `nation` table
Expand All @@ -78,7 +80,7 @@ std::unique_ptr<cudf::table> generate_customer(
*/
std::unique_ptr<cudf::table> generate_nation(
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = rmm::mr::get_current_device_resource());
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/**
* @brief Generate the `region` table
Expand All @@ -88,7 +90,7 @@ std::unique_ptr<cudf::table> generate_nation(
*/
std::unique_ptr<cudf::table> generate_region(
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = rmm::mr::get_current_device_resource());
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

} // namespace datagen
} // namespace CUDF_EXPORT cudf
5 changes: 3 additions & 2 deletions cpp/benchmarks/copying/contiguous_split.cu
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2023, NVIDIA CORPORATION.
* Copyright (c) 2019-2024, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -22,6 +22,7 @@

#include <cudf/column/column.hpp>
#include <cudf/contiguous_split.hpp>
#include <cudf/utilities/memory_resource.hpp>

#include <thrust/iterator/counting_iterator.h>

Expand All @@ -32,7 +33,7 @@ void contiguous_split(cudf::table_view const& src_table, std::vector<cudf::size_

void chunked_pack(cudf::table_view const& src_table, std::vector<cudf::size_type> const&)
{
auto const mr = rmm::mr::get_current_device_resource();
auto const mr = cudf::get_current_device_resource_ref();
auto const stream = cudf::get_default_stream();
auto user_buffer = rmm::device_uvector<std::uint8_t>(100L * 1024 * 1024, stream, mr);
auto chunked_pack = cudf::chunked_pack::create(src_table, user_buffer.size(), mr);
Expand Down
5 changes: 2 additions & 3 deletions cpp/benchmarks/copying/shift.cu
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@
#include <cudf/copying.hpp>
#include <cudf/types.hpp>
#include <cudf/utilities/default_stream.hpp>

#include <rmm/resource_ref.hpp>
#include <cudf/utilities/memory_resource.hpp>

template <typename T, typename ScalarType = cudf::scalar_type_t<T>>
std::unique_ptr<cudf::scalar> make_scalar(
T value = 0,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = rmm::mr::get_current_device_resource())
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref())
{
auto s = new ScalarType(value, true, stream, mr);
return std::unique_ptr<cudf::scalar>(s);
Expand Down
13 changes: 7 additions & 6 deletions cpp/benchmarks/fixture/benchmark_fixture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@

#pragma once

#include <cudf/utilities/memory_resource.hpp>

#include <rmm/cuda_device.hpp>
#include <rmm/mr/device/cuda_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 <rmm/mr/device/statistics_resource_adaptor.hpp>

Expand Down Expand Up @@ -83,13 +84,13 @@ class benchmark : public ::benchmark::Fixture {
void SetUp(::benchmark::State const& state) override
{
mr = make_pool_instance();
rmm::mr::set_current_device_resource(mr.get()); // set default resource to pool
cudf::set_current_device_resource(mr.get()); // set default resource to pool
}

void TearDown(::benchmark::State const& state) override
{
// reset default resource to the initial resource
rmm::mr::set_current_device_resource(nullptr);
cudf::set_current_device_resource(nullptr);
mr.reset();
}

Expand All @@ -106,13 +107,13 @@ class benchmark : public ::benchmark::Fixture {
class memory_stats_logger {
public:
memory_stats_logger()
: existing_mr(rmm::mr::get_current_device_resource()),
: existing_mr(cudf::get_current_device_resource()),
statistics_mr(rmm::mr::statistics_resource_adaptor(existing_mr))
{
rmm::mr::set_current_device_resource(&statistics_mr);
cudf::set_current_device_resource(&statistics_mr);
}

~memory_stats_logger() { rmm::mr::set_current_device_resource(existing_mr); }
~memory_stats_logger() { cudf::set_current_device_resource(existing_mr); }

[[nodiscard]] size_t peak_memory_usage() const noexcept
{
Expand Down
5 changes: 2 additions & 3 deletions cpp/benchmarks/fixture/nvbench_fixture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#pragma once

#include <cudf/utilities/error.hpp>
#include <cudf/utilities/memory_resource.hpp>
#include <cudf/utilities/pinned_memory.hpp>

#include <rmm/cuda_device.hpp>
Expand All @@ -24,10 +25,8 @@
#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 <rmm/mr/pinned_host_memory_resource.hpp>
#include <rmm/resource_ref.hpp>

#include <string>

Expand Down Expand Up @@ -110,7 +109,7 @@ struct nvbench_base_fixture {
}

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

cudf::set_pinned_memory_resource(create_cuio_host_memory_resource(cuio_host_mode));
Expand Down
Loading
Loading