binaryop.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019-2024, NVIDIA CORPORATION.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <cudf/column/column.hpp>
20 #include <cudf/scalar/scalar.hpp>
21 
22 #include <rmm/mr/device/per_device_resource.hpp>
23 #include <rmm/resource_ref.hpp>
24 
25 #include <memory>
26 
27 namespace cudf {
28 
39 enum class binary_operator : int32_t {
40  ADD,
41  SUB,
42  MUL,
43  DIV,
44  TRUE_DIV,
45  FLOOR_DIV,
53  MOD,
54  PMOD,
57  PYMOD,
58  POW,
59  INT_POW,
61  LOG_BASE,
62  ATAN2,
63  SHIFT_LEFT,
64  SHIFT_RIGHT,
67  BITWISE_AND,
68  BITWISE_OR,
69  BITWISE_XOR,
70  LOGICAL_AND,
71  LOGICAL_OR,
72  EQUAL,
73  NOT_EQUAL,
74  LESS,
75  GREATER,
76  LESS_EQUAL,
78  NULL_EQUALS,
82  NULL_MAX,
84  NULL_MIN,
93 };
117 std::unique_ptr<column> binary_operation(
118  scalar const& lhs,
119  column_view const& rhs,
120  binary_operator op,
121  data_type output_type,
122  rmm::cuda_stream_view stream = cudf::get_default_stream(),
123  rmm::device_async_resource_ref mr = rmm::mr::get_current_device_resource());
124 
148 std::unique_ptr<column> binary_operation(
149  column_view const& lhs,
150  scalar const& rhs,
151  binary_operator op,
152  data_type output_type,
153  rmm::cuda_stream_view stream = cudf::get_default_stream(),
154  rmm::device_async_resource_ref mr = rmm::mr::get_current_device_resource());
155 
178 std::unique_ptr<column> binary_operation(
179  column_view const& lhs,
180  column_view const& rhs,
181  binary_operator op,
182  data_type output_type,
183  rmm::cuda_stream_view stream = cudf::get_default_stream(),
184  rmm::device_async_resource_ref mr = rmm::mr::get_current_device_resource());
185 
209 std::unique_ptr<column> binary_operation(
210  column_view const& lhs,
211  column_view const& rhs,
212  std::string const& ptx,
213  data_type output_type,
214  rmm::cuda_stream_view stream = cudf::get_default_stream(),
215  rmm::device_async_resource_ref mr = rmm::mr::get_current_device_resource());
216 
226  int32_t left_scale,
227  int32_t right_scale);
228 
238  cudf::data_type const& lhs,
239  cudf::data_type const& rhs);
240 
241 namespace binops {
242 
252 std::pair<rmm::device_buffer, size_type> scalar_col_valid_mask_and(
253  column_view const& col,
254  scalar const& s,
255  rmm::cuda_stream_view stream = cudf::get_default_stream(),
256  rmm::device_async_resource_ref mr = rmm::mr::get_current_device_resource());
257 
258 namespace compiled {
259 namespace detail {
260 
273  column_view const& lhs,
274  column_view const& rhs,
275  bool is_lhs_scalar,
276  bool is_rhs_scalar,
277  binary_operator op,
278  rmm::cuda_stream_view stream);
279 } // namespace detail
280 } // namespace compiled
281 } // namespace binops
282  // end of group
284 } // namespace cudf
std::pair< rmm::device_buffer, size_type > scalar_col_valid_mask_and(column_view const &col, scalar const &s, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=rmm::mr::get_current_device_resource())
Computes output valid mask for op between a column and a scalar.
void apply_sorting_struct_binary_op(mutable_column_view &out, column_view const &lhs, column_view const &rhs, bool is_lhs_scalar, bool is_rhs_scalar, binary_operator op, rmm::cuda_stream_view stream)
struct binary operation using NaN aware sorting physical element comparators
A non-owning, immutable view of device data as a column of elements, some of which may be null as ind...
Indicator for the logical data type of an element in a column.
Definition: types.hpp:241
A non-owning, mutable view of device data as a column of elements, some of which may be null as indic...
An owning class to represent a singular value.
Definition: scalar.hpp:49
Class definition for cudf::column.
rmm::cuda_stream_view const get_default_stream()
Get the current default stream.
binary_operator
Types of binary operations that can be performed on data.
Definition: binaryop.hpp:39
cudf::data_type binary_operation_fixed_point_output_type(binary_operator op, cudf::data_type const &lhs, cudf::data_type const &rhs)
Computes the data_type for a fixed_point number based on given binary operator op
std::unique_ptr< column > binary_operation(scalar const &lhs, column_view const &rhs, binary_operator op, data_type output_type, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=rmm::mr::get_current_device_resource())
Performs a binary operation between a scalar and a column.
int32_t binary_operation_fixed_point_scale(binary_operator op, int32_t left_scale, int32_t right_scale)
Computes the scale for a fixed_point number based on given binary operator op
@ INVALID_BINARY
invalid operation
@ LOGICAL_OR
operator ||
@ BITWISE_OR
operator |
@ LOG_BASE
logarithm to the base
@ DIV
operator / using common type of lhs and rhs
@ PYMOD
operator % but following Python's sign rules for negatives
@ NOT_EQUAL
operator !=
@ BITWISE_XOR
operator ^
@ GREATER_EQUAL
operator >=
@ LESS_EQUAL
operator <=
@ TRUE_DIV
operator / after promoting type to floating point
@ LOGICAL_AND
operator &&
@ BITWISE_AND
operator &
@ SHIFT_LEFT
operator <<
@ SHIFT_RIGHT
operator >>
@ ATAN2
2-argument arctangent
cuDF interfaces
Definition: aggregation.hpp:34
Class definitions for cudf::scalar.