Skip to content

Commit e20e98b

Browse files
authored
Merge branch 'main' into disable-large-extent-join-tests
2 parents 8e6f77f + c17a76f commit e20e98b

25 files changed

Lines changed: 552 additions & 1372 deletions

‎cpp/CMakeLists.txt‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -466,11 +466,6 @@ rtcx_embed_includes(
466466
cudf/cpp/src/jit INCLUDE_DIRECTORIES cudf/cpp/src
467467
)
468468

469-
rtcx_embed_includes(
470-
cudf_cuda_embed SOURCE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/binaryop/jit DEST_DIRECTORY
471-
cudf/cpp/src/binaryop/jit INCLUDE_DIRECTORIES cudf/cpp/src
472-
)
473-
474469
rtcx_embed_includes(
475470
cudf_cuda_embed SOURCE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/join/jit DEST_DIRECTORY
476471
cudf/cpp/src/join/jit INCLUDE_DIRECTORIES cudf/cpp/src

‎cpp/include/cudf/binaryop.hpp‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,20 @@
77

88
#include <cudf/column/column.hpp>
99
#include <cudf/scalar/scalar.hpp>
10+
#include <cudf/types.hpp>
11+
#include <cudf/utilities/default_stream.hpp>
1012
#include <cudf/utilities/export.hpp>
1113
#include <cudf/utilities/memory_resource.hpp>
14+
#include <cudf/utilities/traits.hpp>
15+
16+
#include <cuda/buffer>
17+
#include <cuda/std/type_traits>
18+
#include <cuda/stream>
1219

1320
#include <memory>
21+
#include <string>
22+
#include <type_traits>
23+
#include <utility>
1424

1525
/**
1626
* @file
@@ -333,6 +343,9 @@ std::unique_ptr<column> binary_operation(
333343
* @brief Performs a binary operation between two columns using a
334344
* user-defined PTX function.
335345
*
346+
* @deprecated in release 26.12 and will be removed in a future release. Use `cudf::transform`
347+
* instead.
348+
*
336349
* The output contains the result of `op(lhs[i], rhs[i])` for all `0 <= i < lhs.size()`
337350
*
338351
* Regardless of the operator, the validity of the output value is the logical
@@ -352,7 +365,7 @@ std::unique_ptr<column> binary_operation(
352365
* @throw cudf::logic_error if @p lhs and @p rhs dtypes aren't numeric
353366
* @throw cudf::logic_error if @p output_type dtype isn't numeric
354367
*/
355-
std::unique_ptr<column> binary_operation(
368+
[[deprecated("Use cudf::transform instead")]] std::unique_ptr<column> binary_operation(
356369
column_view const& lhs,
357370
column_view const& rhs,
358371
std::string const& ptx,

‎cpp/include/cudf/join/join.hpp‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <cstdint>
2424
#include <memory>
2525
#include <optional>
26+
#include <string>
2627
#include <utility>
2728

2829
/**
@@ -522,8 +523,8 @@ filter_join_indices_output_size(
522523
* For both null-aware and non-null-aware predicates, the output value is uninitialized and must
523524
* be set on every execution path.
524525
* The remaining parameters correspond to columns in the left table followed by the right table.
525-
* The CUDA function may return `cudf::errc` instead of `void` to report evaluation errors. PTX UDFs
526-
* do not support returning errors.
526+
* The CUDA function may return `cudf::errc` instead of `void` to report evaluation errors.
527+
* PTX modules functions must return `cudf::errc` as a 32-bit integer status.
527528
*
528529
*
529530
* @throw std::invalid_argument if join_kind is not INNER_JOIN, LEFT_JOIN, or FULL_JOIN.

‎cpp/include/cudf/transform.hpp‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,20 @@
99
#include <cudf/column/scalar_column_view.hpp>
1010
#include <cudf/types.hpp>
1111
#include <cudf/udf.hpp>
12+
#include <cudf/utilities/default_stream.hpp>
1213
#include <cudf/utilities/export.hpp>
1314
#include <cudf/utilities/memory_resource.hpp>
1415

1516
#include <cuda/buffer>
17+
#include <cuda/stream>
1618

19+
#include <cstdint>
1720
#include <functional>
1821
#include <memory>
1922
#include <optional>
2023
#include <span>
24+
#include <string>
25+
#include <utility>
2126
#include <variant>
2227
#include <vector>
2328

@@ -237,6 +242,8 @@ struct transform_program {
237242
* Computes:
238243
* `(outputs[i]...) = UDF(inputs[i]...)`.
239244
*
245+
* PTX UDFs are linked as complete modules. The function must follow the CUDF UDF ABI.
246+
*
240247
* For both null-aware and non-null-aware UDFs, output values have the following initialization:
241248
* - Fixed-width outputs have uninitialized values.
242249
* - Mutable string outputs (`cuda::std::span<char>`, used with preallocated string offsets) contain
@@ -310,8 +317,9 @@ std::unique_ptr<table> transform(
310317
* The size of the resulting column is the `row_size` if provided, otherwise it is inferred from
311318
* the input and pre-allocated output columns.
312319
*
313-
* @param udf The LTO-IR fragment containing the transform function to apply. The UDF must
314-
* be named `transform` and follow the CUDF UDF ABI
320+
* @param udf The LTO-IR, FATBIN, or PTX fragment containing the transform function to
321+
* apply. The UDF must follow the CUDF UDF ABI and be named `transform`. For PTX, the first function
322+
* and references to it are renamed to `transform` before linking. PTX input must be null-terminated
315323
* @param binary_type The type of the LTO binary provided in `udf`
316324
* @param is_null_aware Signifies the UDF will receive row inputs as optional values
317325
* @param user_data User-defined device data to pass to the UDF

‎cpp/include/cudf/udf.hpp‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ namespace CUDF_EXPORT cudf {
2121
*/
2222
enum class lto_binary_type : uint8_t {
2323
LTO_IR, //< LTO-IR binary
24-
FATBIN //< FATBIN binary
24+
FATBIN, //< FATBIN binary
25+
PTX //< Null-terminated PTX code string
2526
};
2627

2728
/**

‎cpp/src/binaryop/binaryop.cpp‎

Lines changed: 29 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,34 @@
2222
*/
2323

2424
#include "compiled/binary_ops.hpp"
25-
#include "jit/cache.hpp"
26-
#include "jit/helpers.hpp"
27-
#include "jit/parser.hpp"
28-
#include "jit/util.hpp"
2925

3026
#include <cudf/binaryop.hpp>
3127
#include <cudf/column/column_factories.hpp>
3228
#include <cudf/detail/binaryop.hpp>
3329
#include <cudf/detail/null_mask.hpp>
3430
#include <cudf/detail/nvtx/ranges.hpp>
35-
#include <cudf/replace.hpp>
3631
#include <cudf/scalar/scalar.hpp>
32+
#include <cudf/table/table.hpp>
3733
#include <cudf/table/table_view.hpp>
34+
#include <cudf/transform.hpp>
3835
#include <cudf/types.hpp>
3936
#include <cudf/utilities/error.hpp>
4037
#include <cudf/utilities/traits.hpp>
41-
#include <cudf/utilities/type_dispatcher.hpp>
4238

4339
#include <cuda/std/optional>
4440
#include <cuda/stream>
4541

4642
#include <transform/checked_arithmetic.hpp>
4743

44+
#include <algorithm>
45+
#include <array>
46+
#include <cstdint>
47+
#include <optional>
48+
#include <span>
49+
#include <stdexcept>
4850
#include <string>
51+
#include <type_traits>
52+
#include <utility>
4953

5054
namespace cudf {
5155
namespace binops {
@@ -149,45 +153,6 @@ bool is_same_scale_necessary(binary_operator op)
149153
op != binary_operator::MUL_OVERFLOW && op != binary_operator::DIV_OVERFLOW;
150154
}
151155

152-
namespace jit {
153-
void binary_operation(mutable_column_view& out,
154-
column_view const& lhs,
155-
column_view const& rhs,
156-
std::string const& ptx,
157-
cuda::stream_ref stream)
158-
{
159-
std::string const output_type_name = cudf::type_to_name(out.type());
160-
161-
std::string cuda_source =
162-
cudf::jit::parse_single_function_ptx(ptx,
163-
"GENERIC_BINARY_OP",
164-
{
165-
{0, output_type_name + " *"},
166-
{1, cudf::type_to_name(lhs.type())},
167-
{2, cudf::type_to_name(rhs.type())},
168-
});
169-
170-
std::string kernel_reflection = rtcx::reflect_template("cudf::binops::jit::binary_op_kernel",
171-
output_type_name,
172-
cudf::type_to_name(lhs.type()),
173-
cudf::type_to_name(rhs.type()),
174-
"cudf::binops::jit::UserDefinedOp");
175-
176-
auto kernel = cudf::jit::get_udf_kernel(
177-
"cudf/cpp/src/binaryop/jit/kernel.cu", kernel_reflection, cuda_source, {});
178-
auto cfg = kernel.max_occupancy_config(0, 0);
179-
180-
kernel.launch_with({cfg.min_grid_size},
181-
{cfg.block_size},
182-
0,
183-
stream,
184-
static_cast<size_type>(out.size()),
185-
cudf::jit::get_data_ptr(out),
186-
cudf::jit::get_data_ptr(lhs),
187-
cudf::jit::get_data_ptr(rhs));
188-
}
189-
} // namespace jit
190-
191156
// Compiled Binary operation
192157
namespace compiled {
193158

@@ -409,17 +374,25 @@ std::unique_ptr<column> binary_operation(column_view const& lhs,
409374

410375
CUDF_EXPECTS((lhs.size() == rhs.size()), "Column sizes don't match");
411376

412-
auto [new_mask, null_count] = cudf::detail::bitmask_and(table_view({lhs, rhs}), stream, mr);
413-
auto out =
414-
make_fixed_width_column(output_type, lhs.size(), std::move(new_mask), null_count, stream, mr);
415-
416-
// Check for 0 sized data
417-
if (lhs.is_empty() or rhs.is_empty()) return out;
418-
419-
auto out_view = out->mutable_view();
420-
binops::jit::binary_operation(out_view, lhs, rhs, ptx, stream);
421-
out->set_null_count(cudf::detail::null_count(out_view.null_mask(), 0, out->size(), stream));
422-
return out;
377+
if (lhs.is_empty()) { return make_empty_column(output_type); }
378+
379+
std::array<transform_input, 2> inputs{lhs, rhs};
380+
std::array<transform_output, 1> outputs{transform_output{.type = output_type}};
381+
382+
auto result =
383+
cudf::transform_lto(std::span{reinterpret_cast<uint8_t const*>(ptx.data()), ptx.size()},
384+
lto_binary_type::PTX,
385+
null_aware::NO,
386+
std::nullopt,
387+
inputs,
388+
outputs,
389+
{},
390+
std::nullopt,
391+
stream,
392+
mr.get_output_mr());
393+
394+
auto columns = result->release();
395+
return std::move(columns.front());
423396
}
424397
} // namespace detail
425398

‎cpp/src/binaryop/jit/kernel.cu‎

Lines changed: 0 additions & 87 deletions
This file was deleted.

‎cpp/src/jit/cache.cpp‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,19 @@ rtcx::blob compile_fragment(char const* name,
371371

372372
} // namespace
373373

374+
rtcx::binary_type as_rtcx_binary_type(lto_binary_type type)
375+
{
376+
switch (type) {
377+
case lto_binary_type::LTO_IR: return rtcx::binary_type::LTO_IR;
378+
case lto_binary_type::FATBIN: return rtcx::binary_type::FATBIN;
379+
case lto_binary_type::PTX: return rtcx::binary_type::PTX;
380+
default:
381+
CUDF_FAIL(
382+
std::format("Unrecognized LTO binary type {} for LTO transform", static_cast<int>(type)),
383+
std::invalid_argument);
384+
}
385+
}
386+
374387
kernel get_kernel(std::string const& name,
375388
std::string const& source_file_id,
376389
std::span<char const* const> header_include_names,

‎cpp/src/jit/cache.hpp‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55

66
#pragma once
7+
#include <cudf/udf.hpp>
78
#include <cudf/utilities/export.hpp>
89

910
#include <cuda/stream>
@@ -72,6 +73,13 @@ struct [[nodiscard]] kernel {
7273
}
7374
};
7475

76+
/**
77+
* @brief Converts an LTO binary type to the corresponding RTCX binary type
78+
* @param type The LTO binary type to convert
79+
* @return The corresponding RTCX binary type
80+
*/
81+
rtcx::binary_type as_rtcx_binary_type(lto_binary_type type);
82+
7583
/**
7684
* @brief Gets a kernel from an embedded CUDA source file
7785
* @param name Debug name for the kernel (used for caching and logging)

0 commit comments

Comments
 (0)