Skip to content

Commit

Permalink
Convert to device_async_resource_ref
Browse files Browse the repository at this point in the history
  • Loading branch information
harrism committed Apr 11, 2024
1 parent 15c148d commit 8e152c7
Show file tree
Hide file tree
Showing 540 changed files with 3,626 additions and 3,022 deletions.
10 changes: 6 additions & 4 deletions cpp/benchmarks/copying/shift.cu
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023, NVIDIA CORPORATION.
* Copyright (c) 2020-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 @@ -21,11 +21,13 @@
#include <cudf/types.hpp>
#include <cudf/utilities/default_stream.hpp>

#include <rmm/resource_ref.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::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource())
T value = 0,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = rmm::mr::get_current_device_resource())
{
auto s = new ScalarType(value, true, stream, mr);
return std::unique_ptr<cudf::scalar>(s);
Expand Down
2 changes: 2 additions & 0 deletions cpp/benchmarks/fixture/benchmark_fixture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <rmm/mr/device/per_device_resource.hpp>
#include <rmm/mr/device/pool_memory_resource.hpp>
#include <rmm/mr/device/statistics_resource_adaptor.hpp>
#include <rmm/resource_ref.hpp>

#include <benchmark/benchmark.h>

Expand Down Expand Up @@ -120,6 +121,7 @@ class memory_stats_logger {
}

private:
// TODO change to resource_ref once set_current_device_resource supports it
rmm::mr::device_memory_resource* existing_mr;
rmm::mr::statistics_resource_adaptor<rmm::mr::device_memory_resource> statistics_mr;
};
Expand Down
10 changes: 6 additions & 4 deletions cpp/include/cudf/ast/detail/expression_parser.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2023, NVIDIA CORPORATION.
* Copyright (c) 2020-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 @@ -21,6 +21,8 @@
#include <cudf/table/table_view.hpp>
#include <cudf/types.hpp>

#include <rmm/resource_ref.hpp>

#include <thrust/scan.h>

#include <functional>
Expand Down Expand Up @@ -118,7 +120,7 @@ class expression_parser {
std::optional<std::reference_wrapper<cudf::table_view const>> right,
bool has_nulls,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
rmm::device_async_resource_ref mr)
: _left{left},
_right{right},
_expression_count{0},
Expand All @@ -139,7 +141,7 @@ class expression_parser {
cudf::table_view const& table,
bool has_nulls,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
rmm::device_async_resource_ref mr)
: expression_parser(expr, table, {}, has_nulls, stream, mr)
{
}
Expand Down Expand Up @@ -240,7 +242,7 @@ class expression_parser {
data_pointers.push_back(v.data());
}

void move_to_device(rmm::cuda_stream_view stream, rmm::mr::device_memory_resource* mr)
void move_to_device(rmm::cuda_stream_view stream, rmm::device_async_resource_ref mr)
{
std::vector<cudf::size_type> sizes;
std::vector<void const*> data_pointers;
Expand Down
23 changes: 12 additions & 11 deletions cpp/include/cudf/binaryop.hpp
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 @@ -20,6 +20,7 @@
#include <cudf/scalar/scalar.hpp>

#include <rmm/mr/device/per_device_resource.hpp>
#include <rmm/resource_ref.hpp>

#include <memory>

Expand Down Expand Up @@ -116,8 +117,8 @@ std::unique_ptr<column> binary_operation(
column_view const& rhs,
binary_operator op,
data_type output_type,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = rmm::mr::get_current_device_resource());

/**
* @brief Performs a binary operation between a column and a scalar.
Expand Down Expand Up @@ -147,8 +148,8 @@ std::unique_ptr<column> binary_operation(
scalar const& rhs,
binary_operator op,
data_type output_type,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = rmm::mr::get_current_device_resource());

/**
* @brief Performs a binary operation between two columns.
Expand Down Expand Up @@ -177,8 +178,8 @@ std::unique_ptr<column> binary_operation(
column_view const& rhs,
binary_operator op,
data_type output_type,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = rmm::mr::get_current_device_resource());

/**
* @brief Performs a binary operation between two columns using a
Expand Down Expand Up @@ -208,8 +209,8 @@ std::unique_ptr<column> binary_operation(
column_view const& rhs,
std::string const& ptx,
data_type output_type,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = rmm::mr::get_current_device_resource());

/**
* @brief Computes the `scale` for a `fixed_point` number based on given binary operator `op`
Expand Down Expand Up @@ -249,8 +250,8 @@ namespace binops {
std::pair<rmm::device_buffer, size_type> scalar_col_valid_mask_and(
column_view const& col,
scalar const& s,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = rmm::mr::get_current_device_resource());

namespace compiled {
namespace detail {
Expand Down
9 changes: 5 additions & 4 deletions cpp/include/cudf/column/column.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <rmm/device_buffer.hpp>
#include <rmm/device_uvector.hpp>
#include <rmm/mr/device/per_device_resource.hpp>
#include <rmm/resource_ref.hpp>

#include <memory>
#include <type_traits>
Expand Down Expand Up @@ -63,8 +64,8 @@ class column {
* @param mr Device memory resource to use for all device memory allocations
*/
column(column const& other,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = rmm::mr::get_current_device_resource());

/**
* @brief Move the contents from `other` to create a new column.
Expand Down Expand Up @@ -141,8 +142,8 @@ class column {
* @param mr Device memory resource to use for all device memory allocations
*/
explicit column(column_view view,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = rmm::mr::get_current_device_resource());

/**
* @brief Returns the column's logical element type
Expand Down
75 changes: 38 additions & 37 deletions cpp/include/cudf/column/column_factories.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include <rmm/cuda_stream_view.hpp>
#include <rmm/mr/device/per_device_resource.hpp>
#include <rmm/resource_ref.hpp>

#include <thrust/pair.h>

Expand Down Expand Up @@ -75,9 +76,9 @@ std::unique_ptr<column> make_empty_column(type_id id);
std::unique_ptr<column> make_numeric_column(
data_type type,
size_type size,
mask_state state = mask_state::UNALLOCATED,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
mask_state state = mask_state::UNALLOCATED,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = rmm::mr::get_current_device_resource());

/**
* @brief Construct column with sufficient uninitialized storage to hold `size` elements of the
Expand All @@ -102,8 +103,8 @@ std::unique_ptr<column> make_numeric_column(
size_type size,
B&& null_mask,
size_type null_count,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource())
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = rmm::mr::get_current_device_resource())
{
CUDF_EXPECTS(is_numeric(type), "Invalid, non-numeric type.");
return std::make_unique<column>(type,
Expand Down Expand Up @@ -133,9 +134,9 @@ std::unique_ptr<column> make_numeric_column(
std::unique_ptr<column> make_fixed_point_column(
data_type type,
size_type size,
mask_state state = mask_state::UNALLOCATED,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
mask_state state = mask_state::UNALLOCATED,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = rmm::mr::get_current_device_resource());

/**
* @brief Construct column with sufficient uninitialized storage to hold `size` elements of the
Expand All @@ -159,8 +160,8 @@ std::unique_ptr<column> make_fixed_point_column(
size_type size,
B&& null_mask,
size_type null_count,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource())
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = rmm::mr::get_current_device_resource())
{
CUDF_EXPECTS(is_fixed_point(type), "Invalid, non-fixed_point type.");
return std::make_unique<column>(type,
Expand Down Expand Up @@ -191,9 +192,9 @@ std::unique_ptr<column> make_fixed_point_column(
std::unique_ptr<column> make_timestamp_column(
data_type type,
size_type size,
mask_state state = mask_state::UNALLOCATED,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
mask_state state = mask_state::UNALLOCATED,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = rmm::mr::get_current_device_resource());

/**
* @brief Construct column with sufficient uninitialized storage to hold `size` elements of the
Expand All @@ -218,8 +219,8 @@ std::unique_ptr<column> make_timestamp_column(
size_type size,
B&& null_mask,
size_type null_count,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource())
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = rmm::mr::get_current_device_resource())
{
CUDF_EXPECTS(is_timestamp(type), "Invalid, non-timestamp type.");
return std::make_unique<column>(type,
Expand Down Expand Up @@ -250,9 +251,9 @@ std::unique_ptr<column> make_timestamp_column(
std::unique_ptr<column> make_duration_column(
data_type type,
size_type size,
mask_state state = mask_state::UNALLOCATED,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
mask_state state = mask_state::UNALLOCATED,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = rmm::mr::get_current_device_resource());

/**
* @brief Construct column with sufficient uninitialized storage to hold `size` elements of the
Expand All @@ -277,8 +278,8 @@ std::unique_ptr<column> make_duration_column(
size_type size,
B&& null_mask,
size_type null_count,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource())
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = rmm::mr::get_current_device_resource())
{
CUDF_EXPECTS(is_duration(type), "Invalid, non-duration type.");
return std::make_unique<column>(type,
Expand Down Expand Up @@ -309,9 +310,9 @@ std::unique_ptr<column> make_duration_column(
std::unique_ptr<column> make_fixed_width_column(
data_type type,
size_type size,
mask_state state = mask_state::UNALLOCATED,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
mask_state state = mask_state::UNALLOCATED,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = rmm::mr::get_current_device_resource());

/**
* @brief Construct column with sufficient uninitialized storage to hold `size` elements of the
Expand All @@ -336,8 +337,8 @@ std::unique_ptr<column> make_fixed_width_column(
size_type size,
B&& null_mask,
size_type null_count,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource())
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = rmm::mr::get_current_device_resource())
{
CUDF_EXPECTS(is_fixed_width(type), "Invalid, non-fixed-width type.");
if (is_timestamp(type)) {
Expand Down Expand Up @@ -375,8 +376,8 @@ std::unique_ptr<column> make_fixed_width_column(
*/
std::unique_ptr<column> make_strings_column(
cudf::device_span<thrust::pair<char const*, size_type> const> strings,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = rmm::mr::get_current_device_resource());

/**
* @brief Construct a STRING type column given a device span of string_view.
Expand Down Expand Up @@ -407,8 +408,8 @@ std::unique_ptr<column> make_strings_column(
std::unique_ptr<column> make_strings_column(
cudf::device_span<string_view const> string_views,
string_view const null_placeholder,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = rmm::mr::get_current_device_resource());

/**
* @brief Construct a STRING type column given offsets column, chars columns, and null mask and null
Expand Down Expand Up @@ -495,8 +496,8 @@ std::unique_ptr<cudf::column> make_lists_column(
std::unique_ptr<column> child_column,
size_type null_count,
rmm::device_buffer&& null_mask,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = rmm::mr::get_current_device_resource());

/**
* @brief Construct a STRUCT column using specified child columns as members.
Expand Down Expand Up @@ -526,8 +527,8 @@ std::unique_ptr<cudf::column> make_structs_column(
std::vector<std::unique_ptr<column>>&& child_columns,
size_type null_count,
rmm::device_buffer&& null_mask,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = rmm::mr::get_current_device_resource());

/**
* @brief Construct a column with size elements that are all equal to the given scalar.
Expand All @@ -546,8 +547,8 @@ std::unique_ptr<cudf::column> make_structs_column(
std::unique_ptr<column> make_column_from_scalar(
scalar const& s,
size_type size,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = rmm::mr::get_current_device_resource());

/**
* @brief Construct a dictionary column with size elements that are all equal to the given scalar.
Expand All @@ -566,8 +567,8 @@ std::unique_ptr<column> make_column_from_scalar(
std::unique_ptr<column> make_dictionary_from_scalar(
scalar const& s,
size_type size,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = rmm::mr::get_current_device_resource());

/** @} */ // end of group
} // namespace cudf
Loading

0 comments on commit 8e152c7

Please sign in to comment.