-
Notifications
You must be signed in to change notification settings - Fork 902
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add in support for NULL_LOGICAL_AND and NULL_LOGICAL_OR binops (#10016)
These already exist as a part of the AST. Spark's AND/OR implementations follow these requirements and to be able to re-implement it using existing CUDF functionality ended up being very expensive. We found that this one change could cut almost 13% off the total run time on TPC-DS query 28. AND/OR are common enough in all queries we expect this to have a major performance impact generally. We tried to use the AST version instead, but depending on the hardware used the overhead of AST does not pay for itself when the input/intermediate outputs are boolean columns. It appears to be because the amount of memory transfers saved is relatively small in most boolean cases and on large GPUs like the a100 the intermediate results might even fit entirely in the L2 cache. Authors: - Robert (Bobby) Evans (https://github.com/revans2) Approvers: - Jason Lowe (https://github.com/jlowe) - Conor Hoekstra (https://github.com/codereport) - Jake Hemstad (https://github.com/jrhemstad) - Jim Brennan (https://github.com/jbrennan333) URL: #10016
- Loading branch information
Showing
13 changed files
with
259 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright (c) 2019-2021, NVIDIA CORPORATION. | ||
* Copyright (c) 2019-2022, NVIDIA CORPORATION. | ||
* | ||
* Copyright 2018-2019 BlazingDB, Inc. | ||
* Copyright 2018 Christian Noboa Mardini <[email protected]> | ||
|
@@ -74,7 +74,8 @@ rmm::device_buffer scalar_col_valid_mask_and(column_view const& col, | |
inline bool is_null_dependent(binary_operator op) | ||
{ | ||
return op == binary_operator::NULL_EQUALS || op == binary_operator::NULL_MIN || | ||
op == binary_operator::NULL_MAX; | ||
op == binary_operator::NULL_MAX || op == binary_operator::NULL_LOGICAL_AND || | ||
op == binary_operator::NULL_LOGICAL_OR; | ||
} | ||
|
||
/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright (c) 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. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include "binary_ops.cuh" | ||
|
||
namespace cudf::binops::compiled { | ||
template void apply_binary_op<ops::NullLogicalAnd>(mutable_column_device_view&, | ||
column_device_view const&, | ||
column_device_view const&, | ||
bool is_lhs_scalar, | ||
bool is_rhs_scalar, | ||
rmm::cuda_stream_view); | ||
} // namespace cudf::binops::compiled |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright (c) 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. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include "binary_ops.cuh" | ||
|
||
namespace cudf::binops::compiled { | ||
template void apply_binary_op<ops::NullLogicalOr>(mutable_column_device_view&, | ||
column_device_view const&, | ||
column_device_view const&, | ||
bool is_lhs_scalar, | ||
bool is_rhs_scalar, | ||
rmm::cuda_stream_view); | ||
} // namespace cudf::binops::compiled |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright (c) 2019-2021, NVIDIA CORPORATION. | ||
* Copyright (c) 2019-2022, NVIDIA CORPORATION. | ||
* | ||
* Copyright 2018-2019 BlazingDB, Inc. | ||
* Copyright 2018 Christian Noboa Mardini <[email protected]> | ||
|
@@ -323,6 +323,48 @@ struct PyMod { | |
} | ||
}; | ||
|
||
template <typename TypeOut, typename TypeLhs, typename TypeRhs> | ||
struct NullLogicalAnd { | ||
TypeOut operator()(TypeLhs x, TypeRhs y, bool lhs_valid, bool rhs_valid, bool& output_valid) const | ||
{ | ||
if (lhs_valid && !x) { | ||
output_valid = true; | ||
return false; | ||
} | ||
if (rhs_valid && !y) { | ||
output_valid = true; | ||
return false; | ||
} | ||
if (lhs_valid && rhs_valid) { | ||
output_valid = true; | ||
return true; | ||
} | ||
output_valid = false; | ||
return false; | ||
} | ||
}; | ||
|
||
template <typename TypeOut, typename TypeLhs, typename TypeRhs> | ||
struct NullLogicalOr { | ||
TypeOut operator()(TypeLhs x, TypeRhs y, bool lhs_valid, bool rhs_valid, bool& output_valid) const | ||
{ | ||
if (lhs_valid && x) { | ||
output_valid = true; | ||
return true; | ||
} | ||
if (rhs_valid && y) { | ||
output_valid = true; | ||
return true; | ||
} | ||
if (lhs_valid && rhs_valid) { | ||
output_valid = true; | ||
return false; | ||
} | ||
output_valid = false; | ||
return false; | ||
} | ||
}; | ||
|
||
template <typename TypeOut, typename TypeLhs, typename TypeRhs> | ||
struct NullEquals { | ||
TypeOut operator()(TypeLhs x, TypeRhs y, bool lhs_valid, bool rhs_valid, bool& output_valid) const | ||
|
Oops, something went wrong.