|
22 | 22 | */ |
23 | 23 |
|
24 | 24 | #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" |
29 | 25 |
|
30 | 26 | #include <cudf/binaryop.hpp> |
31 | 27 | #include <cudf/column/column_factories.hpp> |
32 | 28 | #include <cudf/detail/binaryop.hpp> |
33 | 29 | #include <cudf/detail/null_mask.hpp> |
34 | 30 | #include <cudf/detail/nvtx/ranges.hpp> |
35 | | -#include <cudf/replace.hpp> |
36 | 31 | #include <cudf/scalar/scalar.hpp> |
| 32 | +#include <cudf/table/table.hpp> |
37 | 33 | #include <cudf/table/table_view.hpp> |
| 34 | +#include <cudf/transform.hpp> |
38 | 35 | #include <cudf/types.hpp> |
39 | 36 | #include <cudf/utilities/error.hpp> |
40 | 37 | #include <cudf/utilities/traits.hpp> |
41 | | -#include <cudf/utilities/type_dispatcher.hpp> |
42 | 38 |
|
43 | 39 | #include <cuda/std/optional> |
44 | 40 | #include <cuda/stream> |
45 | 41 |
|
46 | 42 | #include <transform/checked_arithmetic.hpp> |
47 | 43 |
|
| 44 | +#include <algorithm> |
| 45 | +#include <array> |
| 46 | +#include <cstdint> |
| 47 | +#include <optional> |
| 48 | +#include <span> |
| 49 | +#include <stdexcept> |
48 | 50 | #include <string> |
| 51 | +#include <type_traits> |
| 52 | +#include <utility> |
49 | 53 |
|
50 | 54 | namespace cudf { |
51 | 55 | namespace binops { |
@@ -149,45 +153,6 @@ bool is_same_scale_necessary(binary_operator op) |
149 | 153 | op != binary_operator::MUL_OVERFLOW && op != binary_operator::DIV_OVERFLOW; |
150 | 154 | } |
151 | 155 |
|
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 | | - |
191 | 156 | // Compiled Binary operation |
192 | 157 | namespace compiled { |
193 | 158 |
|
@@ -409,17 +374,25 @@ std::unique_ptr<column> binary_operation(column_view const& lhs, |
409 | 374 |
|
410 | 375 | CUDF_EXPECTS((lhs.size() == rhs.size()), "Column sizes don't match"); |
411 | 376 |
|
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()); |
423 | 396 | } |
424 | 397 | } // namespace detail |
425 | 398 |
|
|
0 commit comments