From 0d11591f23b566e99f30cd06593e78097262a6fe Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Wed, 4 May 2022 15:16:51 -0500 Subject: [PATCH] Use column_views instead of column_device_views in binary operations. (#10780) This PR changes the internal APIs used for binary operations to use `column_view` objects instead of `column_device_view` objects. This change is needed for the eventual support of structs in binary operations. See also: PR #9452. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Ryan Lee (https://github.com/rwlee) - Nghia Truong (https://github.com/ttnghia) - Jake Hemstad (https://github.com/jrhemstad) URL: https://github.com/rapidsai/cudf/pull/10780 --- cpp/src/binaryop/compiled/ATan2.cu | 8 +-- cpp/src/binaryop/compiled/Add.cu | 8 +-- cpp/src/binaryop/compiled/BitwiseAnd.cu | 8 +-- cpp/src/binaryop/compiled/BitwiseOr.cu | 8 +-- cpp/src/binaryop/compiled/BitwiseXor.cu | 8 +-- cpp/src/binaryop/compiled/Div.cu | 8 +-- cpp/src/binaryop/compiled/FloorDiv.cu | 8 +-- cpp/src/binaryop/compiled/Greater.cu | 8 +-- cpp/src/binaryop/compiled/GreaterEqual.cu | 8 +-- cpp/src/binaryop/compiled/Less.cu | 8 +-- cpp/src/binaryop/compiled/LessEqual.cu | 8 +-- cpp/src/binaryop/compiled/LogBase.cu | 8 +-- cpp/src/binaryop/compiled/LogicalAnd.cu | 8 +-- cpp/src/binaryop/compiled/LogicalOr.cu | 8 +-- cpp/src/binaryop/compiled/Mod.cu | 8 +-- cpp/src/binaryop/compiled/Mul.cu | 8 +-- cpp/src/binaryop/compiled/NullEquals.cu | 8 +-- cpp/src/binaryop/compiled/NullLogicalAnd.cu | 6 +- cpp/src/binaryop/compiled/NullLogicalOr.cu | 6 +- cpp/src/binaryop/compiled/NullMax.cu | 8 +-- cpp/src/binaryop/compiled/NullMin.cu | 8 +-- cpp/src/binaryop/compiled/PMod.cu | 8 +-- cpp/src/binaryop/compiled/Pow.cu | 8 +-- cpp/src/binaryop/compiled/PyMod.cu | 8 +-- cpp/src/binaryop/compiled/ShiftLeft.cu | 8 +-- cpp/src/binaryop/compiled/ShiftRight.cu | 8 +-- .../binaryop/compiled/ShiftRightUnsigned.cu | 8 +-- cpp/src/binaryop/compiled/Sub.cu | 8 +-- cpp/src/binaryop/compiled/TrueDiv.cu | 8 +-- cpp/src/binaryop/compiled/binary_ops.cu | 57 +++++++------------ cpp/src/binaryop/compiled/binary_ops.cuh | 25 +++++--- cpp/src/binaryop/compiled/binary_ops.hpp | 40 ++++++------- cpp/src/binaryop/compiled/equality_ops.cu | 34 +++++------ 33 files changed, 190 insertions(+), 194 deletions(-) diff --git a/cpp/src/binaryop/compiled/ATan2.cu b/cpp/src/binaryop/compiled/ATan2.cu index 8e5cbf57f55..f43a469a2c9 100644 --- a/cpp/src/binaryop/compiled/ATan2.cu +++ b/cpp/src/binaryop/compiled/ATan2.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,9 +17,9 @@ #include "binary_ops.cuh" namespace cudf::binops::compiled { -template void apply_binary_op(mutable_column_device_view&, - column_device_view const&, - column_device_view const&, +template void apply_binary_op(mutable_column_view&, + column_view const&, + column_view const&, bool is_lhs_scalar, bool is_rhs_scalar, rmm::cuda_stream_view); diff --git a/cpp/src/binaryop/compiled/Add.cu b/cpp/src/binaryop/compiled/Add.cu index 4cd2ced66f4..1dbfa5b4718 100644 --- a/cpp/src/binaryop/compiled/Add.cu +++ b/cpp/src/binaryop/compiled/Add.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,9 +17,9 @@ #include "binary_ops.cuh" namespace cudf::binops::compiled { -template void apply_binary_op(mutable_column_device_view&, - column_device_view const&, - column_device_view const&, +template void apply_binary_op(mutable_column_view&, + column_view const&, + column_view const&, bool is_lhs_scalar, bool is_rhs_scalar, rmm::cuda_stream_view); diff --git a/cpp/src/binaryop/compiled/BitwiseAnd.cu b/cpp/src/binaryop/compiled/BitwiseAnd.cu index 6abac2bd197..cfabb1402ce 100644 --- a/cpp/src/binaryop/compiled/BitwiseAnd.cu +++ b/cpp/src/binaryop/compiled/BitwiseAnd.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,9 +17,9 @@ #include "binary_ops.cuh" namespace cudf::binops::compiled { -template void apply_binary_op(mutable_column_device_view&, - column_device_view const&, - column_device_view const&, +template void apply_binary_op(mutable_column_view&, + column_view const&, + column_view const&, bool is_lhs_scalar, bool is_rhs_scalar, rmm::cuda_stream_view); diff --git a/cpp/src/binaryop/compiled/BitwiseOr.cu b/cpp/src/binaryop/compiled/BitwiseOr.cu index 6d523cbf1d1..01ef118665b 100644 --- a/cpp/src/binaryop/compiled/BitwiseOr.cu +++ b/cpp/src/binaryop/compiled/BitwiseOr.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,9 +17,9 @@ #include "binary_ops.cuh" namespace cudf::binops::compiled { -template void apply_binary_op(mutable_column_device_view&, - column_device_view const&, - column_device_view const&, +template void apply_binary_op(mutable_column_view&, + column_view const&, + column_view const&, bool is_lhs_scalar, bool is_rhs_scalar, rmm::cuda_stream_view); diff --git a/cpp/src/binaryop/compiled/BitwiseXor.cu b/cpp/src/binaryop/compiled/BitwiseXor.cu index 45175681574..44f74bab876 100644 --- a/cpp/src/binaryop/compiled/BitwiseXor.cu +++ b/cpp/src/binaryop/compiled/BitwiseXor.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,9 +17,9 @@ #include "binary_ops.cuh" namespace cudf::binops::compiled { -template void apply_binary_op(mutable_column_device_view&, - column_device_view const&, - column_device_view const&, +template void apply_binary_op(mutable_column_view&, + column_view const&, + column_view const&, bool is_lhs_scalar, bool is_rhs_scalar, rmm::cuda_stream_view); diff --git a/cpp/src/binaryop/compiled/Div.cu b/cpp/src/binaryop/compiled/Div.cu index 7cc895ecd06..f377778c427 100644 --- a/cpp/src/binaryop/compiled/Div.cu +++ b/cpp/src/binaryop/compiled/Div.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,9 +17,9 @@ #include "binary_ops.cuh" namespace cudf::binops::compiled { -template void apply_binary_op(mutable_column_device_view&, - column_device_view const&, - column_device_view const&, +template void apply_binary_op(mutable_column_view&, + column_view const&, + column_view const&, bool is_lhs_scalar, bool is_rhs_scalar, rmm::cuda_stream_view); diff --git a/cpp/src/binaryop/compiled/FloorDiv.cu b/cpp/src/binaryop/compiled/FloorDiv.cu index 99ea2706b86..f9cd323caec 100644 --- a/cpp/src/binaryop/compiled/FloorDiv.cu +++ b/cpp/src/binaryop/compiled/FloorDiv.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,9 +17,9 @@ #include "binary_ops.cuh" namespace cudf::binops::compiled { -template void apply_binary_op(mutable_column_device_view&, - column_device_view const&, - column_device_view const&, +template void apply_binary_op(mutable_column_view&, + column_view const&, + column_view const&, bool is_lhs_scalar, bool is_rhs_scalar, rmm::cuda_stream_view); diff --git a/cpp/src/binaryop/compiled/Greater.cu b/cpp/src/binaryop/compiled/Greater.cu index 679e029b5fc..db06cc409da 100644 --- a/cpp/src/binaryop/compiled/Greater.cu +++ b/cpp/src/binaryop/compiled/Greater.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,9 +17,9 @@ #include "binary_ops.cuh" namespace cudf::binops::compiled { -template void apply_binary_op(mutable_column_device_view&, - column_device_view const&, - column_device_view const&, +template void apply_binary_op(mutable_column_view&, + column_view const&, + column_view const&, bool is_lhs_scalar, bool is_rhs_scalar, rmm::cuda_stream_view); diff --git a/cpp/src/binaryop/compiled/GreaterEqual.cu b/cpp/src/binaryop/compiled/GreaterEqual.cu index 23b0c6aaa0d..c239e1e1345 100644 --- a/cpp/src/binaryop/compiled/GreaterEqual.cu +++ b/cpp/src/binaryop/compiled/GreaterEqual.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,9 +17,9 @@ #include "binary_ops.cuh" namespace cudf::binops::compiled { -template void apply_binary_op(mutable_column_device_view&, - column_device_view const&, - column_device_view const&, +template void apply_binary_op(mutable_column_view&, + column_view const&, + column_view const&, bool is_lhs_scalar, bool is_rhs_scalar, rmm::cuda_stream_view); diff --git a/cpp/src/binaryop/compiled/Less.cu b/cpp/src/binaryop/compiled/Less.cu index 7ab5dfe3478..e8663715c87 100644 --- a/cpp/src/binaryop/compiled/Less.cu +++ b/cpp/src/binaryop/compiled/Less.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,9 +17,9 @@ #include "binary_ops.cuh" namespace cudf::binops::compiled { -template void apply_binary_op(mutable_column_device_view&, - column_device_view const&, - column_device_view const&, +template void apply_binary_op(mutable_column_view&, + column_view const&, + column_view const&, bool is_lhs_scalar, bool is_rhs_scalar, rmm::cuda_stream_view); diff --git a/cpp/src/binaryop/compiled/LessEqual.cu b/cpp/src/binaryop/compiled/LessEqual.cu index 983c50c9575..d2f88fab81b 100644 --- a/cpp/src/binaryop/compiled/LessEqual.cu +++ b/cpp/src/binaryop/compiled/LessEqual.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,9 +17,9 @@ #include "binary_ops.cuh" namespace cudf::binops::compiled { -template void apply_binary_op(mutable_column_device_view&, - column_device_view const&, - column_device_view const&, +template void apply_binary_op(mutable_column_view&, + column_view const&, + column_view const&, bool is_lhs_scalar, bool is_rhs_scalar, rmm::cuda_stream_view); diff --git a/cpp/src/binaryop/compiled/LogBase.cu b/cpp/src/binaryop/compiled/LogBase.cu index bdc709b86bf..8a2162c4ca4 100644 --- a/cpp/src/binaryop/compiled/LogBase.cu +++ b/cpp/src/binaryop/compiled/LogBase.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,9 +17,9 @@ #include "binary_ops.cuh" namespace cudf::binops::compiled { -template void apply_binary_op(mutable_column_device_view&, - column_device_view const&, - column_device_view const&, +template void apply_binary_op(mutable_column_view&, + column_view const&, + column_view const&, bool is_lhs_scalar, bool is_rhs_scalar, rmm::cuda_stream_view); diff --git a/cpp/src/binaryop/compiled/LogicalAnd.cu b/cpp/src/binaryop/compiled/LogicalAnd.cu index 08112fadfff..64e5c1a31c0 100644 --- a/cpp/src/binaryop/compiled/LogicalAnd.cu +++ b/cpp/src/binaryop/compiled/LogicalAnd.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,9 +17,9 @@ #include "binary_ops.cuh" namespace cudf::binops::compiled { -template void apply_binary_op(mutable_column_device_view&, - column_device_view const&, - column_device_view const&, +template void apply_binary_op(mutable_column_view&, + column_view const&, + column_view const&, bool is_lhs_scalar, bool is_rhs_scalar, rmm::cuda_stream_view); diff --git a/cpp/src/binaryop/compiled/LogicalOr.cu b/cpp/src/binaryop/compiled/LogicalOr.cu index bc400afd4cd..a4b64cc6afc 100644 --- a/cpp/src/binaryop/compiled/LogicalOr.cu +++ b/cpp/src/binaryop/compiled/LogicalOr.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,9 +17,9 @@ #include "binary_ops.cuh" namespace cudf::binops::compiled { -template void apply_binary_op(mutable_column_device_view&, - column_device_view const&, - column_device_view const&, +template void apply_binary_op(mutable_column_view&, + column_view const&, + column_view const&, bool is_lhs_scalar, bool is_rhs_scalar, rmm::cuda_stream_view); diff --git a/cpp/src/binaryop/compiled/Mod.cu b/cpp/src/binaryop/compiled/Mod.cu index 0b82c09c8a6..fcdd01b7be8 100644 --- a/cpp/src/binaryop/compiled/Mod.cu +++ b/cpp/src/binaryop/compiled/Mod.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,9 +17,9 @@ #include "binary_ops.cuh" namespace cudf::binops::compiled { -template void apply_binary_op(mutable_column_device_view&, - column_device_view const&, - column_device_view const&, +template void apply_binary_op(mutable_column_view&, + column_view const&, + column_view const&, bool is_lhs_scalar, bool is_rhs_scalar, rmm::cuda_stream_view); diff --git a/cpp/src/binaryop/compiled/Mul.cu b/cpp/src/binaryop/compiled/Mul.cu index 15394245259..de6506d43f1 100644 --- a/cpp/src/binaryop/compiled/Mul.cu +++ b/cpp/src/binaryop/compiled/Mul.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,9 +17,9 @@ #include "binary_ops.cuh" namespace cudf::binops::compiled { -template void apply_binary_op(mutable_column_device_view&, - column_device_view const&, - column_device_view const&, +template void apply_binary_op(mutable_column_view&, + column_view const&, + column_view const&, bool is_lhs_scalar, bool is_rhs_scalar, rmm::cuda_stream_view); diff --git a/cpp/src/binaryop/compiled/NullEquals.cu b/cpp/src/binaryop/compiled/NullEquals.cu index 3fc76e804f7..f4780c13bef 100644 --- a/cpp/src/binaryop/compiled/NullEquals.cu +++ b/cpp/src/binaryop/compiled/NullEquals.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,9 +17,9 @@ #include "binary_ops.cuh" namespace cudf::binops::compiled { -template void apply_binary_op(mutable_column_device_view&, - column_device_view const&, - column_device_view const&, +template void apply_binary_op(mutable_column_view&, + column_view const&, + column_view const&, bool is_lhs_scalar, bool is_rhs_scalar, rmm::cuda_stream_view); diff --git a/cpp/src/binaryop/compiled/NullLogicalAnd.cu b/cpp/src/binaryop/compiled/NullLogicalAnd.cu index 48ae125bc93..55e71a52dae 100644 --- a/cpp/src/binaryop/compiled/NullLogicalAnd.cu +++ b/cpp/src/binaryop/compiled/NullLogicalAnd.cu @@ -17,9 +17,9 @@ #include "binary_ops.cuh" namespace cudf::binops::compiled { -template void apply_binary_op(mutable_column_device_view&, - column_device_view const&, - column_device_view const&, +template void apply_binary_op(mutable_column_view&, + column_view const&, + column_view const&, bool is_lhs_scalar, bool is_rhs_scalar, rmm::cuda_stream_view); diff --git a/cpp/src/binaryop/compiled/NullLogicalOr.cu b/cpp/src/binaryop/compiled/NullLogicalOr.cu index e0ea95ac3ee..ee3b27c0934 100644 --- a/cpp/src/binaryop/compiled/NullLogicalOr.cu +++ b/cpp/src/binaryop/compiled/NullLogicalOr.cu @@ -17,9 +17,9 @@ #include "binary_ops.cuh" namespace cudf::binops::compiled { -template void apply_binary_op(mutable_column_device_view&, - column_device_view const&, - column_device_view const&, +template void apply_binary_op(mutable_column_view&, + column_view const&, + column_view const&, bool is_lhs_scalar, bool is_rhs_scalar, rmm::cuda_stream_view); diff --git a/cpp/src/binaryop/compiled/NullMax.cu b/cpp/src/binaryop/compiled/NullMax.cu index 78a44041cba..6fae253d41f 100644 --- a/cpp/src/binaryop/compiled/NullMax.cu +++ b/cpp/src/binaryop/compiled/NullMax.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,9 +17,9 @@ #include "binary_ops.cuh" namespace cudf::binops::compiled { -template void apply_binary_op(mutable_column_device_view&, - column_device_view const&, - column_device_view const&, +template void apply_binary_op(mutable_column_view&, + column_view const&, + column_view const&, bool is_lhs_scalar, bool is_rhs_scalar, rmm::cuda_stream_view); diff --git a/cpp/src/binaryop/compiled/NullMin.cu b/cpp/src/binaryop/compiled/NullMin.cu index 629ab600fd7..cb7fdb4f76a 100644 --- a/cpp/src/binaryop/compiled/NullMin.cu +++ b/cpp/src/binaryop/compiled/NullMin.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,9 +17,9 @@ #include "binary_ops.cuh" namespace cudf::binops::compiled { -template void apply_binary_op(mutable_column_device_view&, - column_device_view const&, - column_device_view const&, +template void apply_binary_op(mutable_column_view&, + column_view const&, + column_view const&, bool is_lhs_scalar, bool is_rhs_scalar, rmm::cuda_stream_view); diff --git a/cpp/src/binaryop/compiled/PMod.cu b/cpp/src/binaryop/compiled/PMod.cu index 36902c0ed10..63b1f1f8269 100644 --- a/cpp/src/binaryop/compiled/PMod.cu +++ b/cpp/src/binaryop/compiled/PMod.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,9 +17,9 @@ #include "binary_ops.cuh" namespace cudf::binops::compiled { -template void apply_binary_op(mutable_column_device_view&, - column_device_view const&, - column_device_view const&, +template void apply_binary_op(mutable_column_view&, + column_view const&, + column_view const&, bool is_lhs_scalar, bool is_rhs_scalar, rmm::cuda_stream_view); diff --git a/cpp/src/binaryop/compiled/Pow.cu b/cpp/src/binaryop/compiled/Pow.cu index c6f897ee18d..435e1ac044a 100644 --- a/cpp/src/binaryop/compiled/Pow.cu +++ b/cpp/src/binaryop/compiled/Pow.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,9 +17,9 @@ #include "binary_ops.cuh" namespace cudf::binops::compiled { -template void apply_binary_op(mutable_column_device_view&, - column_device_view const&, - column_device_view const&, +template void apply_binary_op(mutable_column_view&, + column_view const&, + column_view const&, bool is_lhs_scalar, bool is_rhs_scalar, rmm::cuda_stream_view); diff --git a/cpp/src/binaryop/compiled/PyMod.cu b/cpp/src/binaryop/compiled/PyMod.cu index b05dcd8e7bc..1e213598681 100644 --- a/cpp/src/binaryop/compiled/PyMod.cu +++ b/cpp/src/binaryop/compiled/PyMod.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,9 +17,9 @@ #include "binary_ops.cuh" namespace cudf::binops::compiled { -template void apply_binary_op(mutable_column_device_view&, - column_device_view const&, - column_device_view const&, +template void apply_binary_op(mutable_column_view&, + column_view const&, + column_view const&, bool is_lhs_scalar, bool is_rhs_scalar, rmm::cuda_stream_view); diff --git a/cpp/src/binaryop/compiled/ShiftLeft.cu b/cpp/src/binaryop/compiled/ShiftLeft.cu index 6cc950b2d50..797821a9057 100644 --- a/cpp/src/binaryop/compiled/ShiftLeft.cu +++ b/cpp/src/binaryop/compiled/ShiftLeft.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,9 +17,9 @@ #include "binary_ops.cuh" namespace cudf::binops::compiled { -template void apply_binary_op(mutable_column_device_view&, - column_device_view const&, - column_device_view const&, +template void apply_binary_op(mutable_column_view&, + column_view const&, + column_view const&, bool is_lhs_scalar, bool is_rhs_scalar, rmm::cuda_stream_view); diff --git a/cpp/src/binaryop/compiled/ShiftRight.cu b/cpp/src/binaryop/compiled/ShiftRight.cu index 1ddd7100a73..8a2566ff775 100644 --- a/cpp/src/binaryop/compiled/ShiftRight.cu +++ b/cpp/src/binaryop/compiled/ShiftRight.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,9 +17,9 @@ #include "binary_ops.cuh" namespace cudf::binops::compiled { -template void apply_binary_op(mutable_column_device_view&, - column_device_view const&, - column_device_view const&, +template void apply_binary_op(mutable_column_view&, + column_view const&, + column_view const&, bool is_lhs_scalar, bool is_rhs_scalar, rmm::cuda_stream_view); diff --git a/cpp/src/binaryop/compiled/ShiftRightUnsigned.cu b/cpp/src/binaryop/compiled/ShiftRightUnsigned.cu index a87b4b9f9ac..827029bc75c 100644 --- a/cpp/src/binaryop/compiled/ShiftRightUnsigned.cu +++ b/cpp/src/binaryop/compiled/ShiftRightUnsigned.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,9 +17,9 @@ #include "binary_ops.cuh" namespace cudf::binops::compiled { -template void apply_binary_op(mutable_column_device_view&, - column_device_view const&, - column_device_view const&, +template void apply_binary_op(mutable_column_view&, + column_view const&, + column_view const&, bool is_lhs_scalar, bool is_rhs_scalar, rmm::cuda_stream_view); diff --git a/cpp/src/binaryop/compiled/Sub.cu b/cpp/src/binaryop/compiled/Sub.cu index e0cf47c1310..3022294f86f 100644 --- a/cpp/src/binaryop/compiled/Sub.cu +++ b/cpp/src/binaryop/compiled/Sub.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,9 +17,9 @@ #include "binary_ops.cuh" namespace cudf::binops::compiled { -template void apply_binary_op(mutable_column_device_view&, - column_device_view const&, - column_device_view const&, +template void apply_binary_op(mutable_column_view&, + column_view const&, + column_view const&, bool is_lhs_scalar, bool is_rhs_scalar, rmm::cuda_stream_view); diff --git a/cpp/src/binaryop/compiled/TrueDiv.cu b/cpp/src/binaryop/compiled/TrueDiv.cu index d8f1d956340..4d0fc2d456b 100644 --- a/cpp/src/binaryop/compiled/TrueDiv.cu +++ b/cpp/src/binaryop/compiled/TrueDiv.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,9 +17,9 @@ #include "binary_ops.cuh" namespace cudf::binops::compiled { -template void apply_binary_op(mutable_column_device_view&, - column_device_view const&, - column_device_view const&, +template void apply_binary_op(mutable_column_view&, + column_view const&, + column_view const&, bool is_lhs_scalar, bool is_rhs_scalar, rmm::cuda_stream_view); diff --git a/cpp/src/binaryop/compiled/binary_ops.cu b/cpp/src/binaryop/compiled/binary_ops.cu index c01359b80d0..d260aa6d6a0 100644 --- a/cpp/src/binaryop/compiled/binary_ops.cu +++ b/cpp/src/binaryop/compiled/binary_ops.cu @@ -37,23 +37,20 @@ namespace compiled { namespace { /** - * @brief Converts scalar to column_device_view with single element. + * @brief Converts scalar to column_view with single element. * - * @return pair with column_device_view and column containing any auxilary data to create - * column_view from scalar + * @return pair with column_view and column containing any auxilary data to create column_view from + * scalar */ -struct scalar_as_column_device_view { - using return_type = typename std::pair>; +struct scalar_as_column_view { + using return_type = typename std::pair>; template ())>* = nullptr> - return_type operator()(scalar const& s, - rmm::cuda_stream_view stream, - rmm::mr::device_memory_resource*) + return_type operator()(scalar const& s, rmm::cuda_stream_view, rmm::mr::device_memory_resource*) { auto& h_scalar_type_view = static_cast&>(const_cast(s)); auto col_v = column_view(s.type(), 1, h_scalar_type_view.data(), (bitmask_type const*)s.validity_data()); - return std::pair{column_device_view::create(col_v, stream), std::unique_ptr(nullptr)}; + return std::pair{col_v, std::unique_ptr(nullptr)}; } template ())>* = nullptr> return_type operator()(scalar const&, rmm::cuda_stream_view, rmm::mr::device_memory_resource*) @@ -63,10 +60,8 @@ struct scalar_as_column_device_view { }; // specialization for cudf::string_view template <> -scalar_as_column_device_view::return_type -scalar_as_column_device_view::operator()(scalar const& s, - rmm::cuda_stream_view stream, - rmm::mr::device_memory_resource* mr) +scalar_as_column_view::return_type scalar_as_column_view::operator()( + scalar const& s, rmm::cuda_stream_view stream, rmm::mr::device_memory_resource* mr) { using T = cudf::string_view; auto& h_scalar_type_view = static_cast&>(const_cast(s)); @@ -87,24 +82,24 @@ scalar_as_column_device_view::operator()(scalar const& s, cudf::UNKNOWN_NULL_COUNT, 0, {offsets_column->view(), chars_column_v}); - return std::pair{column_device_view::create(col_v, stream), std::move(offsets_column)}; + return std::pair{col_v, std::move(offsets_column)}; } /** - * @brief Converts scalar to column_device_view with single element. + * @brief Converts scalar to column_view with single element. * * @param scal scalar to convert * @param stream CUDA stream used for device memory operations and kernel launches. * @param mr Device memory resource used to allocate the returned column's device memory - * @return pair with column_device_view and column containing any auxilary data to create + * @return pair with column_view and column containing any auxilary data to create * column_view from scalar */ -auto scalar_to_column_device_view( +auto scalar_to_column_view( scalar const& scal, rmm::cuda_stream_view stream, rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()) { - return type_dispatcher(scal.type(), scalar_as_column_device_view{}, scal, stream, mr); + return type_dispatcher(scal.type(), scalar_as_column_view{}, scal, stream, mr); } // This functor does the actual comparison between string column value and a scalar string @@ -300,9 +295,9 @@ std::unique_ptr string_null_min_max(column_view const& lhs, *lhs_device_view, *rhs_device_view, op, output_type, lhs.size(), stream, mr); } -void operator_dispatcher(mutable_column_device_view& out, - column_device_view const& lhs, - column_device_view const& rhs, +void operator_dispatcher(mutable_column_view& out, + column_view const& lhs, + column_view const& rhs, bool is_lhs_scalar, bool is_rhs_scalar, binary_operator op, @@ -358,10 +353,7 @@ void binary_operation(mutable_column_view& out, binary_operator op, rmm::cuda_stream_view stream) { - auto lhsd = column_device_view::create(lhs, stream); - auto rhsd = column_device_view::create(rhs, stream); - auto outd = mutable_column_device_view::create(out, stream); - operator_dispatcher(*outd, *lhsd, *rhsd, false, false, op, stream); + operator_dispatcher(out, lhs, rhs, false, false, op, stream); } // scalar_vector void binary_operation(mutable_column_view& out, @@ -370,10 +362,8 @@ void binary_operation(mutable_column_view& out, binary_operator op, rmm::cuda_stream_view stream) { - auto [lhsd, aux] = scalar_to_column_device_view(lhs, stream); - auto rhsd = column_device_view::create(rhs, stream); - auto outd = mutable_column_device_view::create(out, stream); - operator_dispatcher(*outd, *lhsd, *rhsd, true, false, op, stream); + auto [lhsv, aux] = scalar_to_column_view(lhs, stream); + operator_dispatcher(out, lhsv, rhs, true, false, op, stream); } // vector_scalar void binary_operation(mutable_column_view& out, @@ -382,12 +372,9 @@ void binary_operation(mutable_column_view& out, binary_operator op, rmm::cuda_stream_view stream) { - auto lhsd = column_device_view::create(lhs, stream); - auto [rhsd, aux] = scalar_to_column_device_view(rhs, stream); - auto outd = mutable_column_device_view::create(out, stream); - operator_dispatcher(*outd, *lhsd, *rhsd, false, true, op, stream); + auto [rhsv, aux] = scalar_to_column_view(rhs, stream); + operator_dispatcher(out, lhs, rhsv, false, true, op, stream); } - } // namespace compiled } // namespace binops } // namespace cudf diff --git a/cpp/src/binaryop/compiled/binary_ops.cuh b/cpp/src/binaryop/compiled/binary_ops.cuh index ec41fbb8883..d88d2be2499 100644 --- a/cpp/src/binaryop/compiled/binary_ops.cuh +++ b/cpp/src/binaryop/compiled/binary_ops.cuh @@ -20,6 +20,7 @@ #include "operation.cuh" #include +#include #include #include @@ -271,30 +272,36 @@ void for_each(rmm::cuda_stream_view stream, cudf::size_type size, Functor f) const int grid_size = util::div_rounding_up_safe(size, 2 * block_size); for_each_kernel<<>>(size, std::forward(f)); } - +namespace detail { +template +inline constexpr bool is_any_v = std::disjunction...>::value; +} template -void apply_binary_op(mutable_column_device_view& outd, - column_device_view const& lhsd, - column_device_view const& rhsd, +void apply_binary_op(mutable_column_view& out, + column_view const& lhs, + column_view const& rhs, bool is_lhs_scalar, bool is_rhs_scalar, rmm::cuda_stream_view stream) { - auto common_dtype = get_common_type(outd.type(), lhsd.type(), rhsd.type()); + auto common_dtype = get_common_type(out.type(), lhs.type(), rhs.type()); + auto lhsd = column_device_view::create(lhs, stream); + auto rhsd = column_device_view::create(rhs, stream); + auto outd = mutable_column_device_view::create(out, stream); // Create binop functor instance if (common_dtype) { // Execute it on every element for_each(stream, - outd.size(), + out.size(), binary_op_device_dispatcher{ - *common_dtype, outd, lhsd, rhsd, is_lhs_scalar, is_rhs_scalar}); + *common_dtype, *outd, *lhsd, *rhsd, is_lhs_scalar, is_rhs_scalar}); } else { // Execute it on every element for_each(stream, - outd.size(), + out.size(), binary_op_double_device_dispatcher{ - outd, lhsd, rhsd, is_lhs_scalar, is_rhs_scalar}); + *outd, *lhsd, *rhsd, is_lhs_scalar, is_rhs_scalar}); } } diff --git a/cpp/src/binaryop/compiled/binary_ops.hpp b/cpp/src/binaryop/compiled/binary_ops.hpp index 26a0f26b59c..d1a40e15326 100644 --- a/cpp/src/binaryop/compiled/binary_ops.hpp +++ b/cpp/src/binaryop/compiled/binary_ops.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2021, NVIDIA CORPORATION. + * Copyright (c) 2018-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -175,45 +175,45 @@ bool is_supported_operation(data_type out, data_type lhs, data_type rhs, binary_ // Defined in individual .cu files. /** * @brief Deploys single type or double type dispatcher that runs binary operation on each element - * of @p lhsd and @p rhsd columns. + * of @p lhs and @p rhs columns. * * This template is instantiated for each binary operator. * * @tparam BinaryOperator Binary operator functor - * @param outd mutable device view of output column - * @param lhsd device view of left operand column - * @param rhsd device view of right operand column - * @param is_lhs_scalar true if @p lhsd is a single element column representing a scalar - * @param is_rhs_scalar true if @p rhsd is a single element column representing a scalar + * @param out mutable view of output column + * @param lhs view of left operand column + * @param rhs view of right operand column + * @param is_lhs_scalar true if @p lhs is a single element column representing a scalar + * @param is_rhs_scalar true if @p rhs is a single element column representing a scalar * @param stream CUDA stream used for device memory operations */ template -void apply_binary_op(mutable_column_device_view&, - column_device_view const&, - column_device_view const&, +void apply_binary_op(mutable_column_view& out, + column_view const& lhs, + column_view const& rhs, bool is_lhs_scalar, bool is_rhs_scalar, rmm::cuda_stream_view stream); /** * @brief Deploys single type or double type dispatcher that runs equality operation on each element - * of @p lhsd and @p rhsd columns. + * of @p lhs and @p rhs columns. * * Comparison operators are EQUAL, NOT_EQUAL, NULL_EQUALS. - * @p outd type is boolean. + * @p out type is boolean. * * This template is instantiated for each binary operator. * - * @param outd mutable device view of output column - * @param lhsd device view of left operand column - * @param rhsd device view of right operand column - * @param is_lhs_scalar true if @p lhsd is a single element column representing a scalar - * @param is_rhs_scalar true if @p rhsd is a single element column representing a scalar + * @param out mutable view of output column + * @param lhs view of left operand column + * @param rhs view of right operand column + * @param is_lhs_scalar true if @p lhs is a single element column representing a scalar + * @param is_rhs_scalar true if @p rhs is a single element column representing a scalar * @param op comparison binary operator * @param stream CUDA stream used for device memory operations */ -void dispatch_equality_op(mutable_column_device_view& outd, - column_device_view const& lhsd, - column_device_view const& rhsd, +void dispatch_equality_op(mutable_column_view& out, + column_view const& lhs, + column_view const& rhs, bool is_lhs_scalar, bool is_rhs_scalar, binary_operator op, diff --git a/cpp/src/binaryop/compiled/equality_ops.cu b/cpp/src/binaryop/compiled/equality_ops.cu index 03c3e373476..61f02252a26 100644 --- a/cpp/src/binaryop/compiled/equality_ops.cu +++ b/cpp/src/binaryop/compiled/equality_ops.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,41 +17,43 @@ #include "binary_ops.cuh" namespace cudf::binops::compiled { -void dispatch_equality_op(mutable_column_device_view& outd, - column_device_view const& lhsd, - column_device_view const& rhsd, +void dispatch_equality_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) { - auto common_dtype = get_common_type(outd.type(), lhsd.type(), rhsd.type()); - - // Execute it on every element - + CUDF_EXPECTS(op == binary_operator::EQUAL || op == binary_operator::NOT_EQUAL, + "Unsupported operator for these types"); + auto common_dtype = get_common_type(out.type(), lhs.type(), rhs.type()); + auto outd = mutable_column_device_view::create(out, stream); + auto lhsd = column_device_view::create(lhs, stream); + auto rhsd = column_device_view::create(rhs, stream); if (common_dtype) { if (op == binary_operator::EQUAL) { for_each(stream, - outd.size(), + out.size(), binary_op_device_dispatcher{ - *common_dtype, outd, lhsd, rhsd, is_lhs_scalar, is_rhs_scalar}); + *common_dtype, *outd, *lhsd, *rhsd, is_lhs_scalar, is_rhs_scalar}); } else if (op == binary_operator::NOT_EQUAL) { for_each(stream, - outd.size(), + out.size(), binary_op_device_dispatcher{ - *common_dtype, outd, lhsd, rhsd, is_lhs_scalar, is_rhs_scalar}); + *common_dtype, *outd, *lhsd, *rhsd, is_lhs_scalar, is_rhs_scalar}); } } else { if (op == binary_operator::EQUAL) { for_each(stream, - outd.size(), + out.size(), binary_op_double_device_dispatcher{ - outd, lhsd, rhsd, is_lhs_scalar, is_rhs_scalar}); + *outd, *lhsd, *rhsd, is_lhs_scalar, is_rhs_scalar}); } else if (op == binary_operator::NOT_EQUAL) { for_each(stream, - outd.size(), + out.size(), binary_op_double_device_dispatcher{ - outd, lhsd, rhsd, is_lhs_scalar, is_rhs_scalar}); + *outd, *lhsd, *rhsd, is_lhs_scalar, is_rhs_scalar}); } } }