Files | Classes | Typedefs | Enumerations | Functions | Variables
Binary Operations

Files

file  binaryop.hpp
 Column APIs for binary ops.
 

Classes

struct  cudf::binary_op_common_type< L, R, typename >
 Binary operation common type default. More...
 
struct  cudf::binary_op_common_type< L, R, std::enable_if_t< has_common_type_v< L, R > > >
 Binary operation common type specialization. More...
 

Typedefs

template<typename L , typename R >
using cudf::binary_op_common_type_t = typename binary_op_common_type< L, R >::type
 Binary operation common type helper.
 

Enumerations

enum class  cudf::binary_operator : int32_t {
  cudf::ADD , cudf::SUB , cudf::MUL , cudf::DIV ,
  cudf::TRUE_DIV , cudf::FLOOR_DIV , cudf::MOD , cudf::PMOD ,
  cudf::PYMOD , cudf::POW , cudf::INT_POW , cudf::LOG_BASE ,
  cudf::ATAN2 , cudf::SHIFT_LEFT , cudf::SHIFT_RIGHT , cudf::SHIFT_RIGHT_UNSIGNED ,
  cudf::BITWISE_AND , cudf::BITWISE_OR , cudf::BITWISE_XOR , cudf::LOGICAL_AND ,
  cudf::LOGICAL_OR , cudf::EQUAL , cudf::NOT_EQUAL , cudf::LESS ,
  cudf::GREATER , cudf::LESS_EQUAL , cudf::GREATER_EQUAL , cudf::NULL_EQUALS ,
  cudf::NULL_NOT_EQUALS , cudf::NULL_MAX , cudf::NULL_MIN , cudf::GENERIC_BINARY ,
  cudf::NULL_LOGICAL_AND , cudf::NULL_LOGICAL_OR , cudf::INVALID_BINARY
}
 Types of binary operations that can be performed on data. More...
 

Functions

std::unique_ptr< columncudf::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=cudf::get_current_device_resource_ref())
 Performs a binary operation between a scalar and a column. More...
 
std::unique_ptr< columncudf::binary_operation (column_view const &lhs, scalar const &rhs, binary_operator op, data_type output_type, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
 Performs a binary operation between a column and a scalar. More...
 
std::unique_ptr< columncudf::binary_operation (column_view 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=cudf::get_current_device_resource_ref())
 Performs a binary operation between two columns. More...
 
std::unique_ptr< columncudf::binary_operation (column_view const &lhs, column_view const &rhs, std::string const &ptx, data_type output_type, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
 Performs a binary operation between two columns using a user-defined PTX function. More...
 
int32_t cudf::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 More...
 
cudf::data_type cudf::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 More...
 

Variables

template<typename L , typename R >
constexpr bool cudf::binary_op_has_common_type_v
 Checks if binary operation types have a common type. More...
 

Detailed Description

Enumeration Type Documentation

◆ binary_operator

enum cudf::binary_operator : int32_t
strong

Types of binary operations that can be performed on data.

Enumerator
ADD 

operator +

SUB 

operator -

MUL 

operator *

DIV 

operator / using common type of lhs and rhs

TRUE_DIV 

operator / after promoting type to floating point

FLOOR_DIV 

operator // integer division rounding towards negative infinity if both arguments are integral; floor division for floating types (using C++ type promotion for mixed integral/floating arguments) If different promotion semantics are required, it is the responsibility of the caller to promote manually before calling in to this function.

MOD 

operator %

PMOD 

positive modulo operator If remainder is negative, this returns (remainder + divisor) % divisor else, it returns (dividend % divisor)

PYMOD 

operator % but following Python's sign rules for negatives

POW 

lhs ^ rhs

INT_POW 

int ^ int, used to avoid floating point precision loss. Returns 0 for negative exponents.

LOG_BASE 

logarithm to the base

ATAN2 

2-argument arctangent

SHIFT_LEFT 

operator <<

SHIFT_RIGHT 

operator >>

SHIFT_RIGHT_UNSIGNED 

operator >>> (from Java) Logical right shift. Casts to an unsigned value before shifting.

BITWISE_AND 

operator &

BITWISE_OR 

operator |

BITWISE_XOR 

operator ^

LOGICAL_AND 

operator &&

LOGICAL_OR 

operator ||

EQUAL 

operator ==

NOT_EQUAL 

operator !=

LESS 

operator <

GREATER 

operator >

LESS_EQUAL 

operator <=

GREATER_EQUAL 

operator >=

NULL_EQUALS 

Returns true when both operands are null; false when one is null; the result of equality when both are non-null

NULL_NOT_EQUALS 

Returns false when both operands are null; true when one is null; the result of inequality when both are non-null

NULL_MAX 

Returns max of operands when both are non-null; returns the non-null operand when one is null; or invalid when both are null

NULL_MIN 

Returns min of operands when both are non-null; returns the non-null operand when one is null; or invalid when both are null

GENERIC_BINARY 

generic binary operator to be generated with input ptx code

NULL_LOGICAL_AND 

operator && with Spark rules: (null, null) is null, (null, true) is null, (null, false) is false, and (valid, valid) == LOGICAL_AND(valid, valid)

NULL_LOGICAL_OR 

operator || with Spark rules: (null, null) is null, (null, true) is true, (null, false) is null, and (valid, valid) == LOGICAL_OR(valid, valid)

INVALID_BINARY 

invalid operation

Definition at line 38 of file binaryop.hpp.

Function Documentation

◆ binary_operation() [1/4]

std::unique_ptr<column> cudf::binary_operation ( column_view 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 = cudf::get_current_device_resource_ref() 
)

Performs a binary operation between two columns.

The output contains the result of op(lhs[i], rhs[i]) for all 0 <= i < lhs.size()

Regardless of the operator, the validity of the output value is the logical AND of the validity of the two operands except NullMin and NullMax (logical OR).

Parameters
lhsThe left operand column
rhsThe right operand column
opThe binary operator
output_typeThe desired data type of the output column
streamCUDA stream used for device memory operations and kernel launches
mrDevice memory resource used to allocate the returned column's device memory
Returns
Output column of output_type type containing the result of the binary operation
Exceptions
cudf::logic_errorif lhs and rhs are different sizes
cudf::logic_errorif output_type dtype isn't boolean for comparison and logical operations.
cudf::logic_errorif output_type dtype isn't fixed-width
cudf::data_type_errorif the operation is not supported for the types of lhs and rhs

◆ binary_operation() [2/4]

std::unique_ptr<column> cudf::binary_operation ( column_view const &  lhs,
column_view const &  rhs,
std::string const &  ptx,
data_type  output_type,
rmm::cuda_stream_view  stream = cudf::get_default_stream(),
rmm::device_async_resource_ref  mr = cudf::get_current_device_resource_ref() 
)

Performs a binary operation between two columns using a user-defined PTX function.

The output contains the result of op(lhs[i], rhs[i]) for all 0 <= i < lhs.size()

Regardless of the operator, the validity of the output value is the logical AND of the validity of the two operands

Parameters
lhsThe left operand column
rhsThe right operand column
ptxString containing the PTX of a binary function
output_typeThe desired data type of the output column. It is assumed that output_type is compatible with the output data type of the function in the PTX code
streamCUDA stream used for device memory operations and kernel launches
mrDevice memory resource used to allocate the returned column's device memory
Returns
Output column of output_type type containing the result of the binary operation
Exceptions
cudf::logic_errorif lhs and rhs are different sizes
cudf::logic_errorif lhs and rhs dtypes aren't numeric
cudf::logic_errorif output_type dtype isn't numeric

◆ binary_operation() [3/4]

std::unique_ptr<column> cudf::binary_operation ( column_view const &  lhs,
scalar const &  rhs,
binary_operator  op,
data_type  output_type,
rmm::cuda_stream_view  stream = cudf::get_default_stream(),
rmm::device_async_resource_ref  mr = cudf::get_current_device_resource_ref() 
)

Performs a binary operation between a column and a scalar.

The output contains the result of op(lhs[i], rhs) for all 0 <= i < lhs.size() The column elements are the left operand and the scalar is the right operand. This distinction is significant in case of non-commutative binary operations

Regardless of the operator, the validity of the output value is the logical AND of the validity of the two operands except NullMin and NullMax (logical OR).

Parameters
lhsThe left operand column
rhsThe right operand scalar
opThe binary operator
output_typeThe desired data type of the output column
streamCUDA stream used for device memory operations and kernel launches
mrDevice memory resource used to allocate the returned column's device memory
Returns
Output column of output_type type containing the result of the binary operation
Exceptions
cudf::logic_errorif output_type dtype isn't fixed-width
cudf::logic_errorif output_type dtype isn't boolean for comparison and logical operations.
cudf::data_type_errorif the operation is not supported for the types of lhs and rhs

◆ binary_operation() [4/4]

std::unique_ptr<column> cudf::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 = cudf::get_current_device_resource_ref() 
)

Performs a binary operation between a scalar and a column.

The output contains the result of op(lhs, rhs[i]) for all 0 <= i < rhs.size() The scalar is the left operand and the column elements are the right operand. This distinction is significant in case of non-commutative binary operations

Regardless of the operator, the validity of the output value is the logical AND of the validity of the two operands except NullMin and NullMax (logical OR).

Parameters
lhsThe left operand scalar
rhsThe right operand column
opThe binary operator
output_typeThe desired data type of the output column
streamCUDA stream used for device memory operations and kernel launches
mrDevice memory resource used to allocate the returned column's device memory
Returns
Output column of output_type type containing the result of the binary operation
Exceptions
cudf::logic_errorif output_type dtype isn't fixed-width
cudf::logic_errorif output_type dtype isn't boolean for comparison and logical operations.
cudf::data_type_errorif the operation is not supported for the types of lhs and rhs

◆ binary_operation_fixed_point_output_type()

cudf::data_type cudf::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

Parameters
opThe binary_operator used for two fixed_point numbers
lhscudf::data_type of left fixed_point number
rhscudf::data_type of right fixed_point number
Returns
The resulting cudf::data_type of the computed fixed_point number

◆ binary_operation_fixed_point_scale()

int32_t cudf::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

Parameters
opThe binary_operator used for two fixed_point numbers
left_scaleScale of left fixed_point number
right_scaleScale of right fixed_point number
Returns
The resulting scale of the computed fixed_point number

Variable Documentation

◆ binary_op_has_common_type_v

template<typename L , typename R >
constexpr bool cudf::binary_op_has_common_type_v
inlineconstexpr
Initial value:
=
detail::binary_op_has_common_type_impl<void, L, R>::value

Checks if binary operation types have a common type.

Definition at line 140 of file binaryop.hpp.