Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add stream and memory-resource parameters to struct-scalar copy ctor #8901

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions cpp/include/cudf/scalar/scalar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -706,13 +706,16 @@ class list_scalar : public scalar {
*/
class struct_scalar : public scalar {
public:
struct_scalar() = delete;
~struct_scalar() = default;
struct_scalar(struct_scalar&& other) = default;
struct_scalar(struct_scalar const& other) = default;
struct_scalar() = delete;
~struct_scalar() = default;
struct_scalar(struct_scalar&& other) = default;
struct_scalar& operator=(struct_scalar const& other) = delete;
struct_scalar& operator=(struct_scalar&& other) = delete;

struct_scalar(struct_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 struct scalar object from table_view.
*
Expand Down
7 changes: 7 additions & 0 deletions cpp/src/scalar/scalar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,13 @@ list_scalar::list_scalar(list_scalar const& other,

column_view list_scalar::view() const { return _data.view(); }

struct_scalar::struct_scalar(struct_scalar const& other,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
: scalar{other, stream, mr}, _data(other._data, stream, mr)
{
}

struct_scalar::struct_scalar(table_view const& data,
bool is_valid,
rmm::cuda_stream_view stream,
Expand Down
19 changes: 10 additions & 9 deletions cpp/src/strings/copying/concatenate.cu
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@

#include <cudf/column/column_device_view.cuh>
#include <cudf/column/column_factories.hpp>
#include <cudf/copying.hpp>
#include <cudf/detail/concatenate.cuh>
#include <cudf/detail/get_value.cuh>
#include <cudf/detail/null_mask.hpp>
#include <cudf/detail/utilities/cuda.cuh>
#include <cudf/detail/utilities/vector_factories.hpp>
Expand All @@ -27,12 +26,11 @@
#include <cudf/table/table_device_view.cuh>

#include <rmm/cuda_stream_view.hpp>
#include <rmm/device_scalar.hpp>
#include <rmm/exec_policy.hpp>
#include "thrust/iterator/transform_iterator.h"

#include <thrust/binary_search.h>
#include <thrust/for_each.h>
#include <thrust/transform_reduce.h>
#include <thrust/execution_policy.h>
#include <thrust/transform_scan.h>

namespace cudf {
Expand Down Expand Up @@ -287,12 +285,15 @@ std::unique_ptr<column> concatenate(host_span<column_view const> columns,
column_view offsets_child = column->child(strings_column_view::offsets_column_index);
column_view chars_child = column->child(strings_column_view::chars_column_index);

auto d_offsets = offsets_child.data<int32_t>() + column_offset;
int32_t bytes_offset = thrust::device_pointer_cast(d_offsets)[0];
auto bytes_offset =
cudf::detail::get_value<offset_type>(offsets_child, column_offset, stream);

// copy the chars column data
auto d_chars = chars_child.data<char>() + bytes_offset;
size_type bytes = thrust::device_pointer_cast(d_offsets)[column_size] - bytes_offset;
auto d_chars = chars_child.data<char>() + bytes_offset;
auto const bytes =
cudf::detail::get_value<offset_type>(offsets_child, column_size + column_offset, stream) -
bytes_offset;
karthikeyann marked this conversation as resolved.
Show resolved Hide resolved

CUDA_TRY(
cudaMemcpyAsync(d_new_chars, d_chars, bytes, cudaMemcpyDeviceToDevice, stream.value()));

Expand Down
9 changes: 1 addition & 8 deletions cpp/tests/scalar/scalar_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,12 @@
* limitations under the License.
*/

#include <cudf/scalar/scalar.hpp>
#include <cudf/types.hpp>
#include <cudf/utilities/type_dispatcher.hpp>
#include <cudf_test/base_fixture.hpp>
#include <cudf_test/column_wrapper.hpp>
#include <cudf_test/cudf_gtest.hpp>
#include <cudf_test/table_utilities.hpp>
#include <cudf_test/type_list_utilities.hpp>
#include <cudf_test/type_lists.hpp>

#include <thrust/sequence.h>
#include <random>
#include <rmm/cuda_stream_view.hpp>
#include <cudf/scalar/scalar.hpp>

template <typename T>
struct TypedScalarTest : public cudf::test::BaseFixture {
Expand Down