Skip to content
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: 6 additions & 5 deletions cpp/include/cudf/column/column.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION.
* SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
Expand All @@ -10,10 +10,11 @@
#include <cudf/utilities/default_stream.hpp>
#include <cudf/utilities/memory_resource.hpp>

#include <rmm/cuda_stream_view.hpp>
#include <rmm/device_buffer.hpp>
#include <rmm/device_uvector.hpp>

#include <cuda/stream_ref>

#include <memory>
#include <type_traits>
#include <utility>
Expand Down Expand Up @@ -52,7 +53,7 @@ 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(),
cuda::stream_ref stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/**
Expand Down Expand Up @@ -130,7 +131,7 @@ 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(),
cuda::stream_ref stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/**
Expand Down Expand Up @@ -181,7 +182,7 @@ class column {
*/
void set_null_mask(rmm::device_buffer const& new_null_mask,
size_type new_null_count,
rmm::cuda_stream_view stream = cudf::get_default_stream());
cuda::stream_ref stream = cudf::get_default_stream());

/**
* @brief Updates the count of null elements.
Expand Down
6 changes: 3 additions & 3 deletions cpp/include/cudf/column/column_device_view.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
#include <cudf/utilities/span.hpp>
#include <cudf/utilities/type_dispatcher.hpp>

#include <rmm/cuda_stream_view.hpp>
#include <rmm/resource_ref.hpp>

#include <cuda/iterator>
#include <cuda/std/utility>
#include <cuda/stream_ref>
#include <thrust/iterator/transform_iterator.h>

#include <functional>
Expand Down Expand Up @@ -506,7 +506,7 @@ class alignas(16) column_device_view : public column_device_view_core {
*/
static std::unique_ptr<column_device_view, std::function<void(column_device_view*)>> create(
column_view source_view,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
cuda::stream_ref stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/**
Expand Down Expand Up @@ -657,7 +657,7 @@ class alignas(16) mutable_column_device_view : public mutable_column_device_view
static std::unique_ptr<mutable_column_device_view,
std::function<void(mutable_column_device_view*)>>
create(mutable_column_view source_view,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
cuda::stream_ref stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/**
Expand Down
25 changes: 13 additions & 12 deletions cpp/include/cudf/column/column_factories.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <rmm/cuda_stream_view.hpp>

#include <cuda/std/utility>
#include <cuda/stream_ref>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

ast-grep outline cpp/include/cudf/column/column_factories.hpp --items all --type function

rg -n -C 3 \
  'rmm::cuda_stream_view|cuda::stream_ref|make_strings_column|make_structs_column|create_structs_hierarchy' \
  cpp/include/cudf/column/column_factories.hpp \
  cpp/src/column/column_factories.cpp \
  cpp/src/column/column_factories.cu

Repository: NVIDIA/cudf

Length of output: 22503


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- declarations and definitions ---'
rg -n -C 5 \
  'make_strings_column\s*\(|make_strings_column_batch\s*\(|make_structs_column\s*\(|create_structs_hierarchy\s*\(' \
  cpp --glob '*.{cpp,cu,hpp,cuh,h,cc,cxx}' \
  | head -n 500

printf '%s\n' '--- stream type usage in factory-related implementation files ---'
rg -n -C 3 \
  'rmm::cuda_stream_view|cuda::stream_ref' \
  cpp/src cpp/include/cudf/column \
  --glob '*.{cpp,cu,hpp,cuh,h,cc,cxx}' \
  | head -n 700

printf '%s\n' '--- changed paths and focused diff summary ---'
git diff --stat -- cpp/include/cudf/column/column_factories.hpp cpp/src
git status --short

Repository: NVIDIA/cudf

Length of output: 50367


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- focused header ---'
sed -n '350,590p' cpp/include/cudf/column/column_factories.hpp

printf '%s\n' '--- factory definitions outside tests ---'
rg -n \
  '(^|::)(make_strings_column|make_strings_column_batch|make_structs_column|create_structs_hierarchy)\s*\(' \
  cpp/src --glob '*.{cpp,cu,cc,cxx}' \
  --glob '!**/tests/**'

printf '%s\n' '--- stream-bearing factory declarations and definitions ---'
rg -n \
  '(make_strings_column|make_strings_column_batch|make_structs_column|create_structs_hierarchy)[^(]*\(|rmm::cuda_stream_view|cuda::stream_ref' \
  cpp/include/cudf/column/column_factories.hpp cpp/src/column \
  --glob '*.{hpp,h,cuh,cpp,cu,cc,cxx}'

printf '%s\n' '--- focused diff ---'
git diff -- cpp/include/cudf/column/column_factories.hpp cpp/src/column

Repository: NVIDIA/cudf

Length of output: 21596


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- public string factory definitions ---'
sed -n '150,235p' cpp/src/strings/strings_column_factories.cu

printf '%s\n' '--- public struct factory definitions ---'
rg -n -C 8 \
  'std::unique_ptr<.*(make_structs_column|create_structs_hierarchy)|make_structs_column\(|create_structs_hierarchy\(' \
  cpp/src --glob '*.{cpp,cu,cc,cxx}' \
  --glob '!**/tests/**' \
  | rg -v '(^|/)(make_|create_).*:' | head -n 300

printf '%s\n' '--- all implementation stream-view declarations near factory definitions ---'
rg -l \
  'make_strings_column|make_strings_column_batch|make_structs_column|create_structs_hierarchy' \
  cpp/src --glob '*.{cpp,cu,cc,cxx}' \
  --glob '!**/tests/**' \
  | while read -r file; do
    if rg -q 'rmm::cuda_stream_view|cuda::stream_ref' "$file"; then
      printf '%s\n' "--- $file"
      rg -n 'rmm::cuda_stream_view|cuda::stream_ref|make_strings_column|make_strings_column_batch|make_structs_column|create_structs_hierarchy' "$file"
    fi
  done

printf '%s\n' '--- focused non-default-stream tests ---'
sed -n '1,110p' cpp/tests/streams/strings/factory_test.cpp
rg -n -C 4 \
  'make_structs_column|create_structs_hierarchy|make_strings_column_batch|make_strings_column\(' \
  cpp/tests/streams cpp/tests/column \
  --glob '*.{cpp,cu,cc,cxx,hpp,h}' \
  | head -n 350

Repository: NVIDIA/cudf

Length of output: 26743


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- stream test helpers and string factory tests ---'
rg -n -C 6 \
  'get_default_stream\(|get_new_stream\(|cuda_stream_view|stream_ref' \
  cpp/tests/streams cpp/include/cudf_test \
  --glob '*.{cpp,cu,hpp,h,cuh}' \
  | head -n 500

printf '%s\n' '--- factory benchmarks ---'
rg -n -C 4 \
  'make_strings_column|make_strings_column_batch|make_structs_column|create_structs_hierarchy|factory' \
  cpp/benchmarks cpp/benchmarks --glob '*.{cpp,cu,hpp,h,cuh}' \
  2>/dev/null | head -n 400

printf '%s\n' '--- all stream-specific factory tests ---'
rg -n -C 5 \
  'make_strings_column|make_strings_column_batch|make_structs_column|create_structs_hierarchy' \
  cpp/tests/streams cpp/tests/column/factories_test.cpp \
  --glob '*.{cpp,cu,hpp,h,cuh}' \
  | head -n 500

printf '%s\n' '--- header stream includes ---'
sed -n '1,35p' cpp/include/cudf/column/column_factories.hpp

Repository: NVIDIA/cudf

Length of output: 50367


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- string stream tests ---'
cat -n cpp/tests/streams/strings/factory_test.cpp

printf '%s\n' '--- string factory benchmark stream setup ---'
sed -n '1,100p' cpp/benchmarks/string/make_strings_column.cu

printf '%s\n' '--- factory tests with explicit stream arguments ---'
rg -n -C 3 \
  'get_default_stream|get_new_stream|cudaStream|stream[[:space:]]*[),]' \
  cpp/tests/column/factories_test.cpp cpp/tests/structs/structs_column_tests.cpp \
  --glob '*.{cpp,cu,hpp,h,cuh}'

printf '%s\n' '--- stream helper definition ---'
rg -n -C 5 \
  'get_default_stream\s*\(' \
  cpp/include/cudf_test cpp/tests \
  --glob '*.{hpp,h,cpp,cu,cuh}' \
  | head -n 120

printf '%s\n' '--- struct factory benchmarks ---'
rg -l \
  'make_structs_column|create_structs_hierarchy' \
  cpp/benchmarks --glob '*.{cpp,cu,hpp,h,cuh}' \
  | sort

Repository: NVIDIA/cudf

Length of output: 5932


Migrate the remaining stream-bearing factory APIs.

Use cuda::stream_ref in the declarations and definitions of make_strings_column, make_strings_column_batch, make_structs_column, and create_structs_hierarchy. Add non-default-stream coverage to the related tests and benchmarks.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cpp/include/cudf/column/column_factories.hpp` at line 17, Update the
declarations and definitions of make_strings_column, make_strings_column_batch,
make_structs_column, and create_structs_hierarchy to accept and propagate
cuda::stream_ref instead of the legacy stream type. Extend their related tests
and benchmarks to exercise a non-default stream.

Source: Coding guidelines


/**
* @file
Expand Down Expand Up @@ -68,7 +69,7 @@ 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(),
cuda::stream_ref stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/**
Expand All @@ -94,7 +95,7 @@ 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(),
cuda::stream_ref stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref())
{
CUDF_EXPECTS(is_numeric(type), "Invalid, non-numeric type.");
Expand Down Expand Up @@ -126,7 +127,7 @@ 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(),
cuda::stream_ref stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/**
Expand All @@ -151,7 +152,7 @@ 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(),
cuda::stream_ref stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref())
{
CUDF_EXPECTS(is_fixed_point(type), "Invalid, non-fixed_point type.");
Expand Down Expand Up @@ -184,7 +185,7 @@ 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(),
cuda::stream_ref stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/**
Expand All @@ -210,7 +211,7 @@ 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(),
cuda::stream_ref stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref())
{
CUDF_EXPECTS(is_timestamp(type), "Invalid, non-timestamp type.");
Expand Down Expand Up @@ -243,7 +244,7 @@ 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(),
cuda::stream_ref stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/**
Expand All @@ -269,7 +270,7 @@ 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(),
cuda::stream_ref stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref())
{
CUDF_EXPECTS(is_duration(type), "Invalid, non-duration type.");
Expand Down Expand Up @@ -302,7 +303,7 @@ 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(),
cuda::stream_ref stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/**
Expand All @@ -328,7 +329,7 @@ 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(),
cuda::stream_ref stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref())
{
CUDF_EXPECTS(is_fixed_width(type), "Invalid, non-fixed-width type.");
Expand Down Expand Up @@ -593,7 +594,7 @@ std::unique_ptr<cudf::column> create_structs_hierarchy(
std::unique_ptr<column> make_column_from_scalar(
scalar const& s,
size_type size,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
cuda::stream_ref stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/**
Expand All @@ -613,7 +614,7 @@ 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(),
cuda::stream_ref stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/** @} */ // end of group
Expand Down
4 changes: 2 additions & 2 deletions cpp/include/cudf/column/column_stream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include <cudf/column/column.hpp>

#include <rmm/cuda_stream_view.hpp>
#include <cuda/stream_ref>

#include <memory>

Expand Down Expand Up @@ -40,7 +40,7 @@ namespace CUDF_EXPORT cudf {
* @param stream Stream used for future asynchronous deallocation of the buffers
* @return Column with equivalent contents and rebinding applied
*/
[[nodiscard]] std::unique_ptr<column> rebind_stream(column&& col, rmm::cuda_stream_view stream);
[[nodiscard]] std::unique_ptr<column> rebind_stream(column&& col, cuda::stream_ref stream);

/** @} */ // end of group
} // namespace CUDF_EXPORT cudf
9 changes: 4 additions & 5 deletions cpp/include/cudf/column/column_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,9 @@ class column_view_base {
* @param[in] stream CUDA stream used for device memory operations and kernel launches
* @return The count of null elements in the given range
*/
[[nodiscard]] size_type null_count(
size_type begin,
size_type end,
rmm::cuda_stream_view stream = cudf::get_default_stream()) const;
[[nodiscard]] size_type null_count(size_type begin,
size_type end,
cuda::stream_ref stream = cudf::get_default_stream()) const;

/**
* @brief Indicates if the column contains null elements,
Expand All @@ -199,7 +198,7 @@ class column_view_base {
*/
[[nodiscard]] bool has_nulls(size_type begin,
size_type end,
rmm::cuda_stream_view stream = cudf::get_default_stream()) const
cuda::stream_ref stream = cudf::get_default_stream()) const
{
return null_count(begin, end, stream) > 0;
}
Expand Down
8 changes: 5 additions & 3 deletions cpp/include/cudf/concatenate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include <cudf/utilities/memory_resource.hpp>
#include <cudf/utilities/span.hpp>

#include <cuda/stream_ref>

#include <memory>
#include <span>

Expand Down Expand Up @@ -39,7 +41,7 @@ namespace CUDF_EXPORT cudf {
*/
rmm::device_buffer concatenate_masks(
std::span<column_view const> views,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
cuda::stream_ref stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/**
Expand All @@ -56,7 +58,7 @@ rmm::device_buffer concatenate_masks(
*/
std::unique_ptr<column> concatenate(
std::span<column_view const> columns_to_concat,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
cuda::stream_ref stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/**
Expand Down Expand Up @@ -85,7 +87,7 @@ std::unique_ptr<column> concatenate(
*/
std::unique_ptr<table> concatenate(
std::span<table_view const> tables_to_concat,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
cuda::stream_ref stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/** @} */ // end of group
Expand Down
10 changes: 5 additions & 5 deletions cpp/include/cudf/contiguous_split.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ namespace CUDF_EXPORT cudf {
std::vector<packed_table> contiguous_split(
cudf::table_view const& input,
std::vector<size_type> const& splits,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
cuda::stream_ref stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

namespace detail {
Expand Down Expand Up @@ -155,7 +155,7 @@ class chunked_pack {
explicit chunked_pack(
cudf::table_view const& input,
std::size_t user_buffer_size,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
cuda::stream_ref stream = cudf::get_default_stream(),
rmm::device_async_resource_ref temp_mr = cudf::get_current_device_resource_ref());
Comment on lines +158 to 159

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -e
file=$(git ls-files 'cpp/include/cudf/contiguous_split.hpp')
printf '%s\n' "$file"
ast-grep outline "$file"
printf '\n--- relevant documentation and declarations ---\n'
rg -n -C 12 'chunked_pack|cudaMemcpyAsync|contiguous_split|create\(' "$file"
printf '\n--- related declarations/usages ---\n'
rg -n -C 8 'chunked_pack::create|class chunked_pack|struct chunked_pack|create\(.*user_buffer_size|cudaMemcpyAsync' cpp/include cpp/src tests 2>/dev/null | head -n 240

Repository: NVIDIA/cudf

Length of output: 26307


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- stream_ref definition and handle accessors ---'
rg -n -C 10 'class stream_ref|struct stream_ref|stream_ref::get|get\(\).*cudaStream_t|cudaStream_t.*get\(\)' cpp/include cpp/src 2>/dev/null | head -n 220
printf '%s\n' '--- all stream declarations in the example/header ---'
rg -n -C 4 '\bstream\b|cuda::stream_ref' cpp/include/cudf/contiguous_split.hpp
printf '%s\n' '--- exact API argument types ---'
sed -n '143,228p' cpp/include/cudf/contiguous_split.hpp
printf '%s\n' '--- implementation forwarding ---'
sed -n '2197,2210p' cpp/src/copying/contiguous_split.cu

Repository: NVIDIA/cudf

Length of output: 8995


🏁 Script executed:

#!/bin/bash
set -e
python3 - <<'PY'
from pathlib import Path
import re

p = Path("cpp/include/cudf/contiguous_split.hpp")
s = p.read_text()

decl = re.search(
    r'static std::unique_ptr<chunked_pack> create\(\s*'
    r'cudf::table_view const& input,\s*'
    r'std::size_t user_buffer_size,\s*'
    r'cuda::stream_ref stream\s*=.*?,\s*'
    r'rmm::device_async_resource_ref temp_mr\s*=.*?\);',
    s,
    re.S,
)
assert decl, "chunked_pack::create declaration was not found"
print("create declaration orders arguments as: input, user_buffer_size, stream, temp_mr")

example = s[s.index(" * `@code`{.pseudo}", s.index("class chunked_pack")):
           s.index(" * `@endcode`", s.index("class chunked_pack"))]
assert "auto mr = cudf::get_current_device_resource_ref();" in example
assert "auto chunked_packer = cudf::chunked_pack::create(tv, user_buffer_size, mr);" in example
assert "cudaMemcpyDefault,\n *     stream);" in example
print("example passes mr as the third create argument and stream as cudaMemcpyAsync's final argument")
print("example declares stream:", bool(re.search(r'\b(stream|auto const stream)\b', example)))
PY

printf '%s\n' '--- repository references to stream_ref handle access ---'
rg -n -C 4 'cuda::stream_ref|stream\.get\(\)|stream\.value\(\)' cpp include 2>/dev/null | head -n 260

Repository: NVIDIA/cudf

Length of output: 336


🌐 Web query:

CCCL cuda::stream_ref get() CUDA runtime handle interoperability

💡 Result:

In the CUDA Core Compute Libraries (CCCL), cuda::stream_ref is a non-owning wrapper designed to interoperate seamlessly with native CUDA Runtime (cudart) handles [1][2]. The get member function is the standard mechanism for retrieving the underlying native cudaStream_t handle from a cuda::stream_ref object [3][2]. Key details regarding this interoperability include: 1. Retrieval: Calling.get on a cuda::stream_ref returns the managed cudaStream_t handle, allowing you to pass the underlying stream to traditional CUDA Runtime APIs [1][3]. 2. Construction: You can construct a cuda::stream_ref directly from a native cudaStream_t handle [3][2]. Furthermore, cudaStream_t supports implicit conversion to cuda::stream_ref, facilitating easier integration into C++ codebases [3][4]. 3. Lifetime Management: Because cuda::stream_ref is non-owning, it does not manage the lifetime of the underlying stream; the caller must ensure that the stream handle remains valid for the duration of the cuda::stream_ref's usage [3][4]. 4. Ownership Transfer: For scenarios requiring ownership (where the C++ object should manage the stream's lifetime, such as destroying it upon destruction), use the owning counterpart, cuda::stream [1][2]. The owning type supports from_native_handle to take control of a raw handle and release to relinquish that control back to the native CUDA Runtime [1][5][4]. This pattern is consistent across other CCCL runtime types, such as event_ref, providing a unified approach to bridging modern C++ interfaces with legacy CUDA Runtime code [1][4].

Citations:


🏁 Script executed:

#!/bin/bash
set -e
python3 - <<'PY'
from pathlib import Path
import re

s = Path("cpp/include/cudf/contiguous_split.hpp").read_text()
start = s.index(" * `@code`{.pseudo}", s.index("class chunked_pack"))
end = s.index("`@endcode`", start)
example = s[start:end]

assert "auto mr = cudf::get_current_device_resource_ref();" in example
assert "auto chunked_packer = cudf::chunked_pack::create(tv, user_buffer_size, mr);" in example
assert "cudaMemcpyDefault,\n *     stream);" in example
assert not re.search(r"auto\s+(?:const\s+)?stream\s*=", example)
print("The example has no stream declaration.")
print("The example passes mr as create's third argument.")
print("The example passes stream directly as cudaMemcpyAsync's final argument.")

create = re.search(
    r'static std::unique_ptr<chunked_pack> create\(\s*'
    r'cudf::table_view const& input,\s*'
    r'std::size_t user_buffer_size,\s*'
    r'cuda::stream_ref stream\s*=.*?,\s*'
    r'rmm::device_async_resource_ref temp_mr\s*=.*?\);',
    s,
    re.S,
)
assert create
print("The declaration requires the third argument to be cuda::stream_ref and the fourth to be temp_mr.")
PY

Repository: NVIDIA/cudf

Length of output: 254


🏁 Script executed:

#!/bin/bash
set -e
python3 - <<'PY'
from pathlib import Path
import re

s = Path("cpp/include/cudf/contiguous_split.hpp").read_text()
start = s.index(" * `@code`{.pseudo}")
end = s.index("`@endcode`", start)
example = s[start:end]

assert "auto mr = cudf::get_current_device_resource_ref();" in example
assert "auto chunked_packer = cudf::chunked_pack::create(tv, user_buffer_size, mr);" in example
assert "cudaMemcpyDefault,\n *     stream);" in example
assert not re.search(r"auto\s+(?:const\s+)?stream\s*=", example)
print("The example has no stream declaration.")
print("The example passes mr as create's third argument.")
print("The example passes stream directly as cudaMemcpyAsync's final argument.")

decl_start = s.index("static std::unique_ptr<chunked_pack> create(")
decl_end = s.index(");", decl_start)
decl = s[decl_start:decl_end]
assert re.search(r"cuda::stream_ref\s+stream", decl)
assert re.search(r"rmm::device_async_resource_ref\s+temp_mr", decl)
print("The declaration requires stream before temp_mr.")
PY

Repository: NVIDIA/cudf

Length of output: 237


🏁 Script executed:

#!/bin/bash
set -e
python3 - <<'PY'
from pathlib import Path

lines = Path("cpp/include/cudf/contiguous_split.hpp").read_text().splitlines()
start = next(i for i, line in enumerate(lines) if "`@code`{.pseudo}" in line)
end = next(i for i in range(start + 1, len(lines)) if "`@endcode`" in lines[i])
print("\n".join(f"{i+1}: {lines[i]}" for i in range(start, end + 1)))
print("--- checks ---")
checks = {
    "mr declaration": any("auto mr = cudf::get_current_device_resource_ref();" in x for x in lines[start:end]),
    "create call": any("create(tv, user_buffer_size, mr);" in x for x in lines[start:end]),
    "cudaMemcpyDefault": any("cudaMemcpyDefault," in x for x in lines[start:end]),
    "direct stream": any("stream);" in x for x in lines[start:end]),
    "stream declaration": any("auto const stream" in x or "auto stream" in x for x in lines[start:end]),
}
for name, value in checks.items():
    print(f"{name}: {value}")
PY

Repository: NVIDIA/cudf

Length of output: 609


🏁 Script executed:

#!/bin/bash
set -e
python3 - <<'PY'
from pathlib import Path

lines = Path("cpp/include/cudf/contiguous_split.hpp").read_text().splitlines()
marker = next(i for i, line in enumerate(lines) if "Create a table_view" in line)
start = max(i for i in range(marker + 1) if "`@code`{.pseudo}" in lines[i])
end = next(i for i in range(marker, len(lines)) if "`@endcode`" in lines[i])
example = lines[start:end]

assert any("auto mr = cudf::get_current_device_resource_ref();" in x for x in example)
assert any("create(tv, user_buffer_size, mr);" in x for x in example)
assert any("cudaMemcpyDefault," in x for x in example)
assert any("stream);" in x for x in example)
assert not any("auto const stream" in x or "auto stream" in x for x in example)

decl_start = next(i for i, line in enumerate(lines) if "static std::unique_ptr<chunked_pack> create(" in line)
decl = "\n".join(lines[decl_start:decl_start + 6])
stream_pos = decl.index("cuda::stream_ref stream")
mr_pos = decl.index("rmm::device_async_resource_ref temp_mr")
assert stream_pos < mr_pos

print("The chunked_pack example has no stream declaration.")
print("The example passes mr as create's third argument.")
print("The example passes stream directly to cudaMemcpyAsync.")
print("chunked_pack::create declares stream before temp_mr.")
PY

Repository: NVIDIA/cudf

Length of output: 359


Correct the chunked_pack example for cuda::stream_ref.

Declare stream, pass it before mr to chunked_pack::create, and pass stream.get() to cudaMemcpyAsync.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cpp/include/cudf/contiguous_split.hpp` around lines 158 - 159, Update the
chunked_pack example to declare a cuda::stream_ref variable, pass it before the
memory-resource argument in chunked_pack::create, and use stream.get() as the
stream argument to cudaMemcpyAsync.

Source: Coding guidelines


/**
Expand Down Expand Up @@ -222,7 +222,7 @@ class chunked_pack {
[[nodiscard]] static std::unique_ptr<chunked_pack> create(
cudf::table_view const& input,
std::size_t user_buffer_size,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
cuda::stream_ref stream = cudf::get_default_stream(),
rmm::device_async_resource_ref temp_mr = cudf::get_current_device_resource_ref());

private:
Expand All @@ -244,7 +244,7 @@ class chunked_pack {
* and device memory respectively
*/
packed_columns pack(cudf::table_view const& input,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
cuda::stream_ref stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/**
Expand All @@ -261,7 +261,7 @@ packed_columns pack(cudf::table_view const& input,
*/
std::size_t packed_size(
cudf::table_view const& input,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
cuda::stream_ref stream = cudf::get_default_stream(),
rmm::device_async_resource_ref temp_mr = cudf::get_current_device_resource_ref());

/**
Expand Down
Loading
Loading