binaryop.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019-2023, 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 
23 
24 #include <memory>
25 
26 namespace cudf {
27 
38 enum class binary_operator : int32_t {
39  ADD,
40  SUB,
41  MUL,
42  DIV,
43  TRUE_DIV,
44  FLOOR_DIV,
52  MOD,
53  PMOD,
56  PYMOD,
57  POW,
58  INT_POW,
60  LOG_BASE,
61  ATAN2,
62  SHIFT_LEFT,
63  SHIFT_RIGHT,
66  BITWISE_AND,
67  BITWISE_OR,
68  BITWISE_XOR,
69  LOGICAL_AND,
70  LOGICAL_OR,
71  EQUAL,
72  NOT_EQUAL,
73  LESS,
74  GREATER,
75  LESS_EQUAL,
77  NULL_EQUALS,
79  NULL_MAX,
81  NULL_MIN,
90 };
114 std::unique_ptr<column> binary_operation(
115  scalar const& lhs,
116  column_view const& rhs,
117  binary_operator op,
118  data_type output_type,
121 
145 std::unique_ptr<column> binary_operation(
146  column_view const& lhs,
147  scalar const& rhs,
148  binary_operator op,
149  data_type output_type,
152 
175 std::unique_ptr<column> binary_operation(
176  column_view const& lhs,
177  column_view const& rhs,
178  binary_operator op,
179  data_type output_type,
182 
206 std::unique_ptr<column> binary_operation(
207  column_view const& lhs,
208  column_view const& rhs,
209  std::string const& ptx,
210  data_type output_type,
213 
223  int32_t left_scale,
224  int32_t right_scale);
225 
235  cudf::data_type const& lhs,
236  cudf::data_type const& rhs);
237 
238 namespace binops {
239 
249 std::pair<rmm::device_buffer, size_type> scalar_col_valid_mask_and(
250  column_view const& col,
251  scalar const& s,
254 
255 namespace compiled {
256 namespace detail {
257 
270  column_view const& lhs,
271  column_view const& rhs,
272  bool is_lhs_scalar,
273  bool is_rhs_scalar,
274  binary_operator op,
275  rmm::cuda_stream_view stream);
276 } // namespace detail
277 } // namespace compiled
278 } // namespace binops
279  // end of group
281 } // 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::mr::device_memory_resource *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:48
Class definition for cudf::column.
rmm::cuda_stream_view const get_default_stream()
Get the current default stream.
device_memory_resource * get_current_device_resource()
binary_operator
Types of binary operations that can be performed on data.
Definition: binaryop.hpp:38
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::mr::device_memory_resource *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.