diff --git a/cpp/benchmarks/iterator/iterator_benchmark.cu b/cpp/benchmarks/iterator/iterator_benchmark.cu index d83fc8af3a3..04307f5db25 100644 --- a/cpp/benchmarks/iterator/iterator_benchmark.cu +++ b/cpp/benchmarks/iterator/iterator_benchmark.cu @@ -50,7 +50,7 @@ inline auto reduce_by_cub(OutputIterator result, InputIterator d_in, int num_ite nullptr, temp_storage_bytes, d_in, result, num_items, cudf::DeviceSum{}, init); // Allocate temporary storage - rmm::device_buffer d_temp_storage(temp_storage_bytes); + rmm::device_buffer d_temp_storage(temp_storage_bytes, rmm::cuda_stream_default); // Run reduction cub::DeviceReduce::Reduce( diff --git a/cpp/benchmarks/type_dispatcher/type_dispatcher_benchmark.cu b/cpp/benchmarks/type_dispatcher/type_dispatcher_benchmark.cu index 14e79629fee..b09a7911595 100644 --- a/cpp/benchmarks/type_dispatcher/type_dispatcher_benchmark.cu +++ b/cpp/benchmarks/type_dispatcher/type_dispatcher_benchmark.cu @@ -27,6 +27,7 @@ #include #include +#include #include @@ -186,10 +187,12 @@ void type_dispatcher_benchmark(::benchmark::State& state) cudf::mutable_table_view source_table{source_columns}; // For no dispatching - std::vector h_vec(n_cols, - rmm::device_buffer(source_size * sizeof(TypeParam))); + std::vector h_vec(n_cols); std::vector h_vec_p(n_cols); - for (int c = 0; c < n_cols; c++) { h_vec_p[c] = static_cast(h_vec[c].data()); } + std::transform(h_vec.begin(), h_vec.end(), h_vec_p.begin(), [source_size](auto& col) { + col.resize(source_size * sizeof(TypeParam), rmm::cuda_stream_default); + return static_cast(col.data()); + }); rmm::device_uvector d_vec(n_cols, rmm::cuda_stream_default); if (dispatching_type == NO_DISPATCHING) { diff --git a/cpp/docs/DEVELOPER_GUIDE.md b/cpp/docs/DEVELOPER_GUIDE.md index b1d62261225..0f6e110ffd0 100644 --- a/cpp/docs/DEVELOPER_GUIDE.md +++ b/cpp/docs/DEVELOPER_GUIDE.md @@ -414,9 +414,9 @@ Allocates a specified number of bytes of untyped, uninitialized device memory us `device_memory_resource`. If no resource is explicitly provided, uses `rmm::mr::get_current_device_resource()`. -`rmm::device_buffer` is copyable and movable. A copy performs a deep copy of the `device_buffer`'s -device memory, whereas a move moves ownership of the device memory from one `device_buffer` to -another. +`rmm::device_buffer` is movable and copyable on a stream. A copy performs a deep copy of the +`device_buffer`'s device memory on the specified stream, whereas a move moves ownership of the +device memory from one `device_buffer` to another. ```c++ // Allocates at least 100 bytes of uninitialized device memory @@ -424,11 +424,15 @@ another. rmm::device_buffer buff(100, stream, mr); void * raw_data = buff.data(); // Raw pointer to underlying device memory -rmm::device_buffer copy(buff); // Deep copies `buff` into `copy` -rmm::device_buffer moved_to(std::move(buff)); // Moves contents of `buff` into `moved_to` +// Deep copies `buff` into `copy` on `stream` +rmm::device_buffer copy(buff, stream); + +// Moves contents of `buff` into `moved_to` +rmm::device_buffer moved_to(std::move(buff)); custom_memory_resource *mr...; -rmm::device_buffer custom_buff(100, mr); // Allocates 100 bytes from the custom_memory_resource +// Allocates 100 bytes from the custom_memory_resource +rmm::device_buffer custom_buff(100, mr, stream); ``` #### `rmm::device_scalar` diff --git a/cpp/include/cudf/column/column.hpp b/cpp/include/cudf/column/column.hpp index a08b10df6f4..ee367840644 100644 --- a/cpp/include/cudf/column/column.hpp +++ b/cpp/include/cudf/column/column.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2020, NVIDIA CORPORATION. + * Copyright (c) 2019-2021, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,13 +49,6 @@ class column { column& operator=(column const& other) = delete; column& operator=(column&& other) = delete; - /** - * @brief Construct a new column by deep copying the contents of `other`. - * - * @param other The column to copy - */ - column(column const& other); - /** * @brief Construct a new column object by deep copying the contents of *`other`. @@ -68,7 +61,7 @@ class column { * @param mr Device memory resource to use for all device memory allocations */ column(column const& other, - rmm::cuda_stream_view stream, + rmm::cuda_stream_view stream = rmm::cuda_stream_view{}, rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); /** @@ -165,18 +158,21 @@ class column { /** * @brief Sets the column's null value indicator bitmask to `new_null_mask`. * - * @throws cudf::logic_error if new_null_count is larger than 0 and the size - * of `new_null_mask` does not match the size of this column. - * - * @param new_null_mask New null value indicator bitmask (lvalue overload & - * copied) to set the column's null value indicator mask. May be empty if - * `new_null_count` is 0 or `UNKOWN_NULL_COUNT`. - * @param new_null_count Optional, the count of null elements. If unknown, - * specify `UNKNOWN_NULL_COUNT` to indicate that the null count should be - * computed on the first invocation of `null_count()`. + * @throws cudf::logic_error if new_null_count is larger than 0 and the size of `new_null_mask` + * does not match the size of this column. + * + * @param new_null_mask New null value indicator bitmask (lvalue overload & copied) to set the + * column's null value indicator mask. May be empty if `new_null_count` is 0 or + * `UNKOWN_NULL_COUNT`. + * @param new_null_count Optional, the count of null elements. If unknown, specify + * `UNKNOWN_NULL_COUNT` to indicate that the null count should be computed on the first invocation + * of `null_count()`. + * @param stream The stream on which to perform the allocation and copy. Uses the default CUDA + * stream if none is specified. */ void set_null_mask(rmm::device_buffer const& new_null_mask, - size_type new_null_count = UNKNOWN_NULL_COUNT); + size_type new_null_count = UNKNOWN_NULL_COUNT, + rmm::cuda_stream_view stream = rmm::cuda_stream_view{}); /** * @brief Updates the count of null elements. diff --git a/cpp/include/cudf/lists/detail/scatter.cuh b/cpp/include/cudf/lists/detail/scatter.cuh index 33d3d1cb09e..dac67545748 100644 --- a/cpp/include/cudf/lists/detail/scatter.cuh +++ b/cpp/include/cudf/lists/detail/scatter.cuh @@ -306,7 +306,7 @@ struct list_child_constructor { auto const num_child_rows{ cudf::detail::get_value(list_offsets, list_offsets.size() - 1, stream)}; - auto const child_null_mask = + auto child_null_mask = source_lists_column_view.child().nullable() || target_lists_column_view.child().nullable() ? construct_child_nullmask( list_vector, list_offsets, source_lists, target_lists, num_child_rows, stream, mr) @@ -314,7 +314,7 @@ struct list_child_constructor { auto child_column = cudf::make_fixed_width_column(source_lists_column_view.child().type(), num_child_rows, - child_null_mask.first, + std::move(child_null_mask.first), child_null_mask.second, stream, mr); @@ -595,7 +595,7 @@ struct list_child_constructor { std::make_unique(structs_list_offsets, stream, mr), std::make_unique(structs_member, stream, mr), structs_list_null_count, - rmm::device_buffer(structs_list_nullmask), + rmm::device_buffer(structs_list_nullmask, stream), stream, mr); }; diff --git a/cpp/include/cudf/scalar/scalar.hpp b/cpp/include/cudf/scalar/scalar.hpp index 3025c01d747..6938ad5feaa 100644 --- a/cpp/include/cudf/scalar/scalar.hpp +++ b/cpp/include/cudf/scalar/scalar.hpp @@ -45,12 +45,23 @@ namespace cudf { */ class scalar { public: - virtual ~scalar() = default; - scalar(scalar&& other) = default; - scalar(scalar const& other) = default; + virtual ~scalar() = default; + scalar(scalar&& other) = default; + scalar& operator=(scalar const& other) = delete; scalar& operator=(scalar&& other) = delete; + /** + * @brief Construct a new scalar object by deep copying another. + * + * @param[in] other The scalar to copy. + * @param[in] stream CUDA stream used for device memory operations. + * @param[in] mr Device memory resource to use for device memory allocation + */ + scalar(scalar const& other, + rmm::cuda_stream_view stream = rmm::cuda_stream_default, + rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); + /** * @brief Returns the scalar's logical value type */ @@ -116,12 +127,23 @@ class fixed_width_scalar : public scalar { public: using value_type = T; - ~fixed_width_scalar() = default; - fixed_width_scalar(fixed_width_scalar&& other) = default; - fixed_width_scalar(fixed_width_scalar const& other) = default; + ~fixed_width_scalar() = default; + fixed_width_scalar(fixed_width_scalar&& other) = default; + fixed_width_scalar& operator=(fixed_width_scalar const& other) = delete; fixed_width_scalar& operator=(fixed_width_scalar&& other) = delete; + /** + * @brief Construct a new fixed-width scalar object by deep copying another. + * + * @param[in] other The scalar to copy. + * @param[in] stream CUDA stream used for device memory operations. + * @param[in] mr Device memory resource to use for device memory allocation + */ + fixed_width_scalar(fixed_width_scalar const& other, + rmm::cuda_stream_view stream = rmm::cuda_stream_default, + rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); + /** * @brief Set the value of the scalar * @@ -196,13 +218,24 @@ class numeric_scalar : public detail::fixed_width_scalar { static_assert(is_numeric(), "Unexpected non-numeric type."); public: - numeric_scalar() = default; - ~numeric_scalar() = default; - numeric_scalar(numeric_scalar&& other) = default; - numeric_scalar(numeric_scalar const& other) = default; + numeric_scalar() = default; + ~numeric_scalar() = default; + numeric_scalar(numeric_scalar&& other) = default; + numeric_scalar& operator=(numeric_scalar const& other) = delete; numeric_scalar& operator=(numeric_scalar&& other) = delete; + /** + * @brief Construct a new numeric scalar object by deep copying another. + * + * @param[in] other The scalar to copy. + * @param[in] stream CUDA stream used for device memory operations. + * @param[in] mr Device memory resource to use for device memory allocation + */ + numeric_scalar(numeric_scalar const& other, + rmm::cuda_stream_view stream = rmm::cuda_stream_default, + rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); + /** * @brief Construct a new numeric scalar object * @@ -244,12 +277,23 @@ class fixed_point_scalar : public scalar { using value_type = T; fixed_point_scalar(); - ~fixed_point_scalar() = default; - fixed_point_scalar(fixed_point_scalar&& other) = default; - fixed_point_scalar(fixed_point_scalar const& other) = default; + ~fixed_point_scalar() = default; + fixed_point_scalar(fixed_point_scalar&& other) = default; + fixed_point_scalar& operator=(fixed_point_scalar const& other) = delete; fixed_point_scalar& operator=(fixed_point_scalar&& other) = delete; + /** + * @brief Construct a new fixed_point scalar object by deep copying another. + * + * @param[in] other The scalar to copy. + * @param[in] stream CUDA stream used for device memory operations. + * @param[in] mr Device memory resource to use for device memory allocation + */ + fixed_point_scalar(fixed_point_scalar const& other, + rmm::cuda_stream_view stream = rmm::cuda_stream_default, + rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); + /** * @brief Construct a new fixed_point scalar object from already shifted value and scale * @@ -342,12 +386,23 @@ class string_scalar : public scalar { using value_type = cudf::string_view; string_scalar(); - ~string_scalar() = default; - string_scalar(string_scalar&& other) = default; - string_scalar(string_scalar const& other) = default; + ~string_scalar() = default; + string_scalar(string_scalar&& other) = default; + string_scalar& operator=(string_scalar const& other) = delete; string_scalar& operator=(string_scalar&& other) = delete; + /** + * @brief Construct a new string scalar object by deep copying another string_scalar. + * + * @param[in] other The other string_scalar to copy + * @param[in] stream CUDA stream used for device memory operations. + * @param[in] mr Device memory resource to use for device memory allocation + */ + string_scalar(string_scalar const& other, + rmm::cuda_stream_view stream = rmm::cuda_stream_default, + rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); + /** * @brief Construct a new string scalar object * @@ -433,13 +488,24 @@ class chrono_scalar : public detail::fixed_width_scalar { static_assert(is_chrono(), "Unexpected non-chrono type"); public: - chrono_scalar() = default; - ~chrono_scalar() = default; - chrono_scalar(chrono_scalar&& other) = default; - chrono_scalar(chrono_scalar const& other) = default; + chrono_scalar() = default; + ~chrono_scalar() = default; + chrono_scalar(chrono_scalar&& other) = default; + chrono_scalar& operator=(chrono_scalar const& other) = delete; chrono_scalar& operator=(chrono_scalar&& other) = delete; + /** + * @brief Construct a new chrono scalar object by deep copying another. + * + * @param[in] other The scalar to copy. + * @param[in] stream CUDA stream used for device memory operations. + * @param[in] mr Device memory resource to use for device memory allocation + */ + chrono_scalar(chrono_scalar const& other, + rmm::cuda_stream_view stream = rmm::cuda_stream_default, + rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); + /** * @brief Construct a new chrono scalar object * @@ -468,12 +534,25 @@ class chrono_scalar : public detail::fixed_width_scalar { }; template -struct timestamp_scalar : chrono_scalar { +class timestamp_scalar : public chrono_scalar { + public: static_assert(is_timestamp(), "Unexpected non-timestamp type"); using chrono_scalar::chrono_scalar; using rep_type = typename T::rep; - timestamp_scalar() = default; + timestamp_scalar() = default; + timestamp_scalar(timestamp_scalar&& other) = default; + + /** + * @brief Construct a new timestamp scalar object by deep copying another. + * + * @param[in] other The scalar to copy. + * @param[in] stream CUDA stream used for device memory operations. + * @param[in] mr Device memory resource to use for device memory allocation + */ + timestamp_scalar(timestamp_scalar const& other, + rmm::cuda_stream_view stream = rmm::cuda_stream_default, + rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); /** * @brief Construct a new timestamp scalar object from a duration that is @@ -498,12 +577,25 @@ struct timestamp_scalar : chrono_scalar { }; template -struct duration_scalar : chrono_scalar { +class duration_scalar : public chrono_scalar { + public: static_assert(is_duration(), "Unexpected non-duration type"); using chrono_scalar::chrono_scalar; using rep_type = typename T::rep; - duration_scalar() = default; + duration_scalar() = default; + duration_scalar(duration_scalar&& other) = default; + + /** + * @brief Construct a new duration scalar object by deep copying another. + * + * @param[in] other The scalar to copy. + * @param[in] stream CUDA stream used for device memory operations. + * @param[in] mr Device memory resource to use for device memory allocation + */ + duration_scalar(duration_scalar const& other, + rmm::cuda_stream_view stream = rmm::cuda_stream_default, + rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); /** * @brief Construct a new duration scalar object from tick counts @@ -530,12 +622,23 @@ struct duration_scalar : chrono_scalar { class list_scalar : public scalar { public: list_scalar(); - ~list_scalar() = default; - list_scalar(list_scalar&& other) = default; - list_scalar(list_scalar const& other) = default; + ~list_scalar() = default; + list_scalar(list_scalar&& other) = default; + list_scalar& operator=(list_scalar const& other) = delete; list_scalar& operator=(list_scalar&& other) = delete; + /** + * @brief Construct a new list scalar object by deep copying another. + * + * @param[in] other The scalar to copy. + * @param[in] stream CUDA stream used for device memory operations. + * @param[in] mr Device memory resource to use for device memory allocation + */ + list_scalar(list_scalar const& other, + rmm::cuda_stream_view stream = rmm::cuda_stream_default, + rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); + /** * @brief Construct a new list scalar object from column_view * diff --git a/cpp/include/cudf/strings/detail/copy_if_else.cuh b/cpp/include/cudf/strings/detail/copy_if_else.cuh index 7121a6a5a8a..bffcb5c1a31 100644 --- a/cpp/include/cudf/strings/detail/copy_if_else.cuh +++ b/cpp/include/cudf/strings/detail/copy_if_else.cuh @@ -74,8 +74,7 @@ std::unique_ptr copy_if_else( stream, mr); size_type null_count = valid_mask.second; - rmm::device_buffer null_mask{0, stream, mr}; - if (null_count) null_mask = valid_mask.first; + auto null_mask = (null_count > 0) ? std::move(valid_mask.first) : rmm::device_buffer{}; // build offsets column auto offsets_transformer = [lhs_begin, rhs_begin, filter_fn] __device__(size_type idx) { diff --git a/cpp/include/cudf/types.hpp b/cpp/include/cudf/types.hpp index ddba575cb07..8116097e38e 100644 --- a/cpp/include/cudf/types.hpp +++ b/cpp/include/cudf/types.hpp @@ -65,8 +65,8 @@ class struct_scalar; class string_scalar; template class numeric_scalar; template class fixed_point_scalar; -template struct timestamp_scalar; -template struct duration_scalar; +template class timestamp_scalar; +template class duration_scalar; class string_scalar_device_view; template class numeric_scalar_device_view; diff --git a/cpp/include/cudf_test/column_wrapper.hpp b/cpp/include/cudf_test/column_wrapper.hpp index 7667254ffbf..74d22085b26 100644 --- a/cpp/include/cudf_test/column_wrapper.hpp +++ b/cpp/include/cudf_test/column_wrapper.hpp @@ -145,7 +145,7 @@ rmm::device_buffer make_elements(InputIterator begin, InputIterator end) auto transform_begin = thrust::make_transform_iterator(begin, transformer); auto const size = cudf::distance(begin, end); auto const elements = thrust::host_vector(transform_begin, transform_begin + size); - return rmm::device_buffer{elements.data(), size * sizeof(ElementTo)}; + return rmm::device_buffer{elements.data(), size * sizeof(ElementTo), rmm::cuda_stream_default}; } /** @@ -171,7 +171,7 @@ rmm::device_buffer make_elements(InputIterator begin, InputIterator end) auto transform_begin = thrust::make_transform_iterator(begin, transformer); auto const size = cudf::distance(begin, end); auto const elements = thrust::host_vector(transform_begin, transform_begin + size); - return rmm::device_buffer{elements.data(), size * sizeof(RepType)}; + return rmm::device_buffer{elements.data(), size * sizeof(RepType), rmm::cuda_stream_default}; } /** @@ -198,7 +198,7 @@ rmm::device_buffer make_elements(InputIterator begin, InputIterator end) auto transformer_begin = thrust::make_transform_iterator(begin, to_rep); auto const size = cudf::distance(begin, end); auto const elements = thrust::host_vector(transformer_begin, transformer_begin + size); - return rmm::device_buffer{elements.data(), size * sizeof(RepType)}; + return rmm::device_buffer{elements.data(), size * sizeof(RepType), rmm::cuda_stream_default}; } /** @@ -245,7 +245,8 @@ rmm::device_buffer make_null_mask(ValidityIterator begin, ValidityIterator end) { auto null_mask = make_null_mask_vector(begin, end); return rmm::device_buffer{null_mask.data(), - null_mask.size() * sizeof(decltype(null_mask.front()))}; + null_mask.size() * sizeof(decltype(null_mask.front())), + rmm::cuda_stream_default}; } /** @@ -514,8 +515,10 @@ class fixed_point_column_wrapper : public detail::column_wrapper { auto const id = is_decimal32 ? type_id::DECIMAL32 : type_id::DECIMAL64; auto const data_type = cudf::data_type{id, static_cast(scale)}; - wrapped.reset( - new cudf::column{data_type, size, rmm::device_buffer{elements.data(), size * sizeof(Rep)}}); + wrapped.reset(new cudf::column{ + data_type, + size, + rmm::device_buffer{elements.data(), size * sizeof(Rep), rmm::cuda_stream_default}}); } /** @@ -577,11 +580,12 @@ class fixed_point_column_wrapper : public detail::column_wrapper { auto const id = is_decimal32 ? type_id::DECIMAL32 : type_id::DECIMAL64; auto const data_type = cudf::data_type{id, static_cast(scale)}; - wrapped.reset(new cudf::column{data_type, - size, - rmm::device_buffer{elements.data(), size * sizeof(Rep)}, - detail::make_null_mask(v, v + size), - cudf::UNKNOWN_NULL_COUNT}); + wrapped.reset(new cudf::column{ + data_type, + size, + rmm::device_buffer{elements.data(), size * sizeof(Rep), rmm::cuda_stream_default}, + detail::make_null_mask(v, v + size), + cudf::UNKNOWN_NULL_COUNT}); } /** @@ -1514,7 +1518,7 @@ class lists_column_wrapper : public detail::column_wrapper { std::move(offsets), std::move(data), v.size() <= 0 ? 0 : cudf::UNKNOWN_NULL_COUNT, - v.size() <= 0 ? rmm::device_buffer{0} + v.size() <= 0 ? rmm::device_buffer{} : cudf::test::detail::make_null_mask(v.begin(), v.end())); } @@ -1544,7 +1548,7 @@ class lists_column_wrapper : public detail::column_wrapper { size_type num_elements = offsets->size() == 0 ? 0 : offsets->size() - 1; wrapped = - make_lists_column(num_elements, std::move(offsets), std::move(c), 0, rmm::device_buffer{0}); + make_lists_column(num_elements, std::move(offsets), std::move(c), 0, rmm::device_buffer{}); } /** @@ -1776,7 +1780,7 @@ class structs_column_wrapper : public detail::column_wrapper { num_rows, std::move(child_columns), validity.size() <= 0 ? 0 : cudf::UNKNOWN_NULL_COUNT, - validity.size() <= 0 ? rmm::device_buffer{0} + validity.size() <= 0 ? rmm::device_buffer{} : detail::make_null_mask(validity.begin(), validity.end())); } diff --git a/cpp/src/binaryop/compiled/binary_ops.cu b/cpp/src/binaryop/compiled/binary_ops.cu index 7d43524f608..2b24e0cfa3d 100644 --- a/cpp/src/binaryop/compiled/binary_ops.cu +++ b/cpp/src/binaryop/compiled/binary_ops.cu @@ -123,7 +123,8 @@ struct binary_op { auto out_view = out->mutable_view(); auto out_itr = out_view.begin(); auto lhs_device_view = column_device_view::create(lhs, stream); - auto rhs_scalar = static_cast const&>(rhs); + using rhs_type = cudf::scalar_type_t; + auto rhs_scalar = rhs_type(static_cast(rhs), stream); auto rhs_scalar_view = get_scalar_device_view(rhs_scalar); if (lhs.has_nulls()) { auto lhs_itr = cudf::detail::make_null_replacement_iterator(*lhs_device_view, Lhs{}); diff --git a/cpp/src/column/column.cu b/cpp/src/column/column.cu index d30e5fc746a..3ee8e0a33a9 100644 --- a/cpp/src/column/column.cu +++ b/cpp/src/column/column.cu @@ -43,19 +43,8 @@ #include namespace cudf { -// Copy constructor -column::column(column const &other) - : _type{other._type}, - _size{other._size}, - _data{other._data}, - _null_mask{other._null_mask}, - _null_count{other._null_count} -{ - _children.reserve(other.num_children()); - for (auto const &c : other._children) { _children.emplace_back(std::make_unique(*c)); } -} -// Copy ctor w/ explicit stream/mr +// Copy ctor w/ optional stream/mr column::column(column const &other, rmm::cuda_stream_view stream, rmm::mr::device_memory_resource *mr) @@ -165,14 +154,16 @@ void column::set_null_mask(rmm::device_buffer &&new_null_mask, size_type new_nul _null_count = new_null_count; } -void column::set_null_mask(rmm::device_buffer const &new_null_mask, size_type new_null_count) +void column::set_null_mask(rmm::device_buffer const &new_null_mask, + size_type new_null_count, + rmm::cuda_stream_view stream) { if (new_null_count > 0) { CUDF_EXPECTS(new_null_mask.size() >= cudf::bitmask_allocation_size_bytes(this->size()), "Column with null values must be nullable and the null mask \ buffer size should match the size of the column."); } - _null_mask = new_null_mask; // copy + _null_mask = rmm::device_buffer{new_null_mask, stream}; // copy _null_count = new_null_count; } diff --git a/cpp/src/column/column_factories.cu b/cpp/src/column/column_factories.cu index 6ba8497b320..9168d47aaf7 100644 --- a/cpp/src/column/column_factories.cu +++ b/cpp/src/column/column_factories.cu @@ -56,7 +56,7 @@ std::unique_ptr column_from_scalar_dispatch::operator()( - value.type(), size, rmm::device_buffer{0, stream, mr}, null_mask, size); + value.type(), size, rmm::device_buffer{}, std::move(null_mask), size); // Create a strings column_view with all nulls and no children. // Since we are setting every row to the scalar, the fill() never needs to access @@ -66,7 +66,7 @@ std::unique_ptr column_from_scalar_dispatch::operator() const&>(value); // fill the column with the scalar auto output = strings::detail::fill(strings_column_view(sc), 0, size, sv, stream, mr); - output->set_null_mask(rmm::device_buffer{0, stream, mr}, 0); // should be no nulls + output->set_null_mask(rmm::device_buffer{}, 0); // should be no nulls return output; } diff --git a/cpp/src/copying/scatter.cu b/cpp/src/copying/scatter.cu index 994e085585c..a932957ada4 100644 --- a/cpp/src/copying/scatter.cu +++ b/cpp/src/copying/scatter.cu @@ -194,8 +194,8 @@ struct column_scalar_scatterer_impl { auto contents = new_indices->release(); auto indices_column = std::make_unique(indices_type, static_cast(output_size), - *(contents.data.release()), - rmm::device_buffer{0, stream, mr}, + std::move(*(contents.data.release())), + rmm::device_buffer{}, 0); // use the keys from the matched column std::unique_ptr keys_column(std::move(dict_target->release().children.back())); diff --git a/cpp/src/dictionary/dictionary_factories.cu b/cpp/src/dictionary/dictionary_factories.cu index 73d1becf639..35e7d5fbc27 100644 --- a/cpp/src/dictionary/dictionary_factories.cu +++ b/cpp/src/dictionary/dictionary_factories.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * Copyright (c) 2020-2021, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -134,7 +134,7 @@ std::unique_ptr make_dictionary_column(std::unique_ptr keys, // If the types match, then just commandeer the column's data buffer. if (new_type.id() == indices_type) { return std::make_unique( - new_type, indices_size, *(contents.data.release()), rmm::device_buffer{0, stream, mr}, 0); + new_type, indices_size, std::move(*(contents.data.release())), rmm::device_buffer{}, 0); } // If the new type does not match, then convert the data. cudf::column_view cast_view{cudf::data_type{indices_type}, indices_size, contents.data->data()}; diff --git a/cpp/src/interop/from_arrow.cu b/cpp/src/interop/from_arrow.cu index ee02fadc017..9475d3136e5 100644 --- a/cpp/src/interop/from_arrow.cu +++ b/cpp/src/interop/from_arrow.cu @@ -150,7 +150,7 @@ struct dispatch_to_cudf_column { // If array is sliced, we have to copy whole mask and then take copy. auto out_mask = (num_rows == static_cast(data_buffer->size() / sizeof(T))) - ? *tmp_mask + ? std::move(*tmp_mask) : cudf::detail::copy_bitmask(static_cast(tmp_mask->data()), array.offset(), array.offset() + num_rows, @@ -166,7 +166,7 @@ struct dispatch_to_cudf_column { std::unique_ptr get_empty_type_column(size_type size) { - return std::make_unique(data_type(type_id::EMPTY), size, rmm::device_buffer(0)); + return std::make_unique(data_type(type_id::EMPTY), size, rmm::device_buffer{}); } /** @@ -215,7 +215,7 @@ std::unique_ptr dispatch_to_cudf_column::operator()( auto temp_mask = get_mask_buffer(array, stream, mr); // If array is sliced, we have to copy whole mask and then take copy. return (num_rows == static_cast(data_buffer->size() / sizeof(DeviceType))) - ? *temp_mask.release() + ? std::move(*temp_mask.release()) : cudf::detail::copy_bitmask(static_cast(temp_mask->data()), array.offset(), array.offset() + num_rows, @@ -350,7 +350,7 @@ std::unique_ptr dispatch_to_cudf_column::operator()( return get_column(*child_array, type, false, stream, mr); }); - auto out_mask = *(get_mask_buffer(array, stream, mr)); + auto out_mask = std::move(*(get_mask_buffer(array, stream, mr))); if (struct_array->null_bitmap_data() != nullptr) { out_mask = detail::copy_bitmask(static_cast(out_mask.data()), array.offset(), @@ -433,7 +433,7 @@ std::unique_ptr from_arrow(arrow::Table const& input_table, return get_column(*array_chunk, cudf_type, false, stream, mr); }); if (concat_columns.empty()) { - return std::make_unique(cudf_type, 0, rmm::device_buffer(0)); + return std::make_unique(cudf_type, 0, rmm::device_buffer{}); } else if (concat_columns.size() == 1) { return std::move(concat_columns[0]); } diff --git a/cpp/src/io/avro/reader_impl.cu b/cpp/src/io/avro/reader_impl.cu index 070a5ca2529..21253ce8cdf 100644 --- a/cpp/src/io/avro/reader_impl.cu +++ b/cpp/src/io/avro/reader_impl.cu @@ -213,7 +213,7 @@ rmm::device_buffer reader::impl::decompress_data(const rmm::device_buffer &comp_ actual_uncompressed_size += inflate_in[i].dstSize; } if (actual_uncompressed_size > uncompressed_data_size) { - decomp_block_data.resize(actual_uncompressed_size); + decomp_block_data.resize(actual_uncompressed_size, stream); for (size_t i = 0, dst_pos = 0; i < _metadata->block_list.size(); i++) { auto dst_base = static_cast(decomp_block_data.data()); inflate_in[i].dstDevice = dst_base + dst_pos; @@ -374,7 +374,7 @@ table_with_metadata reader::impl::read(avro_reader_options const &options, _metadata->total_data_size, static_cast(block_data.data()), stream); - block_data.resize(read_bytes); + block_data.resize(read_bytes, stream); } else { const auto buffer = _source->host_read(_metadata->block_list[0].offset, _metadata->total_data_size); diff --git a/cpp/src/lists/explode.cu b/cpp/src/lists/explode.cu index 1fe750e69e0..3ce0f91fd71 100644 --- a/cpp/src/lists/explode.cu +++ b/cpp/src/lists/explode.cu @@ -94,7 +94,7 @@ std::unique_ptr
build_table( std::make_unique(data_type(type_to_id()), position_size, position_array->release(), - nullmask.first, + std::move(nullmask.first), nullmask.second)); } diff --git a/cpp/src/lists/lists_column_factories.cu b/cpp/src/lists/lists_column_factories.cu index 3291aeb9f22..9c1cbd8a8cc 100644 --- a/cpp/src/lists/lists_column_factories.cu +++ b/cpp/src/lists/lists_column_factories.cu @@ -109,8 +109,8 @@ std::unique_ptr make_lists_column(size_type num_rows, children.emplace_back(std::move(child_column)); return std::make_unique(cudf::data_type{type_id::LIST}, num_rows, - rmm::device_buffer{0, stream, mr}, - null_mask, + rmm::device_buffer{}, + std::move(null_mask), null_count, std::move(children)); } diff --git a/cpp/src/replace/clamp.cu b/cpp/src/replace/clamp.cu index e0e54570cd6..bf2ae63a99d 100644 --- a/cpp/src/replace/clamp.cu +++ b/cpp/src/replace/clamp.cu @@ -324,8 +324,8 @@ std::unique_ptr dispatch_clamp::operator()( auto contents = new_indices->release(); auto indices_column = std::make_unique(indices_type, static_cast(output_size), - *(contents.data.release()), - rmm::device_buffer{0, stream, mr}, + std::move(*(contents.data.release())), + rmm::device_buffer{}, 0); // take the keys from the matched column allocated using mr diff --git a/cpp/src/replace/replace.cu b/cpp/src/replace/replace.cu index 43040ac5dfb..6ddf7a584ba 100644 --- a/cpp/src/replace/replace.cu +++ b/cpp/src/replace/replace.cu @@ -470,7 +470,7 @@ std::unique_ptr replace_kernel_forwarder::operator()null_count(); auto contents = new_indices->release(); auto indices_column = std::make_unique( - indices_type, input.size(), *(contents.data.release()), rmm::device_buffer{0, stream, mr}, 0); + indices_type, input.size(), std::move(*(contents.data.release())), rmm::device_buffer{}, 0); std::unique_ptr keys_column(std::move(matched_input->release().children.back())); return cudf::make_dictionary_column(std::move(keys_column), std::move(indices_column), diff --git a/cpp/src/reshape/interleave_columns.cu b/cpp/src/reshape/interleave_columns.cu index 667937830f6..9024584a16b 100644 --- a/cpp/src/reshape/interleave_columns.cu +++ b/cpp/src/reshape/interleave_columns.cu @@ -69,7 +69,7 @@ struct interleave_columns_functor { auto d_table = *table; auto num_strings = num_columns * strings_count; - std::pair valid_mask{{}, 0}; + std::pair valid_mask{}; if (create_mask) { // Create resulting null mask valid_mask = cudf::detail::valid_if( diff --git a/cpp/src/scalar/scalar.cpp b/cpp/src/scalar/scalar.cpp index f21b1c7ca20..9189634b5d8 100644 --- a/cpp/src/scalar/scalar.cpp +++ b/cpp/src/scalar/scalar.cpp @@ -37,6 +37,13 @@ scalar::scalar(data_type type, { } +scalar::scalar(scalar const& other, + rmm::cuda_stream_view stream, + rmm::mr::device_memory_resource* mr) + : _type(other.type()), _is_valid(other._is_valid, stream, mr) +{ +} + data_type scalar::type() const noexcept { return _type; } void scalar::set_valid(bool is_valid, rmm::cuda_stream_view stream) @@ -60,6 +67,13 @@ string_scalar::string_scalar(std::string const& string, { } +string_scalar::string_scalar(string_scalar const& other, + rmm::cuda_stream_view stream, + rmm::mr::device_memory_resource* mr) + : scalar(other, stream, mr), _data(other._data, stream, mr) +{ +} + string_scalar::string_scalar(rmm::device_scalar& data, bool is_valid, rmm::cuda_stream_view stream, @@ -141,6 +155,14 @@ fixed_point_scalar::fixed_point_scalar(rmm::device_scalar&& data, { } +template +fixed_point_scalar::fixed_point_scalar(fixed_point_scalar const& other, + rmm::cuda_stream_view stream, + rmm::mr::device_memory_resource* mr) + : scalar{other, stream, mr}, _data(other._data, stream, mr) +{ +} + template typename fixed_point_scalar::rep_type fixed_point_scalar::value( rmm::cuda_stream_view stream) const @@ -204,6 +226,14 @@ fixed_width_scalar::fixed_width_scalar(rmm::device_scalar&& data, { } +template +fixed_width_scalar::fixed_width_scalar(fixed_width_scalar const& other, + rmm::cuda_stream_view stream, + rmm::mr::device_memory_resource* mr) + : scalar{other, stream, mr}, _data(other._data, stream, mr) +{ +} + template void fixed_width_scalar::set_value(T value, rmm::cuda_stream_view stream) { @@ -285,6 +315,14 @@ numeric_scalar::numeric_scalar(rmm::device_scalar&& data, { } +template +numeric_scalar::numeric_scalar(numeric_scalar const& other, + rmm::cuda_stream_view stream, + rmm::mr::device_memory_resource* mr) + : detail::fixed_width_scalar{other, stream, mr} +{ +} + /** * @brief These define the valid numeric scalar types. * @@ -323,6 +361,14 @@ chrono_scalar::chrono_scalar(rmm::device_scalar&& data, { } +template +chrono_scalar::chrono_scalar(chrono_scalar const& other, + rmm::cuda_stream_view stream, + rmm::mr::device_memory_resource* mr) + : detail::fixed_width_scalar{other, stream, mr} +{ +} + /** * @brief These define the valid chrono scalar types. * @@ -351,6 +397,14 @@ duration_scalar::duration_scalar(rep_type value, { } +template +duration_scalar::duration_scalar(duration_scalar const& other, + rmm::cuda_stream_view stream, + rmm::mr::device_memory_resource* mr) + : chrono_scalar{other, stream, mr} +{ +} + template typename duration_scalar::rep_type duration_scalar::count() { @@ -401,6 +455,14 @@ timestamp_scalar::timestamp_scalar(D const& value, { } +template +timestamp_scalar::timestamp_scalar(timestamp_scalar const& other, + rmm::cuda_stream_view stream, + rmm::mr::device_memory_resource* mr) + : chrono_scalar{other, stream, mr} +{ +} + #define TS_CTOR(TimestampType, DurationType) \ template timestamp_scalar::timestamp_scalar( \ DurationType const&, bool, rmm::cuda_stream_view, rmm::mr::device_memory_resource*); @@ -447,6 +509,13 @@ list_scalar::list_scalar(cudf::column&& data, { } +list_scalar::list_scalar(list_scalar const& other, + rmm::cuda_stream_view stream, + rmm::mr::device_memory_resource* mr) + : scalar{other, stream, mr}, _data(other._data, stream, mr) +{ +} + column_view list_scalar::view() const { return _data.view(); } struct_scalar::struct_scalar() : scalar(data_type(type_id::STRUCT)) {} diff --git a/cpp/src/strings/replace/multi_re.cu b/cpp/src/strings/replace/multi_re.cu index a1b196f792d..2672dc4fb7a 100644 --- a/cpp/src/strings/replace/multi_re.cu +++ b/cpp/src/strings/replace/multi_re.cu @@ -159,7 +159,7 @@ std::unique_ptr replace_re( } // copy all the reprog_device instances to a device memory array - rmm::device_buffer progs_buffer{sizeof(reprog_device) * progs.size()}; + rmm::device_buffer progs_buffer{sizeof(reprog_device) * progs.size(), stream}; CUDA_TRY(cudaMemcpyAsync(progs_buffer.data(), progs.data(), progs.size() * sizeof(reprog_device), diff --git a/cpp/src/strings/strings_column_factories.cu b/cpp/src/strings/strings_column_factories.cu index 7aba5adaf4e..abf1f9599dc 100644 --- a/cpp/src/strings/strings_column_factories.cu +++ b/cpp/src/strings/strings_column_factories.cu @@ -131,8 +131,8 @@ std::unique_ptr make_strings_column(size_type num_strings, children.emplace_back(std::move(chars_column)); return std::make_unique(data_type{type_id::STRING}, num_strings, - rmm::device_buffer{0, stream, mr}, - null_mask, + rmm::device_buffer{}, + std::move(null_mask), null_count, std::move(children)); } diff --git a/cpp/src/structs/structs_column_factories.cu b/cpp/src/structs/structs_column_factories.cu index d8b94d1c448..833ceab7518 100644 --- a/cpp/src/structs/structs_column_factories.cu +++ b/cpp/src/structs/structs_column_factories.cu @@ -50,13 +50,12 @@ std::unique_ptr make_structs_column( } } - return std::make_unique( - cudf::data_type{type_id::STRUCT}, - num_rows, - rmm::device_buffer{0, stream, mr}, // Empty data buffer. Structs hold no data. - null_mask, - null_count, - std::move(child_columns)); + return std::make_unique(cudf::data_type{type_id::STRUCT}, + num_rows, + rmm::device_buffer{}, // Empty data buffer. Structs hold no data. + std::move(null_mask), + null_count, + std::move(child_columns)); } } // namespace cudf diff --git a/cpp/tests/bitmask/bitmask_tests.cpp b/cpp/tests/bitmask/bitmask_tests.cpp index 3fb12efcc93..3e6e88fa955 100644 --- a/cpp/tests/bitmask/bitmask_tests.cpp +++ b/cpp/tests/bitmask/bitmask_tests.cpp @@ -462,8 +462,11 @@ TEST_F(CopyBitmaskTest, TestCopyColumnViewVectorContiguous) for (auto &m : validity_bit) { m = this->generate(); } auto gold_mask = cudf::test::detail::make_null_mask(validity_bit.begin(), validity_bit.end()); - auto copy_mask = gold_mask; - cudf::column original{t, num_elements, rmm::device_buffer{num_elements * sizeof(int)}, copy_mask}; + rmm::device_buffer copy_mask{gold_mask, rmm::cuda_stream_default}; + cudf::column original{t, + num_elements, + rmm::device_buffer{num_elements * sizeof(int), rmm::cuda_stream_default}, + std::move(copy_mask)}; std::vector indices{0, 104, 104, @@ -501,11 +504,12 @@ TEST_F(CopyBitmaskTest, TestCopyColumnViewVectorDiscontiguous) std::vector cols; std::vector views; for (unsigned i = 0; i < split.size() - 1; i++) { - cols.emplace_back(t, - split[i + 1] - split[i], - rmm::device_buffer{sizeof(int) * (split[i + 1] - split[i])}, - cudf::test::detail::make_null_mask(validity_bit.begin() + split[i], - validity_bit.begin() + split[i + 1])); + cols.emplace_back( + t, + split[i + 1] - split[i], + rmm::device_buffer{sizeof(int) * (split[i + 1] - split[i]), rmm::cuda_stream_default}, + cudf::test::detail::make_null_mask(validity_bit.begin() + split[i], + validity_bit.begin() + split[i + 1])); views.push_back(cols.back()); } rmm::device_buffer concatenated_bitmask = cudf::concatenate_masks(views); diff --git a/cpp/tests/bitmask/valid_if_tests.cu b/cpp/tests/bitmask/valid_if_tests.cu index fc60011d39d..a69f5609fef 100644 --- a/cpp/tests/bitmask/valid_if_tests.cu +++ b/cpp/tests/bitmask/valid_if_tests.cu @@ -40,7 +40,7 @@ TEST_F(ValidIfTest, EmptyRange) { auto actual = cudf::detail::valid_if( thrust::make_counting_iterator(0), thrust::make_counting_iterator(0), odds_valid{}); - auto buffer = actual.first; + auto const& buffer = actual.first; EXPECT_EQ(0u, buffer.size()); EXPECT_EQ(nullptr, buffer.data()); EXPECT_EQ(0, actual.second); diff --git a/cpp/tests/column/column_test.cu b/cpp/tests/column/column_test.cu index 38b95030465..909b8fc1b6b 100644 --- a/cpp/tests/column/column_test.cu +++ b/cpp/tests/column/column_test.cu @@ -38,8 +38,8 @@ struct TypedColumnTest : public cudf::test::BaseFixture { cudf::data_type type() { return cudf::data_type{cudf::type_to_id()}; } TypedColumnTest() - : data{_num_elements * cudf::size_of(type())}, - mask{cudf::bitmask_allocation_size_bytes(_num_elements)} + : data{_num_elements * cudf::size_of(type()), rmm::cuda_stream_default}, + mask{cudf::bitmask_allocation_size_bytes(_num_elements), rmm::cuda_stream_default} { auto typed_data = static_cast(data.data()); auto typed_mask = static_cast(mask.data()); @@ -87,7 +87,7 @@ void verify_column_views(cudf::column col) TYPED_TEST(TypedColumnTest, DefaultNullCountNoMask) { - cudf::column col{this->type(), this->num_elements(), this->data}; + cudf::column col{this->type(), this->num_elements(), std::move(this->data)}; EXPECT_FALSE(col.nullable()); EXPECT_FALSE(col.has_nulls()); EXPECT_EQ(0, col.null_count()); @@ -95,7 +95,7 @@ TYPED_TEST(TypedColumnTest, DefaultNullCountNoMask) TYPED_TEST(TypedColumnTest, DefaultNullCountEmptyMask) { - cudf::column col{this->type(), this->num_elements(), this->data, rmm::device_buffer{}}; + cudf::column col{this->type(), this->num_elements(), std::move(this->data), rmm::device_buffer{}}; EXPECT_FALSE(col.nullable()); EXPECT_FALSE(col.has_nulls()); EXPECT_EQ(0, col.null_count()); @@ -103,7 +103,8 @@ TYPED_TEST(TypedColumnTest, DefaultNullCountEmptyMask) TYPED_TEST(TypedColumnTest, DefaultNullCountAllValid) { - cudf::column col{this->type(), this->num_elements(), this->data, this->all_valid_mask}; + cudf::column col{ + this->type(), this->num_elements(), std::move(this->data), std::move(this->all_valid_mask)}; EXPECT_TRUE(col.nullable()); EXPECT_FALSE(col.has_nulls()); EXPECT_EQ(0, col.null_count()); @@ -111,7 +112,8 @@ TYPED_TEST(TypedColumnTest, DefaultNullCountAllValid) TYPED_TEST(TypedColumnTest, ExplicitNullCountAllValid) { - cudf::column col{this->type(), this->num_elements(), this->data, this->all_valid_mask, 0}; + cudf::column col{ + this->type(), this->num_elements(), std::move(this->data), std::move(this->all_valid_mask), 0}; EXPECT_TRUE(col.nullable()); EXPECT_FALSE(col.has_nulls()); EXPECT_EQ(0, col.null_count()); @@ -119,7 +121,8 @@ TYPED_TEST(TypedColumnTest, ExplicitNullCountAllValid) TYPED_TEST(TypedColumnTest, DefaultNullCountAllNull) { - cudf::column col{this->type(), this->num_elements(), this->data, this->all_null_mask}; + cudf::column col{ + this->type(), this->num_elements(), std::move(this->data), std::move(this->all_null_mask)}; EXPECT_TRUE(col.nullable()); EXPECT_TRUE(col.has_nulls()); EXPECT_EQ(this->num_elements(), col.null_count()); @@ -127,8 +130,11 @@ TYPED_TEST(TypedColumnTest, DefaultNullCountAllNull) TYPED_TEST(TypedColumnTest, ExplicitNullCountAllNull) { - cudf::column col{ - this->type(), this->num_elements(), this->data, this->all_null_mask, this->num_elements()}; + cudf::column col{this->type(), + this->num_elements(), + std::move(this->data), + std::move(this->all_null_mask), + this->num_elements()}; EXPECT_TRUE(col.nullable()); EXPECT_TRUE(col.has_nulls()); EXPECT_EQ(this->num_elements(), col.null_count()); @@ -136,20 +142,20 @@ TYPED_TEST(TypedColumnTest, ExplicitNullCountAllNull) TYPED_TEST(TypedColumnTest, SetNullCountNoMask) { - cudf::column col{this->type(), this->num_elements(), this->data}; + cudf::column col{this->type(), this->num_elements(), std::move(this->data)}; EXPECT_THROW(col.set_null_count(1), cudf::logic_error); } TYPED_TEST(TypedColumnTest, SetEmptyNullMaskNonZeroNullCount) { - cudf::column col{this->type(), this->num_elements(), this->data}; + cudf::column col{this->type(), this->num_elements(), std::move(this->data)}; rmm::device_buffer empty_null_mask{}; EXPECT_THROW(col.set_null_mask(empty_null_mask, this->num_elements()), cudf::logic_error); } TYPED_TEST(TypedColumnTest, SetInvalidSizeNullMaskNonZeroNullCount) { - cudf::column col{this->type(), this->num_elements(), this->data}; + cudf::column col{this->type(), this->num_elements(), std::move(this->data)}; auto invalid_size_null_mask = create_null_mask(std::min(this->num_elements() - 50, 0), cudf::mask_state::ALL_VALID); EXPECT_THROW(col.set_null_mask(invalid_size_null_mask, this->num_elements()), cudf::logic_error); @@ -157,27 +163,30 @@ TYPED_TEST(TypedColumnTest, SetInvalidSizeNullMaskNonZeroNullCount) TYPED_TEST(TypedColumnTest, SetNullCountEmptyMask) { - cudf::column col{this->type(), this->num_elements(), this->data, rmm::device_buffer{}}; + cudf::column col{this->type(), this->num_elements(), std::move(this->data), rmm::device_buffer{}}; EXPECT_THROW(col.set_null_count(1), cudf::logic_error); } TYPED_TEST(TypedColumnTest, SetNullCountAllValid) { - cudf::column col{this->type(), this->num_elements(), this->data, this->all_valid_mask}; + cudf::column col{ + this->type(), this->num_elements(), std::move(this->data), std::move(this->all_valid_mask)}; EXPECT_NO_THROW(col.set_null_count(0)); EXPECT_EQ(0, col.null_count()); } TYPED_TEST(TypedColumnTest, SetNullCountAllNull) { - cudf::column col{this->type(), this->num_elements(), this->data, this->all_null_mask}; + cudf::column col{ + this->type(), this->num_elements(), std::move(this->data), std::move(this->all_null_mask)}; EXPECT_NO_THROW(col.set_null_count(this->num_elements())); EXPECT_EQ(this->num_elements(), col.null_count()); } TYPED_TEST(TypedColumnTest, ResetNullCountAllNull) { - cudf::column col{this->type(), this->num_elements(), this->data, this->all_null_mask}; + cudf::column col{ + this->type(), this->num_elements(), std::move(this->data), std::move(this->all_null_mask)}; EXPECT_EQ(this->num_elements(), col.null_count()); EXPECT_NO_THROW(col.set_null_count(cudf::UNKNOWN_NULL_COUNT)); @@ -186,7 +195,8 @@ TYPED_TEST(TypedColumnTest, ResetNullCountAllNull) TYPED_TEST(TypedColumnTest, ResetNullCountAllValid) { - cudf::column col{this->type(), this->num_elements(), this->data, this->all_valid_mask}; + cudf::column col{ + this->type(), this->num_elements(), std::move(this->data), std::move(this->all_valid_mask)}; EXPECT_EQ(0, col.null_count()); EXPECT_NO_THROW(col.set_null_count(cudf::UNKNOWN_NULL_COUNT)); EXPECT_EQ(0, col.null_count()); @@ -194,7 +204,7 @@ TYPED_TEST(TypedColumnTest, ResetNullCountAllValid) TYPED_TEST(TypedColumnTest, CopyDataNoMask) { - cudf::column col{this->type(), this->num_elements(), this->data}; + cudf::column col{this->type(), this->num_elements(), std::move(this->data)}; EXPECT_EQ(this->type(), col.type()); EXPECT_FALSE(col.nullable()); EXPECT_EQ(0, col.null_count()); @@ -228,7 +238,10 @@ TYPED_TEST(TypedColumnTest, MoveDataNoMask) TYPED_TEST(TypedColumnTest, CopyDataAndMask) { - cudf::column col{this->type(), this->num_elements(), this->data, this->all_valid_mask}; + cudf::column col{this->type(), + this->num_elements(), + rmm::device_buffer{this->data, rmm::cuda_stream_default}, + rmm::device_buffer{this->all_valid_mask, rmm::cuda_stream_default}}; EXPECT_EQ(this->type(), col.type()); EXPECT_TRUE(col.nullable()); EXPECT_EQ(0, col.null_count()); @@ -267,7 +280,7 @@ TYPED_TEST(TypedColumnTest, MoveDataAndMask) TYPED_TEST(TypedColumnTest, CopyConstructorNoMask) { - cudf::column original{this->type(), this->num_elements(), this->data}; + cudf::column original{this->type(), this->num_elements(), std::move(this->data)}; cudf::column copy{original}; verify_column_views(copy); CUDF_TEST_EXPECT_COLUMNS_EQUAL(original, copy); @@ -280,7 +293,8 @@ TYPED_TEST(TypedColumnTest, CopyConstructorNoMask) TYPED_TEST(TypedColumnTest, CopyConstructorWithMask) { - cudf::column original{this->type(), this->num_elements(), this->data, this->all_valid_mask}; + cudf::column original{ + this->type(), this->num_elements(), std::move(this->data), std::move(this->all_valid_mask)}; cudf::column copy{original}; verify_column_views(copy); CUDF_TEST_EXPECT_COLUMNS_EQUAL(original, copy); @@ -294,7 +308,7 @@ TYPED_TEST(TypedColumnTest, CopyConstructorWithMask) TYPED_TEST(TypedColumnTest, MoveConstructorNoMask) { - cudf::column original{this->type(), this->num_elements(), this->data}; + cudf::column original{this->type(), this->num_elements(), std::move(this->data)}; auto original_data = original.view().head(); @@ -312,7 +326,8 @@ TYPED_TEST(TypedColumnTest, MoveConstructorNoMask) TYPED_TEST(TypedColumnTest, MoveConstructorWithMask) { - cudf::column original{this->type(), this->num_elements(), this->data, this->all_valid_mask}; + cudf::column original{ + this->type(), this->num_elements(), std::move(this->data), std::move(this->all_valid_mask)}; auto original_data = original.view().head(); auto original_mask = original.view().null_mask(); cudf::column moved_to{std::move(original)}; @@ -330,14 +345,21 @@ TYPED_TEST(TypedColumnTest, MoveConstructorWithMask) TYPED_TEST(TypedColumnTest, ConstructWithChildren) { std::vector> children; + ; children.emplace_back(std::make_unique( - cudf::data_type{cudf::type_id::INT8}, 42, this->data, this->all_valid_mask)); + cudf::data_type{cudf::type_id::INT8}, + 42, + rmm::device_buffer{this->data, rmm::cuda_stream_default}, + rmm::device_buffer{this->all_valid_mask, rmm::cuda_stream_default})); children.emplace_back(std::make_unique( - cudf::data_type{cudf::type_id::FLOAT64}, 314, this->data, this->all_valid_mask)); + cudf::data_type{cudf::type_id::FLOAT64}, + 314, + rmm::device_buffer{this->data, rmm::cuda_stream_default}, + rmm::device_buffer{this->all_valid_mask, rmm::cuda_stream_default})); cudf::column col{this->type(), this->num_elements(), - this->data, - this->all_valid_mask, + rmm::device_buffer{this->data, rmm::cuda_stream_default}, + rmm::device_buffer{this->all_valid_mask, rmm::cuda_stream_default}, cudf::UNKNOWN_NULL_COUNT, std::move(children)}; @@ -351,7 +373,8 @@ TYPED_TEST(TypedColumnTest, ConstructWithChildren) TYPED_TEST(TypedColumnTest, ReleaseNoChildren) { - cudf::column col{this->type(), this->num_elements(), this->data, this->all_valid_mask}; + cudf::column col{ + this->type(), this->num_elements(), std::move(this->data), std::move(this->all_valid_mask)}; auto original_data = col.view().head(); auto original_mask = col.view().null_mask(); @@ -369,13 +392,19 @@ TYPED_TEST(TypedColumnTest, ReleaseWithChildren) { std::vector> children; children.emplace_back(std::make_unique( - this->type(), this->num_elements(), this->data, this->all_valid_mask)); + this->type(), + this->num_elements(), + rmm::device_buffer{this->data, rmm::cuda_stream_default}, + rmm::device_buffer{this->all_valid_mask, rmm::cuda_stream_default})); children.emplace_back(std::make_unique( - this->type(), this->num_elements(), this->data, this->all_valid_mask)); + this->type(), + this->num_elements(), + rmm::device_buffer{this->data, rmm::cuda_stream_default}, + rmm::device_buffer{this->all_valid_mask, rmm::cuda_stream_default})); cudf::column col{this->type(), this->num_elements(), - this->data, - this->all_valid_mask, + rmm::device_buffer{this->data, rmm::cuda_stream_default}, + rmm::device_buffer{this->all_valid_mask, rmm::cuda_stream_default}, cudf::UNKNOWN_NULL_COUNT, std::move(children)}; @@ -394,7 +423,8 @@ TYPED_TEST(TypedColumnTest, ReleaseWithChildren) TYPED_TEST(TypedColumnTest, ColumnViewConstructorWithMask) { - cudf::column original{this->type(), this->num_elements(), this->data, this->all_valid_mask}; + cudf::column original{ + this->type(), this->num_elements(), std::move(this->data), std::move(this->all_valid_mask)}; cudf::column_view original_view = original; cudf::column copy{original_view}; verify_column_views(copy); diff --git a/cpp/tests/column/compound_test.cu b/cpp/tests/column/compound_test.cu index 0df1cfaeccc..9a0259ee49a 100644 --- a/cpp/tests/column/compound_test.cu +++ b/cpp/tests/column/compound_test.cu @@ -68,15 +68,27 @@ TEST_F(CompoundColumnTest, ChildrenLevel1) thrust::sequence(rmm::exec_policy(), data.begin(), data.end(), 1); auto null_mask = cudf::create_null_mask(100, cudf::mask_state::UNALLOCATED); - rmm::device_buffer data1(data.data() + 100, 100 * sizeof(int32_t)); - rmm::device_buffer data2(data.data() + 200, 100 * sizeof(int32_t)); - rmm::device_buffer data3(data.data() + 300, 100 * sizeof(int32_t)); + rmm::device_buffer data1{data.data() + 100, 100 * sizeof(int32_t), rmm::cuda_stream_default}; + rmm::device_buffer data2{data.data() + 200, 100 * sizeof(int32_t), rmm::cuda_stream_default}; + rmm::device_buffer data3{data.data() + 300, 100 * sizeof(int32_t), rmm::cuda_stream_default}; auto child1 = - std::make_unique(cudf::data_type{cudf::type_id::INT32}, 100, data1, null_mask, 0); + std::make_unique(cudf::data_type{cudf::type_id::INT32}, + 100, + std::move(data1), + cudf::create_null_mask(100, cudf::mask_state::UNALLOCATED), + 0); auto child2 = - std::make_unique(cudf::data_type{cudf::type_id::INT32}, 200, data2, null_mask, 0); + std::make_unique(cudf::data_type{cudf::type_id::INT32}, + 200, + std::move(data2), + cudf::create_null_mask(100, cudf::mask_state::UNALLOCATED), + 0); auto child3 = - std::make_unique(cudf::data_type{cudf::type_id::INT32}, 300, data3, null_mask, 0); + std::make_unique(cudf::data_type{cudf::type_id::INT32}, + 300, + std::move(data3), + cudf::create_null_mask(100, cudf::mask_state::UNALLOCATED), + 0); std::vector> children; children.emplace_back(std::move(child1)); @@ -85,8 +97,8 @@ TEST_F(CompoundColumnTest, ChildrenLevel1) auto parent = std::make_unique(cudf::data_type{cudf::type_id::STRING}, 100, - rmm::device_buffer{0}, - rmm::device_buffer{0}, + rmm::device_buffer{}, + rmm::device_buffer{}, 0, std::move(children)); @@ -112,24 +124,48 @@ TEST_F(CompoundColumnTest, ChildrenLevel2) thrust::sequence(rmm::exec_policy(), data.begin(), data.end(), 1); auto null_mask = cudf::create_null_mask(100, cudf::mask_state::UNALLOCATED); - rmm::device_buffer data11(data.data() + 100, 100 * sizeof(int32_t)); - rmm::device_buffer data12(data.data() + 200, 100 * sizeof(int32_t)); - rmm::device_buffer data13(data.data() + 300, 100 * sizeof(int32_t)); - rmm::device_buffer data21(data.data() + 400, 100 * sizeof(int32_t)); - rmm::device_buffer data22(data.data() + 500, 100 * sizeof(int32_t)); - rmm::device_buffer data23(data.data() + 600, 100 * sizeof(int32_t)); - auto gchild11 = std::make_unique( - cudf::data_type{cudf::type_id::INT32}, 100, data11, null_mask, 0); - auto gchild12 = std::make_unique( - cudf::data_type{cudf::type_id::INT32}, 200, data12, null_mask, 0); - auto gchild13 = std::make_unique( - cudf::data_type{cudf::type_id::INT32}, 300, data13, null_mask, 0); - auto gchild21 = std::make_unique( - cudf::data_type{cudf::type_id::INT32}, 400, data21, null_mask, 0); - auto gchild22 = std::make_unique( - cudf::data_type{cudf::type_id::INT32}, 500, data22, null_mask, 0); - auto gchild23 = std::make_unique( - cudf::data_type{cudf::type_id::INT32}, 600, data23, null_mask, 0); + rmm::device_buffer data11{data.data() + 100, 100 * sizeof(int32_t), rmm::cuda_stream_default}; + rmm::device_buffer data12{data.data() + 200, 100 * sizeof(int32_t), rmm::cuda_stream_default}; + rmm::device_buffer data13{data.data() + 300, 100 * sizeof(int32_t), rmm::cuda_stream_default}; + rmm::device_buffer data21{data.data() + 400, 100 * sizeof(int32_t), rmm::cuda_stream_default}; + rmm::device_buffer data22{data.data() + 500, 100 * sizeof(int32_t), rmm::cuda_stream_default}; + rmm::device_buffer data23{data.data() + 600, 100 * sizeof(int32_t), rmm::cuda_stream_default}; + auto gchild11 = + std::make_unique(cudf::data_type{cudf::type_id::INT32}, + 100, + std::move(data11), + cudf::create_null_mask(100, cudf::mask_state::UNALLOCATED), + 0); + auto gchild12 = + std::make_unique(cudf::data_type{cudf::type_id::INT32}, + 200, + std::move(data12), + cudf::create_null_mask(100, cudf::mask_state::UNALLOCATED), + 0); + auto gchild13 = + std::make_unique(cudf::data_type{cudf::type_id::INT32}, + 300, + std::move(data13), + cudf::create_null_mask(100, cudf::mask_state::UNALLOCATED), + 0); + auto gchild21 = + std::make_unique(cudf::data_type{cudf::type_id::INT32}, + 400, + std::move(data21), + cudf::create_null_mask(100, cudf::mask_state::UNALLOCATED), + 0); + auto gchild22 = + std::make_unique(cudf::data_type{cudf::type_id::INT32}, + 500, + std::move(data22), + cudf::create_null_mask(100, cudf::mask_state::UNALLOCATED), + 0); + auto gchild23 = + std::make_unique(cudf::data_type{cudf::type_id::INT32}, + 600, + std::move(data23), + cudf::create_null_mask(100, cudf::mask_state::UNALLOCATED), + 0); std::vector> gchildren1; gchildren1.emplace_back(std::move(gchild11)); @@ -142,14 +178,14 @@ TEST_F(CompoundColumnTest, ChildrenLevel2) auto children1 = std::make_unique(cudf::data_type{cudf::type_id::STRING}, 100, - rmm::device_buffer{0}, - rmm::device_buffer{0}, + rmm::device_buffer{}, + rmm::device_buffer{}, 0, std::move(gchildren1)); auto children2 = std::make_unique(cudf::data_type{cudf::type_id::STRING}, 100, - rmm::device_buffer{0}, - rmm::device_buffer{0}, + rmm::device_buffer{}, + rmm::device_buffer{}, 0, std::move(gchildren2)); @@ -158,8 +194,8 @@ TEST_F(CompoundColumnTest, ChildrenLevel2) children.emplace_back(std::move(children2)); auto parent = std::make_unique(cudf::data_type{cudf::type_id::STRING}, 100, - rmm::device_buffer{0}, - rmm::device_buffer{0}, + rmm::device_buffer{}, + rmm::device_buffer{}, 0, std::move(children)); diff --git a/cpp/tests/column/factories_test.cpp b/cpp/tests/column/factories_test.cpp index f9e83311b1b..2c7984b5f79 100644 --- a/cpp/tests/column/factories_test.cpp +++ b/cpp/tests/column/factories_test.cpp @@ -150,7 +150,7 @@ TYPED_TEST(NumericFactoryTest, NullMaskAsParm) rmm::device_buffer null_mask{create_null_mask(this->size(), cudf::mask_state::ALL_NULL)}; auto column = cudf::make_numeric_column(cudf::data_type{cudf::type_to_id()}, this->size(), - null_mask, + std::move(null_mask), this->size(), this->stream(), this->mr()); @@ -164,10 +164,9 @@ TYPED_TEST(NumericFactoryTest, NullMaskAsParm) TYPED_TEST(NumericFactoryTest, NullMaskAsEmptyParm) { - rmm::device_buffer null_mask{}; auto column = cudf::make_numeric_column(cudf::data_type{cudf::type_to_id()}, this->size(), - null_mask, + rmm::device_buffer{}, 0, this->stream(), this->mr()); @@ -327,7 +326,7 @@ TYPED_TEST(FixedWidthFactoryTest, NullMaskAsParm) rmm::device_buffer null_mask{create_null_mask(this->size(), cudf::mask_state::ALL_NULL)}; auto column = cudf::make_fixed_width_column(cudf::data_type{cudf::type_to_id()}, this->size(), - null_mask, + std::move(null_mask), this->size(), this->stream(), this->mr()); @@ -341,10 +340,9 @@ TYPED_TEST(FixedWidthFactoryTest, NullMaskAsParm) TYPED_TEST(FixedWidthFactoryTest, NullMaskAsEmptyParm) { - rmm::device_buffer null_mask{}; auto column = cudf::make_fixed_width_column(cudf::data_type{cudf::type_to_id()}, this->size(), - null_mask, + rmm::device_buffer{}, 0, this->stream(), this->mr()); diff --git a/cpp/tests/copying/concatenate_tests.cu b/cpp/tests/copying/concatenate_tests.cu index 8c4259fb18b..a5564062de6 100644 --- a/cpp/tests/copying/concatenate_tests.cu +++ b/cpp/tests/copying/concatenate_tests.cu @@ -54,8 +54,8 @@ struct TypedColumnTest : public cudf::test::BaseFixture { cudf::data_type type() { return cudf::data_type{cudf::type_to_id()}; } TypedColumnTest() - : data{_num_elements * cudf::size_of(type())}, - mask{cudf::bitmask_allocation_size_bytes(_num_elements)} + : data{_num_elements * cudf::size_of(type()), rmm::cuda_stream_default}, + mask{cudf::bitmask_allocation_size_bytes(_num_elements), rmm::cuda_stream_default} { auto typed_data = static_cast(data.data()); auto typed_mask = static_cast(mask.data()); @@ -99,7 +99,7 @@ TYPED_TEST(TypedColumnTest, ConcatenateNoColumns) TYPED_TEST(TypedColumnTest, ConcatenateColumnView) { - column original{this->type(), this->num_elements(), this->data, this->mask}; + column original{this->type(), this->num_elements(), std::move(this->data), std::move(this->mask)}; std::vector indices{0, this->num_elements() / 3, this->num_elements() / 3, @@ -354,7 +354,7 @@ TEST_F(TableTest, SizeOverflowTest) auto offsets = cudf::test::fixed_width_column_wrapper{0, size}; auto many_chars = cudf::make_fixed_width_column(cudf::data_type{cudf::type_id::INT8}, size); auto col = cudf::make_strings_column( - 1, offsets.release(), std::move(many_chars), 0, rmm::device_buffer{0}); + 1, offsets.release(), std::move(many_chars), 0, rmm::device_buffer{}); cudf::table_view tbl({*col}); EXPECT_THROW(cudf::concatenate(std::vector({tbl, tbl, tbl, tbl, tbl, tbl})), @@ -371,7 +371,7 @@ TEST_F(TableTest, SizeOverflowTest) cudf::make_fixed_width_column(cudf::data_type{cudf::type_id::INT32}, size + 1); auto chars = cudf::test::fixed_width_column_wrapper{0, 1, 2}; auto col = cudf::make_strings_column( - size, std::move(many_offsets), chars.release(), 0, rmm::device_buffer{0}); + size, std::move(many_offsets), chars.release(), 0, rmm::device_buffer{}); cudf::table_view tbl({*col}); EXPECT_THROW(cudf::concatenate(std::vector({tbl, tbl, tbl, tbl, tbl, tbl})), @@ -390,12 +390,12 @@ TEST_F(TableTest, SizeOverflowTest) children.push_back( cudf::make_fixed_width_column(cudf::data_type{cudf::type_id::INT8}, inner_size)); auto struct_col = - cudf::make_structs_column(inner_size, std::move(children), 0, rmm::device_buffer{0}); + cudf::make_structs_column(inner_size, std::move(children), 0, rmm::device_buffer{}); // list auto offsets = cudf::test::fixed_width_column_wrapper{0, inner_size}; - auto col = cudf::make_lists_column( - 1, offsets.release(), std::move(struct_col), 0, rmm::device_buffer{0}); + auto col = + cudf::make_lists_column(1, offsets.release(), std::move(struct_col), 0, rmm::device_buffer{}); cudf::table_view tbl({*col}); auto tables = std::vector({tbl, tbl, tbl, tbl, tbl, tbl, tbl, tbl, tbl, tbl, tbl, tbl}); @@ -412,14 +412,14 @@ TEST_F(TableTest, SizeOverflowTest) auto offsets = cudf::test::fixed_width_column_wrapper{0, 0, 0, inner_size}; auto many_chars = cudf::make_fixed_width_column(cudf::data_type{cudf::type_id::INT8}, inner_size); - auto list_col = cudf::make_lists_column( - 3, offsets.release(), std::move(many_chars), 0, rmm::device_buffer{0}); + auto list_col = + cudf::make_lists_column(3, offsets.release(), std::move(many_chars), 0, rmm::device_buffer{}); // struct std::vector> children; children.push_back(cudf::make_fixed_width_column(cudf::data_type{cudf::type_id::INT32}, size)); children.push_back(std::move(list_col)); - auto col = cudf::make_structs_column(size, std::move(children), 0, rmm::device_buffer{0}); + auto col = cudf::make_structs_column(size, std::move(children), 0, rmm::device_buffer{}); cudf::table_view tbl({*col}); auto tables = std::vector({tbl, tbl, tbl, tbl, tbl, tbl, tbl, tbl, tbl, tbl, tbl, tbl}); diff --git a/cpp/tests/copying/pack_tests.cu b/cpp/tests/copying/pack_tests.cu index b11ebb0183f..84cf176061d 100644 --- a/cpp/tests/copying/pack_tests.cu +++ b/cpp/tests/copying/pack_tests.cu @@ -359,7 +359,7 @@ TEST_F(PackUnpackTest, NestedEmpty) auto empty_string = cudf::strings::detail::make_empty_strings_column(); auto offsets = cudf::test::fixed_width_column_wrapper({0, 0}); auto list = cudf::make_lists_column( - 1, offsets.release(), std::move(empty_string), 0, rmm::device_buffer{0}); + 1, offsets.release(), std::move(empty_string), 0, rmm::device_buffer{}); cudf::table_view src_table({static_cast(*list)}); this->run_test(src_table); @@ -372,7 +372,7 @@ TEST_F(PackUnpackTest, NestedEmpty) auto empty_string = cudf::empty_like(str); auto offsets = cudf::test::fixed_width_column_wrapper({0, 0}); auto list = cudf::make_lists_column( - 1, offsets.release(), std::move(empty_string), 0, rmm::device_buffer{0}); + 1, offsets.release(), std::move(empty_string), 0, rmm::device_buffer{}); cudf::table_view src_table({static_cast(*list)}); this->run_test(src_table); @@ -385,7 +385,7 @@ TEST_F(PackUnpackTest, NestedEmpty) auto empty_list = cudf::empty_like(listw); auto offsets = cudf::test::fixed_width_column_wrapper({0, 0}); auto list = cudf::make_lists_column( - 1, offsets.release(), std::move(empty_list), 0, rmm::device_buffer{0}); + 1, offsets.release(), std::move(empty_list), 0, rmm::device_buffer{}); cudf::table_view src_table({static_cast(*list)}); this->run_test(src_table); @@ -398,7 +398,7 @@ TEST_F(PackUnpackTest, NestedEmpty) auto empty_list = cudf::empty_like(listw); auto offsets = cudf::test::fixed_width_column_wrapper({0, 0}); auto list = cudf::make_lists_column( - 1, offsets.release(), std::move(empty_list), 0, rmm::device_buffer{0}); + 1, offsets.release(), std::move(empty_list), 0, rmm::device_buffer{}); cudf::table_view src_table({static_cast(*list)}); this->run_test(src_table); @@ -413,7 +413,7 @@ TEST_F(PackUnpackTest, NestedEmpty) auto empty_struct = cudf::empty_like(struct_column); auto offsets = cudf::test::fixed_width_column_wrapper({0, 0}); auto list = cudf::make_lists_column( - 1, offsets.release(), std::move(empty_struct), 0, rmm::device_buffer{0}); + 1, offsets.release(), std::move(empty_struct), 0, rmm::device_buffer{}); cudf::table_view src_table({static_cast(*list)}); this->run_test(src_table); diff --git a/cpp/tests/copying/split_tests.cpp b/cpp/tests/copying/split_tests.cpp index 80fa56b398c..d4e5a53aa85 100644 --- a/cpp/tests/copying/split_tests.cpp +++ b/cpp/tests/copying/split_tests.cpp @@ -1549,7 +1549,7 @@ TEST_F(ContiguousSplitTableCornerCases, NestedEmpty) auto empty_string = cudf::strings::detail::make_empty_strings_column(); auto offsets = cudf::test::fixed_width_column_wrapper({0, 0}); auto list = cudf::make_lists_column( - 1, offsets.release(), std::move(empty_string), 0, rmm::device_buffer{0}); + 1, offsets.release(), std::move(empty_string), 0, rmm::device_buffer{}); cudf::table_view src_table({static_cast(*list)}); @@ -1567,7 +1567,7 @@ TEST_F(ContiguousSplitTableCornerCases, NestedEmpty) auto empty_string = cudf::empty_like(str); auto offsets = cudf::test::fixed_width_column_wrapper({0, 0}); auto list = cudf::make_lists_column( - 1, offsets.release(), std::move(empty_string), 0, rmm::device_buffer{0}); + 1, offsets.release(), std::move(empty_string), 0, rmm::device_buffer{}); cudf::table_view src_table({static_cast(*list)}); @@ -1584,8 +1584,8 @@ TEST_F(ContiguousSplitTableCornerCases, NestedEmpty) cudf::test::lists_column_wrapper listw{{1.0f, 2.0f}, {3.0f, 4.0f}}; auto empty_list = cudf::empty_like(listw); auto offsets = cudf::test::fixed_width_column_wrapper({0, 0}); - auto list = cudf::make_lists_column( - 1, offsets.release(), std::move(empty_list), 0, rmm::device_buffer{0}); + auto list = + cudf::make_lists_column(1, offsets.release(), std::move(empty_list), 0, rmm::device_buffer{}); cudf::table_view src_table({static_cast(*list)}); @@ -1602,8 +1602,8 @@ TEST_F(ContiguousSplitTableCornerCases, NestedEmpty) cudf::test::lists_column_wrapper listw{{1.0f, 2.0f}, {3.0f, 4.0f}}; auto empty_list = cudf::empty_like(listw); auto offsets = cudf::test::fixed_width_column_wrapper({0, 0}); - auto list = cudf::make_lists_column( - 1, offsets.release(), std::move(empty_list), 0, rmm::device_buffer{0}); + auto list = + cudf::make_lists_column(1, offsets.release(), std::move(empty_list), 0, rmm::device_buffer{}); cudf::table_view src_table({static_cast(*list)}); @@ -1623,7 +1623,7 @@ TEST_F(ContiguousSplitTableCornerCases, NestedEmpty) auto empty_struct = cudf::empty_like(struct_column); auto offsets = cudf::test::fixed_width_column_wrapper({0, 0}); auto list = cudf::make_lists_column( - 1, offsets.release(), std::move(empty_struct), 0, rmm::device_buffer{0}); + 1, offsets.release(), std::move(empty_struct), 0, rmm::device_buffer{}); cudf::table_view src_table({static_cast(*list)}); diff --git a/cpp/tests/datetime/datetime_ops_test.cpp b/cpp/tests/datetime/datetime_ops_test.cpp index e407af667db..8aa83ce6b22 100644 --- a/cpp/tests/datetime/datetime_ops_test.cpp +++ b/cpp/tests/datetime/datetime_ops_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2020, NVIDIA CORPORATION. + * Copyright (c) 2019-2021, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,7 +44,7 @@ TYPED_TEST(NonTimestampTest, TestThrowsOnNonTimestamp) using namespace cuda::std::chrono; cudf::data_type dtype{cudf::type_to_id()}; - cudf::column col{dtype, 0, rmm::device_buffer{0}}; + cudf::column col{dtype, 0, rmm::device_buffer{}}; EXPECT_THROW(extract_year(col), cudf::logic_error); EXPECT_THROW(extract_month(col), cudf::logic_error); @@ -55,10 +55,9 @@ TYPED_TEST(NonTimestampTest, TestThrowsOnNonTimestamp) EXPECT_THROW(extract_second(col), cudf::logic_error); EXPECT_THROW(last_day_of_month(col), cudf::logic_error); EXPECT_THROW(day_of_year(col), cudf::logic_error); - EXPECT_THROW( - add_calendrical_months( - col, cudf::column{cudf::data_type{cudf::type_id::INT16}, 0, rmm::device_buffer{0}}), - cudf::logic_error); + EXPECT_THROW(add_calendrical_months( + col, cudf::column{cudf::data_type{cudf::type_id::INT16}, 0, rmm::device_buffer{}}), + cudf::logic_error); } struct BasicDatetimeOpsTest : public cudf::test::BaseFixture { @@ -159,8 +158,8 @@ TYPED_TEST(TypedDatetimeOpsTest, TestEmptyColumns) auto int16s_dtype = cudf::data_type{cudf::type_to_id()}; auto timestamps_dtype = cudf::data_type{cudf::type_to_id()}; - cudf::column int16s{int16s_dtype, 0, rmm::device_buffer{0}}; - cudf::column timestamps{timestamps_dtype, 0, rmm::device_buffer{0}}; + cudf::column int16s{int16s_dtype, 0, rmm::device_buffer{}}; + cudf::column timestamps{timestamps_dtype, 0, rmm::device_buffer{}}; CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_year(timestamps), int16s); CUDF_TEST_EXPECT_COLUMNS_EQUAL(*extract_month(timestamps), int16s); diff --git a/cpp/tests/dictionary/factories_test.cpp b/cpp/tests/dictionary/factories_test.cpp index 5af04ef9cc3..d8e70afb6f5 100644 --- a/cpp/tests/dictionary/factories_test.cpp +++ b/cpp/tests/dictionary/factories_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * Copyright (c) 2020-2021, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -61,7 +61,7 @@ TEST_F(DictionaryFactoriesTest, CreateFromColumns) cudf::test::fixed_width_column_wrapper values(h_values.begin(), h_values.end()); auto dictionary = - cudf::make_dictionary_column(keys.release(), values.release(), rmm::device_buffer{0}, 0); + cudf::make_dictionary_column(keys.release(), values.release(), rmm::device_buffer{}, 0); cudf::dictionary_column_view view(dictionary->view()); cudf::test::strings_column_wrapper keys_expected(h_keys.begin(), h_keys.end()); @@ -104,7 +104,7 @@ TEST_F(DictionaryFactoriesTest, IndicesWithNulls) cudf::test::fixed_width_column_wrapper keys{0, 1, 2, 3, 4}; cudf::test::fixed_width_column_wrapper indices{{5, 4, 3, 2, 1, 0}, {1, 1, 1, 0, 1, 0}}; EXPECT_THROW( - cudf::make_dictionary_column(keys.release(), indices.release(), rmm::device_buffer{0}, 0), + cudf::make_dictionary_column(keys.release(), indices.release(), rmm::device_buffer{}, 0), cudf::logic_error); } @@ -114,6 +114,6 @@ TEST_F(DictionaryFactoriesTest, InvalidIndices) cudf::test::fixed_width_column_wrapper indices{5, 4, 3, 2, 1, 0}; EXPECT_THROW(cudf::make_dictionary_column(keys, indices), cudf::logic_error); EXPECT_THROW( - cudf::make_dictionary_column(keys.release(), indices.release(), rmm::device_buffer{0}, 0), + cudf::make_dictionary_column(keys.release(), indices.release(), rmm::device_buffer{}, 0), cudf::logic_error); } diff --git a/cpp/tests/fixed_point/fixed_point_tests.cpp b/cpp/tests/fixed_point/fixed_point_tests.cpp index 9292c4a193d..47b2a95e7b5 100644 --- a/cpp/tests/fixed_point/fixed_point_tests.cpp +++ b/cpp/tests/fixed_point/fixed_point_tests.cpp @@ -491,10 +491,11 @@ TYPED_TEST(FixedPointTestBothReps, FixedPointColumnWrapper) TYPED_TEST(FixedPointTestBothReps, NoScaleOrWrongTypeID) { - auto const null_mask = cudf::create_null_mask(0, cudf::mask_state::ALL_NULL); + auto null_mask = cudf::create_null_mask(0, cudf::mask_state::ALL_NULL); - EXPECT_THROW(cudf::make_fixed_point_column(cudf::data_type{cudf::type_id::INT32}, 0, null_mask), - cudf::logic_error); + EXPECT_THROW( + cudf::make_fixed_point_column(cudf::data_type{cudf::type_id::INT32}, 0, std::move(null_mask)), + cudf::logic_error); } TYPED_TEST(FixedPointTestBothReps, SimpleFixedPointColumnWrapper) diff --git a/cpp/tests/groupby/collect_list_tests.cpp b/cpp/tests/groupby/collect_list_tests.cpp index 9d2141c913c..43c62743b9f 100644 --- a/cpp/tests/groupby/collect_list_tests.cpp +++ b/cpp/tests/groupby/collect_list_tests.cpp @@ -210,7 +210,7 @@ TYPED_TEST(groupby_collect_list_test, dictionary) std::make_unique(offsets), std::make_unique(vals), 0, - rmm::device_buffer{0}); + rmm::device_buffer{}); test_single_agg( keys, vals, expect_keys, expect_vals->view(), cudf::make_collect_list_aggregation()); diff --git a/cpp/tests/io/comp/decomp_test.cu b/cpp/tests/io/comp/decomp_test.cu index c7e1ae91bd9..a2e2fee8242 100644 --- a/cpp/tests/io/comp/decomp_test.cu +++ b/cpp/tests/io/comp/decomp_test.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2020, NVIDIA CORPORATION. + * Copyright (c) 2019-2021, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -57,8 +57,8 @@ struct DecompressTest : public cudf::test::BaseFixture { const uint8_t* compressed, size_t compressed_size) { - rmm::device_buffer src(compressed, compressed_size); - rmm::device_buffer dst(decompressed->size()); + rmm::device_buffer src{compressed, compressed_size, rmm::cuda_stream_default}; + rmm::device_buffer dst{decompressed->size(), rmm::cuda_stream_default}; inf_args->srcDevice = static_cast(src.data()); inf_args->dstDevice = static_cast(dst.data()); @@ -117,7 +117,8 @@ struct SnappyDecompressTest : public DecompressTest { struct BrotliDecompressTest : public DecompressTest { cudaError_t dispatch() { - rmm::device_buffer d_scratch(cudf::io::get_gpu_debrotli_scratch_size(1)); + rmm::device_buffer d_scratch{cudf::io::get_gpu_debrotli_scratch_size(1), + rmm::cuda_stream_default}; return cudf::io::gpu_debrotli( d_inf_args.data().get(), d_inf_stat.data().get(), d_scratch.data(), d_scratch.size(), 1); diff --git a/cpp/tests/iterator/iterator_tests.cuh b/cpp/tests/iterator/iterator_tests.cuh index 06ac472d6d5..68051098595 100644 --- a/cpp/tests/iterator/iterator_tests.cuh +++ b/cpp/tests/iterator/iterator_tests.cuh @@ -59,7 +59,7 @@ struct IteratorTest : public cudf::test::BaseFixture { init); // Allocate temporary storage - rmm::device_buffer d_temp_storage(temp_storage_bytes); + rmm::device_buffer d_temp_storage(temp_storage_bytes, rmm::cuda_stream_default); // Run reduction cub::DeviceReduce::Reduce(d_temp_storage.data(), diff --git a/cpp/tests/unary/cast_tests.cpp b/cpp/tests/unary/cast_tests.cpp index 15d014f9d9c..6121af01720 100644 --- a/cpp/tests/unary/cast_tests.cpp +++ b/cpp/tests/unary/cast_tests.cpp @@ -85,61 +85,71 @@ inline cudf::column make_exp_chrono_column(cudf::type_id type_id) cudf::data_type{type_id}, test_timestamps_D.size(), rmm::device_buffer{test_timestamps_D.data(), - test_timestamps_D.size() * sizeof(test_timestamps_D.front())}); + test_timestamps_D.size() * sizeof(test_timestamps_D.front()), + rmm::cuda_stream_default}); case cudf::type_id::TIMESTAMP_SECONDS: return cudf::column( cudf::data_type{type_id}, test_timestamps_s.size(), rmm::device_buffer{test_timestamps_s.data(), - test_timestamps_s.size() * sizeof(test_timestamps_s.front())}); + test_timestamps_s.size() * sizeof(test_timestamps_s.front()), + rmm::cuda_stream_default}); case cudf::type_id::TIMESTAMP_MILLISECONDS: return cudf::column( cudf::data_type{type_id}, test_timestamps_ms.size(), rmm::device_buffer{test_timestamps_ms.data(), - test_timestamps_ms.size() * sizeof(test_timestamps_ms.front())}); + test_timestamps_ms.size() * sizeof(test_timestamps_ms.front()), + rmm::cuda_stream_default}); case cudf::type_id::TIMESTAMP_MICROSECONDS: return cudf::column( cudf::data_type{type_id}, test_timestamps_us.size(), rmm::device_buffer{test_timestamps_us.data(), - test_timestamps_us.size() * sizeof(test_timestamps_us.front())}); + test_timestamps_us.size() * sizeof(test_timestamps_us.front()), + rmm::cuda_stream_default}); case cudf::type_id::TIMESTAMP_NANOSECONDS: return cudf::column( cudf::data_type{type_id}, test_timestamps_ns.size(), rmm::device_buffer{test_timestamps_ns.data(), - test_timestamps_ns.size() * sizeof(test_timestamps_ns.front())}); + test_timestamps_ns.size() * sizeof(test_timestamps_ns.front()), + rmm::cuda_stream_default}); case cudf::type_id::DURATION_DAYS: return cudf::column( cudf::data_type{type_id}, test_durations_D.size(), rmm::device_buffer{test_durations_D.data(), - test_durations_D.size() * sizeof(test_durations_D.front())}); + test_durations_D.size() * sizeof(test_durations_D.front()), + rmm::cuda_stream_default}); case cudf::type_id::DURATION_SECONDS: return cudf::column( cudf::data_type{type_id}, test_durations_s.size(), rmm::device_buffer{test_durations_s.data(), - test_durations_s.size() * sizeof(test_durations_s.front())}); + test_durations_s.size() * sizeof(test_durations_s.front()), + rmm::cuda_stream_default}); case cudf::type_id::DURATION_MILLISECONDS: return cudf::column( cudf::data_type{type_id}, test_durations_ms.size(), rmm::device_buffer{test_durations_ms.data(), - test_durations_ms.size() * sizeof(test_durations_ms.front())}); + test_durations_ms.size() * sizeof(test_durations_ms.front()), + rmm::cuda_stream_default}); case cudf::type_id::DURATION_MICROSECONDS: return cudf::column( cudf::data_type{type_id}, test_durations_us.size(), rmm::device_buffer{test_durations_us.data(), - test_durations_us.size() * sizeof(test_durations_us.front())}); + test_durations_us.size() * sizeof(test_durations_us.front()), + rmm::cuda_stream_default}); case cudf::type_id::DURATION_NANOSECONDS: return cudf::column( cudf::data_type{type_id}, test_durations_ns.size(), rmm::device_buffer{test_durations_ns.data(), - test_durations_ns.size() * sizeof(test_durations_ns.front())}); + test_durations_ns.size() * sizeof(test_durations_ns.front()), + rmm::cuda_stream_default}); default: CUDF_FAIL(""); } }; diff --git a/java/src/main/native/src/ColumnViewJni.cpp b/java/src/main/native/src/ColumnViewJni.cpp index f09b9029ecb..6dcfe1f82ce 100644 --- a/java/src/main/native/src/ColumnViewJni.cpp +++ b/java/src/main/native/src/ColumnViewJni.cpp @@ -1341,7 +1341,7 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_bitwiseMergeAndSetValidit cudf::jni::native_jpointerArray n_cudf_columns(env, column_handles); if (n_cudf_columns.size() == 0) { - rmm::device_buffer null_mask{0}; + rmm::device_buffer null_mask{}; copy->set_null_mask(null_mask); return reinterpret_cast(copy.release()); } diff --git a/java/src/main/native/src/row_conversion.cu b/java/src/main/native/src/row_conversion.cu index a0938ddb2b5..402a592ef99 100644 --- a/java/src/main/native/src/row_conversion.cu +++ b/java/src/main/native/src/row_conversion.cu @@ -404,7 +404,7 @@ static std::unique_ptr fixed_width_convert_to_rows( input_data->data(), input_nm->data(), data->mutable_view().data()); return cudf::make_lists_column(num_rows, std::move(offsets), std::move(data), 0, - rmm::device_buffer{0, rmm::cuda_stream_default, mr}, stream, mr); + rmm::device_buffer{}, stream, mr); } static cudf::data_type get_data_type(const cudf::column_view &v) { diff --git a/python/cudf/cudf/_lib/null_mask.pyx b/python/cudf/cudf/_lib/null_mask.pyx index 8c209cd86bd..81ddbaa48ac 100644 --- a/python/cudf/cudf/_lib/null_mask.pyx +++ b/python/cudf/cudf/_lib/null_mask.pyx @@ -45,7 +45,7 @@ def copy_bitmask(Column col): cdef unique_ptr[device_buffer] up_db with nogil: - db = cpp_copy_bitmask(col_view) + db = move(cpp_copy_bitmask(col_view)) up_db = make_unique[device_buffer](move(db)) rmm_db = DeviceBuffer.c_from_unique_ptr(move(up_db)) @@ -91,7 +91,7 @@ def create_null_mask(size_type size, state=MaskState.UNINITIALIZED): ) with nogil: - db = cpp_create_null_mask(size, c_mask_state) + db = move(cpp_create_null_mask(size, c_mask_state)) up_db = make_unique[device_buffer](move(db)) rmm_db = DeviceBuffer.c_from_unique_ptr(move(up_db))