From ad8577cc327663ba3585d58865ad80a583daf89e Mon Sep 17 00:00:00 2001 From: Raymond Douglass Date: Thu, 17 Mar 2022 12:39:36 -0400 Subject: [PATCH 001/246] DOC --- CHANGELOG.md | 4 ++++ ci/checks/style.sh | 2 +- ci/gpu/build.sh | 2 +- ci/gpu/java.sh | 2 +- conda/environments/cudf_dev_cuda11.5.yml | 2 +- cpp/CMakeLists.txt | 2 +- cpp/doxygen/Doxyfile | 4 ++-- cpp/examples/basic/CMakeLists.txt | 2 +- cpp/libcudf_kafka/CMakeLists.txt | 2 +- docs/cudf/source/conf.py | 4 ++-- fetch_rapids.cmake | 2 +- java/src/main/native/CMakeLists.txt | 2 +- 12 files changed, 17 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ab550f87403..176b087cfc6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# cuDF 22.06.00 (Date TBD) + +Please see https://github.com/rapidsai/cudf/releases/tag/v22.06.00a for the latest changes to this development branch. + # cuDF 22.04.00 (Date TBD) Please see https://github.com/rapidsai/cudf/releases/tag/v22.04.00a for the latest changes to this development branch. diff --git a/ci/checks/style.sh b/ci/checks/style.sh index a7ad260758d..5ed64af8388 100755 --- a/ci/checks/style.sh +++ b/ci/checks/style.sh @@ -14,7 +14,7 @@ LANG=C.UTF-8 . /opt/conda/etc/profile.d/conda.sh conda activate rapids -FORMAT_FILE_URL=https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-22.04/cmake-format-rapids-cmake.json +FORMAT_FILE_URL=https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-22.06/cmake-format-rapids-cmake.json export RAPIDS_CMAKE_FORMAT_FILE=/tmp/rapids_cmake_ci/cmake-formats-rapids-cmake.json mkdir -p $(dirname ${RAPIDS_CMAKE_FORMAT_FILE}) wget -O ${RAPIDS_CMAKE_FORMAT_FILE} ${FORMAT_FILE_URL} diff --git a/ci/gpu/build.sh b/ci/gpu/build.sh index 4492ee1d443..59b8f27c5f3 100755 --- a/ci/gpu/build.sh +++ b/ci/gpu/build.sh @@ -34,7 +34,7 @@ export MINOR_VERSION=`echo $GIT_DESCRIBE_TAG | grep -o -E '([0-9]+\.[0-9]+)'` export INSTALL_DASK_MAIN=1 # ucx-py version -export UCX_PY_VERSION='0.25.*' +export UCX_PY_VERSION='0.26.*' export CMAKE_CUDA_COMPILER_LAUNCHER="sccache" export CMAKE_CXX_COMPILER_LAUNCHER="sccache" diff --git a/ci/gpu/java.sh b/ci/gpu/java.sh index ab5202fa9f7..fd449c44622 100755 --- a/ci/gpu/java.sh +++ b/ci/gpu/java.sh @@ -31,7 +31,7 @@ export GIT_DESCRIBE_TAG=`git describe --tags` export MINOR_VERSION=`echo $GIT_DESCRIBE_TAG | grep -o -E '([0-9]+\.[0-9]+)'` # ucx-py version -export UCX_PY_VERSION='0.25.*' +export UCX_PY_VERSION='0.26.*' ################################################################################ # TRAP - Setup trap for removing jitify cache diff --git a/conda/environments/cudf_dev_cuda11.5.yml b/conda/environments/cudf_dev_cuda11.5.yml index 097ca2089a5..f8fa46c7657 100644 --- a/conda/environments/cudf_dev_cuda11.5.yml +++ b/conda/environments/cudf_dev_cuda11.5.yml @@ -11,7 +11,7 @@ dependencies: - clang=11.1.0 - clang-tools=11.1.0 - cupy>=9.5.0,<11.0.0a0 - - rmm=22.04.* + - rmm=22.06.* - cmake>=3.20.1 - cmake_setuptools>=0.1.3 - python>=3.7,<3.9 diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 8b8198782ba..836223a76e6 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -25,7 +25,7 @@ rapids_cuda_init_architectures(CUDF) project( CUDF - VERSION 22.04.00 + VERSION 22.06.00 LANGUAGES C CXX CUDA ) diff --git a/cpp/doxygen/Doxyfile b/cpp/doxygen/Doxyfile index 3f98209852d..6929b529728 100644 --- a/cpp/doxygen/Doxyfile +++ b/cpp/doxygen/Doxyfile @@ -38,7 +38,7 @@ PROJECT_NAME = "libcudf" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 22.04.00 +PROJECT_NUMBER = 22.06.00 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a @@ -2168,7 +2168,7 @@ SKIP_FUNCTION_MACROS = YES # the path). If a tag file is not located in the directory in which doxygen is # run, you must also specify the path to the tagfile here. -TAGFILES = rmm.tag=https://docs.rapids.ai/api/librmm/22.04 +TAGFILES = rmm.tag=https://docs.rapids.ai/api/librmm/22.06 # When a file name is specified after GENERATE_TAGFILE, doxygen will create a # tag file that is based on the input files it reads. See section "Linking to diff --git a/cpp/examples/basic/CMakeLists.txt b/cpp/examples/basic/CMakeLists.txt index 40718c27988..0ada2977ead 100644 --- a/cpp/examples/basic/CMakeLists.txt +++ b/cpp/examples/basic/CMakeLists.txt @@ -14,7 +14,7 @@ file( ) include(${CMAKE_BINARY_DIR}/cmake/get_cpm.cmake) -set(CUDF_TAG branch-22.04) +set(CUDF_TAG branch-22.06) CPMFindPackage( NAME cudf GIT_REPOSITORY https://github.com/rapidsai/cudf GIT_TAG ${CUDF_TAG} diff --git a/cpp/libcudf_kafka/CMakeLists.txt b/cpp/libcudf_kafka/CMakeLists.txt index bdb7e8afcf9..c94c1a3b9b7 100644 --- a/cpp/libcudf_kafka/CMakeLists.txt +++ b/cpp/libcudf_kafka/CMakeLists.txt @@ -22,7 +22,7 @@ include(rapids-find) project( CUDA_KAFKA - VERSION 22.04.00 + VERSION 22.06.00 LANGUAGES CXX ) diff --git a/docs/cudf/source/conf.py b/docs/cudf/source/conf.py index 60704f3e6ae..562501c01c6 100644 --- a/docs/cudf/source/conf.py +++ b/docs/cudf/source/conf.py @@ -78,9 +78,9 @@ # built documents. # # The short X.Y version. -version = '22.04' +version = '22.06' # The full version, including alpha/beta/rc tags. -release = '22.04.00' +release = '22.06.00' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/fetch_rapids.cmake b/fetch_rapids.cmake index 4c7a8d4e449..17ba1c6d53f 100644 --- a/fetch_rapids.cmake +++ b/fetch_rapids.cmake @@ -11,7 +11,7 @@ # or implied. See the License for the specific language governing permissions and limitations under # the License. # ============================================================================= -file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-22.04/RAPIDS.cmake +file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-22.06/RAPIDS.cmake ${CMAKE_BINARY_DIR}/RAPIDS.cmake ) include(${CMAKE_BINARY_DIR}/RAPIDS.cmake) diff --git a/java/src/main/native/CMakeLists.txt b/java/src/main/native/CMakeLists.txt index 6e0c07bc4f0..2f0e07c9982 100755 --- a/java/src/main/native/CMakeLists.txt +++ b/java/src/main/native/CMakeLists.txt @@ -26,7 +26,7 @@ rapids_cuda_init_architectures(CUDF_JNI) project( CUDF_JNI - VERSION 22.04.00 + VERSION 22.06.00 LANGUAGES C CXX CUDA ) From 8c7260f0cd5c01fa32caf3e485898a72e41ac7f6 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Thu, 24 Mar 2022 12:03:40 -0700 Subject: [PATCH 002/246] Remove deprecated code. (#10450) This PR removes various pieces of deprecated code. These removals are also helpful for certain ongoing refactoring tasks. Resolves #10166 Resolves #9316 Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/cudf/pull/10450 --- python/cudf/cudf/__init__.py | 20 - python/cudf/cudf/core/_base_index.py | 22 - python/cudf/cudf/core/dataframe.py | 30 +- python/cudf/cudf/core/frame.py | 679 +---------------------- python/cudf/cudf/core/indexed_frame.py | 15 +- python/cudf/cudf/core/ops.py | 227 -------- python/cudf/cudf/core/series.py | 85 --- python/cudf/cudf/tests/test_binops.py | 95 ---- python/cudf/cudf/tests/test_dataframe.py | 10 +- python/cudf/cudf/tests/test_index.py | 108 ---- python/cudf/cudf/tests/test_joining.py | 4 +- python/cudf/cudf/tests/test_ops.py | 122 ---- python/cudf/cudf/tests/test_unaops.py | 67 --- 13 files changed, 27 insertions(+), 1457 deletions(-) delete mode 100644 python/cudf/cudf/core/ops.py delete mode 100644 python/cudf/cudf/tests/test_ops.py diff --git a/python/cudf/cudf/__init__.py b/python/cudf/cudf/__init__.py index 049cec77d9c..273ab147241 100644 --- a/python/cudf/cudf/__init__.py +++ b/python/cudf/cudf/__init__.py @@ -58,26 +58,6 @@ StructDtype, ) from cudf.core.groupby import Grouper -from cudf.core.ops import ( - add, - arccos, - arcsin, - arctan, - cos, - exp, - floor_divide, - log, - logical_and, - logical_not, - logical_or, - multiply, - remainder, - sin, - sqrt, - subtract, - tan, - true_divide, -) from cudf.core.reshape import ( concat, get_dummies, diff --git a/python/cudf/cudf/core/_base_index.py b/python/cudf/cudf/core/_base_index.py index 4e09d3868f5..e05c55bd78f 100644 --- a/python/cudf/cudf/core/_base_index.py +++ b/python/cudf/cudf/core/_base_index.py @@ -3,7 +3,6 @@ from __future__ import annotations import pickle -import warnings from functools import cached_property from typing import Any, Set @@ -1556,27 +1555,6 @@ def _split_columns_by_levels(self, levels): def _split(self, splits): raise NotImplementedError - def sample( - self, - n=None, - frac=None, - replace=False, - weights=None, - random_state=None, - axis=None, - ignore_index=False, - ): - warnings.warn( - "Index.sample is deprecated and will be removed.", FutureWarning, - ) - return cudf.core.index._index_from_data( - self.to_frame() - .sample( - n, frac, replace, weights, random_state, axis, ignore_index - ) - ._data - ) - def _get_result_name(left_name, right_name): if left_name == right_name: diff --git a/python/cudf/cudf/core/dataframe.py b/python/cudf/cudf/core/dataframe.py index 4982b75f753..233a0b0beda 100644 --- a/python/cudf/cudf/core/dataframe.py +++ b/python/cudf/cudf/core/dataframe.py @@ -2023,16 +2023,6 @@ def update( def __iter__(self): return iter(self._column_names) - @_cudf_nvtx_annotate - def iteritems(self): - """Iterate over column names and series pairs""" - warnings.warn( - "iteritems is deprecated and will be removed in a future version. " - "Use .items instead.", - FutureWarning, - ) - return self.items() - @_cudf_nvtx_annotate def items(self): """Iterate over column names and series pairs""" @@ -3361,22 +3351,6 @@ def merge( - For outer joins, the result will be the union of categories from both sides. """ - if indicator: - raise NotImplementedError( - "Only indicator=False is currently supported" - ) - - if lsuffix or rsuffix: - raise ValueError( - "The lsuffix and rsuffix keywords have been replaced with the " - "``suffixes=`` keyword. " - "Please provide the following instead: \n\n" - " suffixes=('%s', '%s')" - % (lsuffix or "_x", rsuffix or "_y") - ) - else: - lsuffix, rsuffix = suffixes - # Compute merge gdf_result = super()._merge( right, @@ -3389,6 +3363,8 @@ def merge( sort=sort, indicator=indicator, suffixes=suffixes, + lsuffix=lsuffix, + rsuffix=rsuffix, ) return gdf_result @@ -6341,7 +6317,7 @@ def from_pandas(obj, nan_as_null=None): @_cudf_nvtx_annotate def merge(left, right, *args, **kwargs): - return left.merge(right, *args, **kwargs) + return super(type(left), left)._merge(right, *args, **kwargs) # a bit of fanciness to inject docstring with left parameter diff --git a/python/cudf/cudf/core/frame.py b/python/cudf/cudf/core/frame.py index b0a0436655c..a9d7fce9d9b 100644 --- a/python/cudf/cudf/core/frame.py +++ b/python/cudf/cudf/core/frame.py @@ -2298,589 +2298,6 @@ def _get_sorted_inds(self, by=None, ascending=True, na_position="last"): return libcudf.sort.order_by(to_sort, ascending, na_position) - @_cudf_nvtx_annotate - def sin(self): - """ - Get Trigonometric sine, element-wise. - - Returns - ------- - DataFrame/Series/Index - Result of the trigonometric operation. - - Examples - -------- - >>> import cudf - >>> ser = cudf.Series([0.0, 0.32434, 0.5, 45, 90, 180, 360]) - >>> ser - 0 0.00000 - 1 0.32434 - 2 0.50000 - 3 45.00000 - 4 90.00000 - 5 180.00000 - 6 360.00000 - dtype: float64 - >>> ser.sin() - 0 0.000000 - 1 0.318683 - 2 0.479426 - 3 0.850904 - 4 0.893997 - 5 -0.801153 - 6 0.958916 - dtype: float64 - - `sin` operation on DataFrame: - - >>> df = cudf.DataFrame({'first': [0.0, 5, 10, 15], - ... 'second': [100.0, 360, 720, 300]}) - >>> df - first second - 0 0.0 100.0 - 1 5.0 360.0 - 2 10.0 720.0 - 3 15.0 300.0 - >>> df.sin() - first second - 0 0.000000 -0.506366 - 1 -0.958924 0.958916 - 2 -0.544021 -0.544072 - 3 0.650288 -0.999756 - - `sin` operation on Index: - - >>> index = cudf.Index([-0.4, 100, -180, 90]) - >>> index - Float64Index([-0.4, 100.0, -180.0, 90.0], dtype='float64') - >>> index.sin() - Float64Index([-0.3894183423086505, -0.5063656411097588, - 0.8011526357338306, 0.8939966636005579], - dtype='float64') - """ - warnings.warn( - "sin is deprecated and will be removed. Use numpy.sin instead", - FutureWarning, - ) - - return self._unaryop("sin") - - @_cudf_nvtx_annotate - def cos(self): - """ - Get Trigonometric cosine, element-wise. - - Returns - ------- - DataFrame/Series/Index - Result of the trigonometric operation. - - Examples - -------- - >>> import cudf - >>> ser = cudf.Series([0.0, 0.32434, 0.5, 45, 90, 180, 360]) - >>> ser - 0 0.00000 - 1 0.32434 - 2 0.50000 - 3 45.00000 - 4 90.00000 - 5 180.00000 - 6 360.00000 - dtype: float64 - >>> ser.cos() - 0 1.000000 - 1 0.947861 - 2 0.877583 - 3 0.525322 - 4 -0.448074 - 5 -0.598460 - 6 -0.283691 - dtype: float64 - - `cos` operation on DataFrame: - - >>> df = cudf.DataFrame({'first': [0.0, 5, 10, 15], - ... 'second': [100.0, 360, 720, 300]}) - >>> df - first second - 0 0.0 100.0 - 1 5.0 360.0 - 2 10.0 720.0 - 3 15.0 300.0 - >>> df.cos() - first second - 0 1.000000 0.862319 - 1 0.283662 -0.283691 - 2 -0.839072 -0.839039 - 3 -0.759688 -0.022097 - - `cos` operation on Index: - - >>> index = cudf.Index([-0.4, 100, -180, 90]) - >>> index - Float64Index([-0.4, 100.0, -180.0, 90.0], dtype='float64') - >>> index.cos() - Float64Index([ 0.9210609940028851, 0.8623188722876839, - -0.5984600690578581, -0.4480736161291701], - dtype='float64') - """ - warnings.warn( - "cos is deprecated and will be removed. Use numpy.cos instead", - FutureWarning, - ) - - return self._unaryop("cos") - - @_cudf_nvtx_annotate - def tan(self): - """ - Get Trigonometric tangent, element-wise. - - Returns - ------- - DataFrame/Series/Index - Result of the trigonometric operation. - - Examples - -------- - >>> import cudf - >>> ser = cudf.Series([0.0, 0.32434, 0.5, 45, 90, 180, 360]) - >>> ser - 0 0.00000 - 1 0.32434 - 2 0.50000 - 3 45.00000 - 4 90.00000 - 5 180.00000 - 6 360.00000 - dtype: float64 - >>> ser.tan() - 0 0.000000 - 1 0.336213 - 2 0.546302 - 3 1.619775 - 4 -1.995200 - 5 1.338690 - 6 -3.380140 - dtype: float64 - - `tan` operation on DataFrame: - - >>> df = cudf.DataFrame({'first': [0.0, 5, 10, 15], - ... 'second': [100.0, 360, 720, 300]}) - >>> df - first second - 0 0.0 100.0 - 1 5.0 360.0 - 2 10.0 720.0 - 3 15.0 300.0 - >>> df.tan() - first second - 0 0.000000 -0.587214 - 1 -3.380515 -3.380140 - 2 0.648361 0.648446 - 3 -0.855993 45.244742 - - `tan` operation on Index: - - >>> index = cudf.Index([-0.4, 100, -180, 90]) - >>> index - Float64Index([-0.4, 100.0, -180.0, 90.0], dtype='float64') - >>> index.tan() - Float64Index([-0.4227932187381618, -0.587213915156929, - -1.3386902103511544, -1.995200412208242], - dtype='float64') - """ - warnings.warn( - "tan is deprecated and will be removed. Use numpy.tan instead", - FutureWarning, - ) - - return self._unaryop("tan") - - @_cudf_nvtx_annotate - def asin(self): - """ - Get Trigonometric inverse sine, element-wise. - - The inverse of sine so that, if y = x.sin(), then x = y.asin() - - Returns - ------- - DataFrame/Series/Index - Result of the trigonometric operation. - - Examples - -------- - >>> import cudf - >>> ser = cudf.Series([-1, 0, 1, 0.32434, 0.5]) - >>> ser.asin() - 0 -1.570796 - 1 0.000000 - 2 1.570796 - 3 0.330314 - 4 0.523599 - dtype: float64 - - `asin` operation on DataFrame: - - >>> df = cudf.DataFrame({'first': [-1, 0, 0.5], - ... 'second': [0.234, 0.3, 0.1]}) - >>> df - first second - 0 -1.0 0.234 - 1 0.0 0.300 - 2 0.5 0.100 - >>> df.asin() - first second - 0 -1.570796 0.236190 - 1 0.000000 0.304693 - 2 0.523599 0.100167 - - `asin` operation on Index: - - >>> index = cudf.Index([-1, 0.4, 1, 0.3]) - >>> index - Float64Index([-1.0, 0.4, 1.0, 0.3], dtype='float64') - >>> index.asin() - Float64Index([-1.5707963267948966, 0.41151684606748806, - 1.5707963267948966, 0.3046926540153975], - dtype='float64') - """ - warnings.warn( - "asin is deprecated and will be removed in the future", - FutureWarning, - ) - - return self._unaryop("asin") - - @_cudf_nvtx_annotate - def acos(self): - """ - Get Trigonometric inverse cosine, element-wise. - - The inverse of cos so that, if y = x.cos(), then x = y.acos() - - Returns - ------- - DataFrame/Series/Index - Result of the trigonometric operation. - - Examples - -------- - >>> import cudf - >>> ser = cudf.Series([-1, 0, 1, 0.32434, 0.5]) - >>> ser.acos() - 0 3.141593 - 1 1.570796 - 2 0.000000 - 3 1.240482 - 4 1.047198 - dtype: float64 - - `acos` operation on DataFrame: - - >>> df = cudf.DataFrame({'first': [-1, 0, 0.5], - ... 'second': [0.234, 0.3, 0.1]}) - >>> df - first second - 0 -1.0 0.234 - 1 0.0 0.300 - 2 0.5 0.100 - >>> df.acos() - first second - 0 3.141593 1.334606 - 1 1.570796 1.266104 - 2 1.047198 1.470629 - - `acos` operation on Index: - - >>> index = cudf.Index([-1, 0.4, 1, 0, 0.3]) - >>> index - Float64Index([-1.0, 0.4, 1.0, 0.0, 0.3], dtype='float64') - >>> index.acos() - Float64Index([ 3.141592653589793, 1.1592794807274085, 0.0, - 1.5707963267948966, 1.266103672779499], - dtype='float64') - """ - warnings.warn( - "acos is deprecated and will be removed. Use numpy.acos instead", - FutureWarning, - ) - - result = self.copy(deep=False) - for col in result._data: - min_float_dtype = cudf.utils.dtypes.get_min_float_dtype( - result._data[col] - ) - result._data[col] = result._data[col].astype(min_float_dtype) - result = result._unaryop("acos") - result = result.mask((result < 0) | (result > np.pi + 1)) - return result - - @_cudf_nvtx_annotate - def atan(self): - """ - Get Trigonometric inverse tangent, element-wise. - - The inverse of tan so that, if y = x.tan(), then x = y.atan() - - Returns - ------- - DataFrame/Series/Index - Result of the trigonometric operation. - - Examples - -------- - >>> import cudf - >>> ser = cudf.Series([-1, 0, 1, 0.32434, 0.5, -10]) - >>> ser - 0 -1.00000 - 1 0.00000 - 2 1.00000 - 3 0.32434 - 4 0.50000 - 5 -10.00000 - dtype: float64 - >>> ser.atan() - 0 -0.785398 - 1 0.000000 - 2 0.785398 - 3 0.313635 - 4 0.463648 - 5 -1.471128 - dtype: float64 - - `atan` operation on DataFrame: - - >>> df = cudf.DataFrame({'first': [-1, -10, 0.5], - ... 'second': [0.234, 0.3, 10]}) - >>> df - first second - 0 -1.0 0.234 - 1 -10.0 0.300 - 2 0.5 10.000 - >>> df.atan() - first second - 0 -0.785398 0.229864 - 1 -1.471128 0.291457 - 2 0.463648 1.471128 - - `atan` operation on Index: - - >>> index = cudf.Index([-1, 0.4, 1, 0, 0.3]) - >>> index - Float64Index([-1.0, 0.4, 1.0, 0.0, 0.3], dtype='float64') - >>> index.atan() - Float64Index([-0.7853981633974483, 0.3805063771123649, - 0.7853981633974483, 0.0, - 0.2914567944778671], - dtype='float64') - """ - warnings.warn( - "atan is deprecated and will be removed. Use numpy.atan instead", - FutureWarning, - ) - - return self._unaryop("atan") - - @_cudf_nvtx_annotate - def exp(self): - """ - Get the exponential of all elements, element-wise. - - Exponential is the inverse of the log function, - so that x.exp().log() = x - - Returns - ------- - DataFrame/Series/Index - Result of the element-wise exponential. - - Examples - -------- - >>> import cudf - >>> ser = cudf.Series([-1, 0, 1, 0.32434, 0.5, -10, 100]) - >>> ser - 0 -1.00000 - 1 0.00000 - 2 1.00000 - 3 0.32434 - 4 0.50000 - 5 -10.00000 - 6 100.00000 - dtype: float64 - >>> ser.exp() - 0 3.678794e-01 - 1 1.000000e+00 - 2 2.718282e+00 - 3 1.383117e+00 - 4 1.648721e+00 - 5 4.539993e-05 - 6 2.688117e+43 - dtype: float64 - - `exp` operation on DataFrame: - - >>> df = cudf.DataFrame({'first': [-1, -10, 0.5], - ... 'second': [0.234, 0.3, 10]}) - >>> df - first second - 0 -1.0 0.234 - 1 -10.0 0.300 - 2 0.5 10.000 - >>> df.exp() - first second - 0 0.367879 1.263644 - 1 0.000045 1.349859 - 2 1.648721 22026.465795 - - `exp` operation on Index: - - >>> index = cudf.Index([-1, 0.4, 1, 0, 0.3]) - >>> index - Float64Index([-1.0, 0.4, 1.0, 0.0, 0.3], dtype='float64') - >>> index.exp() - Float64Index([0.36787944117144233, 1.4918246976412703, - 2.718281828459045, 1.0, 1.3498588075760032], - dtype='float64') - """ - warnings.warn( - "exp is deprecated and will be removed. Use numpy.exp instead", - FutureWarning, - ) - - return self._unaryop("exp") - - @_cudf_nvtx_annotate - def log(self): - """ - Get the natural logarithm of all elements, element-wise. - - Natural logarithm is the inverse of the exp function, - so that x.log().exp() = x - - Returns - ------- - DataFrame/Series/Index - Result of the element-wise natural logarithm. - - Examples - -------- - >>> import cudf - >>> ser = cudf.Series([-1, 0, 1, 0.32434, 0.5, -10, 100]) - >>> ser - 0 -1.00000 - 1 0.00000 - 2 1.00000 - 3 0.32434 - 4 0.50000 - 5 -10.00000 - 6 100.00000 - dtype: float64 - >>> ser.log() - 0 NaN - 1 -inf - 2 0.000000 - 3 -1.125963 - 4 -0.693147 - 5 NaN - 6 4.605170 - dtype: float64 - - `log` operation on DataFrame: - - >>> df = cudf.DataFrame({'first': [-1, -10, 0.5], - ... 'second': [0.234, 0.3, 10]}) - >>> df - first second - 0 -1.0 0.234 - 1 -10.0 0.300 - 2 0.5 10.000 - >>> df.log() - first second - 0 NaN -1.452434 - 1 NaN -1.203973 - 2 -0.693147 2.302585 - - `log` operation on Index: - - >>> index = cudf.Index([10, 11, 500.0]) - >>> index - Float64Index([10.0, 11.0, 500.0], dtype='float64') - >>> index.log() - Float64Index([2.302585092994046, 2.3978952727983707, - 6.214608098422191], dtype='float64') - """ - warnings.warn( - "log is deprecated and will be removed. Use numpy.log instead", - FutureWarning, - ) - - return self._unaryop("log") - - @_cudf_nvtx_annotate - def sqrt(self): - """ - Get the non-negative square-root of all elements, element-wise. - - Returns - ------- - DataFrame/Series/Index - Result of the non-negative - square-root of each element. - - Examples - -------- - >>> import cudf - >>> import cudf - >>> ser = cudf.Series([10, 25, 81, 1.0, 100]) - >>> ser - 0 10.0 - 1 25.0 - 2 81.0 - 3 1.0 - 4 100.0 - dtype: float64 - >>> ser.sqrt() - 0 3.162278 - 1 5.000000 - 2 9.000000 - 3 1.000000 - 4 10.000000 - dtype: float64 - - `sqrt` operation on DataFrame: - - >>> df = cudf.DataFrame({'first': [-10.0, 100, 625], - ... 'second': [1, 2, 0.4]}) - >>> df - first second - 0 -10.0 1.0 - 1 100.0 2.0 - 2 625.0 0.4 - >>> df.sqrt() - first second - 0 NaN 1.000000 - 1 10.0 1.414214 - 2 25.0 0.632456 - - `sqrt` operation on Index: - - >>> index = cudf.Index([-10.0, 100, 625]) - >>> index - Float64Index([-10.0, 100.0, 625.0], dtype='float64') - >>> index.sqrt() - Float64Index([nan, 10.0, 25.0], dtype='float64') - """ - warnings.warn( - "sqrt is deprecated and will be removed. Use numpy.sqrt instead", - FutureWarning, - ) - - return self._unaryop("sqrt") - @_cudf_nvtx_annotate def abs(self): """ @@ -2907,84 +2324,6 @@ def abs(self): """ return self._unaryop("abs") - # Rounding - @_cudf_nvtx_annotate - def ceil(self): - """ - Rounds each value upward to the smallest integral value not less - than the original. - - Returns - ------- - DataFrame or Series - Ceiling value of each element. - - Examples - -------- - >>> import cudf - >>> series = cudf.Series([1.1, 2.8, 3.5, 4.5]) - >>> series - 0 1.1 - 1 2.8 - 2 3.5 - 3 4.5 - dtype: float64 - >>> series.ceil() - 0 2.0 - 1 3.0 - 2 4.0 - 3 5.0 - dtype: float64 - """ - - warnings.warn( - "Series.ceil and DataFrame.ceil are deprecated and will be " - "removed in the future", - FutureWarning, - ) - - return self._unaryop("ceil") - - @_cudf_nvtx_annotate - def floor(self): - """Rounds each value downward to the largest integral value not greater - than the original. - - Returns - ------- - DataFrame or Series - Flooring value of each element. - - Examples - -------- - >>> import cudf - >>> series = cudf.Series([-1.9, 2, 0.2, 1.5, 0.0, 3.0]) - >>> series - 0 -1.9 - 1 2.0 - 2 0.2 - 3 1.5 - 4 0.0 - 5 3.0 - dtype: float64 - >>> series.floor() - 0 -2.0 - 1 2.0 - 2 0.0 - 3 1.0 - 4 0.0 - 5 3.0 - dtype: float64 - """ - - warnings.warn( - "Series.floor and DataFrame.floor are deprecated and will be " - "removed in the future.", - FutureWarning, - ) - - return self._unaryop("floor") - @_cudf_nvtx_annotate def scale(self): """ @@ -3033,7 +2372,25 @@ def _merge( sort=False, indicator=False, suffixes=("_x", "_y"), + lsuffix=None, + rsuffix=None, ): + if indicator: + raise NotImplementedError( + "Only indicator=False is currently supported" + ) + + if lsuffix or rsuffix: + raise ValueError( + "The lsuffix and rsuffix keywords have been replaced with the " + "``suffixes=`` keyword. " + "Please provide the following instead: \n\n" + " suffixes=('%s', '%s')" + % (lsuffix or "_x", rsuffix or "_y") + ) + else: + lsuffix, rsuffix = suffixes + lhs, rhs = self, right merge_cls = Merge if how == "right": diff --git a/python/cudf/cudf/core/indexed_frame.py b/python/cudf/cudf/core/indexed_frame.py index 342a4e52101..7e116607017 100644 --- a/python/cudf/cudf/core/indexed_frame.py +++ b/python/cudf/cudf/core/indexed_frame.py @@ -2306,8 +2306,6 @@ def astype(self, dtype, copy=False, errors="raise", **kwargs): - ``raise`` : allow exceptions to be raised - ``ignore`` : suppress exceptions. On error return original object. - - ``warn`` : prints last exceptions as warnings and - return original object. **kwargs : extra arguments to pass on to the constructor Returns @@ -2395,25 +2393,14 @@ def astype(self, dtype, copy=False, errors="raise", **kwargs): 1 2 dtype: int64 """ - if errors not in ("ignore", "warn", "raise"): + if errors not in ("ignore", "raise"): raise ValueError("invalid error value specified") - elif errors == "warn": - warnings.warn( - "Specifying errors='warn' is deprecated and will be removed " - "in a future release.", - FutureWarning, - ) try: data = super().astype(dtype, copy, **kwargs) except Exception as e: if errors == "raise": raise e - elif errors == "warn": - import traceback - - tb = traceback.format_exc() - warnings.warn(tb) return self return self._from_data(data, index=self._index) diff --git a/python/cudf/cudf/core/ops.py b/python/cudf/cudf/core/ops.py deleted file mode 100644 index c2a8c0e72fb..00000000000 --- a/python/cudf/cudf/core/ops.py +++ /dev/null @@ -1,227 +0,0 @@ -# Copyright (c) 2019-2022, NVIDIA CORPORATION. -import warnings -from numbers import Number - -import numpy as np - -from cudf.core.frame import Frame - -""" Global __array_ufunc__ methods -""" - - -def sin(arbitrary): - warnings.warn( - "sin is deprecated and will be removed in the future", FutureWarning, - ) - - if isinstance(arbitrary, Number): - return np.sin(arbitrary) - else: - return getattr(arbitrary, "sin")() - - -def cos(arbitrary): - warnings.warn( - "cos is deprecated and will be removed in the future", FutureWarning, - ) - - if isinstance(arbitrary, Number): - return np.cos(arbitrary) - else: - return getattr(arbitrary, "cos")() - - -def tan(arbitrary): - warnings.warn( - "tan is deprecated and will be removed in the future", FutureWarning, - ) - - if isinstance(arbitrary, Number): - return np.tan(arbitrary) - else: - return getattr(arbitrary, "tan")() - - -def arcsin(arbitrary): - warnings.warn( - "arcsin is deprecated and will be removed in the future", - FutureWarning, - ) - - if isinstance(arbitrary, Number): - return np.arcsin(arbitrary) - else: - return getattr(arbitrary, "asin")() - - -def arccos(arbitrary): - warnings.warn( - "arcsin is deprecated and will be removed in the future", - FutureWarning, - ) - - if isinstance(arbitrary, Number): - return np.arccos(arbitrary) - else: - return getattr(arbitrary, "acos")() - - -def arctan(arbitrary): - warnings.warn( - "arctan is deprecated and will be removed in the future", - FutureWarning, - ) - - if isinstance(arbitrary, Number): - return np.arctan(arbitrary) - else: - return getattr(arbitrary, "atan")() - - -def exp(arbitrary): - warnings.warn( - "exp is deprecated and will be removed in the future", FutureWarning, - ) - - if isinstance(arbitrary, Number): - return np.exp(arbitrary) - else: - return getattr(arbitrary, "exp")() - - -def log(arbitrary): - warnings.warn( - "log is deprecated and will be removed in the future", FutureWarning, - ) - - if isinstance(arbitrary, Number): - return np.log(arbitrary) - else: - return getattr(arbitrary, "log")() - - -def sqrt(arbitrary): - warnings.warn( - "sqrt is deprecated and will be removed in the future", FutureWarning, - ) - - if isinstance(arbitrary, Number): - return np.sqrt(arbitrary) - else: - return getattr(arbitrary, "sqrt")() - - -def logical_not(arbitrary): - warnings.warn( - "logical_not is deprecated and will be removed in the future", - FutureWarning, - ) - - if isinstance(arbitrary, Number): - return np.logical_not(arbitrary) - else: - return getattr(arbitrary, "logical_not")() - - -def logical_and(lhs, rhs): - warnings.warn( - "logical_and is deprecated and will be removed in the future", - FutureWarning, - ) - - if isinstance(lhs, Number) and isinstance(rhs, Number): - return np.logical_and(lhs, rhs) - else: - return getattr(lhs, "logical_and")(rhs) - - -def logical_or(lhs, rhs): - warnings.warn( - "logical_or is deprecated and will be removed in the future", - FutureWarning, - ) - - if isinstance(lhs, Number) and isinstance(rhs, Number): - return np.logical_or(lhs, rhs) - else: - return getattr(lhs, "logical_or")(rhs) - - -def remainder(lhs, rhs): - warnings.warn( - "remainder is deprecated and will be removed in the future", - FutureWarning, - ) - - if isinstance(lhs, Number) and isinstance(rhs, Number): - return np.mod(lhs, rhs) - elif isinstance(lhs, Frame): - return getattr(lhs, "remainder")(rhs) - else: - return getattr(rhs, "__rmod__")(lhs) - - -def floor_divide(lhs, rhs): - warnings.warn( - "sin is deprecated and will be removed in the future", FutureWarning, - ) - - if isinstance(lhs, Number) and isinstance(rhs, Number): - return np.floor_divide(lhs, rhs) - elif isinstance(lhs, Frame): - return getattr(lhs, "floordiv")(rhs) - else: - return getattr(rhs, "__rfloordiv__")(lhs) - - -def subtract(lhs, rhs): - warnings.warn( - "sin is deprecated and will be removed in the future", FutureWarning, - ) - - if isinstance(lhs, Number) and isinstance(rhs, Number): - return np.subtract(lhs, rhs) - elif isinstance(lhs, Frame): - return getattr(lhs, "__sub__")(rhs) - else: - return getattr(rhs, "__rsub__")(lhs) - - -def add(lhs, rhs): - warnings.warn( - "sin is deprecated and will be removed in the future", FutureWarning, - ) - - if isinstance(lhs, Number) and isinstance(rhs, Number): - return np.add(lhs, rhs) - elif isinstance(rhs, Frame): - return getattr(rhs, "__radd__")(lhs) - else: - return getattr(lhs, "__add__")(rhs) - - -def true_divide(lhs, rhs): - warnings.warn( - "sin is deprecated and will be removed in the future", FutureWarning, - ) - - if isinstance(lhs, Number) and isinstance(rhs, Number): - return np.true_divide(lhs, rhs) - elif isinstance(rhs, Frame): - return getattr(rhs, "__rtruediv__")(lhs) - else: - return getattr(lhs, "__truediv__")(rhs) - - -def multiply(lhs, rhs): - warnings.warn( - "sin is deprecated and will be removed in the future", FutureWarning, - ) - - if isinstance(lhs, Number) and isinstance(rhs, Number): - return np.multiply(lhs, rhs) - elif isinstance(rhs, Frame): - return getattr(rhs, "__rmul__")(lhs) - else: - return getattr(lhs, "__mul__")(rhs) diff --git a/python/cudf/cudf/core/series.py b/python/cudf/cudf/core/series.py index b1ee9e99dfb..40e09bb11b8 100644 --- a/python/cudf/cudf/core/series.py +++ b/python/cudf/cudf/core/series.py @@ -5,7 +5,6 @@ import functools import inspect import pickle -import warnings from collections import abc as abc from shutil import get_terminal_size from typing import Any, Dict, MutableMapping, Optional, Set, Tuple, Type, Union @@ -1173,38 +1172,6 @@ def _make_operands_and_index_for_binop( operands = lhs._make_operands_for_binop(other, fill_value, reflect) return operands, lhs._index - @_cudf_nvtx_annotate - def logical_and(self, other): - warnings.warn( - "Series.logical_and is deprecated and will be removed.", - FutureWarning, - ) - return self._binaryop(other, "__l_and__").astype(np.bool_) - - @_cudf_nvtx_annotate - def remainder(self, other): - warnings.warn( - "Series.remainder is deprecated and will be removed.", - FutureWarning, - ) - return self._binaryop(other, "__mod__") - - @_cudf_nvtx_annotate - def logical_or(self, other): - warnings.warn( - "Series.logical_or is deprecated and will be removed.", - FutureWarning, - ) - return self._binaryop(other, "__l_or__").astype(np.bool_) - - @_cudf_nvtx_annotate - def logical_not(self): - warnings.warn( - "Series.logical_not is deprecated and will be removed.", - FutureWarning, - ) - return self._unaryop("not") - @copy_docstring(CategoricalAccessor) # type: ignore @property @_cudf_nvtx_annotate @@ -3160,58 +3127,6 @@ def rename(self, index=None, copy=True): out_data = self._data.copy(deep=copy) return Series._from_data(out_data, self.index, name=index) - @_cudf_nvtx_annotate - def merge( - self, - other, - on=None, - left_on=None, - right_on=None, - left_index=False, - right_index=False, - how="inner", - sort=False, - lsuffix=None, - rsuffix=None, - method="hash", - suffixes=("_x", "_y"), - ): - warnings.warn( - "Series.merge is deprecated and will be removed in a future " - "release. Use cudf.merge instead.", - FutureWarning, - ) - if left_on not in (self.name, None): - raise ValueError( - "Series to other merge uses series name as key implicitly" - ) - - if lsuffix or rsuffix: - raise ValueError( - "The lsuffix and rsuffix keywords have been replaced with the " - "``suffixes=`` keyword. " - "Please provide the following instead: \n\n" - " suffixes=('%s', '%s')" - % (lsuffix or "_x", rsuffix or "_y") - ) - else: - lsuffix, rsuffix = suffixes - - result = super()._merge( - other, - on=on, - left_on=left_on, - right_on=right_on, - left_index=left_index, - right_index=right_index, - how=how, - sort=sort, - indicator=False, - suffixes=suffixes, - ) - - return result - @_cudf_nvtx_annotate def add_prefix(self, prefix): return Series._from_data( diff --git a/python/cudf/cudf/tests/test_binops.py b/python/cudf/cudf/tests/test_binops.py index db12743ac17..aa4075eb887 100644 --- a/python/cudf/cudf/tests/test_binops.py +++ b/python/cudf/cudf/tests/test_binops.py @@ -4,7 +4,6 @@ import decimal import operator import random -from contextlib import contextmanager from itertools import combinations_with_replacement, product import cupy as cp @@ -28,23 +27,6 @@ STRING_TYPES = {"str"} -@contextmanager -def _hide_deprecated_ops_warnings(func, lhs, rhs): - if func in { - cudf.logical_and, - cudf.logical_or, - cudf.remainder, - } and isinstance(lhs, cudf.Series): - name = func.__name__ - with pytest.warns( - FutureWarning, - match=f"Series.{name} is deprecated and will be removed.", - ): - yield - else: - yield - - _binops = [ operator.add, operator.sub, @@ -167,35 +149,6 @@ def test_series_bitwise_binop(binop, obj_class, lhs_dtype, rhs_dtype): np.testing.assert_almost_equal(result.to_numpy(), binop(arr1, arr2)) -_logical_binops = [ - (operator.and_, operator.and_), - (operator.or_, operator.or_), - (np.logical_and, cudf.logical_and), - (np.logical_or, cudf.logical_or), -] - - -@pytest.mark.parametrize("lhstype", _int_types + [np.bool_]) -@pytest.mark.parametrize("rhstype", _int_types + [np.bool_]) -@pytest.mark.parametrize("binop,cubinop", _logical_binops) -def test_series_logical_binop(lhstype, rhstype, binop, cubinop): - arr1 = pd.Series(np.random.choice([True, False], 10)) - if lhstype is not np.bool_: - arr1 = arr1 * (np.random.random(10) * 100).astype(lhstype) - sr1 = Series(arr1) - - arr2 = pd.Series(np.random.choice([True, False], 10)) - if rhstype is not np.bool_: - arr2 = arr2 * (np.random.random(10) * 100).astype(rhstype) - sr2 = Series(arr2) - - with _hide_deprecated_ops_warnings(cubinop, sr1, sr2): - result = cubinop(sr1, sr2) - expect = binop(arr1, arr2) - - utils.assert_eq(result, expect) - - _cmpops = [ operator.lt, operator.gt, @@ -938,54 +891,6 @@ def test_vector_to_none_binops(dtype): utils.assert_eq(expect, got) -@pytest.mark.parametrize( - "lhs", - [ - 1, - 3, - 4, - pd.Series([5, 6, 2]), - pd.Series([0, 10, 20, 30, 3, 4, 5, 6, 2]), - 6, - ], -) -@pytest.mark.parametrize("rhs", [1, 3, 4, pd.Series([5, 6, 2])]) -@pytest.mark.parametrize( - "ops", - [ - (np.remainder, cudf.remainder), - (np.floor_divide, cudf.floor_divide), - (np.subtract, cudf.subtract), - (np.add, cudf.add), - (np.true_divide, cudf.true_divide), - (np.multiply, cudf.multiply), - ], -) -def test_ufunc_ops(lhs, rhs, ops): - np_op, cu_op = ops - - if isinstance(lhs, pd.Series): - culhs = cudf.from_pandas(lhs) - else: - culhs = lhs - - if isinstance(rhs, pd.Series): - curhs = cudf.from_pandas(rhs) - else: - curhs = rhs - - expect = np_op(lhs, rhs) - with _hide_deprecated_ops_warnings(cu_op, culhs, curhs): - got = cu_op(culhs, curhs) - - if np.isscalar(expect): - assert got == expect - else: - utils.assert_eq( - expect, got, - ) - - def dtype_scalar(val, dtype): if dtype == "str": return str(val) diff --git a/python/cudf/cudf/tests/test_dataframe.py b/python/cudf/cudf/tests/test_dataframe.py index 136deb59334..08c8e3485a3 100644 --- a/python/cudf/cudf/tests/test_dataframe.py +++ b/python/cudf/cudf/tests/test_dataframe.py @@ -2079,13 +2079,12 @@ def test_unaryops_df(pdf, gdf, unaryop): assert_eq(d, g) -@pytest.mark.parametrize("unary_func", ["abs", "floor", "ceil"]) -def test_unary_func_df(pdf, unary_func): +def test_df_abs(pdf): np.random.seed(0) disturbance = pd.Series(np.random.rand(10)) pdf = pdf - 5 + disturbance - d = pdf.apply(getattr(np, unary_func)) - g = getattr(cudf.from_pandas(pdf), unary_func)() + d = pdf.apply(np.abs) + g = cudf.from_pandas(pdf).abs() assert_eq(d, g) @@ -4532,9 +4531,6 @@ def test_empty_df_astype(dtype, args): ), pytest.param("other", marks=pytest.mark.xfail(raises=ValueError)), "ignore", - pytest.param( - "warn", marks=pytest.mark.filterwarnings("ignore:Traceback") - ), ], ) def test_series_astype_error_handling(errors): diff --git a/python/cudf/cudf/tests/test_index.py b/python/cudf/cudf/tests/test_index.py index 80270e62da7..b96b8386b10 100644 --- a/python/cudf/cudf/tests/test_index.py +++ b/python/cudf/cudf/tests/test_index.py @@ -1566,114 +1566,6 @@ def test_interval_index_from_breaks(closed): assert_eq(pindex, gindex) -@pytest.mark.parametrize("n", [0, 2, 5, 10, None]) -@pytest.mark.parametrize("frac", [0.1, 0.5, 1, 2, None]) -@pytest.mark.parametrize("replace", [True, False]) -def test_index_sample_basic(n, frac, replace): - psr = pd.Series([1, 2, 3, 4, 5]) - gindex = cudf.Index(psr) - random_state = 0 - - try: - pout = psr.sample( - n=n, frac=frac, replace=replace, random_state=random_state - ) - except BaseException: - assert_exceptions_equal( - lfunc=psr.sample, - rfunc=gindex.sample, - lfunc_args_and_kwargs=( - [], - { - "n": n, - "frac": frac, - "replace": replace, - "random_state": random_state, - }, - ), - rfunc_args_and_kwargs=( - [], - { - "n": n, - "frac": frac, - "replace": replace, - "random_state": random_state, - }, - ), - compare_error_message=False, - ) - else: - gout = gindex.sample( - n=n, frac=frac, replace=replace, random_state=random_state - ) - - assert pout.shape == gout.shape - - -@pytest.mark.parametrize("n", [2, 5, 10, None]) -@pytest.mark.parametrize("frac", [0.5, 1, 2, None]) -@pytest.mark.parametrize("replace", [True, False]) -@pytest.mark.parametrize("axis", [0, 1]) -def test_multiindex_sample_basic(n, frac, replace, axis): - # as we currently don't support column with same name - if axis == 1 and replace: - return - pdf = pd.DataFrame( - { - "a": [1, 2, 3, 4, 5], - "float": [0.05, 0.2, 0.3, 0.2, 0.25], - "int": [1, 3, 5, 4, 2], - }, - ) - mul_index = cudf.Index(cudf.from_pandas(pdf)) - random_state = 0 - - try: - pout = pdf.sample( - n=n, - frac=frac, - replace=replace, - random_state=random_state, - axis=axis, - ) - except BaseException: - assert_exceptions_equal( - lfunc=pdf.sample, - rfunc=mul_index.sample, - lfunc_args_and_kwargs=( - [], - { - "n": n, - "frac": frac, - "replace": replace, - "random_state": random_state, - "axis": axis, - }, - ), - rfunc_args_and_kwargs=( - [], - { - "n": n, - "frac": frac, - "replace": replace, - "random_state": random_state, - "axis": axis, - }, - ), - ) - else: - gout = mul_index.sample( - n=n, - frac=frac, - replace=replace, - random_state=random_state, - axis=axis, - ) - if axis == 1 and n is None and frac is None: - pout = pout.iloc[:, 0] - assert pout.shape == gout.shape - - @pytest.mark.parametrize( "data", [ diff --git a/python/cudf/cudf/tests/test_joining.py b/python/cudf/cudf/tests/test_joining.py index 69793dc1828..f478216cdcf 100644 --- a/python/cudf/cudf/tests/test_joining.py +++ b/python/cudf/cudf/tests/test_joining.py @@ -1813,8 +1813,8 @@ def test_series_dataframe_mixed_merging(lhs, rhs, how, kwargs): if isinstance(rhs, cudf.Series): check_rhs = rhs.to_frame() - expect = check_lhs.merge(check_rhs, how=how, **kwargs) - got = lhs.merge(rhs, how=how, **kwargs) + expect = cudf.merge(check_lhs, check_rhs, how=how, **kwargs) + got = cudf.merge(lhs, rhs, how=how, **kwargs) assert_join_results_equal(expect, got, how=how) diff --git a/python/cudf/cudf/tests/test_ops.py b/python/cudf/cudf/tests/test_ops.py deleted file mode 100644 index ac3f784ecd4..00000000000 --- a/python/cudf/cudf/tests/test_ops.py +++ /dev/null @@ -1,122 +0,0 @@ -# Copyright (c) 2021, NVIDIA CORPORATION. - -import numpy as np -import pandas as pd -import pytest - -import cudf -from cudf.testing._utils import assert_eq, gen_rand - - -def test_sqrt_float(): - assert cudf.sqrt(16.0) == 4.0 - assert_eq(cudf.sqrt(cudf.Series([4.0, 9, 16])), cudf.Series([2.0, 3, 4])) - assert_eq( - cudf.sqrt(cudf.DataFrame({"x": [4.0, 9, 16]})), - cudf.DataFrame({"x": [2.0, 3, 4]}), - ) - - -def test_sqrt_integer(): - assert cudf.sqrt(16) == 4 - assert_eq(cudf.sqrt(cudf.Series([4, 9, 16])), cudf.Series([2, 3, 4])) - assert_eq( - cudf.sqrt(cudf.DataFrame({"x": [4, 9, 16]})), - cudf.DataFrame({"x": [2, 3, 4]}), - ) - - -def math_op_test( - dtype, fn, nelem=128, test_df=False, positive_only=False, check_dtype=True -): - np.random.seed(0) - randvals = gen_rand(dtype, nelem, positive_only=positive_only) - h_series = pd.Series(randvals.astype(dtype)) - d_series = cudf.Series(h_series) - - if test_df: - d_in = cudf.DataFrame() - d_in[0] = d_series - h_in = pd.DataFrame() - h_in[0] = h_series - else: - d_in = d_series - h_in = h_series - - expect = fn(h_in) - got = fn(d_in) - - assert_eq(expect, got, check_dtype=check_dtype) - - -params_real_types = [np.float64, np.float32] -int_type = [np.int64, np.int32] - - -# trig - - -@pytest.mark.parametrize("dtype", params_real_types) -@pytest.mark.parametrize("test_df", [False, True]) -def test_sin(dtype, test_df): - math_op_test(dtype, np.sin, test_df=test_df) - - -@pytest.mark.parametrize("dtype", params_real_types) -@pytest.mark.parametrize("test_df", [False, True]) -def test_cos(dtype, test_df): - math_op_test(dtype, np.cos, test_df=test_df) - - -@pytest.mark.parametrize("dtype", params_real_types) -@pytest.mark.parametrize("test_df", [False, True]) -def test_tan(dtype, test_df): - math_op_test(dtype, np.tan, test_df=test_df) - - -@pytest.mark.parametrize("dtype", params_real_types) -@pytest.mark.parametrize("test_df", [False, True]) -def test_asin(dtype, test_df): - math_op_test(dtype, np.arcsin, test_df=test_df) - - -@pytest.mark.parametrize("dtype", params_real_types) -@pytest.mark.parametrize("test_df", [False, True]) -def test_acos(dtype, test_df): - math_op_test(dtype, np.arccos, test_df=test_df, check_dtype=False) - - -@pytest.mark.parametrize("dtype", int_type) -@pytest.mark.parametrize("test_df", [False, True]) -def test_acos_integer(dtype, test_df): - math_op_test(dtype, np.arccos, test_df=test_df, check_dtype=False) - - -@pytest.mark.parametrize("dtype", params_real_types) -@pytest.mark.parametrize("test_df", [False, True]) -def test_atan(dtype, test_df): - math_op_test(dtype, np.arctan, test_df=test_df) - - -# exponential - - -@pytest.mark.parametrize("dtype", params_real_types) -@pytest.mark.parametrize("test_df", [False, True]) -def test_exp(dtype, test_df): - math_op_test(dtype, np.exp, test_df=test_df) - - -@pytest.mark.parametrize("dtype", params_real_types) -@pytest.mark.parametrize("test_df", [False, True]) -def test_log(dtype, test_df): - math_op_test(dtype, np.log, test_df=test_df, positive_only=True) - - -# power - - -@pytest.mark.parametrize("dtype", params_real_types) -@pytest.mark.parametrize("test_df", [False, True]) -def test_sqrt(dtype, test_df): - math_op_test(dtype, np.sqrt, test_df=test_df, positive_only=True) diff --git a/python/cudf/cudf/tests/test_unaops.py b/python/cudf/cudf/tests/test_unaops.py index bc9edacb68a..3f2f2072758 100644 --- a/python/cudf/cudf/tests/test_unaops.py +++ b/python/cudf/cudf/tests/test_unaops.py @@ -31,79 +31,12 @@ def test_series_invert(dtype): np.testing.assert_equal((~sr).to_numpy(), ~arr) -@pytest.mark.parametrize("dtype", utils.INTEGER_TYPES + ["bool"]) -def test_series_not(dtype): - import pandas as pd - - dtype = cudf.dtype(dtype).type - arr = pd.Series(np.random.choice([True, False], 1000)).astype(dtype) - if dtype is not np.bool_: - arr = arr * (np.random.random(1000) * 100).astype(dtype) - sr = Series(arr) - - with pytest.warns(FutureWarning, match="logical_not is deprecated"): - result = cudf.logical_not(sr).to_numpy() - expect = np.logical_not(arr) - np.testing.assert_equal(result, expect) - np.testing.assert_equal((~sr).to_numpy(), ~arr) - - def test_series_neg(): arr = np.random.random(100) * 100 sr = Series(arr) np.testing.assert_equal((-sr).to_numpy(), -arr) -def test_series_ceil(): - arr = np.random.random(100) * 100 - sr = Series(arr) - with pytest.warns( - FutureWarning, match="Series.ceil and DataFrame.ceil are deprecated" - ): - sr = sr.ceil() - np.testing.assert_equal(sr.to_numpy(), np.ceil(arr)) - - -def test_series_floor(): - arr = np.random.random(100) * 100 - sr = Series(arr) - with pytest.warns( - FutureWarning, match="Series.floor and DataFrame.floor are deprecated" - ): - sr = sr.floor() - np.testing.assert_equal(sr.to_numpy(), np.floor(arr)) - - -@pytest.mark.parametrize("nelem", [1, 7, 8, 9, 32, 64, 128]) -def test_validity_ceil(nelem): - # Data - data = np.random.random(nelem) * 100 - mask = utils.random_bitmask(nelem) - bitmask = utils.expand_bits_to_bytes(mask)[:nelem] - sr = Series.from_masked_array(data, mask) - - # Result - with pytest.warns( - FutureWarning, match="Series.ceil and DataFrame.ceil are deprecated" - ): - res = sr.ceil() - - na_value = -100000 - got = res.fillna(na_value).to_numpy() - res_mask = np.asarray(bitmask, dtype=np.bool_)[: data.size] - - expect = np.ceil(data) - expect[~res_mask] = na_value - - # Check - print("expect") - print(expect) - print("got") - print(got) - - np.testing.assert_array_equal(expect, got) - - @pytest.mark.parametrize("mth", ["min", "max", "sum", "product"]) def test_series_pandas_methods(mth): np.random.seed(0) From ef34c33249cea9e4388b7ad5ee6c6589957f72c3 Mon Sep 17 00:00:00 2001 From: Michael Wang Date: Thu, 24 Mar 2022 13:40:28 -0700 Subject: [PATCH 003/246] Namespace/Docstring Fixes for Reduction (#10471) This PR adds detail namespace for for simple/compound ops for reduction to make code more consistent with segmented reduction. It also includes minor docstring fixes. cc @bdice Authors: - Michael Wang (https://github.com/isVoid) Approvers: - Mike Wilson (https://github.com/hyperbolic2346) - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/cudf/pull/10471 --- .../cudf/detail/reduction_functions.hpp | 4 +++ cpp/src/reductions/all.cu | 11 ++++--- cpp/src/reductions/any.cu | 11 ++++--- cpp/src/reductions/compound.cuh | 32 +++++++++---------- cpp/src/reductions/max.cu | 13 ++++---- cpp/src/reductions/mean.cu | 19 +++++++---- cpp/src/reductions/min.cu | 13 ++++---- cpp/src/reductions/product.cu | 4 +-- cpp/src/reductions/simple.cuh | 16 ++++++---- cpp/src/reductions/std.cu | 24 +++++++------- cpp/src/reductions/sum.cu | 4 +-- cpp/src/reductions/sum_of_squares.cu | 4 +-- cpp/src/reductions/var.cu | 24 +++++++------- 13 files changed, 97 insertions(+), 82 deletions(-) diff --git a/cpp/include/cudf/detail/reduction_functions.hpp b/cpp/include/cudf/detail/reduction_functions.hpp index ccec4bf8a6c..3a6113e66ce 100644 --- a/cpp/include/cudf/detail/reduction_functions.hpp +++ b/cpp/include/cudf/detail/reduction_functions.hpp @@ -192,6 +192,8 @@ std::unique_ptr mean( * * @param col input column to compute variance. * @param output_dtype data type of return type and typecast elements of input column. + * @param ddof Delta degrees of freedom. The divisor used is N - ddof, where N represents the number + * of elements. * @param stream CUDA stream used for device memory operations and kernel launches. * @param mr Device memory resource used to allocate the returned scalar's device memory. * @return Variance as scalar of type `output_dtype`. @@ -213,6 +215,8 @@ std::unique_ptr variance( * * @param col input column to compute standard deviation. * @param output_dtype data type of return type and typecast elements of input column. + * @param ddof Delta degrees of freedom. The divisor used is N - ddof, where N represents the number + * of elements. * @param stream CUDA stream used for device memory operations and kernel launches. * @param mr Device memory resource used to allocate the returned scalar's device memory. * @return Standard deviation as scalar of type `output_dtype`. diff --git a/cpp/src/reductions/all.cu b/cpp/src/reductions/all.cu index 3a076c3b780..b43df279393 100644 --- a/cpp/src/reductions/all.cu +++ b/cpp/src/reductions/all.cu @@ -88,11 +88,12 @@ std::unique_ptr all(column_view const& col, dictionary_column_view(col).keys().type(), detail::all_fn{}, col, stream, mr); } // dispatch for non-dictionary types - return cudf::type_dispatcher(col.type(), - simple::bool_result_element_dispatcher{}, - col, - stream, - mr); + return cudf::type_dispatcher( + col.type(), + simple::detail::bool_result_element_dispatcher{}, + col, + stream, + mr); } } // namespace reduction diff --git a/cpp/src/reductions/any.cu b/cpp/src/reductions/any.cu index 1eb080cfe20..bad7d581255 100644 --- a/cpp/src/reductions/any.cu +++ b/cpp/src/reductions/any.cu @@ -88,11 +88,12 @@ std::unique_ptr any(column_view const& col, dictionary_column_view(col).keys().type(), detail::any_fn{}, col, stream, mr); } // dispatch for non-dictionary types - return cudf::type_dispatcher(col.type(), - simple::bool_result_element_dispatcher{}, - col, - stream, - mr); + return cudf::type_dispatcher( + col.type(), + simple::detail::bool_result_element_dispatcher{}, + col, + stream, + mr); } } // namespace reduction diff --git a/cpp/src/reductions/compound.cuh b/cpp/src/reductions/compound.cuh index c60c819f8e2..89a95f5138c 100644 --- a/cpp/src/reductions/compound.cuh +++ b/cpp/src/reductions/compound.cuh @@ -25,22 +25,21 @@ namespace cudf { namespace reduction { namespace compound { +namespace detail { /** - * @brief Multi-step reduction for operations such as mean and variance, and - * standard deviation. + * @brief Multi-step reduction for operations such as mean, variance, and standard deviation. * - * @param[in] col input column view - * @param[in] ddof `Delta Degrees of Freedom` used for `std`, `var`. - * The divisor used in calculations is N - ddof, where N - * represents the number of elements. - * @param[in] stream CUDA stream used for device memory operations and kernel launches. - * @param[in] mr Device memory resource used to allocate the returned scalar's device memory - * @return Output scalar in device memory + * @tparam ElementType the input column data-type + * @tparam ResultType the output data-type + * @tparam Op the compound operator derived from `cudf::reduction::op::compound_op` * - * @tparam ElementType the input column cudf dtype - * @tparam ResultType the output cudf dtype - * @tparam Op the compound operator derived from - * `cudf::reduction::op::compound_op` + * @param col input column view + * @param output_dtype data type of return type and typecast elements of input column. + * @param ddof Delta degrees of freedom used for standard deviation and variance. The divisor used + * is N - ddof, where N represents the number of elements. + * @param stream CUDA stream used for device memory operations and kernel launches. + * @param mr Device memory resource used to allocate the returned scalar's device memory + * @return Output scalar in device memory */ template std::unique_ptr compound_reduction(column_view const& col, @@ -61,19 +60,19 @@ std::unique_ptr compound_reduction(column_view const& col, auto it = thrust::make_transform_iterator( dcol->pair_begin(), compound_op.template get_null_replacing_element_transformer()); - result = detail::reduce( + result = cudf::reduction::detail::reduce( it, col.size(), compound_op, valid_count, ddof, stream, mr); } else { auto it = thrust::make_transform_iterator( dcol->begin(), compound_op.template get_element_transformer()); - result = detail::reduce( + result = cudf::reduction::detail::reduce( it, col.size(), compound_op, valid_count, ddof, stream, mr); } } else { auto it = thrust::make_transform_iterator( cudf::dictionary::detail::make_dictionary_pair_iterator(*dcol, col.has_nulls()), compound_op.template get_null_replacing_element_transformer()); - result = detail::reduce( + result = cudf::reduction::detail::reduce( it, col.size(), compound_op, valid_count, ddof, stream, mr); } @@ -152,6 +151,7 @@ struct element_type_dispatcher { } }; +} // namespace detail } // namespace compound } // namespace reduction } // namespace cudf diff --git a/cpp/src/reductions/max.cu b/cpp/src/reductions/max.cu index dd283d86d3b..4adf35414dd 100644 --- a/cpp/src/reductions/max.cu +++ b/cpp/src/reductions/max.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2020, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -34,11 +34,12 @@ std::unique_ptr max(column_view const& col, auto const dispatch_type = cudf::is_dictionary(col.type()) ? cudf::dictionary_column_view(col).indices().type() : col.type(); - return cudf::type_dispatcher(dispatch_type, - simple::same_element_type_dispatcher{}, - col, - stream, - mr); + return cudf::type_dispatcher( + dispatch_type, + simple::detail::same_element_type_dispatcher{}, + col, + stream, + mr); } } // namespace reduction diff --git a/cpp/src/reductions/mean.cu b/cpp/src/reductions/mean.cu index ca341090b9f..e4b5f754b9b 100644 --- a/cpp/src/reductions/mean.cu +++ b/cpp/src/reductions/mean.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2020, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// The translation unit for reduction `mean` #include #include @@ -21,14 +20,20 @@ #include -std::unique_ptr cudf::reduction::mean(column_view const& col, - cudf::data_type const output_dtype, - rmm::cuda_stream_view stream, - rmm::mr::device_memory_resource* mr) +namespace cudf { +namespace reduction { + +std::unique_ptr mean(column_view const& col, + cudf::data_type const output_dtype, + rmm::cuda_stream_view stream, + rmm::mr::device_memory_resource* mr) { - using reducer = cudf::reduction::compound::element_type_dispatcher; + using reducer = compound::detail::element_type_dispatcher; auto col_type = cudf::is_dictionary(col.type()) ? dictionary_column_view(col).keys().type() : col.type(); return cudf::type_dispatcher( col_type, reducer(), col, output_dtype, /* ddof is not used for mean*/ 1, stream, mr); } + +} // namespace reduction +} // namespace cudf diff --git a/cpp/src/reductions/min.cu b/cpp/src/reductions/min.cu index 5e1301b2904..ac9bdfe9cdc 100644 --- a/cpp/src/reductions/min.cu +++ b/cpp/src/reductions/min.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2020, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -32,11 +32,12 @@ std::unique_ptr min(column_view const& col, auto const dispatch_type = cudf::is_dictionary(col.type()) ? cudf::dictionary_column_view(col).indices().type() : col.type(); - return cudf::type_dispatcher(dispatch_type, - simple::same_element_type_dispatcher{}, - col, - stream, - mr); + return cudf::type_dispatcher( + dispatch_type, + simple::detail::same_element_type_dispatcher{}, + col, + stream, + mr); } } // namespace reduction diff --git a/cpp/src/reductions/product.cu b/cpp/src/reductions/product.cu index 30342bc4728..5caf498712a 100644 --- a/cpp/src/reductions/product.cu +++ b/cpp/src/reductions/product.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2020, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -30,7 +30,7 @@ std::unique_ptr product(column_view const& col, { return cudf::type_dispatcher( cudf::is_dictionary(col.type()) ? dictionary_column_view(col).keys().type() : col.type(), - simple::element_type_dispatcher{}, + simple::detail::element_type_dispatcher{}, col, output_dtype, stream, diff --git a/cpp/src/reductions/simple.cuh b/cpp/src/reductions/simple.cuh index e5303246452..807462d742f 100644 --- a/cpp/src/reductions/simple.cuh +++ b/cpp/src/reductions/simple.cuh @@ -38,6 +38,7 @@ namespace cudf { namespace reduction { namespace simple { +namespace detail { /** * @brief Reduction for 'sum', 'product', 'min', 'max', 'sum of squares' * which directly compute the reduction by a single step reduction call @@ -64,11 +65,11 @@ std::unique_ptr simple_reduction(column_view const& col, if (col.has_nulls()) { auto f = simple_op.template get_null_replacing_element_transformer(); auto it = thrust::make_transform_iterator(dcol->pair_begin(), f); - return detail::reduce(it, col.size(), simple_op, stream, mr); + return cudf::reduction::detail::reduce(it, col.size(), simple_op, stream, mr); } else { auto f = simple_op.template get_element_transformer(); auto it = thrust::make_transform_iterator(dcol->begin(), f); - return detail::reduce(it, col.size(), simple_op, stream, mr); + return cudf::reduction::detail::reduce(it, col.size(), simple_op, stream, mr); } }(); @@ -102,11 +103,11 @@ std::unique_ptr fixed_point_reduction(column_view const& col, if (col.has_nulls()) { auto f = simple_op.template get_null_replacing_element_transformer(); auto it = thrust::make_transform_iterator(dcol->pair_begin(), f); - return detail::reduce(it, col.size(), simple_op, stream, mr); + return cudf::reduction::detail::reduce(it, col.size(), simple_op, stream, mr); } else { auto f = simple_op.template get_element_transformer(); auto it = thrust::make_transform_iterator(dcol->begin(), f); - return detail::reduce(it, col.size(), simple_op, stream, mr); + return cudf::reduction::detail::reduce(it, col.size(), simple_op, stream, mr); } }(); @@ -149,7 +150,7 @@ std::unique_ptr dictionary_reduction(column_view const& col, auto p = cudf::dictionary::detail::make_dictionary_pair_iterator(*dcol, col.has_nulls()); auto it = thrust::make_transform_iterator(p, f); - return detail::reduce(it, col.size(), simple_op, stream, mr); + return cudf::reduction::detail::reduce(it, col.size(), simple_op, stream, mr); }(); // set scalar is valid @@ -310,9 +311,9 @@ struct same_element_type_dispatcher { rmm::mr::device_memory_resource* mr) { if (!cudf::is_dictionary(col.type())) { - return simple::simple_reduction(col, stream, mr); + return simple_reduction(col, stream, mr); } - auto index = simple::simple_reduction( + auto index = simple_reduction( dictionary_column_view(col).get_indices_annotated(), stream, rmm::mr::get_current_device_resource()); @@ -442,6 +443,7 @@ struct element_type_dispatcher { } }; +} // namespace detail } // namespace simple } // namespace reduction } // namespace cudf diff --git a/cpp/src/reductions/std.cu b/cpp/src/reductions/std.cu index 3c7a05abd4e..bb29e5cd030 100644 --- a/cpp/src/reductions/std.cu +++ b/cpp/src/reductions/std.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2020, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// The translation unit for reduction `standard deviation` #include #include @@ -21,21 +20,19 @@ #include -// @param[in] ddof Delta Degrees of Freedom used for `std`, `var`. -// The divisor used in calculations is N - ddof, where N -// represents the number of elements. +namespace cudf { +namespace reduction { -std::unique_ptr cudf::reduction::standard_deviation( - column_view const& col, - cudf::data_type const output_dtype, - cudf::size_type ddof, - rmm::cuda_stream_view stream, - rmm::mr::device_memory_resource* mr) +std::unique_ptr standard_deviation(column_view const& col, + cudf::data_type const output_dtype, + cudf::size_type ddof, + rmm::cuda_stream_view stream, + rmm::mr::device_memory_resource* mr) { // TODO: add cuda version check when the fix is available #if !defined(__CUDACC_DEBUG__) using reducer = - cudf::reduction::compound::element_type_dispatcher; + compound::detail::element_type_dispatcher; auto col_type = cudf::is_dictionary(col.type()) ? dictionary_column_view(col).keys().type() : col.type(); return cudf::type_dispatcher(col_type, reducer(), col, output_dtype, ddof, stream, mr); @@ -45,3 +42,6 @@ std::unique_ptr cudf::reduction::standard_deviation( CUDF_FAIL("var/std reductions are not supported at debug build."); #endif } + +} // namespace reduction +} // namespace cudf diff --git a/cpp/src/reductions/sum.cu b/cpp/src/reductions/sum.cu index 8bc157668f4..2db19939bd5 100644 --- a/cpp/src/reductions/sum.cu +++ b/cpp/src/reductions/sum.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2020, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -30,7 +30,7 @@ std::unique_ptr sum(column_view const& col, { return cudf::type_dispatcher( cudf::is_dictionary(col.type()) ? dictionary_column_view(col).keys().type() : col.type(), - simple::element_type_dispatcher{}, + simple::detail::element_type_dispatcher{}, col, output_dtype, stream, diff --git a/cpp/src/reductions/sum_of_squares.cu b/cpp/src/reductions/sum_of_squares.cu index eca6aa0d1d9..a3e9368bb02 100644 --- a/cpp/src/reductions/sum_of_squares.cu +++ b/cpp/src/reductions/sum_of_squares.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2020, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -30,7 +30,7 @@ std::unique_ptr sum_of_squares(column_view const& col, { return cudf::type_dispatcher( cudf::is_dictionary(col.type()) ? dictionary_column_view(col).keys().type() : col.type(), - simple::element_type_dispatcher{}, + simple::detail::element_type_dispatcher{}, col, output_dtype, stream, diff --git a/cpp/src/reductions/var.cu b/cpp/src/reductions/var.cu index 2565e472661..2df653858b0 100644 --- a/cpp/src/reductions/var.cu +++ b/cpp/src/reductions/var.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2020, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -14,27 +14,24 @@ * limitations under the License. */ -// The translation unit for reduction `variance` - #include #include #include #include -// @param[in] ddof Delta Degrees of Freedom used for `std`, `var`. -// The divisor used in calculations is N - ddof, where N -// represents the number of elements. +namespace cudf { +namespace reduction { -std::unique_ptr cudf::reduction::variance(column_view const& col, - cudf::data_type const output_dtype, - cudf::size_type ddof, - rmm::cuda_stream_view stream, - rmm::mr::device_memory_resource* mr) +std::unique_ptr variance(column_view const& col, + cudf::data_type const output_dtype, + cudf::size_type ddof, + rmm::cuda_stream_view stream, + rmm::mr::device_memory_resource* mr) { // TODO: add cuda version check when the fix is available #if !defined(__CUDACC_DEBUG__) - using reducer = cudf::reduction::compound::element_type_dispatcher; + using reducer = compound::detail::element_type_dispatcher; auto col_type = cudf::is_dictionary(col.type()) ? dictionary_column_view(col).keys().type() : col.type(); return cudf::type_dispatcher(col_type, reducer(), col, output_dtype, ddof, stream, mr); @@ -44,3 +41,6 @@ std::unique_ptr cudf::reduction::variance(column_view const& col, CUDF_FAIL("var/std reductions are not supported at debug build."); #endif } + +} // namespace reduction +} // namespace cudf From 3a16a7f3b7b7c392fbaa90d856ab84fc71e37449 Mon Sep 17 00:00:00 2001 From: Vukasin Milovanovic Date: Thu, 24 Mar 2022 14:46:58 -0700 Subject: [PATCH 004/246] Allow users to specify data types for a subset of columns in `read_csv` (#10484) Fixes #10254 CSV reader previously assumed that all data types are specified by the user, or none. This PR changes the logic so that user can pass a map/dictionary to specify type for any subset of columns, and reader infers the type for the remaining columns. When passing columns as an array, users still need to specify all columns' types, because the array become ambiguous when reading a subset of columns in the file. Authors: - Vukasin Milovanovic (https://github.com/vuule) Approvers: - Bradley Dice (https://github.com/bdice) - Nghia Truong (https://github.com/ttnghia) URL: https://github.com/rapidsai/cudf/pull/10484 --- cpp/src/io/csv/csv_gpu.cu | 2 +- cpp/src/io/csv/reader_impl.cu | 267 ++++++++++++++++++---------------- cpp/tests/io/csv_test.cpp | 31 +++- 3 files changed, 166 insertions(+), 134 deletions(-) diff --git a/cpp/src/io/csv/csv_gpu.cu b/cpp/src/io/csv/csv_gpu.cu index e2e478af9ef..4bbc04eecb4 100644 --- a/cpp/src/io/csv/csv_gpu.cu +++ b/cpp/src/io/csv/csv_gpu.cu @@ -197,7 +197,7 @@ __global__ void __launch_bounds__(csvparse_block_dim) auto next_delimiter = cudf::io::gpu::seek_field_end(field_start, row_end, opts); // Checking if this is a column that the user wants --- user can filter columns - if (column_flags[col] & column_parse::enabled) { + if (column_flags[col] & column_parse::inferred) { // points to last character in the field auto const field_len = static_cast(next_delimiter - field_start); if (serialized_trie_contains(opts.trie_na, {field_start, field_len})) { diff --git a/cpp/src/io/csv/reader_impl.cu b/cpp/src/io/csv/reader_impl.cu index 0e50bb46232..ace8e77afb5 100644 --- a/cpp/src/io/csv/reader_impl.cu +++ b/cpp/src/io/csv/reader_impl.cu @@ -457,116 +457,111 @@ std::pair, selected_rows_offsets> select_data_and_row_ return {rmm::device_uvector{0, stream}, selected_rows_offsets{stream}}; } -std::vector select_data_types(std::vector const& column_flags, - std::vector const& dtypes, - int32_t num_actual_columns, - int32_t num_active_columns) +void select_data_types(host_span user_dtypes, + host_span column_flags, + host_span column_types) { - std::vector selected_dtypes; - - if (dtypes.size() == 1) { - // If it's a single dtype, assign that dtype to all active columns - selected_dtypes.resize(num_active_columns, dtypes.front()); - } else { - // If it's a list, assign dtypes to active columns in the given order - CUDF_EXPECTS(static_cast(dtypes.size()) >= num_actual_columns, - "Must specify data types for all columns"); - - for (int i = 0; i < num_actual_columns; i++) { - if (column_flags[i] & column_parse::enabled) { selected_dtypes.emplace_back(dtypes[i]); } + if (user_dtypes.empty()) { return; } + + CUDF_EXPECTS(user_dtypes.size() == 1 || user_dtypes.size() == column_flags.size(), + "Specify data types for all columns in file, or use a dictionary/map"); + + for (auto col_idx = 0u; col_idx < column_flags.size(); ++col_idx) { + if (column_flags[col_idx] & column_parse::enabled) { + // If it's a single dtype, assign that dtype to all active columns + auto const& dtype = user_dtypes.size() == 1 ? user_dtypes[0] : user_dtypes[col_idx]; + column_types[col_idx] = dtype; + // Reset the inferred flag, no need to infer the types from the data + column_flags[col_idx] &= ~column_parse::inferred; } } - return selected_dtypes; } -std::vector get_data_types_from_column_names( - std::vector const& column_flags, - std::map const& column_type_map, - std::vector const& column_names, - int32_t num_actual_columns) +void get_data_types_from_column_names(std::map const& user_dtypes, + host_span column_names, + host_span column_flags, + host_span column_types) { - std::vector selected_dtypes; - - for (int32_t i = 0; i < num_actual_columns; i++) { - if (column_flags[i] & column_parse::enabled) { - auto const col_type_it = column_type_map.find(column_names[i]); - CUDF_EXPECTS(col_type_it != column_type_map.end(), - "Must specify data types for all active columns"); - selected_dtypes.emplace_back(col_type_it->second); + if (user_dtypes.empty()) { return; } + for (auto col_idx = 0u; col_idx < column_flags.size(); ++col_idx) { + if (column_flags[col_idx] & column_parse::enabled) { + auto const col_type_it = user_dtypes.find(column_names[col_idx]); + if (col_type_it != user_dtypes.end()) { + // Assign the type from the map + column_types[col_idx] = col_type_it->second; + // Reset the inferred flag, no need to infer the types from the data + column_flags[col_idx] &= ~column_parse::inferred; + } } } - - return selected_dtypes; } -std::vector infer_column_types(parse_options const& parse_opts, - std::vector const& column_flags, - device_span data, - device_span row_offsets, - int32_t num_records, - int32_t num_active_columns, - data_type timestamp_type, - rmm::cuda_stream_view stream) +void infer_column_types(parse_options const& parse_opts, + host_span column_flags, + device_span data, + device_span row_offsets, + int32_t num_records, + data_type timestamp_type, + host_span column_types, + rmm::cuda_stream_view stream) { - std::vector dtypes; if (num_records == 0) { - dtypes.resize(num_active_columns, data_type{type_id::EMPTY}); - } else { - auto column_stats = - cudf::io::csv::gpu::detect_column_types(parse_opts.view(), - data, - make_device_uvector_async(column_flags, stream), - row_offsets, - num_active_columns, - stream); - - stream.synchronize(); - - for (int col = 0; col < num_active_columns; col++) { - unsigned long long int_count_total = column_stats[col].big_int_count + - column_stats[col].negative_small_int_count + - column_stats[col].positive_small_int_count; - - if (column_stats[col].null_count == num_records) { - // Entire column is NULL; allocate the smallest amount of memory - dtypes.emplace_back(cudf::type_id::INT8); - } else if (column_stats[col].string_count > 0L) { - dtypes.emplace_back(cudf::type_id::STRING); - } else if (column_stats[col].datetime_count > 0L) { - dtypes.emplace_back(cudf::type_id::TIMESTAMP_NANOSECONDS); - } else if (column_stats[col].bool_count > 0L) { - dtypes.emplace_back(cudf::type_id::BOOL8); - } else if (column_stats[col].float_count > 0L || - (column_stats[col].float_count == 0L && int_count_total > 0L && - column_stats[col].null_count > 0L)) { - // The second condition has been added to conform to - // PANDAS which states that a column of integers with - // a single NULL record need to be treated as floats. - dtypes.emplace_back(cudf::type_id::FLOAT64); - } else if (column_stats[col].big_int_count == 0) { - dtypes.emplace_back(cudf::type_id::INT64); - } else if (column_stats[col].big_int_count != 0 && - column_stats[col].negative_small_int_count != 0) { - dtypes.emplace_back(cudf::type_id::STRING); - } else { - // Integers are stored as 64-bit to conform to PANDAS - dtypes.emplace_back(cudf::type_id::UINT64); + for (auto col_idx = 0u; col_idx < column_flags.size(); ++col_idx) { + if (column_flags[col_idx] & column_parse::inferred) { + column_types[col_idx] = data_type(cudf::type_id::STRING); } } + return; } - if (timestamp_type.id() != cudf::type_id::EMPTY) { - for (auto& type : dtypes) { - if (cudf::is_timestamp(type)) { type = timestamp_type; } + auto const num_inferred_columns = + std::count_if(column_flags.begin(), column_flags.end(), [](auto& flags) { + return flags & column_parse::inferred; + }); + if (num_inferred_columns == 0) { return; } + + auto const column_stats = + cudf::io::csv::gpu::detect_column_types(parse_opts.view(), + data, + make_device_uvector_async(column_flags, stream), + row_offsets, + num_inferred_columns, + stream); + stream.synchronize(); + + auto inf_col_idx = 0; + for (auto col_idx = 0u; col_idx < column_flags.size(); ++col_idx) { + if (not(column_flags[col_idx] & column_parse::inferred)) { continue; } + auto const& stats = column_stats[inf_col_idx++]; + unsigned long long int_count_total = + stats.big_int_count + stats.negative_small_int_count + stats.positive_small_int_count; + + if (stats.null_count == num_records) { + // Entire column is NULL; allocate the smallest amount of memory + column_types[col_idx] = data_type(cudf::type_id::INT8); + } else if (stats.string_count > 0L) { + column_types[col_idx] = data_type(cudf::type_id::STRING); + } else if (stats.datetime_count > 0L) { + column_types[col_idx] = timestamp_type.id() == cudf::type_id::EMPTY + ? data_type(cudf::type_id::TIMESTAMP_NANOSECONDS) + : timestamp_type; + } else if (stats.bool_count > 0L) { + column_types[col_idx] = data_type(cudf::type_id::BOOL8); + } else if (stats.float_count > 0L || + (stats.float_count == 0L && int_count_total > 0L && stats.null_count > 0L)) { + // The second condition has been added to conform to + // pandas which states that a column of integers with + // a single NULL record need to be treated as floats. + column_types[col_idx] = data_type(cudf::type_id::FLOAT64); + } else if (stats.big_int_count == 0) { + column_types[col_idx] = data_type(cudf::type_id::INT64); + } else if (stats.big_int_count != 0 && stats.negative_small_int_count != 0) { + column_types[col_idx] = data_type(cudf::type_id::STRING); + } else { + // Integers are stored as 64-bit to conform to PANDAS + column_types[col_idx] = data_type(cudf::type_id::UINT64); } } - - for (size_t i = 0; i < dtypes.size(); i++) { - // Replace EMPTY dtype with STRING - if (dtypes[i].id() == type_id::EMPTY) { dtypes[i] = data_type{type_id::STRING}; } - } - - return dtypes; } std::vector decode_data(parse_options const& parse_opts, @@ -622,6 +617,49 @@ std::vector decode_data(parse_options const& parse_opts, return out_buffers; } +std::vector determine_column_types(csv_reader_options const& reader_opts, + parse_options const& parse_opts, + host_span column_names, + device_span data, + device_span row_offsets, + int32_t num_records, + host_span column_flags, + rmm::cuda_stream_view stream) +{ + std::vector column_types(column_flags.size()); + + std::visit(cudf::detail::visitor_overload{ + [&](const std::vector& user_dtypes) { + return select_data_types(user_dtypes, column_flags, column_types); + }, + [&](const std::map& user_dtypes) { + return get_data_types_from_column_names( + user_dtypes, column_names, column_flags, column_types); + }}, + reader_opts.get_dtypes()); + + infer_column_types(parse_opts, + column_flags, + data, + row_offsets, + num_records, + reader_opts.get_timestamp_type(), + column_types, + stream); + + // compact column_types to only include active columns + std::vector active_col_types; + std::copy_if(column_types.cbegin(), + column_types.cend(), + std::back_inserter(active_col_types), + [&column_flags, &types = std::as_const(column_types)](auto& dtype) { + auto const idx = std::distance(types.data(), &dtype); + return column_flags[idx] & column_parse::enabled; + }); + + return active_col_types; +} + table_with_metadata read_csv(cudf::io::datasource* source, csv_reader_options const& reader_opts, parse_options const& parse_opts, @@ -645,7 +683,8 @@ table_with_metadata read_csv(cudf::io::datasource* source, // Check if the user gave us a list of column names if (not reader_opts.get_names().empty()) { - column_flags.resize(reader_opts.get_names().size(), column_parse::enabled); + column_flags.resize(reader_opts.get_names().size(), + column_parse::enabled | column_parse::inferred); column_names = reader_opts.get_names(); } else { column_names = get_column_names( @@ -653,7 +692,7 @@ table_with_metadata read_csv(cudf::io::datasource* source, num_actual_columns = num_active_columns = column_names.size(); - column_flags.resize(num_actual_columns, column_parse::enabled); + column_flags.resize(num_actual_columns, column_parse::enabled | column_parse::inferred); // Rename empty column names to "Unnamed: col_index" for (size_t col_idx = 0; col_idx < column_names.size(); ++col_idx) { @@ -694,7 +733,7 @@ table_with_metadata read_csv(cudf::io::datasource* source, std::fill(column_flags.begin(), column_flags.end(), column_parse::disabled); for (const auto index : reader_opts.get_use_cols_indexes()) { - column_flags[index] = column_parse::enabled; + column_flags[index] = column_parse::enabled | column_parse::inferred; } num_active_columns = std::unordered_set(reader_opts.get_use_cols_indexes().begin(), reader_opts.get_use_cols_indexes().end()) @@ -705,7 +744,7 @@ table_with_metadata read_csv(cudf::io::datasource* source, if (it != column_names.end()) { auto curr_it = it - column_names.begin(); if (column_flags[curr_it] == column_parse::disabled) { - column_flags[curr_it] = column_parse::enabled; + column_flags[curr_it] = column_parse::enabled | column_parse::inferred; num_active_columns++; } } @@ -744,42 +783,12 @@ table_with_metadata read_csv(cudf::io::datasource* source, // Return empty table rather than exception if nothing to load if (num_active_columns == 0) { return {std::make_unique(), {}}; } + auto const column_types = determine_column_types( + reader_opts, parse_opts, column_names, data, row_offsets, num_records, column_flags, stream); + auto metadata = table_metadata{}; auto out_columns = std::vector>(); - - bool has_to_infer_column_types = - std::visit([](const auto& dtypes) { return dtypes.empty(); }, reader_opts.get_dtypes()); - - std::vector column_types; - if (has_to_infer_column_types) { - column_types = infer_column_types( // - parse_opts, - column_flags, - data, - row_offsets, - num_records, - num_active_columns, - reader_opts.get_timestamp_type(), - stream); - } else { - column_types = - std::visit(cudf::detail::visitor_overload{ - [&](const std::vector& data_types) { - return select_data_types( - column_flags, data_types, num_actual_columns, num_active_columns); - }, - [&](const std::map& data_types) { - return get_data_types_from_column_names( // - column_flags, - data_types, - column_names, - num_actual_columns); - }}, - reader_opts.get_dtypes()); - } - out_columns.reserve(column_types.size()); - if (num_records != 0) { auto out_buffers = decode_data( // parse_opts, diff --git a/cpp/tests/io/csv_test.cpp b/cpp/tests/io/csv_test.cpp index e5e44b1aa6e..7ae97c19bf3 100644 --- a/cpp/tests/io/csv_test.cpp +++ b/cpp/tests/io/csv_test.cpp @@ -2188,14 +2188,37 @@ TEST_F(CsvReaderTest, DtypesMap) expect_column_data_equal(std::vector{9, 8, 7}, result_table.column(1)); } -TEST_F(CsvReaderTest, DtypesMapInvalid) +TEST_F(CsvReaderTest, DtypesMapPartial) { - std::string csv_in{""}; - cudf_io::csv_reader_options in_opts = - cudf_io::csv_reader_options::builder(cudf_io::source_info{csv_in.c_str(), csv_in.size()}) + cudf_io::csv_reader_options::builder(cudf_io::source_info{nullptr, 0}) .names({"A", "B"}) .dtypes({{"A", dtype()}}); + { + auto result = cudf_io::read_csv(in_opts); + + const auto view = result.tbl->view(); + ASSERT_EQ(type_id::INT16, view.column(0).type().id()); + // Default to String if there's no data + ASSERT_EQ(type_id::STRING, view.column(1).type().id()); + } + + in_opts.set_dtypes({{"B", dtype()}}); + { + auto result = cudf_io::read_csv(in_opts); + + const auto view = result.tbl->view(); + ASSERT_EQ(type_id::STRING, view.column(0).type().id()); + ASSERT_EQ(type_id::UINT32, view.column(1).type().id()); + } +} + +TEST_F(CsvReaderTest, DtypesArrayInvalid) +{ + cudf_io::csv_reader_options in_opts = + cudf_io::csv_reader_options::builder(cudf_io::source_info{nullptr, 0}) + .names({"A", "B", "C"}) + .dtypes(std::vector{dtype(), dtype()}); EXPECT_THROW(cudf_io::read_csv(in_opts), cudf::logic_error); } From 17c913ccf95d3b3e046a70cc4d9843005ee6d5ae Mon Sep 17 00:00:00 2001 From: Peixin Date: Fri, 25 Mar 2022 11:49:48 +0800 Subject: [PATCH 005/246] Update cudfjni 22.06.0-SNAPSHOT (#10467) As title, update cudf JNI version 22.06.0-SNAPSHOT Authors: - Peixin (https://github.com/pxLi) Approvers: - Jason Lowe (https://github.com/jlowe) - Robert (Bobby) Evans (https://github.com/revans2) URL: https://github.com/rapidsai/cudf/pull/10467 --- java/ci/README.md | 4 ++-- java/pom.xml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/java/ci/README.md b/java/ci/README.md index f022bec04e3..59874d11b8f 100644 --- a/java/ci/README.md +++ b/java/ci/README.md @@ -34,7 +34,7 @@ nvidia-docker run -it cudf-build:11.5.0-devel-centos7 bash You can download the cuDF repo in the docker container or you can mount it into the container. Here I choose to download again in the container. ```bash -git clone --recursive https://github.com/rapidsai/cudf.git -b branch-22.04 +git clone --recursive https://github.com/rapidsai/cudf.git -b branch-22.06 ``` ### Build cuDF jar with devtoolset @@ -47,5 +47,5 @@ scl enable devtoolset-9 "java/ci/build-in-docker.sh" ### The output -You can find the cuDF jar in java/target/ like cudf-22.04.0-SNAPSHOT-cuda11.jar. +You can find the cuDF jar in java/target/ like cudf-22.06.0-SNAPSHOT-cuda11.jar. diff --git a/java/pom.xml b/java/pom.xml index 02828a21e67..d2104269c2c 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -21,7 +21,7 @@ ai.rapids cudf - 22.04.0-SNAPSHOT + 22.06.0-SNAPSHOT cudfjni From 19ab7d6270b5f6d9e952c1fdfc5ef7f48993967c Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Fri, 25 Mar 2022 15:59:11 -0700 Subject: [PATCH 006/246] Define proper binary operation APIs for columns (#10509) This PR changes the way that binary operations are performed between columns. Instead of directly invoking the `_binaryop` method Frame binary operations now invoke operators directly using the `operator` module. Each `Column` subclass now only defines operations that are well-defined, relying on Python to handle raising `TypeError`s for all others. Binary operations return `NotImplemented` instead of raising a `TypeError` _except_ in specific cases where a meaningful error should be raised, allowing us to take advantage of reflected operations to prevent duplicate logic on how to handle binary operations between distinct types. Finally, various edge cases that were previously handled by Frames are now handled in Column so that different dtype columns are the sole source of truth on what operands are supported. These changes move us towards fully functional Column classes that do not rely on preprocessed inputs coming from the Frame layer. This PR has a large changeset, but a large chunk of the changes lines are simply because some changes to the pipeline result in operations having their dunder names instead of having the dunders stripped, e.g. `__add__` instead of `add`. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/cudf/pull/10509 --- python/cudf/cudf/_lib/binaryop.pyx | 6 +- python/cudf/cudf/_lib/datetime.pyx | 6 +- python/cudf/cudf/_typing.py | 2 +- python/cudf/cudf/core/column/categorical.py | 34 ++--- python/cudf/cudf/core/column/column.py | 71 ++------- python/cudf/cudf/core/column/datetime.py | 87 +++++++---- python/cudf/cudf/core/column/decimal.py | 47 +++--- python/cudf/cudf/core/column/lists.py | 53 ++----- python/cudf/cudf/core/column/numerical.py | 81 +++++------ python/cudf/cudf/core/column/string.py | 110 +++++++++----- python/cudf/cudf/core/column/timedelta.py | 152 ++++++++++++-------- python/cudf/cudf/core/frame.py | 119 +-------------- python/cudf/cudf/core/index.py | 4 +- python/cudf/cudf/core/indexed_frame.py | 4 +- python/cudf/cudf/core/mixins/binops.py | 22 ++- python/cudf/cudf/core/mixins/binops.pyi | 10 +- python/cudf/cudf/core/tools/datetimes.py | 10 +- python/cudf/cudf/tests/test_list.py | 2 +- python/cudf/cudf/tests/test_timedelta.py | 9 +- python/cudf/cudf/utils/applyutils.py | 4 +- python/cudf/cudf/utils/utils.py | 86 +++++++++++ 21 files changed, 465 insertions(+), 454 deletions(-) diff --git a/python/cudf/cudf/_lib/binaryop.pyx b/python/cudf/cudf/_lib/binaryop.pyx index 1b590db9e6d..b11d31ab368 100644 --- a/python/cudf/cudf/_lib/binaryop.pyx +++ b/python/cudf/cudf/_lib/binaryop.pyx @@ -1,4 +1,4 @@ -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-2022, NVIDIA CORPORATION. from enum import IntEnum @@ -160,6 +160,10 @@ def binaryop(lhs, rhs, op, dtype): """ Dispatches a binary op call to the appropriate libcudf function: """ + # TODO: Shouldn't have to keep special-casing. We need to define a separate + # pipeline for libcudf binops that don't map to Python binops. + if op != "NULL_EQUALS": + op = op[2:-2] op = BinaryOperation[op.upper()] cdef binary_operator c_op = ( diff --git a/python/cudf/cudf/_lib/datetime.pyx b/python/cudf/cudf/_lib/datetime.pyx index e41016645cd..e218400a2db 100644 --- a/python/cudf/cudf/_lib/datetime.pyx +++ b/python/cudf/cudf/_lib/datetime.pyx @@ -1,3 +1,5 @@ +# Copyright (c) 2020-2022, NVIDIA CORPORATION. + from libcpp.memory cimport unique_ptr from libcpp.utility cimport move @@ -56,8 +58,8 @@ def extract_datetime_component(Column col, object field): if field == "weekday": # Pandas counts Monday-Sunday as 0-6 - # while we count Monday-Sunday as 1-7 - result = result.binary_operator("sub", result.dtype.type(1)) + # while libcudf counts Monday-Sunday as 1-7 + result = result - result.dtype.type(1) return result diff --git a/python/cudf/cudf/_typing.py b/python/cudf/cudf/_typing.py index ca2024929f3..87988150fd3 100644 --- a/python/cudf/cudf/_typing.py +++ b/python/cudf/cudf/_typing.py @@ -25,7 +25,7 @@ ColumnLike = Any # binary operation -BinaryOperand = Union["cudf.Scalar", "cudf.core.column.ColumnBase"] +ColumnBinaryOperand = Union["cudf.Scalar", "cudf.core.column.ColumnBase"] DataFrameOrSeries = Union["cudf.Series", "cudf.DataFrame"] SeriesOrIndex = Union["cudf.Series", "cudf.core.index.BaseIndex"] diff --git a/python/cudf/cudf/core/column/categorical.py b/python/cudf/cudf/core/column/categorical.py index caab2294484..e0022ed21ca 100644 --- a/python/cudf/cudf/core/column/categorical.py +++ b/python/cudf/cudf/core/column/categorical.py @@ -24,7 +24,7 @@ import cudf from cudf import _lib as libcudf from cudf._lib.transform import bools_to_mask -from cudf._typing import ColumnLike, Dtype, ScalarLike +from cudf._typing import ColumnBinaryOperand, ColumnLike, Dtype, ScalarLike from cudf.api.types import is_categorical_dtype, is_interval_dtype from cudf.core.buffer import Buffer from cudf.core.column import column @@ -630,6 +630,14 @@ class CategoricalColumn(column.ColumnBase): dtype: cudf.core.dtypes.CategoricalDtype _codes: Optional[NumericalColumn] _children: Tuple[NumericalColumn] + _VALID_BINARY_OPERATIONS = { + "__eq__", + "__ne__", + "__lt__", + "__le__", + "__gt__", + "__ge__", + } def __init__( self, @@ -875,41 +883,29 @@ def slice( offset=codes.offset, ) - def binary_operator( - self, op: str, rhs, reflect: bool = False - ) -> ColumnBase: - if op not in {"eq", "ne", "lt", "le", "gt", "ge", "NULL_EQUALS"}: - raise TypeError( - "Series of dtype `category` cannot perform the operation: " - f"{op}" - ) - rhs = self._wrap_binop_normalization(rhs) + def _binaryop(self, other: ColumnBinaryOperand, op: str) -> ColumnBase: + other = self._wrap_binop_normalization(other) # TODO: This is currently just here to make mypy happy, but eventually # we'll need to properly establish the APIs for these methods. - if not isinstance(rhs, CategoricalColumn): + if not isinstance(other, CategoricalColumn): raise ValueError # Note: at this stage we are guaranteed that the dtypes are equal. - if not self.ordered and op not in {"eq", "ne", "NULL_EQUALS"}: + if not self.ordered and op not in {"__eq__", "__ne__", "NULL_EQUALS"}: raise TypeError( "The only binary operations supported by unordered " "categorical columns are equality and inequality." ) - return self.as_numerical.binary_operator(op, rhs.as_numerical) + return self.as_numerical._binaryop(other.as_numerical, op) def normalize_binop_value(self, other: ScalarLike) -> CategoricalColumn: if isinstance(other, column.ColumnBase): if not isinstance(other, CategoricalColumn): - raise ValueError( - "Binary operations with categorical columns require both " - "columns to be categorical." - ) + return NotImplemented if other.dtype != self.dtype: raise TypeError( "Categoricals can only compare with the same type" ) return other - if isinstance(other, np.ndarray) and other.ndim == 0: - other = other.item() ary = cudf.utils.utils.scalar_broadcast_to( self._encode(other), size=len(self), dtype=self.codes.dtype diff --git a/python/cudf/cudf/core/column/column.py b/python/cudf/cudf/core/column/column.py index 2919b62b49c..401d5f82743 100644 --- a/python/cudf/cudf/core/column/column.py +++ b/python/cudf/cudf/core/column/column.py @@ -41,7 +41,7 @@ drop_nulls, ) from cudf._lib.transform import bools_to_mask -from cudf._typing import BinaryOperand, ColumnLike, Dtype, ScalarLike +from cudf._typing import ColumnLike, Dtype, ScalarLike from cudf.api.types import ( _is_non_decimal_numeric_dtype, _is_scalar_or_zero_d_array, @@ -68,7 +68,7 @@ ListDtype, StructDtype, ) -from cudf.core.mixins import Reducible +from cudf.core.mixins import BinaryOperand, Reducible from cudf.utils import utils from cudf.utils.dtypes import ( cudf_dtype_from_pa_type, @@ -78,7 +78,7 @@ pandas_dtypes_alias_to_cudf_alias, pandas_dtypes_to_np_dtypes, ) -from cudf.utils.utils import NotIterable, mask_dtype +from cudf.utils.utils import NotIterable, _array_ufunc, mask_dtype T = TypeVar("T", bound="ColumnBase") # TODO: This workaround allows type hints for `slice`, since `slice` is a @@ -86,7 +86,7 @@ Slice = TypeVar("Slice", bound=slice) -class ColumnBase(Column, Serializable, Reducible, NotIterable): +class ColumnBase(Column, Serializable, BinaryOperand, Reducible, NotIterable): _VALID_REDUCTIONS = { "any", "all", @@ -185,7 +185,10 @@ def equals(self, other: ColumnBase, check_dtypes: bool = False) -> bool: return False if check_dtypes and (self.dtype != other.dtype): return False - return self.binary_operator("NULL_EQUALS", other).all() + ret = self._binaryop(other, "NULL_EQUALS") + if ret is NotImplemented: + raise TypeError(f"Cannot compare equality with {type(other)}") + return ret.all() def all(self, skipna: bool = True) -> bool: # The skipna argument is only used for numerical columns. @@ -521,8 +524,10 @@ def __setitem__(self, key: Any, value: Any): self._mimic_inplace(out, inplace=True) def _wrap_binop_normalization(self, other): - if other is cudf.NA: + if other is cudf.NA or other is None: return cudf.Scalar(other, dtype=self.dtype) + if isinstance(other, np.ndarray) and other.ndim == 0: + other = other.item() return self.normalize_binop_value(other) def _scatter_by_slice( @@ -1029,50 +1034,8 @@ def __cuda_array_interface__(self): "`__cuda_array_interface__`" ) - def __add__(self, other): - return self.binary_operator("add", other) - - def __sub__(self, other): - return self.binary_operator("sub", other) - - def __mul__(self, other): - return self.binary_operator("mul", other) - - def __eq__(self, other): - return self.binary_operator("eq", other) - - def __ne__(self, other): - return self.binary_operator("ne", other) - - def __or__(self, other): - return self.binary_operator("or", other) - - def __and__(self, other): - return self.binary_operator("and", other) - - def __floordiv__(self, other): - return self.binary_operator("floordiv", other) - - def __truediv__(self, other): - return self.binary_operator("truediv", other) - - def __mod__(self, other): - return self.binary_operator("mod", other) - - def __pow__(self, other): - return self.binary_operator("pow", other) - - def __lt__(self, other): - return self.binary_operator("lt", other) - - def __gt__(self, other): - return self.binary_operator("gt", other) - - def __le__(self, other): - return self.binary_operator("le", other) - - def __ge__(self, other): - return self.binary_operator("ge", other) + def __array_ufunc__(self, ufunc, method, *inputs, **kwargs): + return _array_ufunc(self, ufunc, method, inputs, kwargs) def searchsorted( self, @@ -1133,14 +1096,6 @@ def unary_operator(self, unaryop: str): f"Operation {unaryop} not supported for dtype {self.dtype}." ) - def binary_operator( - self, op: str, other: BinaryOperand, reflect: bool = False - ) -> ColumnBase: - raise TypeError( - f"Operation {op} not supported between dtypes {self.dtype} and " - f"{other.dtype}." - ) - def normalize_binop_value( self, other: ScalarLike ) -> Union[ColumnBase, ScalarLike]: diff --git a/python/cudf/cudf/core/column/datetime.py b/python/cudf/cudf/core/column/datetime.py index b312f99829f..4ce5a70f0ec 100644 --- a/python/cudf/cudf/core/column/datetime.py +++ b/python/cudf/cudf/core/column/datetime.py @@ -7,14 +7,20 @@ import re from locale import nl_langinfo from types import SimpleNamespace -from typing import Any, Mapping, Sequence, Union, cast +from typing import Any, Mapping, Sequence, cast import numpy as np import pandas as pd import cudf from cudf import _lib as libcudf -from cudf._typing import DatetimeLikeScalar, Dtype, DtypeObj, ScalarLike +from cudf._typing import ( + ColumnBinaryOperand, + DatetimeLikeScalar, + Dtype, + DtypeObj, + ScalarLike, +) from cudf.api.types import is_scalar from cudf.core._compat import PANDAS_GE_120 from cudf.core.buffer import Buffer @@ -109,6 +115,19 @@ class DatetimeColumn(column.ColumnBase): The validity mask """ + _VALID_BINARY_OPERATIONS = { + "__eq__", + "__ne__", + "__lt__", + "__le__", + "__gt__", + "__ge__", + "__add__", + "__sub__", + "__radd__", + "__rsub__", + } + def __init__( self, data: Buffer, @@ -227,8 +246,6 @@ def normalize_binop_value(self, other: DatetimeLikeScalar) -> ScalarLike: if isinstance(other, (cudf.Scalar, ColumnBase, cudf.DateOffset)): return other - if isinstance(other, np.ndarray) and other.ndim == 0: - other = other.item() if isinstance(other, dt.datetime): other = np.datetime64(other) elif isinstance(other, dt.timedelta): @@ -254,10 +271,8 @@ def normalize_binop_value(self, other: DatetimeLikeScalar) -> ScalarLike: return cudf.Scalar(None, dtype=other.dtype) return cudf.Scalar(other) - elif other is None: - return cudf.Scalar(other, dtype=self.dtype) - raise TypeError(f"cannot normalize {type(other)}") + return NotImplemented @property def as_numerical(self) -> "cudf.core.column.NumericalColumn": @@ -388,43 +403,53 @@ def quantile( return pd.Timestamp(result, unit=self.time_unit) return result.astype(self.dtype) - def binary_operator( - self, - op: str, - rhs: Union[ColumnBase, "cudf.Scalar"], - reflect: bool = False, - ) -> ColumnBase: - rhs = self._wrap_binop_normalization(rhs) - if isinstance(rhs, cudf.DateOffset): - return rhs._datetime_binop(self, op, reflect=reflect) - - lhs: Union[ScalarLike, ColumnBase] = self - if op in {"eq", "ne", "lt", "gt", "le", "ge", "NULL_EQUALS"}: + def _binaryop(self, other: ColumnBinaryOperand, op: str) -> ColumnBase: + reflect, op = self._check_reflected_op(op) + other = self._wrap_binop_normalization(other) + if other is NotImplemented: + return NotImplemented + if isinstance(other, cudf.DateOffset): + return other._datetime_binop(self, op, reflect=reflect) + + # TODO: Figure out if I can reflect before we start these checks. That + # requires figuring out why _timedelta_add_result_dtype and + # _timedelta_sub_result_dtype are 1) not symmetric, and 2) different + # from each other. + if op in { + "__eq__", + "__ne__", + "__lt__", + "__gt__", + "__le__", + "__ge__", + "NULL_EQUALS", + }: out_dtype: Dtype = cudf.dtype(np.bool_) - elif op == "add" and pd.api.types.is_timedelta64_dtype(rhs.dtype): + elif op == "__add__" and pd.api.types.is_timedelta64_dtype( + other.dtype + ): out_dtype = cudf.core.column.timedelta._timedelta_add_result_dtype( - rhs, lhs + other, self ) - elif op == "sub" and pd.api.types.is_timedelta64_dtype(rhs.dtype): + elif op == "__sub__" and pd.api.types.is_timedelta64_dtype( + other.dtype + ): out_dtype = cudf.core.column.timedelta._timedelta_sub_result_dtype( - rhs if reflect else lhs, lhs if reflect else rhs + other if reflect else self, self if reflect else other ) - elif op == "sub" and pd.api.types.is_datetime64_dtype(rhs.dtype): + elif op == "__sub__" and pd.api.types.is_datetime64_dtype(other.dtype): units = ["s", "ms", "us", "ns"] - lhs_time_unit = cudf.utils.dtypes.get_time_unit(lhs) + lhs_time_unit = cudf.utils.dtypes.get_time_unit(self) lhs_unit = units.index(lhs_time_unit) - rhs_time_unit = cudf.utils.dtypes.get_time_unit(rhs) + rhs_time_unit = cudf.utils.dtypes.get_time_unit(other) rhs_unit = units.index(rhs_time_unit) out_dtype = np.dtype( f"timedelta64[{units[max(lhs_unit, rhs_unit)]}]" ) else: - raise TypeError( - f"Series of dtype {self.dtype} cannot perform " - f" the operation {op}" - ) + return NotImplemented - lhs, rhs = (self, rhs) if not reflect else (rhs, self) + lhs, rhs = (other, self) if reflect else (self, other) return libcudf.binaryop.binaryop(lhs, rhs, op, out_dtype) def fillna( diff --git a/python/cudf/cudf/core/column/decimal.py b/python/cudf/cudf/core/column/decimal.py index e011afbd0ff..f10e257d359 100644 --- a/python/cudf/cudf/core/column/decimal.py +++ b/python/cudf/cudf/core/column/decimal.py @@ -14,7 +14,7 @@ from cudf._lib.strings.convert.convert_fixed_point import ( from_decimal as cpp_from_decimal, ) -from cudf._typing import Dtype +from cudf._typing import ColumnBinaryOperand, Dtype from cudf.api.types import is_integer_dtype, is_scalar from cudf.core.buffer import Buffer from cudf.core.column import ColumnBase, as_column @@ -24,6 +24,7 @@ Decimal128Dtype, DecimalDtype, ) +from cudf.core.mixins import BinaryOperand from cudf.utils.utils import pa_mask_buffer_to_mask from .numerical_base import NumericalBaseColumn @@ -33,6 +34,7 @@ class DecimalBaseColumn(NumericalBaseColumn): """Base column for decimal32, decimal64 or decimal128 columns""" dtype: DecimalDtype + _VALID_BINARY_OPERATIONS = BinaryOperand._SUPPORTED_BINARY_OPERATIONS def as_decimal_column( self, dtype: Dtype, **kwargs @@ -60,18 +62,25 @@ def as_string_column( "cudf.core.column.StringColumn", as_column([], dtype="object") ) - def binary_operator(self, op, other, reflect=False): - if reflect: - self, other = other, self - # Decimals in libcudf don't support truediv, see - # https://github.com/rapidsai/cudf/pull/7435 for explanation. - op = op.replace("true", "") + # Decimals in libcudf don't support truediv, see + # https://github.com/rapidsai/cudf/pull/7435 for explanation. + def __truediv__(self, other): + return self._binaryop(other, "__div__") + + def __rtruediv__(self, other): + return self._binaryop(other, "__rdiv__") + + def _binaryop(self, other: ColumnBinaryOperand, op: str): + reflect, op = self._check_reflected_op(op) other = self._wrap_binop_normalization(other) + if other is NotImplemented: + return NotImplemented + lhs, rhs = (other, self) if reflect else (self, other) # Binary Arithmetics between decimal columns. `Scale` and `precision` # are computed outside of libcudf try: - if op in {"add", "sub", "mul", "div"}: + if op in {"__add__", "__sub__", "__mul__", "__div__"}: output_type = _get_decimal_type(self.dtype, other.dtype, op) result = libcudf.binaryop.binaryop( self, other, op, output_type @@ -79,7 +88,14 @@ def binary_operator(self, op, other, reflect=False): # TODO: Why is this necessary? Why isn't the result's # precision already set correctly based on output_type? result.dtype.precision = output_type.precision - elif op in {"eq", "ne", "lt", "gt", "le", "ge"}: + elif op in { + "__eq__", + "__ne__", + "__lt__", + "__gt__", + "__le__", + "__ge__", + }: result = libcudf.binaryop.binaryop(self, other, op, bool) except RuntimeError as e: if "Unsupported operator for these types" in str(e): @@ -128,10 +144,7 @@ def normalize_binop_value(self, other): self.dtype.__class__(self.dtype.__class__.MAX_PRECISION, 0) ) elif not isinstance(other, DecimalBaseColumn): - raise TypeError( - f"Binary operations are not supported between" - f"{str(type(self))} and {str(type(other))}" - ) + return NotImplemented elif not isinstance(self.dtype, other.dtype.__class__): # This branch occurs if we have a DecimalBaseColumn of a # different size (e.g. 64 instead of 32). @@ -151,7 +164,7 @@ def normalize_binop_value(self, other): return other elif is_scalar(other) and isinstance(other, (int, Decimal)): return cudf.Scalar(Decimal(other)) - raise TypeError(f"cannot normalize {type(other)}") + return NotImplemented def _decimal_quantile( self, q: Union[float, Sequence[float]], interpolation: str, exact: bool @@ -350,13 +363,13 @@ def _get_decimal_type(lhs_dtype, rhs_dtype, op): p1, p2 = lhs_dtype.precision, rhs_dtype.precision s1, s2 = lhs_dtype.scale, rhs_dtype.scale - if op in ("add", "sub"): + if op in {"__add__", "__sub__"}: scale = max(s1, s2) precision = scale + max(p1 - s1, p2 - s2) + 1 - elif op == "mul": + elif op == "__mul__": scale = s1 + s2 precision = p1 + p2 + 1 - elif op == "div": + elif op == "__div__": scale = max(6, s1 + p2 + 1) precision = p1 - s1 + s2 + scale else: diff --git a/python/cudf/cudf/core/column/lists.py b/python/cudf/cudf/core/column/lists.py index 53ab79542e2..0df5be2d862 100644 --- a/python/cudf/cudf/core/column/lists.py +++ b/python/cudf/cudf/core/column/lists.py @@ -19,7 +19,7 @@ sort_lists, ) from cudf._lib.strings.convert.convert_lists import format_list_column -from cudf._typing import BinaryOperand, ColumnLike, Dtype, ScalarLike +from cudf._typing import ColumnBinaryOperand, ColumnLike, Dtype, ScalarLike from cudf.api.types import _is_non_decimal_numeric_dtype, is_list_dtype from cudf.core.buffer import Buffer from cudf.core.column import ColumnBase, as_column, column @@ -29,6 +29,7 @@ class ListColumn(ColumnBase): dtype: ListDtype + _VALID_BINARY_OPERATIONS = {"__add__", "__radd__"} def __init__( self, size, dtype, mask=None, offset=0, null_count=None, children=(), @@ -92,50 +93,14 @@ def base_size(self): # avoid it being negative return max(0, len(self.base_children[0]) - 1) - def binary_operator( - self, binop: str, other: BinaryOperand, reflect: bool = False - ) -> ColumnBase: - """ - Calls a binary operator *binop* on operands *self* - and *other*. - - Parameters - ---------- - self, other : list columns - - binop : binary operator - Only "add" operator is currently being supported - for lists concatenation functions - - reflect : boolean, default False - If ``True``, swap the order of the operands. See - https://docs.python.org/3/reference/datamodel.html#object.__ror__ - for more information on when this is necessary. - - Returns - ------- - Series : the output dtype is determined by the - input operands. - - Examples - -------- - >>> import cudf - >>> gdf = cudf.DataFrame({'val': [['a', 'a'], ['b'], ['c']]}) - >>> gdf - val - 0 [a, a] - 1 [b] - 2 [c] - >>> gdf['val'] + gdf['val'] - 0 [a, a, a, a] - 1 [b, b] - 2 [c, c] - Name: val, dtype: list - - """ + def _binaryop(self, other: ColumnBinaryOperand, op: str) -> ColumnBase: + # Lists only support __add__, which concatenates lists. + reflect, op = self._check_reflected_op(op) other = self._wrap_binop_normalization(other) + if other is NotImplemented: + return NotImplemented if isinstance(other.dtype, ListDtype): - if binop == "add": + if op == "__add__": return concatenate_rows( cudf.core.frame.Frame({0: self, 1: other}) ) @@ -255,6 +220,8 @@ def __cuda_array_interface__(self): ) def normalize_binop_value(self, other): + if not isinstance(other, ListColumn): + return NotImplemented return other def _with_type_metadata( diff --git a/python/cudf/cudf/core/column/numerical.py b/python/cudf/cudf/core/column/numerical.py index 015524b841e..c9bc3c59aea 100644 --- a/python/cudf/cudf/core/column/numerical.py +++ b/python/cudf/cudf/core/column/numerical.py @@ -21,7 +21,13 @@ import cudf from cudf import _lib as libcudf from cudf._lib.stream_compaction import drop_nulls -from cudf._typing import BinaryOperand, ColumnLike, Dtype, DtypeObj, ScalarLike +from cudf._typing import ( + ColumnBinaryOperand, + ColumnLike, + Dtype, + DtypeObj, + ScalarLike, +) from cudf.api.types import ( is_bool_dtype, is_float_dtype, @@ -37,6 +43,7 @@ string, ) from cudf.core.dtypes import CategoricalDtype +from cudf.core.mixins import BinaryOperand from cudf.utils import cudautils, utils from cudf.utils.dtypes import ( NUMERIC_TYPES, @@ -63,6 +70,7 @@ class NumericalColumn(NumericalBaseColumn): """ _nan_count: Optional[int] + _VALID_BINARY_OPERATIONS = BinaryOperand._SUPPORTED_BINARY_OPERATIONS def __init__( self, @@ -150,9 +158,7 @@ def unary_operator(self, unaryop: Union[str, Callable]) -> ColumnBase: unaryop = libcudf.unary.UnaryOp[unaryop.upper()] return libcudf.unary.unary_operation(self, unaryop) - def binary_operator( - self, binop: str, rhs: BinaryOperand, reflect: bool = False, - ) -> ColumnBase: + def _binaryop(self, other: ColumnBinaryOperand, op: str) -> ColumnBase: int_float_dtype_mapping = { np.int8: np.float32, np.int16: np.float32, @@ -165,23 +171,19 @@ def binary_operator( np.bool_: np.float32, } - if binop in {"truediv", "rtruediv"}: + if op in {"__truediv__", "__rtruediv__"}: # Division with integer types results in a suitable float. if (truediv_type := int_float_dtype_mapping.get(self.dtype.type)) : - return self.astype(truediv_type).binary_operator( - binop, rhs, reflect - ) + return self.astype(truediv_type)._binaryop(other, op) - rhs = self._wrap_binop_normalization(rhs) + reflect, op = self._check_reflected_op(op) + if (other := self._wrap_binop_normalization(other)) is NotImplemented: + return NotImplemented out_dtype = self.dtype - if rhs is not None: - if isinstance(rhs, cudf.core.column.DecimalBaseColumn): - dtyp = rhs.dtype.__class__(rhs.dtype.MAX_PRECISION, 0) - return self.as_decimal_column(dtyp).binary_operator(binop, rhs) - - out_dtype = np.result_type(self.dtype, rhs.dtype) - if binop in {"mod", "floordiv"}: - tmp = self if reflect else rhs + if other is not None: + out_dtype = np.result_type(self.dtype, other.dtype) + if op in {"__mod__", "__floordiv__"}: + tmp = self if reflect else other # Guard against division by zero for integers. if ( (tmp.dtype.type in int_float_dtype_mapping) @@ -195,31 +197,29 @@ def binary_operator( ): out_dtype = cudf.dtype("float64") - if binop in { - "l_and", - "l_or", - "lt", - "gt", - "le", - "ge", - "eq", - "ne", + if op in { + "__lt__", + "__gt__", + "__le__", + "__ge__", + "__eq__", + "__ne__", "NULL_EQUALS", }: out_dtype = "bool" - if binop in {"and", "or", "xor"}: - if is_float_dtype(self.dtype) or is_float_dtype(rhs): + if op in {"__and__", "__or__", "__xor__"}: + if is_float_dtype(self.dtype) or is_float_dtype(other): raise TypeError( - f"Operation 'bitwise {binop}' not supported between " + f"Operation 'bitwise {op[2:-2]}' not supported between " f"{self.dtype.type.__name__} and " - f"{rhs.dtype.type.__name__}" + f"{other.dtype.type.__name__}" ) - if is_bool_dtype(self.dtype) or is_bool_dtype(rhs): + if is_bool_dtype(self.dtype) or is_bool_dtype(other): out_dtype = "bool" - lhs, rhs = (self, rhs) if not reflect else (rhs, self) - return libcudf.binaryop.binaryop(lhs, rhs, binop, out_dtype) + lhs, rhs = (other, self) if reflect else (self, other) + return libcudf.binaryop.binaryop(lhs, rhs, op, out_dtype) def nans_to_nulls(self: NumericalColumn) -> NumericalColumn: # Only floats can contain nan. @@ -232,15 +232,8 @@ def normalize_binop_value( self, other: ScalarLike ) -> Union[ColumnBase, ScalarLike]: if isinstance(other, ColumnBase): - if not isinstance( - other, (NumericalColumn, cudf.core.column.DecimalBaseColumn,), - ): - raise TypeError( - f"Binary operations are not supported between " - f"{type(self)}and {type(other)}" - ) - return other - if other is None: + if not isinstance(other, NumericalColumn): + return NotImplemented return other if isinstance(other, cudf.Scalar): if self.dtype == other.dtype: @@ -248,8 +241,6 @@ def normalize_binop_value( # expensive device-host transfer just to # adjust the dtype other = other.value - elif isinstance(other, np.ndarray) and other.ndim == 0: - other = other.item() other_dtype = np.min_scalar_type(other) if other_dtype.kind in {"b", "i", "u", "f"}: if isinstance(other, cudf.Scalar): @@ -270,7 +261,7 @@ def normalize_binop_value( data=Buffer(ary), dtype=ary.dtype, mask=self.mask, ) else: - raise TypeError(f"cannot broadcast {type(other)}") + return NotImplemented def int2ip(self) -> "cudf.core.column.StringColumn": if self.dtype != cudf.dtype("int64"): diff --git a/python/cudf/cudf/core/column/string.py b/python/cudf/cudf/core/column/string.py index 82be924dfbc..95bb06ebb0c 100644 --- a/python/cudf/cudf/core/column/string.py +++ b/python/cudf/cudf/core/column/string.py @@ -50,7 +50,13 @@ def str_to_boolean(column: StringColumn): if TYPE_CHECKING: - from cudf._typing import ColumnLike, Dtype, ScalarLike, SeriesOrIndex + from cudf._typing import ( + ColumnBinaryOperand, + ColumnLike, + Dtype, + ScalarLike, + SeriesOrIndex, + ) _str_to_numeric_typecast_functions = { @@ -5025,6 +5031,26 @@ class StringColumn(column.ColumnBase): _start_offset: Optional[int] _end_offset: Optional[int] + _VALID_BINARY_OPERATIONS = { + "__eq__", + "__ne__", + "__lt__", + "__le__", + "__gt__", + "__ge__", + "__add__", + "__radd__", + # These operators aren't actually supported, they only exist to allow + # empty column binops with scalars of arbitrary other dtypes. See + # the _binaryop method for more information. + "__sub__", + "__mul__", + "__mod__", + "__pow__", + "__truediv__", + "__floordiv__", + } + def __init__( self, mask: Buffer = None, @@ -5434,50 +5460,49 @@ def normalize_binop_value( and other.dtype == "object" ): return other - if isinstance(other, str) or other is None: - return utils.scalar_broadcast_to( - other, size=len(self), dtype="object" - ) - if isinstance(other, np.ndarray) and other.ndim == 0: - return utils.scalar_broadcast_to( - other.item(), size=len(self), dtype="object" - ) - raise TypeError(f"cannot broadcast {type(other)}") + if isinstance(other, str): + return cudf.Scalar(other) + return NotImplemented - def binary_operator( - self, op: str, rhs, reflect: bool = False + def _binaryop( + self, other: ColumnBinaryOperand, op: str ) -> "column.ColumnBase": - # Handle object columns that are empty or all nulls when performing - # binary operations - # See https://github.com/pandas-dev/pandas/issues/46332 + reflect, op = self._check_reflected_op(op) + # Due to https://github.com/pandas-dev/pandas/issues/46332 we need to + # support binary operations between empty or all null string columns + # and columns of other dtypes, even if those operations would otherwise + # be invalid. For example, you cannot divide strings, but pandas allows + # division between an empty string column and a (nonempty) integer + # column. Ideally we would disable these operators entirely, but until + # the above issue is resolved we cannot avoid this problem. if self.null_count == len(self): if op in { - "add", - "sub", - "mul", - "mod", - "pow", - "truediv", - "floordiv", - "radd", - "rsub", - "rmul", - "rmod", - "rpow", - "rtruediv", - "rfloordiv", + "__add__", + "__sub__", + "__mul__", + "__mod__", + "__pow__", + "__truediv__", + "__floordiv__", }: return self - elif op in {"eq", "lt", "le", "gt", "ge"}: + elif op in {"__eq__", "__lt__", "__le__", "__gt__", "__ge__"}: return self.notnull() - elif op == "ne": + elif op == "__ne__": return self.isnull() - rhs = self._wrap_binop_normalization(rhs) + other = self._wrap_binop_normalization(other) + if other is NotImplemented: + return NotImplemented + + if isinstance(other, (StringColumn, str, cudf.Scalar)): + if op == "__add__": + if isinstance(other, cudf.Scalar): + other = utils.scalar_broadcast_to( + other, size=len(self), dtype="object" + ) + lhs, rhs = (other, self) if reflect else (self, other) - if isinstance(rhs, (StringColumn, str, cudf.Scalar)): - lhs, rhs = (rhs, self) if reflect else (self, rhs) - if op == "add": return cast( "column.ColumnBase", libstrings.concatenate( @@ -5486,13 +5511,20 @@ def binary_operator( na_rep=cudf.Scalar(None, "str"), ), ) - elif op in {"eq", "ne", "gt", "lt", "ge", "le", "NULL_EQUALS"}: + elif op in { + "__eq__", + "__ne__", + "__gt__", + "__lt__", + "__ge__", + "__le__", + "NULL_EQUALS", + }: + lhs, rhs = (other, self) if reflect else (self, other) return libcudf.binaryop.binaryop( lhs=lhs, rhs=rhs, op=op, dtype="bool" ) - raise TypeError( - f"{op} not supported between {type(self)} and {type(rhs)}" - ) + return NotImplemented @copy_docstring(column.ColumnBase.view) def view(self, dtype) -> "cudf.core.column.ColumnBase": diff --git a/python/cudf/cudf/core/column/timedelta.py b/python/cudf/cudf/core/column/timedelta.py index 66e6271a4d1..11d295a6190 100644 --- a/python/cudf/cudf/core/column/timedelta.py +++ b/python/cudf/cudf/core/column/timedelta.py @@ -11,7 +11,12 @@ import cudf from cudf import _lib as libcudf -from cudf._typing import BinaryOperand, DatetimeLikeScalar, Dtype, DtypeObj +from cudf._typing import ( + ColumnBinaryOperand, + DatetimeLikeScalar, + Dtype, + DtypeObj, +) from cudf.api.types import is_scalar from cudf.core.buffer import Buffer from cudf.core.column import ColumnBase, column, string @@ -46,6 +51,27 @@ class TimeDeltaColumn(column.ColumnBase): If None, it is calculated automatically. """ + _VALID_BINARY_OPERATIONS = { + "__eq__", + "__ne__", + "__lt__", + "__le__", + "__gt__", + "__ge__", + "__add__", + "__sub__", + "__mul__", + "__mod__", + "__truediv__", + "__floordiv__", + "__radd__", + "__rsub__", + "__rmul__", + "__rmod__", + "__rtruediv__", + "__rfloordiv__", + } + def __init__( self, data: Buffer, @@ -125,97 +151,106 @@ def to_pandas( return pd_series - def _binary_op_mul(self, rhs: BinaryOperand) -> DtypeObj: - if rhs.dtype.kind in ("f", "i", "u"): + def _binary_op_mul(self, other: ColumnBinaryOperand) -> DtypeObj: + if other.dtype.kind in ("f", "i", "u"): out_dtype = self.dtype else: raise TypeError( - f"Multiplication of {self.dtype} with {rhs.dtype} " + f"Multiplication of {self.dtype} with {other.dtype} " f"cannot be performed." ) return out_dtype - def _binary_op_mod(self, rhs: BinaryOperand) -> DtypeObj: - if pd.api.types.is_timedelta64_dtype(rhs.dtype): - out_dtype = determine_out_dtype(self.dtype, rhs.dtype) - elif rhs.dtype.kind in ("f", "i", "u"): + def _binary_op_mod(self, other: ColumnBinaryOperand) -> DtypeObj: + if pd.api.types.is_timedelta64_dtype(other.dtype): + out_dtype = determine_out_dtype(self.dtype, other.dtype) + elif other.dtype.kind in ("f", "i", "u"): out_dtype = self.dtype else: raise TypeError( - f"Modulus of {self.dtype} with {rhs.dtype} " + f"Modulo of {self.dtype} with {other.dtype} " f"cannot be performed." ) return out_dtype - def _binary_op_lt_gt_le_ge_eq_ne(self, rhs: BinaryOperand) -> DtypeObj: - if pd.api.types.is_timedelta64_dtype(rhs.dtype): + def _binary_op_lt_gt_le_ge_eq_ne( + self, other: ColumnBinaryOperand + ) -> DtypeObj: + if pd.api.types.is_timedelta64_dtype(other.dtype): return np.bool_ raise TypeError( f"Invalid comparison between dtype={self.dtype}" - f" and {rhs.dtype}" + f" and {other.dtype}" ) def _binary_op_div( - self, rhs: BinaryOperand, op: str - ) -> Tuple["column.ColumnBase", BinaryOperand, DtypeObj]: - lhs = self # type: column.ColumnBase - if pd.api.types.is_timedelta64_dtype(rhs.dtype): - common_dtype = determine_out_dtype(self.dtype, rhs.dtype) - lhs = lhs.astype(common_dtype).astype("float64") - if isinstance(rhs, cudf.Scalar): - if rhs.is_valid(): - rhs = rhs.value.astype(common_dtype).astype("float64") + self, other: ColumnBinaryOperand, op: str + ) -> Tuple["column.ColumnBase", ColumnBinaryOperand, DtypeObj]: + this: ColumnBase = self + if pd.api.types.is_timedelta64_dtype(other.dtype): + common_dtype = determine_out_dtype(self.dtype, other.dtype) + this = self.astype(common_dtype).astype("float64") + if isinstance(other, cudf.Scalar): + if other.is_valid(): + other = other.value.astype(common_dtype).astype("float64") else: - rhs = cudf.Scalar(None, "float64") + other = cudf.Scalar(None, "float64") else: - rhs = rhs.astype(common_dtype).astype("float64") + other = other.astype(common_dtype).astype("float64") - out_dtype = cudf.dtype("float64" if op == "truediv" else "int64") - elif rhs.dtype.kind in ("f", "i", "u"): + out_dtype = cudf.dtype( + "float64" if op == "__truediv__" else "int64" + ) + elif other.dtype.kind in ("f", "i", "u"): out_dtype = self.dtype else: raise TypeError( - f"Division of {self.dtype} with {rhs.dtype} " + f"Division of {self.dtype} with {other.dtype} " f"cannot be performed." ) - return lhs, rhs, out_dtype + return this, other, out_dtype - def binary_operator( - self, op: str, rhs: BinaryOperand, reflect: bool = False + def _binaryop( + self, other: ColumnBinaryOperand, op: str ) -> "column.ColumnBase": - rhs = self._wrap_binop_normalization(rhs) - lhs, rhs = self, rhs - - if op in {"eq", "ne", "lt", "gt", "le", "ge", "NULL_EQUALS"}: - out_dtype = self._binary_op_lt_gt_le_ge_eq_ne(rhs) - elif op == "mul": - out_dtype = self._binary_op_mul(rhs) - elif op == "mod": - out_dtype = self._binary_op_mod(rhs) - elif op in {"truediv", "floordiv"}: - lhs, rhs, out_dtype = self._binary_op_div(rhs, op) # type: ignore - op = "truediv" - elif op == "add": - out_dtype = _timedelta_add_result_dtype(lhs, rhs) - elif op == "sub": - out_dtype = _timedelta_sub_result_dtype(lhs, rhs) + reflect, op = self._check_reflected_op(op) + other = self._wrap_binop_normalization(other) + if other is NotImplemented: + return NotImplemented + + this: ColumnBinaryOperand = self + if op in { + "__eq__", + "__ne__", + "__lt__", + "__gt__", + "__le__", + "__ge__", + "NULL_EQUALS", + }: + out_dtype = self._binary_op_lt_gt_le_ge_eq_ne(other) + elif op == "__mul__": + out_dtype = self._binary_op_mul(other) + elif op == "__mod__": + out_dtype = self._binary_op_mod(other) + elif op in {"__truediv__", "__floordiv__"}: + this, other, out_dtype = self._binary_op_div(other, op) + op = "__truediv__" + elif op == "__add__": + out_dtype = _timedelta_add_result_dtype(self, other) + elif op == "__sub__": + out_dtype = _timedelta_sub_result_dtype(self, other) else: - raise TypeError( - f"Series of dtype {self.dtype} cannot perform " - f"the operation {op}" - ) + return NotImplemented - if reflect: - lhs, rhs = rhs, lhs # type: ignore + lhs, rhs = (other, this) if reflect else (this, other) return libcudf.binaryop.binaryop(lhs, rhs, op, out_dtype) - def normalize_binop_value(self, other) -> BinaryOperand: + def normalize_binop_value(self, other) -> ColumnBinaryOperand: if isinstance(other, (ColumnBase, cudf.Scalar)): return other - if isinstance(other, np.ndarray) and other.ndim == 0: - other = other.item() if isinstance(other, dt.timedelta): other = np.timedelta64(other) elif isinstance(other, pd.Timestamp): @@ -235,10 +270,7 @@ def normalize_binop_value(self, other) -> BinaryOperand: return cudf.Scalar(other) elif np.isscalar(other): return cudf.Scalar(other) - elif other is None: - return cudf.Scalar(other, dtype=self.dtype) - else: - raise TypeError(f"cannot normalize {type(other)}") + return NotImplemented @property def as_numerical(self) -> "cudf.core.column.NumericalColumn": @@ -556,7 +588,7 @@ def determine_out_dtype(lhs_dtype: Dtype, rhs_dtype: Dtype) -> Dtype: def _timedelta_add_result_dtype( - lhs: BinaryOperand, rhs: BinaryOperand + lhs: ColumnBinaryOperand, rhs: ColumnBinaryOperand ) -> Dtype: if pd.api.types.is_timedelta64_dtype(rhs.dtype): out_dtype = determine_out_dtype(lhs.dtype, rhs.dtype) @@ -577,7 +609,7 @@ def _timedelta_add_result_dtype( def _timedelta_sub_result_dtype( - lhs: BinaryOperand, rhs: BinaryOperand + lhs: ColumnBinaryOperand, rhs: ColumnBinaryOperand ) -> Dtype: if pd.api.types.is_timedelta64_dtype( lhs.dtype diff --git a/python/cudf/cudf/core/frame.py b/python/cudf/cudf/core/frame.py index a9d7fce9d9b..d78744a719f 100644 --- a/python/cudf/cudf/core/frame.py +++ b/python/cudf/cudf/core/frame.py @@ -3,6 +3,7 @@ from __future__ import annotations import copy +import operator import pickle import warnings from collections import abc @@ -38,7 +39,6 @@ ColumnBase, as_column, build_categorical_column, - column_empty, deserialize_columns, serialize_columns, ) @@ -49,54 +49,11 @@ from cudf.utils import ioutils from cudf.utils.docutils import copy_docstring from cudf.utils.dtypes import find_common_type -from cudf.utils.utils import _cudf_nvtx_annotate +from cudf.utils.utils import _array_ufunc, _cudf_nvtx_annotate T = TypeVar("T", bound="Frame") -# Mapping from ufuncs to the corresponding binary operators. -_ufunc_binary_operations = { - # Arithmetic binary operations. - "add": "add", - "subtract": "sub", - "multiply": "mul", - "matmul": "matmul", - "divide": "truediv", - "true_divide": "truediv", - "floor_divide": "floordiv", - "power": "pow", - "float_power": "pow", - "remainder": "mod", - "mod": "mod", - "fmod": "mod", - # Bitwise binary operations. - "bitwise_and": "and", - "bitwise_or": "or", - "bitwise_xor": "xor", - # Comparison binary operators - "greater": "gt", - "greater_equal": "ge", - "less": "lt", - "less_equal": "le", - "not_equal": "ne", - "equal": "eq", -} - -# These operators need to be mapped to their inverses when performing a -# reflected ufunc operation because no reflected version of the operators -# themselves exist. When these operators are invoked directly (not via -# __array_ufunc__) Python takes care of calling the inverse operation. -_ops_without_reflection = { - "gt": "lt", - "ge": "le", - "lt": "gt", - "le": "ge", - # ne and eq are symmetric, so they are their own inverse op - "ne": "ne", - "eq": "eq", -} - - class Frame(BinaryOperand, Scannable): """A collection of Column objects with an optional index. @@ -2482,30 +2439,6 @@ def _unaryop(self, op): zip(self._column_names, data_columns), self._index ) - def _binaryop( - self, other: T, op: str, fill_value: Any = None, *args, **kwargs, - ) -> Frame: - """Perform a binary operation between two frames. - - Parameters - ---------- - other : Frame - The second operand. - op : str - The operation to perform. - fill_value : Any, default None - The value to replace null values with. If ``None``, nulls are not - filled before the operation. - - Returns - ------- - Frame - A new instance containing the result of the operation. - """ - raise NotImplementedError( - f"Binary operations are not supported for {self.__class__}" - ) - @classmethod @_cudf_nvtx_annotate def _colwise_binop( @@ -2535,8 +2468,6 @@ def _colwise_binop( A dict of columns constructed from the result of performing the requested operation on the operands. """ - fn = fn[2:-2] - # Now actually perform the binop on the columns in left and right. output = {} for ( @@ -2567,11 +2498,9 @@ def _colwise_binop( # are not numerical using the new binops mixin. outcol = ( - left_column.binary_operator(fn, right_column, reflect=reflect) - if right_column is not None - else column_empty( - left_column.size, left_column.dtype, masked=True - ) + getattr(operator, fn)(right_column, left_column) + if reflect + else getattr(operator, fn)(left_column, right_column) ) if output_mask is not None: @@ -2581,44 +2510,8 @@ def _colwise_binop( return output - # For more detail on this function and how it should work, see - # https://numpy.org/doc/stable/reference/ufuncs.html def __array_ufunc__(self, ufunc, method, *inputs, **kwargs): - # We don't currently support reduction, accumulation, etc. We also - # don't support any special kwargs or higher arity ufuncs than binary. - if method != "__call__" or kwargs or ufunc.nin > 2: - return NotImplemented - - fname = ufunc.__name__ - if fname in _ufunc_binary_operations: - reflect = self is not inputs[0] - other = inputs[0] if reflect else inputs[1] - - op = _ufunc_binary_operations[fname] - if reflect and op in _ops_without_reflection: - op = _ops_without_reflection[op] - reflect = False - op = f"__{'r' if reflect else ''}{op}__" - - # Float_power returns float irrespective of the input type. - if fname == "float_power": - return getattr(self, op)(other).astype(float) - return getattr(self, op)(other) - - # Special handling for various unary operations. - if fname == "negative": - return self * -1 - if fname == "positive": - return self.copy(deep=True) - if fname == "invert": - return ~self - if fname == "absolute": - return self.abs() - if fname == "fabs": - return self.abs().astype(np.float64) - - # None is a sentinel used by subclasses to trigger cupy dispatch. - return None + return _array_ufunc(self, ufunc, method, inputs, kwargs) def _apply_cupy_ufunc_to_operands( self, ufunc, cupy_func, operands, **kwargs diff --git a/python/cudf/cudf/core/index.py b/python/cudf/cudf/core/index.py index e60cf1f2103..d935da3bd14 100644 --- a/python/cudf/cudf/core/index.py +++ b/python/cudf/cudf/core/index.py @@ -854,9 +854,7 @@ def _from_data( def _binaryop( self, other: T, op: str, fill_value: Any = None, *args, **kwargs, ) -> SingleColumnFrame: - reflect = self._is_reflected_op(op) - if reflect: - op = op[:2] + op[3:] + reflect, op = self._check_reflected_op(op) operands = self._make_operands_for_binop(other, fill_value, reflect) if operands is NotImplemented: return NotImplemented diff --git a/python/cudf/cudf/core/indexed_frame.py b/python/cudf/cudf/core/indexed_frame.py index 7e116607017..b8077d7d28b 100644 --- a/python/cudf/cudf/core/indexed_frame.py +++ b/python/cudf/cudf/core/indexed_frame.py @@ -2118,9 +2118,7 @@ def _binaryop( *args, **kwargs, ): - reflect = self._is_reflected_op(op) - if reflect: - op = op[:2] + op[3:] + reflect, op = self._check_reflected_op(op) operands, out_index = self._make_operands_and_index_for_binop( other, op, fill_value, reflect, can_reindex ) diff --git a/python/cudf/cudf/core/mixins/binops.py b/python/cudf/cudf/core/mixins/binops.py index 773b47b62b2..e07977ed4c3 100644 --- a/python/cudf/cudf/core/mixins/binops.py +++ b/python/cudf/cudf/core/mixins/binops.py @@ -48,9 +48,25 @@ }, ) +# TODO: See if there is a better approach to these two issues: 1) The mixin +# assumes a single standard parameter, whereas binops have two, and 2) we need +# a way to determine reflected vs normal ops. -def _is_reflected_op(op): - return op[2] == "r" and op != "__rshift__" +def _binaryop(self, other, op: str): + """The core binary_operation function. -BinaryOperand._is_reflected_op = staticmethod(_is_reflected_op) + Must be overridden by subclasses, the default implementation raises a + NotImplementedError. + """ + raise NotImplementedError + + +def _check_reflected_op(op): + if (reflect := op[2] == "r" and op != "__rshift__") : + op = op[:2] + op[3:] + return reflect, op + + +BinaryOperand._binaryop = _binaryop +BinaryOperand._check_reflected_op = staticmethod(_check_reflected_op) diff --git a/python/cudf/cudf/core/mixins/binops.pyi b/python/cudf/cudf/core/mixins/binops.pyi index 45093cd04d4..ff47cdce418 100644 --- a/python/cudf/cudf/core/mixins/binops.pyi +++ b/python/cudf/cudf/core/mixins/binops.pyi @@ -1,10 +1,16 @@ # Copyright (c) 2022, NVIDIA CORPORATION. -from typing import Set +from typing import Any, Set, Tuple, TypeVar + +# Note: It may be possible to define a narrower bound here eventually. +BinaryOperandType = TypeVar("BinaryOperandType", bound="Any") class BinaryOperand: _SUPPORTED_BINARY_OPERATIONS: Set + def _binaryop(self, other: BinaryOperandType, op: str): + ... + def __add__(self, other): ... @@ -84,5 +90,5 @@ class BinaryOperand: ... @staticmethod - def _is_reflected_op(op) -> bool: + def _check_reflected_op(op) -> Tuple[bool, str]: ... diff --git a/python/cudf/cudf/core/tools/datetimes.py b/python/cudf/cudf/core/tools/datetimes.py index 62c31691ac1..b110a10e1e7 100644 --- a/python/cudf/cudf/core/tools/datetimes.py +++ b/python/cudf/cudf/core/tools/datetimes.py @@ -1,4 +1,4 @@ -# Copyright (c) 2019-2021, NVIDIA CORPORATION. +# Copyright (c) 2019-2022, NVIDIA CORPORATION. import math import re @@ -587,12 +587,12 @@ def _combine_kwargs_to_seconds(self, **kwargs): def _datetime_binop( self, datetime_col, op, reflect=False ) -> column.DatetimeColumn: - if reflect and op == "sub": + if reflect and op == "__sub__": raise TypeError( f"Can not subtract a {type(datetime_col).__name__}" f" from a {type(self).__name__}" ) - if op not in {"add", "sub"}: + if op not in {"__add__", "__sub__"}: raise TypeError( f"{op} not supported between {type(self).__name__}" f" and {type(datetime_col).__name__}" @@ -604,7 +604,7 @@ def _datetime_binop( for unit, value in self._scalars.items(): if unit != "months": - value = -value if op == "sub" else value + value = -value if op == "__sub__" else value datetime_col += cudf.core.column.as_column( value, length=len(datetime_col) ) @@ -613,7 +613,7 @@ def _datetime_binop( def _generate_months_column(self, size, op): months = self._scalars["months"] - months = -months if op == "sub" else months + months = -months if op == "__sub__" else months # TODO: pass a scalar instead of constructing a column # https://github.com/rapidsai/cudf/issues/6990 col = cudf.core.column.as_column(months, length=size) diff --git a/python/cudf/cudf/tests/test_list.py b/python/cudf/cudf/tests/test_list.py index fc9ad9711d1..8cc65de739e 100644 --- a/python/cudf/cudf/tests/test_list.py +++ b/python/cudf/cudf/tests/test_list.py @@ -381,7 +381,7 @@ def test_concatenate_rows_of_lists(): def test_concatenate_list_with_nonlist(): - with pytest.raises(TypeError, match="can only concatenate list to list"): + with pytest.raises(TypeError): gdf1 = cudf.DataFrame({"A": [["a", "c"], ["b", "d"], ["c", "d"]]}) gdf2 = cudf.DataFrame({"A": ["a", "b", "c"]}) gdf1["A"] + gdf2["A"] diff --git a/python/cudf/cudf/tests/test_timedelta.py b/python/cudf/cudf/tests/test_timedelta.py index e371cd16180..2623b755cfb 100644 --- a/python/cudf/cudf/tests/test_timedelta.py +++ b/python/cudf/cudf/tests/test_timedelta.py @@ -1175,8 +1175,7 @@ def test_timedelta_invalid_ops(): lfunc_args_and_kwargs=([psr, dt_psr],), rfunc_args_and_kwargs=([sr, dt_sr],), expected_error_message=re.escape( - f"Modulus of {sr.dtype} with {dt_sr.dtype} " - f"cannot be performed." + f"Modulo of {sr.dtype} with {dt_sr.dtype} " f"cannot be performed." ), ) @@ -1186,7 +1185,7 @@ def test_timedelta_invalid_ops(): lfunc_args_and_kwargs=([psr, "a"],), rfunc_args_and_kwargs=([sr, "a"],), expected_error_message=re.escape( - f"Modulus of {sr.dtype} with {np.dtype('object')} " + f"Modulo of {sr.dtype} with {np.dtype('object')} " f"cannot be performed." ), ) @@ -1285,9 +1284,7 @@ def test_timedelta_invalid_ops(): rfunc=operator.xor, lfunc_args_and_kwargs=([psr, psr],), rfunc_args_and_kwargs=([sr, sr],), - expected_error_message=re.escape( - f"Series of dtype {sr.dtype} cannot perform the operation xor" - ), + compare_error_message=False, ) diff --git a/python/cudf/cudf/utils/applyutils.py b/python/cudf/cudf/utils/applyutils.py index 593965046e6..89331b933a8 100644 --- a/python/cudf/cudf/utils/applyutils.py +++ b/python/cudf/cudf/utils/applyutils.py @@ -1,4 +1,4 @@ -# Copyright (c) 2018, NVIDIA CORPORATION. +# Copyright (c) 2018-2022, NVIDIA CORPORATION. import functools from typing import Any, Dict @@ -103,7 +103,7 @@ def apply_chunks( return applychunks.run(df, chunks=chunks, tpb=tpb) -def make_aggregate_nullmask(df, columns=None, op="and"): +def make_aggregate_nullmask(df, columns=None, op="__and__"): out_mask = None for k in columns or df._data: diff --git a/python/cudf/cudf/utils/utils.py b/python/cudf/cudf/utils/utils.py index 1bd3fa7558e..ed714182576 100644 --- a/python/cudf/cudf/utils/utils.py +++ b/python/cudf/cudf/utils/utils.py @@ -24,6 +24,92 @@ mask_dtype = cudf.dtype(np.int32) mask_bitsize = mask_dtype.itemsize * 8 +# Mapping from ufuncs to the corresponding binary operators. +_ufunc_binary_operations = { + # Arithmetic binary operations. + "add": "add", + "subtract": "sub", + "multiply": "mul", + "matmul": "matmul", + "divide": "truediv", + "true_divide": "truediv", + "floor_divide": "floordiv", + "power": "pow", + "float_power": "pow", + "remainder": "mod", + "mod": "mod", + "fmod": "mod", + # Bitwise binary operations. + "bitwise_and": "and", + "bitwise_or": "or", + "bitwise_xor": "xor", + # Comparison binary operators + "greater": "gt", + "greater_equal": "ge", + "less": "lt", + "less_equal": "le", + "not_equal": "ne", + "equal": "eq", +} + +# These operators need to be mapped to their inverses when performing a +# reflected ufunc operation because no reflected version of the operators +# themselves exist. When these operators are invoked directly (not via +# __array_ufunc__) Python takes care of calling the inverse operation. +_ops_without_reflection = { + "gt": "lt", + "ge": "le", + "lt": "gt", + "le": "ge", + # ne and eq are symmetric, so they are their own inverse op + "ne": "ne", + "eq": "eq", +} + + +# This is the implementation of __array_ufunc__ used for Frame and Column. +# For more detail on this function and how it should work, see +# https://numpy.org/doc/stable/reference/ufuncs.html +def _array_ufunc(obj, ufunc, method, inputs, kwargs): + # We don't currently support reduction, accumulation, etc. We also + # don't support any special kwargs or higher arity ufuncs than binary. + if method != "__call__" or kwargs or ufunc.nin > 2: + return NotImplemented + + fname = ufunc.__name__ + if fname in _ufunc_binary_operations: + reflect = obj is not inputs[0] + other = inputs[0] if reflect else inputs[1] + + op = _ufunc_binary_operations[fname] + if reflect and op in _ops_without_reflection: + op = _ops_without_reflection[op] + reflect = False + op = f"__{'r' if reflect else ''}{op}__" + + # float_power returns float irrespective of the input type. + # TODO: Do not get the attribute directly, get from the operator module + # so that we can still exploit reflection. + if fname == "float_power": + return getattr(obj, op)(other).astype(float) + return getattr(obj, op)(other) + + # Special handling for various unary operations. + if fname == "negative": + return obj * -1 + if fname == "positive": + return obj.copy(deep=True) + if fname == "invert": + return ~obj + if fname == "absolute": + # TODO: Make sure all obj (mainly Column) implement abs. + return abs(obj) + if fname == "fabs": + return abs(obj).astype(np.float64) + + # None is a sentinel used by subclasses to trigger cupy dispatch. + return None + _EQUALITY_OPS = { "__eq__", From 65ef0ea4f7d1a3b91f30d24d87b1477b52412448 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Sat, 26 Mar 2022 17:21:35 -0700 Subject: [PATCH 007/246] Fix default value of str.split expand parameter. (#10457) This is a small fix to [match the pandas API](https://pandas.pydata.org/docs/reference/api/pandas.Series.str.split.html) for the `expand` parameter of `Series.str.split`. Only boolean values are allowed. Currently the default is set to `None` and then replaced with the intended default of `False`. This PR changes it to have a default value of `False`. This is a tiny bit of an API break because users who explicitly passed `None` will now see an error instead of getting the intended default value, but the previous behavior was a bug with respect to pandas API compatibility. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - GALI PREM SAGAR (https://github.com/galipremsagar) - Charles Blackmon-Luca (https://github.com/charlesbluca) URL: https://github.com/rapidsai/cudf/pull/10457 --- python/cudf/cudf/core/column/string.py | 10 ++-------- python/cudf/cudf/tests/test_string.py | 10 +++++----- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/python/cudf/cudf/core/column/string.py b/python/cudf/cudf/core/column/string.py index 95bb06ebb0c..d18bcaa84f4 100644 --- a/python/cudf/cudf/core/column/string.py +++ b/python/cudf/cudf/core/column/string.py @@ -2299,7 +2299,7 @@ def split( self, pat: str = None, n: int = -1, - expand: bool = None, + expand: bool = False, regex: bool = None, ) -> SeriesOrIndex: """ @@ -2420,9 +2420,6 @@ def split( 2 """ - if expand is None: - expand = False - if expand not in (True, False): raise ValueError( f"expand parameter accepts only : [True, False], " @@ -2470,7 +2467,7 @@ def rsplit( self, pat: str = None, n: int = -1, - expand: bool = None, + expand: bool = False, regex: bool = None, ) -> SeriesOrIndex: """ @@ -2599,9 +2596,6 @@ def rsplit( 2 """ - if expand is None: - expand = False - if expand not in (True, False): raise ValueError( f"expand parameter accepts only : [True, False], " diff --git a/python/cudf/cudf/tests/test_string.py b/python/cudf/cudf/tests/test_string.py index f237e5bf715..f5bfcd8c9d2 100644 --- a/python/cudf/cudf/tests/test_string.py +++ b/python/cudf/cudf/tests/test_string.py @@ -945,7 +945,7 @@ def test_string_upper(ps_gs): ) @pytest.mark.parametrize("pat", [None, " ", "-"]) @pytest.mark.parametrize("n", [-1, 0, 1, 3, 10]) -@pytest.mark.parametrize("expand", [True, False, None]) +@pytest.mark.parametrize("expand", [True, False]) def test_string_split(data, pat, n, expand): ps = pd.Series(data, dtype="str") gs = cudf.Series(data, dtype="str") @@ -967,7 +967,7 @@ def test_string_split(data, pat, n, expand): ) @pytest.mark.parametrize("pat", [None, " ", "\\-+", "\\s+"]) @pytest.mark.parametrize("n", [-1, 0, 1, 3, 10]) -@pytest.mark.parametrize("expand", [True, False, None]) +@pytest.mark.parametrize("expand", [True, False]) def test_string_split_re(data, pat, n, expand): ps = pd.Series(data, dtype="str") gs = cudf.Series(data, dtype="str") @@ -1510,7 +1510,7 @@ def test_strings_partition(data): ], ) @pytest.mark.parametrize("n", [-1, 2, 1, 9]) -@pytest.mark.parametrize("expand", [True, False, None]) +@pytest.mark.parametrize("expand", [True, False]) def test_strings_rsplit(data, n, expand): gs = cudf.Series(data) ps = pd.Series(data) @@ -1531,7 +1531,7 @@ def test_strings_rsplit(data, n, expand): @pytest.mark.parametrize("n", [-1, 0, 1, 3, 10]) -@pytest.mark.parametrize("expand", [True, False, None]) +@pytest.mark.parametrize("expand", [True, False]) def test_string_rsplit_re(n, expand): data = ["a b", " c ", " d", "e ", "f"] ps = pd.Series(data, dtype="str") @@ -1566,7 +1566,7 @@ def test_string_rsplit_re(n, expand): ], ) @pytest.mark.parametrize("n", [-1, 2, 1, 9]) -@pytest.mark.parametrize("expand", [True, False, None]) +@pytest.mark.parametrize("expand", [True, False]) def test_strings_split(data, n, expand): gs = cudf.Series(data) ps = pd.Series(data) From 0d78007adc3bc4988b7424c726c984e81df4f25a Mon Sep 17 00:00:00 2001 From: Karthikeyan <6488848+karthikeyann@users.noreply.github.com> Date: Mon, 28 Mar 2022 12:24:06 +0530 Subject: [PATCH 008/246] move benchmark input generation in device in reduction nvbench (#10486) Addresses part of https://github.com/rapidsai/cudf/issues/5773 uses `create_random_table` and moves benchmark input generation in device in reduction nvbench Authors: - Karthikeyan (https://github.com/karthikeyann) Approvers: - Christopher Harris (https://github.com/cwharris) - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/cudf/pull/10486 --- cpp/benchmarks/reduction/segment_reduce.cu | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/cpp/benchmarks/reduction/segment_reduce.cu b/cpp/benchmarks/reduction/segment_reduce.cu index 47e47943d36..3723147d95c 100644 --- a/cpp/benchmarks/reduction/segment_reduce.cu +++ b/cpp/benchmarks/reduction/segment_reduce.cu @@ -14,12 +14,10 @@ * limitations under the License. */ +#include #include #include -#include -#include - #include #include #include @@ -33,7 +31,6 @@ #include #include -#include namespace cudf { @@ -71,20 +68,21 @@ std::pair, thrust::device_vector> make_test_d auto segment_length = column_size / num_segments; - test::UniformRandomGenerator rand_gen(0, 100); - auto data_it = detail::make_counting_transform_iterator( - 0, [&rand_gen](auto i) { return rand_gen.generate(); }); + auto const dtype = cudf::type_to_id(); + data_profile profile; + profile.set_null_frequency(std::nullopt); + profile.set_cardinality(0); + profile.set_distribution_params(dtype, distribution_id::UNIFORM, 0, 100); + auto input = create_random_table({dtype}, row_count{column_size}, profile); auto offset_it = - detail::make_counting_transform_iterator(0, [&column_size, &segment_length](auto i) { + detail::make_counting_transform_iterator(0, [column_size, segment_length] __device__(auto i) { return column_size < i * segment_length ? column_size : i * segment_length; }); - test::fixed_width_column_wrapper input(data_it, data_it + column_size); - std::vector h_offsets(offset_it, offset_it + num_segments + 1); - thrust::device_vector d_offsets(h_offsets); + thrust::device_vector d_offsets(offset_it, offset_it + num_segments + 1); - return std::make_pair(input.release(), d_offsets); + return std::make_pair(std::move((input->release())[0]), d_offsets); } template From 516a51032c0527012b5de69bdbb47159b858c384 Mon Sep 17 00:00:00 2001 From: David Wendt <45795991+davidwendt@users.noreply.github.com> Date: Mon, 28 Mar 2022 14:28:36 -0400 Subject: [PATCH 009/246] Fix findall_record to return empty list for no matches (#10491) Closes #10458 Change the behavior of `cudf::strings::findall_record` to return an empty row when the search results in no matches for the corresponding input strings row. The previous behavior was returning a null row when no matches are found. Authors: - David Wendt (https://github.com/davidwendt) Approvers: - Mike Wilson (https://github.com/hyperbolic2346) - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/cudf/pull/10491 --- cpp/doxygen/regex.md | 4 +++- cpp/include/cudf/strings/findall.hpp | 10 +++++---- cpp/src/strings/search/findall_record.cu | 24 ++------------------ cpp/tests/strings/findall_tests.cpp | 28 +++++++++++------------- 4 files changed, 24 insertions(+), 42 deletions(-) diff --git a/cpp/doxygen/regex.md b/cpp/doxygen/regex.md index 76ebb48d195..68a446846ce 100644 --- a/cpp/doxygen/regex.md +++ b/cpp/doxygen/regex.md @@ -6,7 +6,9 @@ This page specifies which regular expression (regex) features are currently supp - cudf::strings::matches_re() - cudf::strings::count_re() - cudf::strings::extract() -- cudf::strings::findall_re() +- cudf::strings::extract_all_record() +- cudf::strings::findall() +- cudf::strings::findall_record() - cudf::strings::replace_re() - cudf::strings::replace_with_backrefs() diff --git a/cpp/include/cudf/strings/findall.hpp b/cpp/include/cudf/strings/findall.hpp index 1cb742ec09e..25ebdc61673 100644 --- a/cpp/include/cudf/strings/findall.hpp +++ b/cpp/include/cudf/strings/findall.hpp @@ -64,19 +64,21 @@ std::unique_ptr
findall( * @brief Returns a lists column of strings for each matching occurrence of the * regex pattern within each string. * + * Each output row includes all the substrings within the corresponding input row + * that match the given pattern. If no matches are found, the output row is empty. + * * @code{.pseudo} * Example: * s = ["bunny", "rabbit", "hare", "dog"] - * r = findall_record(s, "[ab]"") + * r = findall_record(s, "[ab]") * r is now a lists column like: * [ ["b"] * ["a","b","b"] * ["a"] - * null ] + * [] ] * @endcode * - * A null output row results if the pattern is not found in the corresponding row - * input string. + * A null output row occurs if the corresponding input row is null. * * See the @ref md_regex "Regex Features" page for details on patterns supported by this API. * diff --git a/cpp/src/strings/search/findall_record.cu b/cpp/src/strings/search/findall_record.cu index 95e347a7c35..8ce7908f41e 100644 --- a/cpp/src/strings/search/findall_record.cu +++ b/cpp/src/strings/search/findall_record.cu @@ -117,26 +117,6 @@ std::unique_ptr findall_record( auto offsets = count_matches(*d_strings, *d_prog, stream, mr); auto d_offsets = offsets->mutable_view().data(); - // Compute null output rows - auto [null_mask, null_count] = cudf::detail::valid_if( - d_offsets, - d_offsets + strings_count, - [] __device__(auto const v) { return v > 0; }, - stream, - mr); - - auto const valid_count = strings_count - null_count; - // Return an empty lists column if there are no valid rows - if (valid_count == 0) { - return make_lists_column(0, - make_empty_column(type_to_id()), - make_empty_column(type_id::STRING), - 0, - rmm::device_buffer{}, - stream, - mr); - } - // Convert counts into offsets thrust::exclusive_scan( rmm::exec_policy(stream), d_offsets, d_offsets + strings_count + 1, d_offsets); @@ -152,8 +132,8 @@ std::unique_ptr findall_record( return make_lists_column(strings_count, std::move(offsets), std::move(strings_output), - null_count, - std::move(null_mask), + input.null_count(), + cudf::detail::copy_bitmask(input.parent(), stream, mr), stream, mr); } diff --git a/cpp/tests/strings/findall_tests.cpp b/cpp/tests/strings/findall_tests.cpp index a4a28f31ce2..21c38565372 100644 --- a/cpp/tests/strings/findall_tests.cpp +++ b/cpp/tests/strings/findall_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -77,14 +77,14 @@ TEST_F(StringsFindallTests, FindallTest) TEST_F(StringsFindallTests, FindallRecord) { + bool valids[] = {1, 1, 1, 1, 1, 0, 1, 1}; cudf::test::strings_column_wrapper input( {"3-A", "4-May 5-Day 6-Hay", "12-Dec-2021-Jan", "Feb-March", "4 ABC", "", "", "25-9000-Hal"}, - {1, 1, 1, 1, 1, 0, 1, 1}); + valids); auto results = cudf::strings::findall_record(cudf::strings_column_view(input), "(\\d+)-(\\w+)"); - bool valids[] = {1, 1, 1, 0, 0, 0, 0, 1}; - using LCW = cudf::test::lists_column_wrapper; + using LCW = cudf::test::lists_column_wrapper; LCW expected({LCW{"3-A"}, LCW{"4-May", "5-Day", "6-Hay"}, LCW{"12-Dec", "2021-Jan"}, @@ -94,7 +94,7 @@ TEST_F(StringsFindallTests, FindallRecord) LCW{}, LCW{"25-9000"}}, valids); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), expected); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(results->view(), expected); } TEST_F(StringsFindallTests, Multiline) @@ -108,15 +108,14 @@ TEST_F(StringsFindallTests, Multiline) cudf::test::strings_column_wrapper({"abc", "abc", "abc", "", "abc"}, {1, 1, 1, 0, 1}); auto col1 = cudf::test::strings_column_wrapper({"abc", "", "", "", ""}, {1, 0, 0, 0, 0}); auto expected = cudf::table_view({col0, col1}); - CUDF_TEST_EXPECT_TABLES_EQUAL(results->view(), expected); + CUDF_TEST_EXPECT_TABLES_EQUIVALENT(results->view(), expected); } { auto results = cudf::strings::findall_record(view, "(^abc$)", cudf::strings::regex_flags::MULTILINE); - bool valids[] = {1, 1, 1, 0, 1}; - using LCW = cudf::test::lists_column_wrapper; - LCW expected({LCW{"abc", "abc"}, LCW{"abc"}, LCW{"abc"}, LCW{}, LCW{"abc"}}, valids); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), expected); + using LCW = cudf::test::lists_column_wrapper; + LCW expected({LCW{"abc", "abc"}, LCW{"abc"}, LCW{"abc"}, LCW{}, LCW{"abc"}}); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(results->view(), expected); } } @@ -130,15 +129,14 @@ TEST_F(StringsFindallTests, DotAll) auto col0 = cudf::test::strings_column_wrapper({"bc\nfa\nef", "bbc\nfff", "bcdef", ""}, {1, 1, 1, 0}); auto expected = cudf::table_view({col0}); - CUDF_TEST_EXPECT_TABLES_EQUAL(results->view(), expected); + CUDF_TEST_EXPECT_TABLES_EQUIVALENT(results->view(), expected); } { auto results = cudf::strings::findall_record(view, "(b.*f)", cudf::strings::regex_flags::DOTALL); - bool valids[] = {1, 1, 1, 0}; - using LCW = cudf::test::lists_column_wrapper; - LCW expected({LCW{"bc\nfa\nef"}, LCW{"bbc\nfff"}, LCW{"bcdef"}, LCW{}}, valids); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), expected); + using LCW = cudf::test::lists_column_wrapper; + LCW expected({LCW{"bc\nfa\nef"}, LCW{"bbc\nfff"}, LCW{"bcdef"}, LCW{}}); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(results->view(), expected); } } From 90882d36641712a397cce58103b82b644d1ef5cc Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Mon, 28 Mar 2022 13:09:18 -0700 Subject: [PATCH 010/246] Update pre-commit to run black 22.3.0 (#10523) This PR updates us to use black 22.3.0, which is now necessary because older versions of black are not compatible with current versions of Click (see https://github.com/psf/black/issues/2964 is resolved). I've opened this for 22.06 since [I don't see any open PRs attempting to merge into 22.04](https://github.com/rapidsai/cudf/pulls?q=is%3Apr+is%3Aopen+base%3Abranch-22.04) anymore, but this issue will block CI (which runs style checks using pre-commit) so if necessary I can backport. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Bradley Dice (https://github.com/bdice) - GALI PREM SAGAR (https://github.com/galipremsagar) --- .pre-commit-config.yaml | 2 +- python/cudf/cudf/_fuzz_testing/avro.py | 4 +- python/cudf/cudf/_fuzz_testing/csv.py | 6 +- python/cudf/cudf/_fuzz_testing/fuzzer.py | 8 +- python/cudf/cudf/_fuzz_testing/json.py | 6 +- python/cudf/cudf/_fuzz_testing/orc.py | 6 +- python/cudf/cudf/_fuzz_testing/parquet.py | 6 +- .../_fuzz_testing/tests/fuzz_test_parquet.py | 10 +- python/cudf/cudf/_lib/column.pyi | 100 +++--------- python/cudf/cudf/comm/serialize.py | 3 +- python/cudf/cudf/core/_base_index.py | 10 +- python/cudf/cudf/core/_internals/where.py | 27 +-- python/cudf/cudf/core/column/categorical.py | 27 ++- python/cudf/cudf/core/column/column.py | 23 ++- python/cudf/cudf/core/column/lists.py | 8 +- python/cudf/cudf/core/column/methods.py | 7 +- python/cudf/cudf/core/column/numerical.py | 12 +- .../cudf/cudf/core/column/numerical_base.py | 2 +- python/cudf/cudf/core/column/string.py | 30 +++- python/cudf/cudf/core/column/timedelta.py | 5 +- python/cudf/cudf/core/column_accessor.py | 8 +- python/cudf/cudf/core/dataframe.py | 49 +++++- python/cudf/cudf/core/df_protocol.py | 8 +- python/cudf/cudf/core/dtypes.py | 5 +- python/cudf/cudf/core/frame.py | 40 ++++- python/cudf/cudf/core/index.py | 26 ++- python/cudf/cudf/core/indexed_frame.py | 9 +- python/cudf/cudf/core/mixins/binops.py | 2 +- python/cudf/cudf/core/mixins/binops.pyi | 111 ++++--------- python/cudf/cudf/core/mixins/reductions.pyi | 87 +++------- python/cudf/cudf/core/mixins/scans.py | 7 +- python/cudf/cudf/core/mixins/scans.pyi | 15 +- python/cudf/cudf/core/multiindex.py | 17 +- python/cudf/cudf/core/resample.py | 6 +- python/cudf/cudf/core/reshape.py | 3 +- python/cudf/cudf/core/series.py | 29 +++- python/cudf/cudf/core/single_column_frame.py | 7 +- python/cudf/cudf/core/tools/datetimes.py | 12 +- python/cudf/cudf/core/tools/numeric.py | 4 +- python/cudf/cudf/core/udf/lowering.py | 5 +- python/cudf/cudf/core/udf/typing.py | 14 +- python/cudf/cudf/core/window/rolling.py | 5 +- python/cudf/cudf/io/avro.py | 5 +- python/cudf/cudf/io/csv.py | 3 +- python/cudf/cudf/io/json.py | 5 +- python/cudf/cudf/io/orc.py | 8 +- python/cudf/cudf/io/parquet.py | 29 +++- python/cudf/cudf/io/text.py | 5 +- python/cudf/cudf/testing/_utils.py | 3 +- python/cudf/cudf/testing/dataset_generator.py | 51 ++++-- python/cudf/cudf/tests/test_array_ufunc.py | 7 +- python/cudf/cudf/tests/test_binops.py | 6 +- python/cudf/cudf/tests/test_categorical.py | 4 +- python/cudf/cudf/tests/test_column.py | 15 +- python/cudf/cudf/tests/test_concat.py | 39 ++++- python/cudf/cudf/tests/test_csv.py | 4 +- python/cudf/cudf/tests/test_cut.py | 28 +++- python/cudf/cudf/tests/test_dataframe.py | 154 +++++++++++++----- python/cudf/cudf/tests/test_datetime.py | 17 +- python/cudf/cudf/tests/test_doctests.py | 6 +- python/cudf/cudf/tests/test_dropna.py | 5 +- python/cudf/cudf/tests/test_duplicates.py | 5 +- python/cudf/cudf/tests/test_groupby.py | 31 +++- python/cudf/cudf/tests/test_hash_vocab.py | 2 +- python/cudf/cudf/tests/test_index.py | 50 ++++-- python/cudf/cudf/tests/test_indexing.py | 9 +- python/cudf/cudf/tests/test_interval.py | 8 +- python/cudf/cudf/tests/test_joining.py | 9 +- python/cudf/cudf/tests/test_list.py | 55 +++++-- python/cudf/cudf/tests/test_monotonic.py | 5 +- python/cudf/cudf/tests/test_numerical.py | 47 +++--- python/cudf/cudf/tests/test_onehot.py | 2 +- python/cudf/cudf/tests/test_orc.py | 15 +- python/cudf/cudf/tests/test_parquet.py | 15 +- python/cudf/cudf/tests/test_query.py | 4 +- python/cudf/cudf/tests/test_rank.py | 5 +- python/cudf/cudf/tests/test_reductions.py | 7 +- python/cudf/cudf/tests/test_replace.py | 27 ++- python/cudf/cudf/tests/test_resampling.py | 8 +- python/cudf/cudf/tests/test_reshape.py | 4 +- python/cudf/cudf/tests/test_rolling.py | 2 +- python/cudf/cudf/tests/test_s3.py | 9 +- python/cudf/cudf/tests/test_series.py | 56 +++++-- python/cudf/cudf/tests/test_seriesmap.py | 6 +- python/cudf/cudf/tests/test_stats.py | 2 +- python/cudf/cudf/tests/test_string.py | 72 +++++--- python/cudf/cudf/tests/test_testing.py | 14 +- python/cudf/cudf/tests/test_timedelta.py | 12 +- python/cudf/cudf/tests/test_transform.py | 6 +- python/cudf/cudf/tests/test_udf_binops.py | 6 +- python/cudf/cudf/tests/test_udf_masked_ops.py | 8 +- python/cudf/cudf/utils/hash_vocab_utils.py | 14 +- python/cudf/cudf/utils/ioutils.py | 29 +++- python/cudf/setup.py | 5 +- python/cudf_kafka/setup.py | 5 +- python/cudf_kafka/versioneer.py | 3 +- python/dask_cudf/dask_cudf/backends.py | 1 - python/dask_cudf/dask_cudf/core.py | 4 +- python/dask_cudf/dask_cudf/groupby.py | 14 +- python/dask_cudf/dask_cudf/io/parquet.py | 5 +- .../dask_cudf/io/tests/test_parquet.py | 12 +- .../dask_cudf/tests/test_accessor.py | 27 ++- python/dask_cudf/dask_cudf/tests/test_core.py | 6 +- .../dask_cudf/dask_cudf/tests/test_groupby.py | 25 ++- .../dask_cudf/dask_cudf/tests/test_onehot.py | 5 +- 105 files changed, 1173 insertions(+), 648 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9e72c0119f3..21f15ade458 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -28,7 +28,7 @@ repos: args: ["--settings-path=python/dask_cudf/setup.cfg"] files: python/dask_cudf/.* - repo: https://github.com/psf/black - rev: 19.10b0 + rev: 22.3.0 hooks: - id: black files: python/.* diff --git a/python/cudf/cudf/_fuzz_testing/avro.py b/python/cudf/cudf/_fuzz_testing/avro.py index 4c167ac627f..d9974037daa 100644 --- a/python/cudf/cudf/_fuzz_testing/avro.py +++ b/python/cudf/cudf/_fuzz_testing/avro.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2021, NVIDIA CORPORATION. +# Copyright (c) 2020-2022, NVIDIA CORPORATION. import copy import io @@ -73,7 +73,7 @@ def generate_input(self): self, dtypes_list ) self._current_params["dtypes_meta"] = dtypes_meta - seed = random.randint(0, 2 ** 32 - 1) + seed = random.randint(0, 2**32 - 1) self._current_params["seed"] = seed self._current_params["num_rows"] = num_rows self._current_params["num_cols"] = num_cols diff --git a/python/cudf/cudf/_fuzz_testing/csv.py b/python/cudf/cudf/_fuzz_testing/csv.py index 5f628904276..8ab7048cff0 100644 --- a/python/cudf/cudf/_fuzz_testing/csv.py +++ b/python/cudf/cudf/_fuzz_testing/csv.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2021, NVIDIA CORPORATION. +# Copyright (c) 2020-2022, NVIDIA CORPORATION. import logging import random @@ -50,7 +50,7 @@ def generate_input(self): seed, ) = self.get_next_regression_params() else: - seed = random.randint(0, 2 ** 32 - 1) + seed = random.randint(0, 2**32 - 1) random.seed(seed) dtypes_list = list(cudf.utils.dtypes.ALL_TYPES) dtypes_meta, num_rows, num_cols = _generate_rand_meta( @@ -155,7 +155,7 @@ def generate_input(self): seed, ) = self.get_next_regression_params() else: - seed = random.randint(0, 2 ** 32 - 1) + seed = random.randint(0, 2**32 - 1) random.seed(seed) dtypes_list = list(cudf.utils.dtypes.ALL_TYPES) dtypes_meta, num_rows, num_cols = _generate_rand_meta( diff --git a/python/cudf/cudf/_fuzz_testing/fuzzer.py b/python/cudf/cudf/_fuzz_testing/fuzzer.py index a51a5073510..b99cd938a63 100644 --- a/python/cudf/cudf/_fuzz_testing/fuzzer.py +++ b/python/cudf/cudf/_fuzz_testing/fuzzer.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2021, NVIDIA CORPORATION. +# Copyright (c) 2020-2022, NVIDIA CORPORATION. import datetime import json @@ -60,10 +60,12 @@ def write_crash(self, error): error_file_name = datetime.datetime.now().__str__() if self._crash_dir: crash_path = os.path.join( - self._crash_dir, error_file_name + "_crash.json", + self._crash_dir, + error_file_name + "_crash.json", ) crash_log_path = os.path.join( - self._crash_dir, error_file_name + "_crash.log", + self._crash_dir, + error_file_name + "_crash.log", ) else: crash_path = error_file_name + "_crash.json" diff --git a/python/cudf/cudf/_fuzz_testing/json.py b/python/cudf/cudf/_fuzz_testing/json.py index 8a8a3d5bff7..f850a7e79f9 100644 --- a/python/cudf/cudf/_fuzz_testing/json.py +++ b/python/cudf/cudf/_fuzz_testing/json.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2021, NVIDIA CORPORATION. +# Copyright (c) 2020-2022, NVIDIA CORPORATION. import logging import random @@ -65,7 +65,7 @@ def generate_input(self): seed, ) = self.get_next_regression_params() else: - seed = random.randint(0, 2 ** 32 - 1) + seed = random.randint(0, 2**32 - 1) random.seed(seed) dtypes_list = list( cudf.utils.dtypes.ALL_TYPES @@ -140,7 +140,7 @@ def generate_input(self): seed, ) = self.get_next_regression_params() else: - seed = random.randint(0, 2 ** 32 - 1) + seed = random.randint(0, 2**32 - 1) random.seed(seed) dtypes_list = list( cudf.utils.dtypes.ALL_TYPES diff --git a/python/cudf/cudf/_fuzz_testing/orc.py b/python/cudf/cudf/_fuzz_testing/orc.py index 78e01fb76a4..65d2e09988f 100644 --- a/python/cudf/cudf/_fuzz_testing/orc.py +++ b/python/cudf/cudf/_fuzz_testing/orc.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2021, NVIDIA CORPORATION. +# Copyright (c) 2020-2022, NVIDIA CORPORATION. import copy import io @@ -69,7 +69,7 @@ def generate_input(self): ) self._current_params["dtypes_meta"] = dtypes_meta - seed = random.randint(0, 2 ** 32 - 1) + seed = random.randint(0, 2**32 - 1) self._current_params["seed"] = seed self._current_params["num_rows"] = num_rows self._current_params["num_cols"] = num_cols @@ -188,7 +188,7 @@ def generate_input(self): self, dtypes_list ) self._current_params["dtypes_meta"] = dtypes_meta - seed = random.randint(0, 2 ** 32 - 1) + seed = random.randint(0, 2**32 - 1) self._current_params["seed"] = seed self._current_params["num_rows"] = num_rows self._current_params["num_cols"] = num_cols diff --git a/python/cudf/cudf/_fuzz_testing/parquet.py b/python/cudf/cudf/_fuzz_testing/parquet.py index 859d09b407f..31be9aa2a5e 100644 --- a/python/cudf/cudf/_fuzz_testing/parquet.py +++ b/python/cudf/cudf/_fuzz_testing/parquet.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2021, NVIDIA CORPORATION. +# Copyright (c) 2020-2022, NVIDIA CORPORATION. import logging import random @@ -64,7 +64,7 @@ def generate_input(self): self, dtypes_list ) self._current_params["dtypes_meta"] = dtypes_meta - seed = random.randint(0, 2 ** 32 - 1) + seed = random.randint(0, 2**32 - 1) self._current_params["seed"] = seed self._current_params["num_rows"] = num_rows self._current_params["num_cols"] = num_cols @@ -139,7 +139,7 @@ def generate_input(self): seed, ) = self.get_next_regression_params() else: - seed = random.randint(0, 2 ** 32 - 1) + seed = random.randint(0, 2**32 - 1) random.seed(seed) dtypes_list = list( cudf.utils.dtypes.ALL_TYPES diff --git a/python/cudf/cudf/_fuzz_testing/tests/fuzz_test_parquet.py b/python/cudf/cudf/_fuzz_testing/tests/fuzz_test_parquet.py index db2bcf74112..5b5e7c5964d 100644 --- a/python/cudf/cudf/_fuzz_testing/tests/fuzz_test_parquet.py +++ b/python/cudf/cudf/_fuzz_testing/tests/fuzz_test_parquet.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2021, NVIDIA CORPORATION. +# Copyright (c) 2020-2022, NVIDIA CORPORATION. import sys @@ -91,10 +91,14 @@ def parquet_writer_test_rowgroup_index_compression( gdf = cudf.from_pandas(pdf) pdf.to_parquet( - pd_file_name, compression=compression, row_group_size=row_group_size, + pd_file_name, + compression=compression, + row_group_size=row_group_size, ) gdf.to_parquet( - gd_file_name, compression=compression, row_group_size=row_group_size, + gd_file_name, + compression=compression, + row_group_size=row_group_size, ) actual = cudf.read_parquet(gd_file_name) diff --git a/python/cudf/cudf/_lib/column.pyi b/python/cudf/cudf/_lib/column.pyi index 235cb4fd973..0d61e4f02e5 100644 --- a/python/cudf/cudf/_lib/column.pyi +++ b/python/cudf/cudf/_lib/column.pyi @@ -32,94 +32,46 @@ class Column: offset: int = None, null_count: int = None, children: Tuple[ColumnBase, ...] = (), - ) -> None: - ... - + ) -> None: ... @property - def base_size(self) -> int: - ... - + def base_size(self) -> int: ... @property - def dtype(self) -> DtypeObj: - ... - + def dtype(self) -> DtypeObj: ... @property - def size(self) -> int: - ... - + def size(self) -> int: ... @property - def base_data(self) -> Optional[Buffer]: - ... - + def base_data(self) -> Optional[Buffer]: ... @property - def base_data_ptr(self) -> int: - ... - + def base_data_ptr(self) -> int: ... @property - def data(self) -> Optional[Buffer]: - ... - + def data(self) -> Optional[Buffer]: ... @property - def data_ptr(self) -> int: - ... - - def set_base_data(self, value: Buffer) -> None: - ... - + def data_ptr(self) -> int: ... + def set_base_data(self, value: Buffer) -> None: ... @property - def nullable(self) -> bool: - ... - - def has_nulls(self, include_nan: bool=False) -> bool: - ... - + def nullable(self) -> bool: ... + def has_nulls(self, include_nan: bool = False) -> bool: ... @property - def base_mask(self) -> Optional[Buffer]: - ... - + def base_mask(self) -> Optional[Buffer]: ... @property - def base_mask_ptr(self) -> int: - ... - + def base_mask_ptr(self) -> int: ... @property - def mask(self) -> Optional[Buffer]: - ... - + def mask(self) -> Optional[Buffer]: ... @property - def mask_ptr(self) -> int: - ... - - def set_base_mask(self, value: Optional[Buffer]) -> None: - ... - - def set_mask(self: T, value: Optional[Buffer]) -> T: - ... - + def mask_ptr(self) -> int: ... + def set_base_mask(self, value: Optional[Buffer]) -> None: ... + def set_mask(self: T, value: Optional[Buffer]) -> T: ... @property - def null_count(self) -> int: - ... - + def null_count(self) -> int: ... @property - def offset(self) -> int: - ... - + def offset(self) -> int: ... @property - def base_children(self) -> Tuple[ColumnBase, ...]: - ... - + def base_children(self) -> Tuple[ColumnBase, ...]: ... @property - def children(self) -> Tuple[ColumnBase, ...]: - ... - - def set_base_children(self, value: Tuple[ColumnBase, ...]) -> None: - ... - - def _mimic_inplace(self, other_col: ColumnBase, inplace=False) -> Optional[ColumnBase]: - ... - + def children(self) -> Tuple[ColumnBase, ...]: ... + def set_base_children(self, value: Tuple[ColumnBase, ...]) -> None: ... + def _mimic_inplace( + self, other_col: ColumnBase, inplace=False + ) -> Optional[ColumnBase]: ... @staticmethod - def from_scalar( - val: ScalarLike, - size: int - ) -> ColumnBase: # TODO: This should be Scalar, not ScalarLike - ... + def from_scalar(val: ScalarLike, size: int) -> ColumnBase: ... diff --git a/python/cudf/cudf/comm/serialize.py b/python/cudf/cudf/comm/serialize.py index 431b6bb2984..9fb28907e73 100644 --- a/python/cudf/cudf/comm/serialize.py +++ b/python/cudf/cudf/comm/serialize.py @@ -1,3 +1,5 @@ +# Copyright (c) 2019-2022, NVIDIA CORPORATION. + import cudf # noqa: F401 from cudf.core.abc import Serializable @@ -26,7 +28,6 @@ def dask_deserialize_cudf_object(header, frames): with log_errors(): return Serializable.host_deserialize(header, frames) - except ImportError: # distributed is probably not installed on the system pass diff --git a/python/cudf/cudf/core/_base_index.py b/python/cudf/cudf/core/_base_index.py index e05c55bd78f..259a7f711c3 100644 --- a/python/cudf/cudf/core/_base_index.py +++ b/python/cudf/cudf/core/_base_index.py @@ -1389,7 +1389,9 @@ def _constructor_expanddim(self): return cudf.MultiIndex def drop_duplicates( - self, keep="first", nulls_are_equal=True, + self, + keep="first", + nulls_are_equal=True, ): """ Drop duplicate rows in index. @@ -1435,7 +1437,11 @@ def dropna(self, how="any"): ] return self._from_columns_like_self( - drop_nulls(data_columns, how=how, keys=range(len(data_columns)),), + drop_nulls( + data_columns, + how=how, + keys=range(len(data_columns)), + ), self._column_names, ) diff --git a/python/cudf/cudf/core/_internals/where.py b/python/cudf/cudf/core/_internals/where.py index 8bfcad4c8f4..59e7d629092 100644 --- a/python/cudf/cudf/core/_internals/where.py +++ b/python/cudf/cudf/core/_internals/where.py @@ -93,10 +93,10 @@ def _check_and_cast_columns_with_other( def _normalize_columns_and_scalars_type( - frame: Frame, other: Any, inplace: bool = False, -) -> Tuple[ - Union[Frame, ColumnLike], Any, -]: + frame: Frame, + other: Any, + inplace: bool = False, +) -> Tuple[Union[Frame, ColumnLike], Any]: """ Try to normalize the other's dtypes as per frame. @@ -176,7 +176,10 @@ def _normalize_columns_and_scalars_type( def where( - frame: Frame, cond: Any, other: Any = None, inplace: bool = False, + frame: Frame, + cond: Any, + other: Any = None, + inplace: bool = False, ) -> Optional[Union[Frame]]: """ Replace values where the condition is False. @@ -266,9 +269,10 @@ def where( # as `cond` has no column names. cond._set_column_names_like(frame) - (source_df, others,) = _normalize_columns_and_scalars_type( - frame, other - ) + ( + source_df, + others, + ) = _normalize_columns_and_scalars_type(frame, other) if isinstance(others, Frame): others = others._data.columns @@ -340,9 +344,10 @@ def where( """Array conditional must be same shape as self""" ) - (input_col, other,) = _normalize_columns_and_scalars_type( - frame, other, inplace - ) + ( + input_col, + other, + ) = _normalize_columns_and_scalars_type(frame, other, inplace) if isinstance(input_col, cudf.core.column.CategoricalColumn): if cudf.api.types.is_scalar(other): diff --git a/python/cudf/cudf/core/column/categorical.py b/python/cudf/cudf/core/column/categorical.py index e0022ed21ca..9f00f9a203f 100644 --- a/python/cudf/cudf/core/column/categorical.py +++ b/python/cudf/cudf/core/column/categorical.py @@ -350,7 +350,9 @@ def add_categories( return self._return_or_inplace(out_col, inplace=inplace) def remove_categories( - self, removals: Any, inplace: bool = False, + self, + removals: Any, + inplace: bool = False, ) -> Optional[SeriesOrIndex]: """ Remove the specified categories. @@ -768,7 +770,9 @@ def children(self) -> Tuple[NumericalColumn]: codes_column = cast( cudf.core.column.NumericalColumn, column.build_column( - data=buf, dtype=codes_column.dtype, size=self.size, + data=buf, + dtype=codes_column.dtype, + size=self.size, ), ) self._children = (codes_column,) @@ -988,7 +992,9 @@ def to_arrow(self) -> pa.Array: out_dictionary = categories.to_arrow() return pa.DictionaryArray.from_arrays( - out_indices, out_dictionary, ordered=self.ordered, + out_indices, + out_dictionary, + ordered=self.ordered, ) @property @@ -1216,7 +1222,8 @@ def fillna( # TODO: only required if fill_value has a subset of the # categories: fill_value = fill_value._set_categories( - self.categories, is_unique=True, + self.categories, + is_unique=True, ) fill_value = column.as_column(fill_value.codes).astype( self.codes.dtype @@ -1415,7 +1422,10 @@ def _with_type_metadata( return self def set_categories( - self, new_categories: Any, ordered: bool = False, rename: bool = False, + self, + new_categories: Any, + ordered: bool = False, + rename: bool = False, ) -> CategoricalColumn: # See CategoricalAccessor.set_categories. @@ -1460,7 +1470,8 @@ def set_categories( or not self.ordered == ordered ): out_col = out_col._set_categories( - new_categories, ordered=ordered, + new_categories, + ordered=ordered, ) return out_col @@ -1555,7 +1566,9 @@ def _set_categories( ) def reorder_categories( - self, new_categories: Any, ordered: bool = False, + self, + new_categories: Any, + ordered: bool = False, ) -> CategoricalColumn: new_categories = column.as_column(new_categories) # Compare new_categories against current categories. diff --git a/python/cudf/cudf/core/column/column.py b/python/cudf/cudf/core/column/column.py index 401d5f82743..bc59b67119e 100644 --- a/python/cudf/cudf/core/column/column.py +++ b/python/cudf/cudf/core/column/column.py @@ -553,7 +553,10 @@ def _scatter_by_slice( # step != 1, create a scatter map with arange scatter_map = arange( - start=start, stop=stop, step=step, dtype=cudf.dtype(np.int32), + start=start, + stop=stop, + step=step, + dtype=cudf.dtype(np.int32), ) return self._scatter_by_column(scatter_map, value) @@ -620,7 +623,10 @@ def _check_scatter_key_length( raise ValueError(msg) def fillna( - self: T, value: Any = None, method: str = None, dtype: Dtype = None, + self: T, + value: Any = None, + method: str = None, + dtype: Dtype = None, ) -> T: """Fill null values with ``value``. @@ -844,7 +850,9 @@ def get_slice_bound(self, label: ScalarLike, side: str, kind: str) -> int: raise ValueError(f"Invalid value for side: {side}") def sort_by_values( - self: ColumnBase, ascending: bool = True, na_position: str = "last", + self: ColumnBase, + ascending: bool = True, + na_position: str = "last", ) -> Tuple[ColumnBase, "cudf.core.column.NumericalColumn"]: col_inds = self.as_frame()._get_sorted_inds( ascending=ascending, na_position=na_position @@ -1884,7 +1892,8 @@ def as_column( # changing from pd array to series,possible arrow bug interval_series = pd.Series(arbitrary) data = as_column( - pa.Array.from_pandas(interval_series), dtype=arbitrary.dtype, + pa.Array.from_pandas(interval_series), + dtype=arbitrary.dtype, ) if dtype is not None: data = data.astype(dtype) @@ -2109,7 +2118,11 @@ def _construct_array( if ( dtype is None and not cudf._lib.scalar._is_null_host_scalar(arbitrary) - and infer_dtype(arbitrary) in ("mixed", "mixed-integer",) + and infer_dtype(arbitrary) + in ( + "mixed", + "mixed-integer", + ) ): native_dtype = "object" arbitrary = np.asarray( diff --git a/python/cudf/cudf/core/column/lists.py b/python/cudf/cudf/core/column/lists.py index 0df5be2d862..60d13150b39 100644 --- a/python/cudf/cudf/core/column/lists.py +++ b/python/cudf/cudf/core/column/lists.py @@ -32,7 +32,13 @@ class ListColumn(ColumnBase): _VALID_BINARY_OPERATIONS = {"__add__", "__radd__"} def __init__( - self, size, dtype, mask=None, offset=0, null_count=None, children=(), + self, + size, + dtype, + mask=None, + offset=0, + null_count=None, + children=(), ): super().__init__( None, diff --git a/python/cudf/cudf/core/column/methods.py b/python/cudf/cudf/core/column/methods.py index a63fa927cfc..56dcd41666b 100644 --- a/python/cudf/cudf/core/column/methods.py +++ b/python/cudf/cudf/core/column/methods.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-2022, NVIDIA CORPORATION. from __future__ import annotations @@ -40,7 +40,10 @@ def _return_or_inplace( @overload def _return_or_inplace( - self, new_col, expand: bool = False, retain_index: bool = True, + self, + new_col, + expand: bool = False, + retain_index: bool = True, ) -> ParentType: ... diff --git a/python/cudf/cudf/core/column/numerical.py b/python/cudf/cudf/core/column/numerical.py index c9bc3c59aea..a89c8dfed54 100644 --- a/python/cudf/cudf/core/column/numerical.py +++ b/python/cudf/cudf/core/column/numerical.py @@ -173,7 +173,7 @@ def _binaryop(self, other: ColumnBinaryOperand, op: str) -> ColumnBase: if op in {"__truediv__", "__rtruediv__"}: # Division with integer types results in a suitable float. - if (truediv_type := int_float_dtype_mapping.get(self.dtype.type)) : + if truediv_type := int_float_dtype_mapping.get(self.dtype.type): return self.astype(truediv_type)._binaryop(other, op) reflect, op = self._check_reflected_op(op) @@ -258,7 +258,9 @@ def normalize_binop_value( other, size=len(self), dtype=other_dtype ) return column.build_column( - data=Buffer(ary), dtype=ary.dtype, mask=self.mask, + data=Buffer(ary), + dtype=ary.dtype, + mask=self.mask, ) else: return NotImplemented @@ -521,7 +523,11 @@ def _find_value( raise ValueError("Expected a numeric value") found = 0 if len(self): - found = find(self.data_array_view, value, mask=self.mask,) + found = find( + self.data_array_view, + value, + mask=self.mask, + ) if found == -1: if self.is_monotonic_increasing and closest: found = find( diff --git a/python/cudf/cudf/core/column/numerical_base.py b/python/cudf/cudf/core/column/numerical_base.py index b547cb43cf5..3ae60671b5a 100644 --- a/python/cudf/cudf/core/column/numerical_base.py +++ b/python/cudf/cudf/core/column/numerical_base.py @@ -62,7 +62,7 @@ def kurtosis(self, skipna: bool = None) -> float: return 0 term_one_section_one = (n * (n + 1)) / ((n - 1) * (n - 2) * (n - 3)) - term_one_section_two = m4_numerator / (V ** 2) + term_one_section_two = m4_numerator / (V**2) term_two = ((n - 1) ** 2) / ((n - 2) * (n - 3)) kurt = term_one_section_one * term_one_section_two - 3 * term_two return kurt diff --git a/python/cudf/cudf/core/column/string.py b/python/cudf/cudf/core/column/string.py index d18bcaa84f4..c1ef33be975 100644 --- a/python/cudf/cudf/core/column/string.py +++ b/python/cudf/cudf/core/column/string.py @@ -254,7 +254,9 @@ def byte_count(self) -> SeriesOrIndex: 2 11 dtype: int32 """ - return self._return_or_inplace(libstrings.count_bytes(self._column),) + return self._return_or_inplace( + libstrings.count_bytes(self._column), + ) @overload def cat(self, sep: str = None, na_rep: str = None) -> str: @@ -355,7 +357,9 @@ def cat(self, others=None, sep=None, na_rep=None): if others is None: data = libstrings.join( - self._column, cudf.Scalar(sep), cudf.Scalar(na_rep, "str"), + self._column, + cudf.Scalar(sep), + cudf.Scalar(na_rep, "str"), ) else: other_cols = _get_cols_list(self._parent, others) @@ -783,7 +787,10 @@ def contains( ) return self._return_or_inplace(result_col) - def repeat(self, repeats: Union[int, Sequence],) -> SeriesOrIndex: + def repeat( + self, + repeats: Union[int, Sequence], + ) -> SeriesOrIndex: """ Duplicate each string in the Series or Index. Equivalent to `str.repeat() @@ -828,7 +835,8 @@ def repeat(self, repeats: Union[int, Sequence],) -> SeriesOrIndex: if can_convert_to_column(repeats): return self._return_or_inplace( libstrings.repeat_sequence( - self._column, column.as_column(repeats, dtype="int"), + self._column, + column.as_column(repeats, dtype="int"), ), ) @@ -921,7 +929,9 @@ def replace( return self._return_or_inplace( libstrings.replace_multi_re( - self._column, pat, column.as_column(repl, dtype="str"), + self._column, + pat, + column.as_column(repl, dtype="str"), ) if regex else libstrings.replace_multi( @@ -5173,7 +5183,10 @@ def to_arrow(self) -> pa.Array: return super().to_arrow() def sum( - self, skipna: bool = None, dtype: Dtype = None, min_count: int = 0, + self, + skipna: bool = None, + dtype: Dtype = None, + min_count: int = 0, ): result_col = self._process_for_reduction( skipna=skipna, min_count=min_count @@ -5417,7 +5430,10 @@ def find_and_replace( return libcudf.replace.replace(res, df._data["old"], df._data["new"]) def fillna( - self, fill_value: Any = None, method: str = None, dtype: Dtype = None, + self, + fill_value: Any = None, + method: str = None, + dtype: Dtype = None, ) -> StringColumn: if fill_value is not None: if not is_scalar(fill_value): diff --git a/python/cudf/cudf/core/column/timedelta.py b/python/cudf/cudf/core/column/timedelta.py index 11d295a6190..8e1b938033e 100644 --- a/python/cudf/cudf/core/column/timedelta.py +++ b/python/cudf/cudf/core/column/timedelta.py @@ -378,7 +378,10 @@ def quantile( return result.astype(self.dtype) def sum( - self, skipna: bool = None, min_count: int = 0, dtype: Dtype = None, + self, + skipna: bool = None, + min_count: int = 0, + dtype: Dtype = None, ) -> pd.Timedelta: return pd.Timedelta( # Since sum isn't overriden in Numerical[Base]Column, mypy only diff --git a/python/cudf/cudf/core/column_accessor.py b/python/cudf/cudf/core/column_accessor.py index c9c00692174..291e50386cc 100644 --- a/python/cudf/cudf/core/column_accessor.py +++ b/python/cudf/cudf/core/column_accessor.py @@ -378,7 +378,9 @@ def select_by_index(self, index: Any) -> ColumnAccessor: keys = self.get_labels_by_index(index) data = {k: self._data[k] for k in keys} return self.__class__( - data, multiindex=self.multiindex, level_names=self.level_names, + data, + multiindex=self.multiindex, + level_names=self.level_names, ) def set_by_label(self, key: Any, value: Any, validate: bool = True): @@ -412,7 +414,9 @@ def _select_by_label_list_like(self, key: Any) -> ColumnAccessor: if self.multiindex: data = _to_flat_dict(data) return self.__class__( - data, multiindex=self.multiindex, level_names=self.level_names, + data, + multiindex=self.multiindex, + level_names=self.level_names, ) def _select_by_label_grouped(self, key: Any) -> ColumnAccessor: diff --git a/python/cudf/cudf/core/dataframe.py b/python/cudf/cudf/core/dataframe.py index 233a0b0beda..17cac3593a3 100644 --- a/python/cudf/cudf/core/dataframe.py +++ b/python/cudf/cudf/core/dataframe.py @@ -826,7 +826,9 @@ def _init_from_dict_like( masked = index is not None data = { key: cudf.core.column.column_empty( - row_count=row_count, dtype=None, masked=masked, + row_count=row_count, + dtype=None, + masked=masked, ) for key in extra_cols } @@ -855,7 +857,10 @@ def _init_from_dict_like( col_name, tuple ) self._insert( - i, col_name, data[col_name], nan_as_null=nan_as_null, + i, + col_name, + data[col_name], + nan_as_null=nan_as_null, ) if columns is not None: @@ -2095,7 +2100,9 @@ def _set_column_names(self, names, multiindex=False, level_names=None): raise ValueError("Duplicate column names are not allowed") self._data = ColumnAccessor( - data, multiindex=multiindex, level_names=level_names, + data, + multiindex=multiindex, + level_names=level_names, ) def _set_column_names_like(self, other): @@ -3370,7 +3377,13 @@ def merge( @_cudf_nvtx_annotate def join( - self, other, on=None, how="left", lsuffix="", rsuffix="", sort=False, + self, + other, + on=None, + how="left", + lsuffix="", + rsuffix="", + sort=False, ): """Join columns with other DataFrame on index or on a key column. @@ -4507,7 +4520,9 @@ def to_arrow(self, preserve_index=True): gen_names, self.index._data.names ): data._insert( - data.shape[1], gen_name, self.index._data[col_name], + data.shape[1], + gen_name, + self.index._data[col_name], ) descr = gen_names[0] index_descr.append(descr) @@ -5095,7 +5110,12 @@ def count(self, axis=0, level=None, numeric_only=False, **kwargs): @_cudf_nvtx_annotate def _reduce( - self, op, axis=None, level=None, numeric_only=None, **kwargs, + self, + op, + axis=None, + level=None, + numeric_only=None, + **kwargs, ): if level is not None: raise NotImplementedError("level parameter is not implemented yet") @@ -5123,7 +5143,11 @@ def _reduce( @_cudf_nvtx_annotate def _scan( - self, op, axis=None, *args, **kwargs, + self, + op, + axis=None, + *args, + **kwargs, ): axis = self._get_axis_from_axis_arg(axis) @@ -5355,7 +5379,11 @@ def _apply_cupy_method_axis_1(self, method, *args, **kwargs): result = result.set_mask( cudf._lib.transform.bools_to_mask(mask._column) ) - return Series(result, index=self.index, dtype=result_dtype,) + return Series( + result, + index=self.index, + dtype=result_dtype, + ) else: result_df = DataFrame(result).set_index(self.index) result_df._set_column_names_like(prepared) @@ -6532,7 +6560,10 @@ def _cast_cols_to_common_dtypes(col_idxs, list_of_columns, dtypes, categories): if idx in categories: cols[idx] = ( cols[idx] - ._set_categories(categories[idx], is_unique=True,) + ._set_categories( + categories[idx], + is_unique=True, + ) .codes ) cols[idx] = cols[idx].astype(dtype) diff --git a/python/cudf/cudf/core/df_protocol.py b/python/cudf/cudf/core/df_protocol.py index 8f00289afcb..4a30a78bf65 100644 --- a/python/cudf/cudf/core/df_protocol.py +++ b/python/cudf/cudf/core/df_protocol.py @@ -438,7 +438,9 @@ def _get_validity_buffer( f"See {self.__class__.__name__}.describe_null method." ) - def _get_offsets_buffer(self,) -> Optional[Tuple[_CuDFBuffer, ProtoDtype]]: + def _get_offsets_buffer( + self, + ) -> Optional[Tuple[_CuDFBuffer, ProtoDtype]]: """ Return the buffer containing the offset values for variable-size binary data (e.g., variable-length strings) @@ -464,7 +466,9 @@ def _get_offsets_buffer(self,) -> Optional[Tuple[_CuDFBuffer, ProtoDtype]]: return buffer, dtype - def _get_data_buffer(self,) -> Tuple[_CuDFBuffer, ProtoDtype]: + def _get_data_buffer( + self, + ) -> Tuple[_CuDFBuffer, ProtoDtype]: """ Return the buffer containing the data and the buffer's associated dtype. diff --git a/python/cudf/cudf/core/dtypes.py b/python/cudf/cudf/core/dtypes.py index 3a1c366b429..21cae5f05b7 100644 --- a/python/cudf/cudf/core/dtypes.py +++ b/python/cudf/cudf/core/dtypes.py @@ -349,7 +349,10 @@ def deserialize(cls, header: dict, frames: list): dtype_header, (start, stop) = dtype fields[k] = pickle.loads( dtype_header["type-serialized"] - ).deserialize(dtype_header, frames[start:stop],) + ).deserialize( + dtype_header, + frames[start:stop], + ) else: fields[k] = dtype return cls(fields) diff --git a/python/cudf/cudf/core/frame.py b/python/cudf/cudf/core/frame.py index d78744a719f..a84606b0953 100644 --- a/python/cudf/cudf/core/frame.py +++ b/python/cudf/cudf/core/frame.py @@ -145,7 +145,9 @@ def _from_data(cls, data: MutableMapping): @classmethod @_cudf_nvtx_annotate def _from_columns( - cls, columns: List[ColumnBase], column_names: abc.Iterable[str], + cls, + columns: List[ColumnBase], + column_names: abc.Iterable[str], ): """Construct a `Frame` object from a list of columns.""" data = {name: columns[i] for i, name in enumerate(column_names)} @@ -688,7 +690,8 @@ def clip(self, lower=None, upper=None, inplace=False, axis=1): """ if isinstance(self, cudf.BaseIndex): warnings.warn( - "Index.clip is deprecated and will be removed.", FutureWarning, + "Index.clip is deprecated and will be removed.", + FutureWarning, ) if axis != 1: @@ -1131,7 +1134,8 @@ def fillna( filled_data[col_name] = col.copy(deep=True) return self._mimic_inplace( - self._from_data(data=filled_data), inplace=inplace, + self._from_data(data=filled_data), + inplace=inplace, ) @_cudf_nvtx_annotate @@ -2656,7 +2660,12 @@ def _reduce(self, *args, **kwargs): @_cudf_nvtx_annotate def min( - self, axis=None, skipna=None, level=None, numeric_only=None, **kwargs, + self, + axis=None, + skipna=None, + level=None, + numeric_only=None, + **kwargs, ): """ Return the minimum of the values in the DataFrame. @@ -2702,7 +2711,12 @@ def min( @_cudf_nvtx_annotate def max( - self, axis=None, skipna=None, level=None, numeric_only=None, **kwargs, + self, + axis=None, + skipna=None, + level=None, + numeric_only=None, + **kwargs, ): """ Return the maximum of the values in the DataFrame. @@ -3188,7 +3202,11 @@ def all(self, axis=0, skipna=True, level=None, **kwargs): dtype: bool """ return self._reduce( - "all", axis=axis, skipna=skipna, level=level, **kwargs, + "all", + axis=axis, + skipna=skipna, + level=level, + **kwargs, ) @_cudf_nvtx_annotate @@ -3224,7 +3242,11 @@ def any(self, axis=0, skipna=True, level=None, **kwargs): dtype: bool """ return self._reduce( - "any", axis=axis, skipna=skipna, level=level, **kwargs, + "any", + axis=axis, + skipna=skipna, + level=level, + **kwargs, ) @_cudf_nvtx_annotate @@ -5328,7 +5350,9 @@ def _get_replacement_values_for_columns( col: [value] if _is_non_decimal_numeric_dtype(columns_dtype_map[col]) else cudf.utils.utils.scalar_broadcast_to( - value, (len(to_replace),), cudf.dtype(type(value)), + value, + (len(to_replace),), + cudf.dtype(type(value)), ) for col in columns_dtype_map } diff --git a/python/cudf/cudf/core/index.py b/python/cudf/cudf/core/index.py index d935da3bd14..7df5be3f692 100644 --- a/python/cudf/cudf/core/index.py +++ b/python/cudf/cudf/core/index.py @@ -852,7 +852,12 @@ def _from_data( return out def _binaryop( - self, other: T, op: str, fill_value: Any = None, *args, **kwargs, + self, + other: T, + op: str, + fill_value: Any = None, + *args, + **kwargs, ) -> SingleColumnFrame: reflect, op = self._check_reflected_op(op) operands = self._make_operands_for_binop(other, fill_value, reflect) @@ -2369,7 +2374,12 @@ def is_categorical(self): @_cudf_nvtx_annotate def interval_range( - start=None, end=None, periods=None, freq=None, name=None, closed="right", + start=None, + end=None, + periods=None, + freq=None, + name=None, + closed="right", ) -> "IntervalIndex": """ Returns a fixed frequency IntervalIndex. @@ -2532,7 +2542,12 @@ class IntervalIndex(GenericIndex): @_cudf_nvtx_annotate def __init__( - self, data, closed=None, dtype=None, copy=False, name=None, + self, + data, + closed=None, + dtype=None, + copy=False, + name=None, ): if copy: data = column.as_column(data, dtype=dtype).copy() @@ -2542,7 +2557,10 @@ def __init__( elif isinstance(data, pd.Series) and (is_interval_dtype(data.dtype)): data = column.as_column(data, data.dtype) elif isinstance(data, (pd._libs.interval.Interval, pd.IntervalIndex)): - data = column.as_column(data, dtype=dtype,) + data = column.as_column( + data, + dtype=dtype, + ) elif not data: dtype = IntervalDtype("int64", closed) data = column.column_empty_like_same_mask( diff --git a/python/cudf/cudf/core/indexed_frame.py b/python/cudf/cudf/core/indexed_frame.py index b8077d7d28b..c5c2322d95a 100644 --- a/python/cudf/cudf/core/indexed_frame.py +++ b/python/cudf/cudf/core/indexed_frame.py @@ -194,7 +194,9 @@ def _num_rows(self) -> int: @classmethod def _from_data( - cls, data: MutableMapping, index: Optional[BaseIndex] = None, + cls, + data: MutableMapping, + index: Optional[BaseIndex] = None, ): out = super()._from_data(data) out._index = RangeIndex(out._data.nrows) if index is None else index @@ -1758,7 +1760,10 @@ def _reset_index(self, level, drop, col_level=0, col_fill=""): index_names, ) = self._index._split_columns_by_levels(level) if index_columns: - index = _index_from_columns(index_columns, name=self._index.name,) + index = _index_from_columns( + index_columns, + name=self._index.name, + ) if isinstance(index, MultiIndex): index.names = index_names else: diff --git a/python/cudf/cudf/core/mixins/binops.py b/python/cudf/cudf/core/mixins/binops.py index e07977ed4c3..eaabc00f266 100644 --- a/python/cudf/cudf/core/mixins/binops.py +++ b/python/cudf/cudf/core/mixins/binops.py @@ -63,7 +63,7 @@ def _binaryop(self, other, op: str): def _check_reflected_op(op): - if (reflect := op[2] == "r" and op != "__rshift__") : + if reflect := op[2] == "r" and op != "__rshift__": op = op[:2] + op[3:] return reflect, op diff --git a/python/cudf/cudf/core/mixins/binops.pyi b/python/cudf/cudf/core/mixins/binops.pyi index ff47cdce418..8587b2dea48 100644 --- a/python/cudf/cudf/core/mixins/binops.pyi +++ b/python/cudf/cudf/core/mixins/binops.pyi @@ -8,87 +8,32 @@ BinaryOperandType = TypeVar("BinaryOperandType", bound="Any") class BinaryOperand: _SUPPORTED_BINARY_OPERATIONS: Set - def _binaryop(self, other: BinaryOperandType, op: str): - ... - - def __add__(self, other): - ... - - def __sub__(self, other): - ... - - def __mul__(self, other): - ... - - def __truediv__(self, other): - ... - - def __floordiv__(self, other): - ... - - def __mod__(self, other): - ... - - def __pow__(self, other): - ... - - def __and__(self, other): - ... - - def __xor__(self, other): - ... - - def __or__(self, other): - ... - - def __radd__(self, other): - ... - - def __rsub__(self, other): - ... - - def __rmul__(self, other): - ... - - def __rtruediv__(self, other): - ... - - def __rfloordiv__(self, other): - ... - - def __rmod__(self, other): - ... - - def __rpow__(self, other): - ... - - def __rand__(self, other): - ... - - def __rxor__(self, other): - ... - - def __ror__(self, other): - ... - - def __lt__(self, other): - ... - - def __le__(self, other): - ... - - def __eq__(self, other): - ... - - def __ne__(self, other): - ... - - def __gt__(self, other): - ... - - def __ge__(self, other): - ... - + def _binaryop(self, other: BinaryOperandType, op: str): ... + def __add__(self, other): ... + def __sub__(self, other): ... + def __mul__(self, other): ... + def __truediv__(self, other): ... + def __floordiv__(self, other): ... + def __mod__(self, other): ... + def __pow__(self, other): ... + def __and__(self, other): ... + def __xor__(self, other): ... + def __or__(self, other): ... + def __radd__(self, other): ... + def __rsub__(self, other): ... + def __rmul__(self, other): ... + def __rtruediv__(self, other): ... + def __rfloordiv__(self, other): ... + def __rmod__(self, other): ... + def __rpow__(self, other): ... + def __rand__(self, other): ... + def __rxor__(self, other): ... + def __ror__(self, other): ... + def __lt__(self, other): ... + def __le__(self, other): ... + def __eq__(self, other): ... + def __ne__(self, other): ... + def __gt__(self, other): ... + def __ge__(self, other): ... @staticmethod - def _check_reflected_op(op) -> Tuple[bool, str]: - ... + def _check_reflected_op(op) -> Tuple[bool, str]: ... diff --git a/python/cudf/cudf/core/mixins/reductions.pyi b/python/cudf/cudf/core/mixins/reductions.pyi index 3769b7c360e..dbaafdb5cd2 100644 --- a/python/cudf/cudf/core/mixins/reductions.pyi +++ b/python/cudf/cudf/core/mixins/reductions.pyi @@ -5,68 +5,25 @@ from typing import Set class Reducible: _SUPPORTED_REDUCTIONS: Set - def sum(self): - ... - - def product(self): - ... - - def min(self): - ... - - def max(self): - ... - - def count(self): - ... - - def any(self): - ... - - def all(self): - ... - - def sum_of_squares(self): - ... - - def mean(self): - ... - - def var(self): - ... - - def std(self): - ... - - def median(self): - ... - - def argmax(self): - ... - - def argmin(self): - ... - - def nunique(self): - ... - - def nth(self): - ... - - def collect(self): - ... - - def prod(self): - ... - - def idxmin(self): - ... - - def idxmax(self): - ... - - def first(self): - ... - - def last(self): - ... + def sum(self): ... + def product(self): ... + def min(self): ... + def max(self): ... + def count(self): ... + def any(self): ... + def all(self): ... + def sum_of_squares(self): ... + def mean(self): ... + def var(self): ... + def std(self): ... + def median(self): ... + def argmax(self): ... + def argmin(self): ... + def nunique(self): ... + def nth(self): ... + def collect(self): ... + def prod(self): ... + def idxmin(self): ... + def idxmax(self): ... + def first(self): ... + def last(self): ... diff --git a/python/cudf/cudf/core/mixins/scans.py b/python/cudf/cudf/core/mixins/scans.py index 723fc758b13..b0f606e32e6 100644 --- a/python/cudf/cudf/core/mixins/scans.py +++ b/python/cudf/cudf/core/mixins/scans.py @@ -7,5 +7,10 @@ "Mixin encapsulating scan operations.", "SCAN", "_scan", - {"cumsum", "cumprod", "cummin", "cummax",}, # noqa: E231 + { + "cumsum", + "cumprod", + "cummin", + "cummax", + }, # noqa: E231 ) diff --git a/python/cudf/cudf/core/mixins/scans.pyi b/python/cudf/cudf/core/mixins/scans.pyi index 38cb9af284f..37995241b1f 100644 --- a/python/cudf/cudf/core/mixins/scans.pyi +++ b/python/cudf/cudf/core/mixins/scans.pyi @@ -5,14 +5,7 @@ from typing import Set class Scannable: _SUPPORTED_SCANS: Set - def cumsum(self): - ... - - def cumprod(self): - ... - - def cummin(self): - ... - - def cummax(self): - ... + def cumsum(self): ... + def cumprod(self): ... + def cummin(self): ... + def cummax(self): ... diff --git a/python/cudf/cudf/core/multiindex.py b/python/cudf/cudf/core/multiindex.py index 1b946a140c6..39228f034d4 100644 --- a/python/cudf/cudf/core/multiindex.py +++ b/python/cudf/cudf/core/multiindex.py @@ -278,7 +278,11 @@ def set_names(self, names, level=None, inplace=False): @classmethod @_cudf_nvtx_annotate - def _from_data(cls, data: MutableMapping, name: Any = None,) -> MultiIndex: + def _from_data( + cls, + data: MutableMapping, + name: Any = None, + ) -> MultiIndex: obj = cls.from_frame(cudf.DataFrame._from_data(data=data)) if name is not None: obj.name = name @@ -866,7 +870,8 @@ def _validate_indexer( def __eq__(self, other): if isinstance(other, MultiIndex): for self_col, other_col in zip( - self._data.values(), other._data.values(), + self._data.values(), + other._data.values(), ): if not self_col.equals(other_col): return False @@ -1675,9 +1680,11 @@ def get_loc(self, key, method=None, tolerance=None): partial_index = self.__class__._from_data( data=self._data.select_by_index(slice(key_as_table._num_columns)) ) - (lower_bound, upper_bound, sort_inds,) = _lexsorted_equal_range( - partial_index, key_as_table, is_sorted - ) + ( + lower_bound, + upper_bound, + sort_inds, + ) = _lexsorted_equal_range(partial_index, key_as_table, is_sorted) if lower_bound == upper_bound: raise KeyError(key) diff --git a/python/cudf/cudf/core/resample.py b/python/cudf/cudf/core/resample.py index a4810701781..2bed71ea751 100644 --- a/python/cudf/cudf/core/resample.py +++ b/python/cudf/cudf/core/resample.py @@ -157,7 +157,11 @@ def _handle_frequency_grouper(self, by): end += offset # generate the labels for binning the key column: - bin_labels = cudf.date_range(start=start, end=end, freq=freq,) + bin_labels = cudf.date_range( + start=start, + end=end, + freq=freq, + ) # We want the (resampled) column of timestamps in the result # to have a resolution closest to the resampling diff --git a/python/cudf/cudf/core/reshape.py b/python/cudf/cudf/core/reshape.py index 5aa7f616e35..a388e2560ee 100644 --- a/python/cudf/cudf/core/reshape.py +++ b/python/cudf/cudf/core/reshape.py @@ -256,7 +256,8 @@ def concat(objs, axis=0, join="outer", ignore_index=False, sort=None): ) elif isinstance(obj, pd.Series): result = cudf.Series( - data=obj, index=cudf.RangeIndex(len(obj)), + data=obj, + index=cudf.RangeIndex(len(obj)), ) else: result = cudf.DataFrame._from_data( diff --git a/python/cudf/cudf/core/series.py b/python/cudf/cudf/core/series.py index 40e09bb11b8..1f79672f30f 100644 --- a/python/cudf/cudf/core/series.py +++ b/python/cudf/cudf/core/series.py @@ -104,7 +104,8 @@ def __getitem__(self, arg): ): return data return self._frame._from_data( - {self._frame.name: data}, index=cudf.Index(self._frame.index[arg]), + {self._frame.name: data}, + index=cudf.Index(self._frame.index[arg]), ) @_cudf_nvtx_annotate @@ -390,7 +391,12 @@ def from_masked_array(cls, data, mask, null_count=None): @_cudf_nvtx_annotate def __init__( - self, data=None, index=None, dtype=None, name=None, nan_as_null=True, + self, + data=None, + index=None, + dtype=None, + name=None, + nan_as_null=True, ): if isinstance(data, pd.Series): if name is None: @@ -2368,8 +2374,7 @@ def cov(self, other, min_periods=None): @_cudf_nvtx_annotate def transpose(self): - """Return the transpose, which is by definition self. - """ + """Return the transpose, which is by definition self.""" return self @@ -3762,7 +3767,9 @@ def quarter(self): np.int8 ) return Series._from_data( - {None: res}, index=self.series._index, name=self.series.name, + {None: res}, + index=self.series._index, + name=self.series.name, ) @_cudf_nvtx_annotate @@ -3960,7 +3967,9 @@ def is_quarter_start(self): result = ((day == cudf.Scalar(1)) & first_month).fillna(False) return Series._from_data( - {None: result}, index=self.series._index, name=self.series.name, + {None: result}, + index=self.series._index, + name=self.series.name, ) @property # type: ignore @@ -4009,7 +4018,9 @@ def is_quarter_end(self): result = ((day == last_day) & last_month).fillna(False) return Series._from_data( - {None: result}, index=self.series._index, name=self.series.name, + {None: result}, + index=self.series._index, + name=self.series.name, ) @property # type: ignore @@ -4081,7 +4092,9 @@ def is_year_end(self): result = cudf._lib.copying.copy_if_else(leap, non_leap, leap_dates) result = result.fillna(False) return Series._from_data( - {None: result}, index=self.series._index, name=self.series.name, + {None: result}, + index=self.series._index, + name=self.series.name, ) @_cudf_nvtx_annotate diff --git a/python/cudf/cudf/core/single_column_frame.py b/python/cudf/cudf/core/single_column_frame.py index de10261315c..3e91aa634f4 100644 --- a/python/cudf/cudf/core/single_column_frame.py +++ b/python/cudf/cudf/core/single_column_frame.py @@ -34,7 +34,12 @@ class SingleColumnFrame(Frame, NotIterable): @_cudf_nvtx_annotate def _reduce( - self, op, axis=None, level=None, numeric_only=None, **kwargs, + self, + op, + axis=None, + level=None, + numeric_only=None, + **kwargs, ): if axis not in (None, 0): raise NotImplementedError("axis parameter is not implemented yet") diff --git a/python/cudf/cudf/core/tools/datetimes.py b/python/cudf/cudf/core/tools/datetimes.py index b110a10e1e7..f766ea0de74 100644 --- a/python/cudf/cudf/core/tools/datetimes.py +++ b/python/cudf/cudf/core/tools/datetimes.py @@ -346,12 +346,14 @@ def _process_col(col, unit, dayfirst, infer_datetime_format, format): else: if infer_datetime_format and format is None: format = column.datetime.infer_format( - element=col[0], dayfirst=dayfirst, + element=col[0], + dayfirst=dayfirst, ) elif format is None: format = column.datetime.infer_format(element=col[0]) col = col.as_datetime_column( - dtype=_unit_dtype_map[unit], format=format, + dtype=_unit_dtype_map[unit], + format=format, ) return col @@ -923,8 +925,7 @@ def date_range( def _has_fixed_frequency(freq: DateOffset) -> bool: - """Utility to determine if `freq` contains fixed frequency offset - """ + """Utility to determine if `freq` contains fixed frequency offset""" fixed_frequencies = { "weeks", "days", @@ -940,8 +941,7 @@ def _has_fixed_frequency(freq: DateOffset) -> bool: def _has_non_fixed_frequency(freq: DateOffset) -> bool: - """Utility to determine if `freq` contains non-fixed frequency offset - """ + """Utility to determine if `freq` contains non-fixed frequency offset""" non_fixed_frequencies = {"years", "months"} return len(freq.kwds.keys() & non_fixed_frequencies) > 0 diff --git a/python/cudf/cudf/core/tools/numeric.py b/python/cudf/cudf/core/tools/numeric.py index d589b68e7b2..7eea7cedaad 100644 --- a/python/cudf/cudf/core/tools/numeric.py +++ b/python/cudf/cudf/core/tools/numeric.py @@ -247,6 +247,8 @@ def _proc_inf_strings(col): # TODO: This can be handled by libcudf in # future see StringColumn.as_numerical_column col = libstrings.replace_multi( - col, as_column(["+", "inf", "inity"]), as_column(["", "Inf", ""]), + col, + as_column(["+", "inf", "inity"]), + as_column(["", "Inf", ""]), ) return col diff --git a/python/cudf/cudf/core/udf/lowering.py b/python/cudf/cudf/core/udf/lowering.py index 3b6b3b4b831..b54dd9c2367 100644 --- a/python/cudf/cudf/core/udf/lowering.py +++ b/python/cudf/cudf/core/udf/lowering.py @@ -1,3 +1,5 @@ +# Copyright (c) 2021-2022, NVIDIA CORPORATION. + import operator from llvmlite import ir @@ -117,7 +119,8 @@ def masked_scalar_unary_op_impl(context, builder, sig, args): builder, lambda x: op(x), nb_signature( - masked_return_type.value_type, masked_type_1.value_type, + masked_return_type.value_type, + masked_type_1.value_type, ), (m1.value,), ) diff --git a/python/cudf/cudf/core/udf/typing.py b/python/cudf/cudf/core/udf/typing.py index 56e8bec74dc..2be1691a1a6 100644 --- a/python/cudf/cudf/core/udf/typing.py +++ b/python/cudf/cudf/core/udf/typing.py @@ -1,3 +1,5 @@ +# Copyright (c) 2021-2022, NVIDIA CORPORATION. + import operator from numba import types @@ -271,7 +273,11 @@ def generic(self, args, kws): if isinstance(args[0], MaskedType) and isinstance(args[1], NAType): # In the case of op(Masked, NA), the result has the same # dtype as the original regardless of what it is - return nb_signature(args[0], args[0], na_type,) + return nb_signature( + args[0], + args[0], + na_type, + ) elif isinstance(args[0], NAType) and isinstance(args[1], MaskedType): return nb_signature(args[1], na_type, args[1]) @@ -299,7 +305,11 @@ def generic(self, args, kws): return_type = self.context.resolve_function_type( self.key, to_resolve_types, kws ).return_type - return nb_signature(MaskedType(return_type), args[0], args[1],) + return nb_signature( + MaskedType(return_type), + args[0], + args[1], + ) @cuda_decl_registry.register_global(operator.is_) diff --git a/python/cudf/cudf/core/window/rolling.py b/python/cudf/cudf/core/window/rolling.py index fa482d52104..53cbaebb9f1 100644 --- a/python/cudf/cudf/core/window/rolling.py +++ b/python/cudf/cudf/core/window/rolling.py @@ -273,7 +273,10 @@ def _apply_agg(self, agg_name): return self._apply_agg_dataframe(self.obj, agg_name) def _reduce( - self, op: str, *args, **kwargs, + self, + op: str, + *args, + **kwargs, ): """Calculate the rolling {op}. diff --git a/python/cudf/cudf/io/avro.py b/python/cudf/cudf/io/avro.py index 9e38b6e896d..e4824c2ccbe 100644 --- a/python/cudf/cudf/io/avro.py +++ b/python/cudf/cudf/io/avro.py @@ -1,4 +1,4 @@ -# Copyright (c) 2019, NVIDIA CORPORATION. +# Copyright (c) 2019-2022, NVIDIA CORPORATION. import cudf from cudf import _lib as libcudf from cudf.utils import ioutils @@ -16,7 +16,8 @@ def read_avro( """{docstring}""" is_single_filepath_or_buffer = ioutils.ensure_single_filepath_or_buffer( - path_or_data=filepath_or_buffer, **kwargs, + path_or_data=filepath_or_buffer, + **kwargs, ) if not is_single_filepath_or_buffer: raise NotImplementedError( diff --git a/python/cudf/cudf/io/csv.py b/python/cudf/cudf/io/csv.py index f15fef19c07..a81563884d9 100644 --- a/python/cudf/cudf/io/csv.py +++ b/python/cudf/cudf/io/csv.py @@ -52,7 +52,8 @@ def read_csv( """{docstring}""" is_single_filepath_or_buffer = ioutils.ensure_single_filepath_or_buffer( - path_or_data=filepath_or_buffer, **kwargs, + path_or_data=filepath_or_buffer, + **kwargs, ) if not is_single_filepath_or_buffer: raise NotImplementedError( diff --git a/python/cudf/cudf/io/json.py b/python/cudf/cudf/io/json.py index 1f876214b16..142b9c26f96 100644 --- a/python/cudf/cudf/io/json.py +++ b/python/cudf/cudf/io/json.py @@ -1,4 +1,4 @@ -# Copyright (c) 2019-2020, NVIDIA CORPORATION. +# Copyright (c) 2019-2022, NVIDIA CORPORATION. import warnings from io import BytesIO, StringIO @@ -65,7 +65,8 @@ def read_json( ) if not ioutils.ensure_single_filepath_or_buffer( - path_or_data=path_or_buf, **kwargs, + path_or_data=path_or_buf, + **kwargs, ): raise NotImplementedError( "`read_json` does not yet support reading " diff --git a/python/cudf/cudf/io/orc.py b/python/cudf/cudf/io/orc.py index 62260cbb822..0ac0e02e4d1 100644 --- a/python/cudf/cudf/io/orc.py +++ b/python/cudf/cudf/io/orc.py @@ -162,7 +162,9 @@ def read_orc_metadata(path): @ioutils.doc_read_orc_statistics() def read_orc_statistics( - filepaths_or_buffers, columns=None, **kwargs, + filepaths_or_buffers, + columns=None, + **kwargs, ): """{docstring}""" @@ -321,7 +323,9 @@ def read_orc( for source in filepath_or_buffer: if ioutils.is_directory(source, **kwargs): fs = ioutils._ensure_filesystem( - passed_filesystem=None, path=source, **kwargs, + passed_filesystem=None, + path=source, + **kwargs, ) source = stringify_path(source) source = fs.sep.join([source, "*.orc"]) diff --git a/python/cudf/cudf/io/parquet.py b/python/cudf/cudf/io/parquet.py index 52203d0194b..baedc3f174b 100644 --- a/python/cudf/cudf/io/parquet.py +++ b/python/cudf/cudf/io/parquet.py @@ -179,7 +179,11 @@ def read_parquet_metadata(path): @_cudf_nvtx_annotate def _process_dataset( - paths, fs, filters=None, row_groups=None, categorical_partitions=True, + paths, + fs, + filters=None, + row_groups=None, + categorical_partitions=True, ): # Returns: # file_list - Expanded/filtered list of paths @@ -203,7 +207,10 @@ def _process_dataset( # Initialize ds.FilesystemDataset dataset = ds.dataset( - paths, filesystem=fs, format="parquet", partitioning="hive", + paths, + filesystem=fs, + format="parquet", + partitioning="hive", ) file_list = dataset.files if len(file_list) == 0: @@ -287,7 +294,8 @@ def _process_dataset( filtered_row_groups = [ rg_info.id for rg_fragment in file_fragment.split_by_row_group( - filters, schema=dataset.schema, + filters, + schema=dataset.schema, ) for rg_info in rg_fragment.row_groups ] @@ -390,7 +398,10 @@ def read_parquet( filepaths_or_buffers = [] if use_python_file_object: open_file_options = _default_open_file_options( - open_file_options, columns, row_groups, fs=fs, + open_file_options, + columns, + row_groups, + fs=fs, ) for i, source in enumerate(filepath_or_buffer): tmp_source, compression = ioutils.get_filepath_or_buffer( @@ -455,7 +466,10 @@ def _parquet_to_frame( # one call to `_read_parquet` if not partition_keys: return _read_parquet( - paths_or_buffers, *args, row_groups=row_groups, **kwargs, + paths_or_buffers, + *args, + row_groups=row_groups, + **kwargs, ) # For partitioned data, we need a distinct read for each @@ -477,7 +491,10 @@ def _parquet_to_frame( # Add new DataFrame to our list dfs.append( _read_parquet( - key_paths, *args, row_groups=key_row_groups, **kwargs, + key_paths, + *args, + row_groups=key_row_groups, + **kwargs, ) ) # Add partition columns to the last DataFrame diff --git a/python/cudf/cudf/io/text.py b/python/cudf/cudf/io/text.py index e5a3beb7d61..86f99b319f0 100644 --- a/python/cudf/cudf/io/text.py +++ b/python/cudf/cudf/io/text.py @@ -11,7 +11,10 @@ @_cudf_nvtx_annotate @ioutils.doc_read_text() def read_text( - filepath_or_buffer, delimiter=None, byte_range=None, **kwargs, + filepath_or_buffer, + delimiter=None, + byte_range=None, + **kwargs, ): """{docstring}""" diff --git a/python/cudf/cudf/testing/_utils.py b/python/cudf/cudf/testing/_utils.py index f6b5e0f3ccc..2ff311c1399 100644 --- a/python/cudf/cudf/testing/_utils.py +++ b/python/cudf/cudf/testing/_utils.py @@ -320,7 +320,8 @@ def gen_rand_series(dtype, size, **kwargs): def _decimal_series(input, dtype): return cudf.Series( - [x if x is None else Decimal(x) for x in input], dtype=dtype, + [x if x is None else Decimal(x) for x in input], + dtype=dtype, ) diff --git a/python/cudf/cudf/testing/dataset_generator.py b/python/cudf/cudf/testing/dataset_generator.py index e1c7b42c7a3..c3e25adad77 100644 --- a/python/cudf/cudf/testing/dataset_generator.py +++ b/python/cudf/cudf/testing/dataset_generator.py @@ -75,7 +75,10 @@ class Parameters: """ def __init__( - self, num_rows=2048, column_parameters=None, seed=None, + self, + num_rows=2048, + column_parameters=None, + seed=None, ): self.num_rows = num_rows if column_parameters is None: @@ -201,7 +204,10 @@ def _generate_column(column_params, num_rows): def generate( - path, parameters, format=None, use_threads=True, + path, + parameters, + format=None, + use_threads=True, ): """ Generate dataset using given parameters and write to given format @@ -294,7 +300,10 @@ def get_dataframe(parameters, use_threads): pool.close() pool.join() # Convert to Pandas DataFrame and sort columns appropriately - tbl = pa.Table.from_arrays(column_data, schema=schema,) + tbl = pa.Table.from_arrays( + column_data, + schema=schema, + ) if columns_to_sort: tbl = tbl.to_pandas() tbl = tbl.sort_values(columns_to_sort) @@ -303,7 +312,7 @@ def get_dataframe(parameters, use_threads): def rand_dataframe( - dtypes_meta, rows, seed=random.randint(0, 2 ** 32 - 1), use_threads=True + dtypes_meta, rows, seed=random.randint(0, 2**32 - 1), use_threads=True ): """ Generates a random table. @@ -550,7 +559,11 @@ def rand_dataframe( # is merged. df = get_dataframe( - Parameters(num_rows=rows, column_parameters=column_params, seed=seed,), + Parameters( + num_rows=rows, + column_parameters=column_params, + seed=seed, + ), use_threads=use_threads, ) @@ -568,7 +581,10 @@ def int_generator(dtype, size, min_bound=None, max_bound=None): low, high = iinfo.min, iinfo.max return lambda: np.random.randint( - low=low, high=high, size=size, dtype=dtype, + low=low, + high=high, + size=size, + dtype=dtype, ) @@ -578,12 +594,18 @@ def float_generator(dtype, size, min_bound=None, max_bound=None): """ if min_bound is not None and max_bound is not None: low, high = min_bound, max_bound - return lambda: np.random.uniform(low=low, high=high, size=size,) + return lambda: np.random.uniform( + low=low, + high=high, + size=size, + ) else: finfo = np.finfo(dtype) return ( lambda: np.random.uniform( - low=finfo.min / 2, high=finfo.max / 2, size=size, + low=finfo.min / 2, + high=finfo.max / 2, + size=size, ) * 2 ) @@ -632,11 +654,11 @@ def boolean_generator(size): def decimal_generator(dtype, size): max_integral = 10 ** (dtype.precision - dtype.scale) - 1 - max_float = (10 ** dtype.scale - 1) if dtype.scale != 0 else 0 + max_float = (10**dtype.scale - 1) if dtype.scale != 0 else 0 return lambda: ( np.random.uniform( low=-max_integral, - high=max_integral + (max_float / 10 ** dtype.scale), + high=max_integral + (max_float / 10**dtype.scale), size=size, ) ) @@ -658,7 +680,10 @@ def get_values_for_nested_data(dtype, lists_max_length=None, size=None): values = float_generator(dtype=dtype, size=cardinality)() elif dtype.kind in ("U", "O"): values = [ - mimesis.random.random.schoice(string.printable, 100,) + mimesis.random.random.schoice( + string.printable, + 100, + ) for _ in range(cardinality) ] elif dtype.kind == "M": @@ -722,7 +747,9 @@ def make_array_for_struct(dtype, cardinality, size, max_null_frequency): return pa.array( vals, mask=np.random.choice( - [True, False], size=size, p=[null_frequency, 1 - null_frequency], + [True, False], + size=size, + p=[null_frequency, 1 - null_frequency], ) if null_frequency > 0.0 else None, diff --git a/python/cudf/cudf/tests/test_array_ufunc.py b/python/cudf/cudf/tests/test_array_ufunc.py index 9d762f26ebd..19ef2b66c2a 100644 --- a/python/cudf/cudf/tests/test_array_ufunc.py +++ b/python/cudf/cudf/tests/test_array_ufunc.py @@ -60,7 +60,9 @@ def test_ufunc_index(ufunc): # scale to avoid issues with overflow, etc. We use ints because some # operations (like bitwise ops) are not defined for floats. pandas_args = args = [ - cudf.Index(cp.random.randint(low=1, high=10, size=N),) + cudf.Index( + cp.random.randint(low=1, high=10, size=N), + ) for _ in range(ufunc.nin) ] @@ -283,7 +285,8 @@ def test_binary_ufunc_series_array(ufunc, has_nulls, indexed, type_, reflect): @pytest.mark.parametrize( - "func", [np.add], + "func", + [np.add], ) def test_ufunc_cudf_series_error_with_out_kwarg(func): cudf_s1 = cudf.Series(data=[-1, 2, 3, 0]) diff --git a/python/cudf/cudf/tests/test_binops.py b/python/cudf/cudf/tests/test_binops.py index aa4075eb887..742a3d7cd06 100644 --- a/python/cudf/cudf/tests/test_binops.py +++ b/python/cudf/cudf/tests/test_binops.py @@ -1463,8 +1463,8 @@ def test_scalar_power(dtype_l, dtype_r): lval_gpu = cudf.Scalar(test_value, dtype=dtype_l) rval_gpu = cudf.Scalar(test_value, dtype=dtype_r) - expect = lval_host ** rval_host - got = lval_gpu ** rval_gpu + expect = lval_host**rval_host + got = lval_gpu**rval_gpu assert expect == got.value assert expect.dtype == got.dtype @@ -1478,7 +1478,7 @@ def test_scalar_power_invalid(dtype_l, dtype_r): rval_gpu = cudf.Scalar(test_value, dtype=dtype_r) with pytest.raises(TypeError): - lval_gpu ** rval_gpu + lval_gpu**rval_gpu @pytest.mark.parametrize( diff --git a/python/cudf/cudf/tests/test_categorical.py b/python/cudf/cudf/tests/test_categorical.py index 5bceaac45c7..61f09c39123 100644 --- a/python/cudf/cudf/tests/test_categorical.py +++ b/python/cudf/cudf/tests/test_categorical.py @@ -38,7 +38,9 @@ def _hide_deprecated_pandas_categorical_inplace_warnings(function_name): def _hide_cudf_safe_casting_warning(): with warnings.catch_warnings(): warnings.filterwarnings( - "ignore", "Can't safely cast column", category=UserWarning, + "ignore", + "Can't safely cast column", + category=UserWarning, ) yield diff --git a/python/cudf/cudf/tests/test_column.py b/python/cudf/cudf/tests/test_column.py index 365b351061d..854e79af9f4 100644 --- a/python/cudf/cudf/tests/test_column.py +++ b/python/cudf/cudf/tests/test_column.py @@ -415,8 +415,16 @@ def test_as_column_buffer(data, expected): {"type": pa.decimal128(3)}, {"dtype": cudf.core.dtypes.Decimal128Dtype(3, 0)}, ), - ([{"a": 1, "b": 3}, {"c": 2, "d": 4}], {}, {},), - ([[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]], {}, {},), + ( + [{"a": 1, "b": 3}, {"c": 2, "d": 4}], + {}, + {}, + ), + ( + [[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]], + {}, + {}, + ), ], ) def test_as_column_arrow_array(data, pyarrow_kwargs, cudf_kwargs): @@ -533,7 +541,8 @@ def test_concatenate_large_column_strings(): ], ) @pytest.mark.parametrize( - "data", [[1, 2, 0]], + "data", + [[1, 2, 0]], ) def test_astype_with_aliases(alias, expect_dtype, data): pd_data = pd.Series(data) diff --git a/python/cudf/cudf/tests/test_concat.py b/python/cudf/cudf/tests/test_concat.py index 1ab5931fe5f..3cc3e4153b1 100644 --- a/python/cudf/cudf/tests/test_concat.py +++ b/python/cudf/cudf/tests/test_concat.py @@ -341,7 +341,9 @@ def test_pandas_concat_compatibility_axis1(): got = gd.concat([d1, d2, d3, d4, d5], axis=1) assert_eq( - got, expect, check_index_type=True, + got, + expect, + check_index_type=True, ) @@ -658,7 +660,9 @@ def test_concat_dataframe_with_multiIndex(df1, df2): expected = pd.concat([pdf1, pdf2], axis=1) assert_eq( - expected, actual, check_index_type=True, + expected, + actual, + check_index_type=True, ) @@ -749,7 +753,14 @@ def test_concat_join_axis_1_dup_error(objs): # we do not support duplicate columns with pytest.raises(NotImplementedError): assert_eq( - pd.concat(objs, axis=1,), gd.concat(gpu_objs, axis=1,), + pd.concat( + objs, + axis=1, + ), + gd.concat( + gpu_objs, + axis=1, + ), ) @@ -781,7 +792,11 @@ def test_concat_join_axis_1(objs, ignore_index, sort, join, axis): objs, sort=sort, join=join, ignore_index=ignore_index, axis=axis ) actual = gd.concat( - gpu_objs, sort=sort, join=join, ignore_index=ignore_index, axis=axis, + gpu_objs, + sort=sort, + join=join, + ignore_index=ignore_index, + axis=axis, ) # TODO: Remove special handling below # after following bug from pandas is fixed: @@ -969,7 +984,9 @@ def test_concat_join_no_overlapping_columns_many_and_empty( axis=axis, ) assert_eq( - expected, actual, check_index_type=False, + expected, + actual, + check_index_type=False, ) @@ -1028,10 +1045,18 @@ def test_concat_join_no_overlapping_columns_many_and_empty2( objs_gd = [gd.from_pandas(o) if o is not None else o for o in objs] expected = pd.concat( - objs, sort=sort, join=join, ignore_index=ignore_index, axis=axis, + objs, + sort=sort, + join=join, + ignore_index=ignore_index, + axis=axis, ) actual = gd.concat( - objs_gd, sort=sort, join=join, ignore_index=ignore_index, axis=axis, + objs_gd, + sort=sort, + join=join, + ignore_index=ignore_index, + axis=axis, ) assert_eq(expected, actual, check_index_type=False) diff --git a/python/cudf/cudf/tests/test_csv.py b/python/cudf/cudf/tests/test_csv.py index 6176184b670..0c4bf68faa9 100644 --- a/python/cudf/cudf/tests/test_csv.py +++ b/python/cudf/cudf/tests/test_csv.py @@ -580,7 +580,9 @@ def test_csv_reader_NaN_values(): # data type detection should evaluate the column to int8 (all nulls) gdf = read_csv( - StringIO(all_cells), header=None, na_values=custom_na_values, + StringIO(all_cells), + header=None, + na_values=custom_na_values, ) assert gdf.dtypes[0] == "int8" assert all(gdf["0"][idx] is cudf.NA for idx in range(len(gdf["0"]))) diff --git a/python/cudf/cudf/tests/test_cut.py b/python/cudf/cudf/tests/test_cut.py index 710df78e36b..8dda5e793a0 100644 --- a/python/cudf/cudf/tests/test_cut.py +++ b/python/cudf/cudf/tests/test_cut.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021, NVIDIA CORPORATION. +# Copyright (c) 2021-2022, NVIDIA CORPORATION. """ Test related to Cut @@ -132,15 +132,26 @@ def test_cut_labels_non_unique( ], ) @pytest.mark.parametrize( - "bins", [1, 2, 3, [1, 2, 3], [0, 2, 4, 6, 10]], + "bins", + [1, 2, 3, [1, 2, 3], [0, 2, 4, 6, 10]], ) @pytest.mark.parametrize("right", [True, False]) @pytest.mark.parametrize("precision", [3]) def test_cut_right(x, bins, right, precision): - pcat = pd.cut(x=x, bins=bins, right=right, precision=precision,) + pcat = pd.cut( + x=x, + bins=bins, + right=right, + precision=precision, + ) pindex = pd.CategoricalIndex(pcat) - gindex = cut(x=x, bins=bins, right=right, precision=precision,) + gindex = cut( + x=x, + bins=bins, + right=right, + precision=precision, + ) assert_eq(pindex, gindex) @@ -155,7 +166,8 @@ def test_cut_right(x, bins, right, precision): ], ) @pytest.mark.parametrize( - "bins", [[0, 2, 4, 6, 10, 10], [1, 2, 2, 3, 3]], + "bins", + [[0, 2, 4, 6, 10, 10], [1, 2, 2, 3, 3]], ) @pytest.mark.parametrize("right", [True, False]) @pytest.mark.parametrize("include_lowest", [True, False]) @@ -199,7 +211,8 @@ def test_cut_drop_duplicates( ], ) @pytest.mark.parametrize( - "bins", [[0, 2, 4, 6, 10, 10], [1, 2, 2, 3, 3]], + "bins", + [[0, 2, 4, 6, 10, 10], [1, 2, 2, 3, 3]], ) @pytest.mark.parametrize("right", [True, False]) @pytest.mark.parametrize("include_lowest", [True, False]) @@ -244,7 +257,8 @@ def test_cut_drop_duplicates_raises( ], ) @pytest.mark.parametrize( - "bins", [pd.IntervalIndex.from_tuples([(0, 1), (2, 3), (4, 5)])], + "bins", + [pd.IntervalIndex.from_tuples([(0, 1), (2, 3), (4, 5)])], ) @pytest.mark.parametrize("right", [True, False]) @pytest.mark.parametrize("precision", [1, 2, 3]) diff --git a/python/cudf/cudf/tests/test_dataframe.py b/python/cudf/cudf/tests/test_dataframe.py index 08c8e3485a3..303c245777c 100644 --- a/python/cudf/cudf/tests/test_dataframe.py +++ b/python/cudf/cudf/tests/test_dataframe.py @@ -322,7 +322,8 @@ def test_dataframe_basic(): ], ) @pytest.mark.parametrize( - "columns", [["a"], ["b"], "a", "b", ["a", "b"]], + "columns", + [["a"], ["b"], "a", "b", ["a", "b"]], ) @pytest.mark.parametrize("inplace", [True, False]) def test_dataframe_drop_columns(pdf, columns, inplace): @@ -423,8 +424,14 @@ def test_dataframe_drop_index(pdf, index, inplace): ("weight", 1), ("length", 1), ("cow", None), - ("lama", None,), - ("falcon", None,), + ( + "lama", + None, + ), + ( + "falcon", + None, + ), ], ) @pytest.mark.parametrize("inplace", [True, False]) @@ -452,7 +459,8 @@ def test_dataframe_drop_multiindex(pdf, index, level, inplace): ], ) @pytest.mark.parametrize( - "labels", [["a"], ["b"], "a", "b", ["a", "b"]], + "labels", + [["a"], ["b"], "a", "b", ["a", "b"]], ) @pytest.mark.parametrize("inplace", [True, False]) def test_dataframe_drop_labels_axis_1(pdf, labels, inplace): @@ -1828,7 +1836,8 @@ def test_dataframe_transpose(nulls, num_cols, num_rows, dtype): for i in range(num_cols): colname = string.ascii_lowercase[i] data = pd.Series( - np.random.randint(0, 26, num_rows).astype(np_dtype), dtype=dtype, + np.random.randint(0, 26, num_rows).astype(np_dtype), + dtype=dtype, ) if nulls == "some": idx = np.random.choice( @@ -3039,7 +3048,8 @@ def test_dataframe_sort_index( index, axis, ascending, inplace, ignore_index, na_position ): pdf = pd.DataFrame( - {"b": [1, 3, 2], "a": [1, 4, 3], "c": [4, 1, 5]}, index=index, + {"b": [1, 3, 2], "a": [1, 4, 3], "c": [4, 1, 5]}, + index=index, ) gdf = cudf.DataFrame.from_pandas(pdf) @@ -3276,7 +3286,8 @@ def test_select_dtype(): ) assert_exceptions_equal( - lfunc=pdf.select_dtypes, rfunc=gdf.select_dtypes, + lfunc=pdf.select_dtypes, + rfunc=gdf.select_dtypes, ) gdf = cudf.DataFrame( @@ -3297,7 +3308,8 @@ def test_select_dtype(): ) pdf = gdf.to_pandas() assert_eq( - pdf.select_dtypes("int64"), gdf.select_dtypes("int64"), + pdf.select_dtypes("int64"), + gdf.select_dtypes("int64"), ) @@ -4151,7 +4163,8 @@ def test_series_values_host_property(data): marks=pytest.mark.xfail(raises=NotImplementedError), ), pytest.param( - ["m", "a", "d", "v"], marks=pytest.mark.xfail(raises=TypeError), + ["m", "a", "d", "v"], + marks=pytest.mark.xfail(raises=TypeError), ), ], ) @@ -4706,7 +4719,8 @@ def test_rowwise_ops_nullable_dtypes_partial_null(op, expected): { "a": [10, 11, 12, 13, 14, 15], "b": cudf.Series( - [10, None, np.NaN, 2234, None, np.NaN], nan_as_null=False, + [10, None, np.NaN, 2234, None, np.NaN], + nan_as_null=False, ), } ) @@ -4725,33 +4739,51 @@ def test_rowwise_ops_nullable_dtypes_partial_null(op, expected): [ ( "max", - cudf.Series([10, None, None, 2234, None, 453], dtype="int64",), + cudf.Series( + [10, None, None, 2234, None, 453], + dtype="int64", + ), + ), + ( + "min", + cudf.Series( + [10, None, None, 13, None, 15], + dtype="int64", + ), ), - ("min", cudf.Series([10, None, None, 13, None, 15], dtype="int64",),), ( "sum", - cudf.Series([20, None, None, 2247, None, 468], dtype="int64",), + cudf.Series( + [20, None, None, 2247, None, 468], + dtype="int64", + ), ), ( "product", - cudf.Series([100, None, None, 29042, None, 6795], dtype="int64",), + cudf.Series( + [100, None, None, 29042, None, 6795], + dtype="int64", + ), ), ( "mean", cudf.Series( - [10.0, None, None, 1123.5, None, 234.0], dtype="float32", + [10.0, None, None, 1123.5, None, 234.0], + dtype="float32", ), ), ( "var", cudf.Series( - [0.0, None, None, 1233210.25, None, 47961.0], dtype="float32", + [0.0, None, None, 1233210.25, None, 47961.0], + dtype="float32", ), ), ( "std", cudf.Series( - [0.0, None, None, 1110.5, None, 219.0], dtype="float32", + [0.0, None, None, 1110.5, None, 219.0], + dtype="float32", ), ), ], @@ -4761,7 +4793,8 @@ def test_rowwise_ops_nullable_int_dtypes(op, expected): { "a": [10, 11, None, 13, None, 15], "b": cudf.Series( - [10, None, 323, 2234, None, 453], nan_as_null=False, + [10, None, 323, 2234, None, 453], + nan_as_null=False, ), } ) @@ -4977,7 +5010,8 @@ def test_insert(data): @pytest.mark.parametrize( - "data", [{"A": [1, 2, 3], "B": ["a", "b", "c"]}], + "data", + [{"A": [1, 2, 3], "B": ["a", "b", "c"]}], ) def test_insert_NA(data): pdf = pd.DataFrame.from_dict(data) @@ -8090,7 +8124,8 @@ def custom_func(df, column): @pytest.mark.parametrize( - "op", ["count", "kurt", "kurtosis", "skew"], + "op", + ["count", "kurt", "kurtosis", "skew"], ) def test_dataframe_axis1_unsupported_ops(op): df = cudf.DataFrame({"a": [1, 2, 3], "b": [8, 9, 10]}) @@ -8273,13 +8308,16 @@ def test_agg_for_dataframe_with_string_columns(aggs): @pytest.mark.parametrize( - "join", ["left"], + "join", + ["left"], ) @pytest.mark.parametrize( - "overwrite", [True, False], + "overwrite", + [True, False], ) @pytest.mark.parametrize( - "errors", ["ignore"], + "errors", + ["ignore"], ) @pytest.mark.parametrize( "data", @@ -8336,7 +8374,8 @@ def test_update_for_dataframes(data, data2, join, overwrite, errors): @pytest.mark.parametrize( - "join", ["right"], + "join", + ["right"], ) def test_update_for_right_join(join): gdf = cudf.DataFrame({"a": [1, 2, 3], "b": [3.0, 4.0, 5.0]}) @@ -8349,7 +8388,8 @@ def test_update_for_right_join(join): @pytest.mark.parametrize( - "errors", ["raise"], + "errors", + ["raise"], ) def test_update_for_data_overlap(errors): pdf = pd.DataFrame({"a": [1, 2, 3], "b": [3.0, 4.0, 5.0]}) @@ -8440,10 +8480,12 @@ def test_dataframe_setitem_cupy_array(): "data", [{"a": [1, 2, 3], "b": [4, 5, 6], "c": [7, 8, 9]}] ) @pytest.mark.parametrize( - "index", [{0: 123, 1: 4, 2: 6}], + "index", + [{0: 123, 1: 4, 2: 6}], ) @pytest.mark.parametrize( - "level", ["x", 0], + "level", + ["x", 0], ) def test_rename_for_level_MultiIndex_dataframe(data, index, level): pdf = pd.DataFrame( @@ -8463,10 +8505,12 @@ def test_rename_for_level_MultiIndex_dataframe(data, index, level): "data", [{"a": [1, 2, 3], "b": [4, 5, 6], "c": [7, 8, 9]}] ) @pytest.mark.parametrize( - "columns", [{"a": "f", "b": "g"}, {1: 3, 2: 4}, lambda s: 2 * s], + "columns", + [{"a": "f", "b": "g"}, {1: 3, 2: 4}, lambda s: 2 * s], ) @pytest.mark.parametrize( - "level", [0, 1], + "level", + [0, 1], ) def test_rename_for_level_MultiColumn_dataframe(data, columns, level): gdf = cudf.DataFrame(data) @@ -8654,7 +8698,8 @@ def test_dataframe_indexing_setitem_np_cp_array(array, is_error): @pytest.mark.parametrize( - "data", [{"a": [1, 2, 3], "b": [1, 1, 0]}], + "data", + [{"a": [1, 2, 3], "b": [1, 1, 0]}], ) def test_frame_series_where_other(data): gdf = cudf.DataFrame(data) @@ -8714,7 +8759,8 @@ def test_frame_series_where_other(data): ], ) @pytest.mark.parametrize( - "min_per", [0, 1, 2, 3, 4], + "min_per", + [0, 1, 2, 3, 4], ) def test_pearson_corr_passing(data, gkey, min_per): gdf = cudf.DataFrame(data) @@ -8752,7 +8798,10 @@ def test_pearson_corr_empty_columns(): expected = pdf.groupby("id").corr("pearson") assert_eq( - expected, actual, check_dtype=False, check_index_type=False, + expected, + actual, + check_dtype=False, + check_index_type=False, ) @@ -8774,7 +8823,8 @@ def test_pearson_corr_empty_columns(): @pytest.mark.parametrize("gkey", ["id", "val1", "val2"]) def test_pearson_corr_invalid_column_types(data, gkey): with pytest.raises( - TypeError, match="Correlation accepts only numerical column-pairs", + TypeError, + match="Correlation accepts only numerical column-pairs", ): cudf.DataFrame(data).groupby(gkey).corr("pearson") @@ -8865,10 +8915,12 @@ def test_dataframe_add_suffix(): ], ) @pytest.mark.parametrize( - "min_periods", [0, 3], + "min_periods", + [0, 3], ) @pytest.mark.parametrize( - "ddof", [1, 2], + "ddof", + [1, 2], ) def test_groupby_covariance(data, gkey, min_periods, ddof): gdf = cudf.DataFrame(data) @@ -8904,7 +8956,10 @@ def test_groupby_covariance_empty_columns(): expected = pdf.groupby("id").cov() assert_eq( - expected, actual, check_dtype=False, check_index_type=False, + expected, + actual, + check_dtype=False, + check_index_type=False, ) @@ -8917,7 +8972,8 @@ def test_groupby_cov_invalid_column_types(): }, ) with pytest.raises( - TypeError, match="Covariance accepts only numerical column-pairs", + TypeError, + match="Covariance accepts only numerical column-pairs", ): gdf.groupby("id").cov() @@ -8940,7 +8996,9 @@ def test_groupby_cov_positive_semidefinite_matrix(): expected.reset_index(drop=True, inplace=True) assert_eq( - expected, actual, check_dtype=False, + expected, + actual, + check_dtype=False, ) @@ -8979,15 +9037,19 @@ def test_diff_dataframe_numeric_dtypes(data, periods): expected = pdf.diff(periods=periods, axis=0) assert_eq( - expected, actual, check_dtype=False, + expected, + actual, + check_dtype=False, ) @pytest.mark.parametrize( - ("precision", "scale"), [(5, 2), (8, 5)], + ("precision", "scale"), + [(5, 2), (8, 5)], ) @pytest.mark.parametrize( - "dtype", [cudf.Decimal32Dtype, cudf.Decimal64Dtype], + "dtype", + [cudf.Decimal32Dtype, cudf.Decimal64Dtype], ) def test_diff_decimal_dtypes(precision, scale, dtype): gdf = cudf.DataFrame( @@ -9000,7 +9062,9 @@ def test_diff_decimal_dtypes(precision, scale, dtype): expected = pdf.diff() assert_eq( - expected, actual, check_dtype=False, + expected, + actual, + check_dtype=False, ) @@ -9043,7 +9107,8 @@ def test_dataframe_assign_cp_np_array(): @pytest.mark.parametrize( - "data", [{"a": [1, 2, 3], "b": [1, 1, 0]}], + "data", + [{"a": [1, 2, 3], "b": [1, 1, 0]}], ) def test_dataframe_nunique(data): gdf = cudf.DataFrame(data) @@ -9056,7 +9121,8 @@ def test_dataframe_nunique(data): @pytest.mark.parametrize( - "data", [{"key": [0, 1, 1, 0, 0, 1], "val": [1, 8, 3, 9, -3, 8]}], + "data", + [{"key": [0, 1, 1, 0, 0, 1], "val": [1, 8, 3, 9, -3, 8]}], ) def test_dataframe_nunique_index(data): gdf = cudf.DataFrame(data) diff --git a/python/cudf/cudf/tests/test_datetime.py b/python/cudf/cudf/tests/test_datetime.py index 9d120819248..964ac9e5457 100644 --- a/python/cudf/cudf/tests/test_datetime.py +++ b/python/cudf/cudf/tests/test_datetime.py @@ -1,4 +1,4 @@ -# Copyright (c) 2019-2021, NVIDIA CORPORATION. +# Copyright (c) 2019-2022, NVIDIA CORPORATION. import datetime import datetime as dt @@ -580,7 +580,11 @@ def test_datetime_dataframe(): dtype="datetime64[ns]", freq=None, ), - pd.DatetimeIndex([], dtype="datetime64[ns]", freq=None,), + pd.DatetimeIndex( + [], + dtype="datetime64[ns]", + freq=None, + ), pd.Series([1, 2, 3]).astype("datetime64[ns]"), pd.Series([1, 2, 3]).astype("datetime64[us]"), pd.Series([1, 2, 3]).astype("datetime64[ms]"), @@ -681,7 +685,11 @@ def test_to_datetime_not_implemented(): pd.Series([0, 1, -1]), pd.Series([0, 1, -1, 100, 200, 47637]), [10, 12, 1200, 15003], - pd.DatetimeIndex([], dtype="datetime64[ns]", freq=None,), + pd.DatetimeIndex( + [], + dtype="datetime64[ns]", + freq=None, + ), pd.Index([1, 2, 3, 4]), ], ) @@ -941,7 +949,8 @@ def test_datetime_subtract(data, other, data_dtype, other_dtype): ) @pytest.mark.parametrize("dtype", DATETIME_TYPES) @pytest.mark.parametrize( - "op", ["add", "sub"], + "op", + ["add", "sub"], ) def test_datetime_series_ops_with_scalars(data, other_scalars, dtype, op): gsr = cudf.Series(data=data, dtype=dtype) diff --git a/python/cudf/cudf/tests/test_doctests.py b/python/cudf/cudf/tests/test_doctests.py index 05d6886c297..e779ac276a3 100644 --- a/python/cudf/cudf/tests/test_doctests.py +++ b/python/cudf/cudf/tests/test_doctests.py @@ -1,3 +1,4 @@ +# Copyright (c) 2022, NVIDIA CORPORATION. import contextlib import doctest import inspect @@ -88,7 +89,10 @@ def test_docstring(self, docstring): # These global names are pre-defined and can be used in doctests # without first importing them. - globals = dict(cudf=cudf, np=np,) + globals = dict( + cudf=cudf, + np=np, + ) docstring.globs = globals # Capture stdout and include failing outputs in the traceback. diff --git a/python/cudf/cudf/tests/test_dropna.py b/python/cudf/cudf/tests/test_dropna.py index 1e24dd9d275..3e7891ba0af 100644 --- a/python/cudf/cudf/tests/test_dropna.py +++ b/python/cudf/cudf/tests/test_dropna.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2021, NVIDIA CORPORATION. +# Copyright (c) 2020-2022, NVIDIA CORPORATION. import numpy as np import pandas as pd @@ -199,7 +199,8 @@ def test_dropna_thresh_cols(thresh, subset, inplace): actual = gdf assert_eq( - expected, actual, + expected, + actual, ) diff --git a/python/cudf/cudf/tests/test_duplicates.py b/python/cudf/cudf/tests/test_duplicates.py index bc43c82729b..e8a695570f0 100644 --- a/python/cudf/cudf/tests/test_duplicates.py +++ b/python/cudf/cudf/tests/test_duplicates.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2021, NVIDIA CORPORATION. +# Copyright (c) 2020-2022, NVIDIA CORPORATION. import itertools as it import random @@ -615,5 +615,6 @@ def test_drop_duplicates_multi_index(): for col in gdf.columns: assert_df( - gdf[col].drop_duplicates().to_pandas(), pdf[col].drop_duplicates(), + gdf[col].drop_duplicates().to_pandas(), + pdf[col].drop_duplicates(), ) diff --git a/python/cudf/cudf/tests/test_groupby.py b/python/cudf/cudf/tests/test_groupby.py index 61c7d1958a0..eba37c1f5af 100644 --- a/python/cudf/cudf/tests/test_groupby.py +++ b/python/cudf/cudf/tests/test_groupby.py @@ -1,4 +1,4 @@ -# Copyright (c) 2018-2021, NVIDIA CORPORATION. +# Copyright (c) 2018-2022, NVIDIA CORPORATION. import datetime import itertools @@ -223,7 +223,8 @@ def test_groupby_getitem_getattr(as_index): by="x", ) assert_groupby_results_equal( - pdf.groupby("x")[["y"]].sum(), gdf.groupby("x")[["y"]].sum(), + pdf.groupby("x")[["y"]].sum(), + gdf.groupby("x")[["y"]].sum(), ) assert_groupby_results_equal( pdf.groupby(["x", "y"], as_index=as_index).sum(), @@ -375,7 +376,7 @@ def test_groupby_agg_decimal(num_groups, nelem_per_group, func): # The number of digits before the decimal to use. whole_digits = 2 - scale = 10 ** whole_digits + scale = 10**whole_digits nelem = num_groups * nelem_per_group # The unique is necessary because otherwise if there are duplicates idxmin @@ -589,7 +590,8 @@ def test_groupby_levels(level): pdf = pd.DataFrame({"c": [1, 2, 3], "d": [2, 3, 4]}, index=idx) gdf = cudf.from_pandas(pdf) assert_groupby_results_equal( - pdf.groupby(level=level).sum(), gdf.groupby(level=level).sum(), + pdf.groupby(level=level).sum(), + gdf.groupby(level=level).sum(), ) @@ -840,7 +842,11 @@ def test_groupby_multi_agg_hash_groupby(agg): coll_dict[prefix + this_name] = float coll_dict["id"] = int gdf = cudf.datasets.timeseries( - start="2000", end="2000-01-2", dtypes=coll_dict, freq="1s", seed=1, + start="2000", + end="2000-01-2", + dtypes=coll_dict, + freq="1s", + seed=1, ).reset_index(drop=True) pdf = gdf.to_pandas() check_dtype = False if "count" in agg else True @@ -975,7 +981,9 @@ def test_groupby_cat(): ) gdf = cudf.from_pandas(pdf) assert_groupby_results_equal( - pdf.groupby("a").count(), gdf.groupby("a").count(), check_dtype=False, + pdf.groupby("a").count(), + gdf.groupby("a").count(), + check_dtype=False, ) @@ -1046,7 +1054,9 @@ def test_groupby_size(): gdf = cudf.from_pandas(pdf) assert_groupby_results_equal( - pdf.groupby("a").size(), gdf.groupby("a").size(), check_dtype=False, + pdf.groupby("a").size(), + gdf.groupby("a").size(), + check_dtype=False, ) assert_groupby_results_equal( @@ -1057,7 +1067,9 @@ def test_groupby_size(): sr = pd.Series(range(len(pdf))) assert_groupby_results_equal( - pdf.groupby(sr).size(), gdf.groupby(sr).size(), check_dtype=False, + pdf.groupby(sr).size(), + gdf.groupby(sr).size(), + check_dtype=False, ) @@ -1282,7 +1294,8 @@ def test_groupby_nunique(agg, by): @pytest.mark.parametrize( - "n", [0, 1, 2, 10], + "n", + [0, 1, 2, 10], ) @pytest.mark.parametrize("by", ["a", ["a", "b"], ["a", "c"]]) def test_groupby_nth(n, by): diff --git a/python/cudf/cudf/tests/test_hash_vocab.py b/python/cudf/cudf/tests/test_hash_vocab.py index a30f4e20849..dcf40417e4f 100644 --- a/python/cudf/cudf/tests/test_hash_vocab.py +++ b/python/cudf/cudf/tests/test_hash_vocab.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2021, NVIDIA CORPORATION. +# Copyright (c) 2020-2022, NVIDIA CORPORATION. import filecmp import os diff --git a/python/cudf/cudf/tests/test_index.py b/python/cudf/cudf/tests/test_index.py index b96b8386b10..37286c65341 100644 --- a/python/cudf/cudf/tests/test_index.py +++ b/python/cudf/cudf/tests/test_index.py @@ -464,7 +464,8 @@ def test_range_index_from_range(data): @pytest.mark.parametrize( - "n", [-10, -5, -2, 0, 1, 0, 2, 5, 10], + "n", + [-10, -5, -2, 0, 1, 0, 2, 5, 10], ) def test_empty_df_head_tail_index(n): df = cudf.DataFrame() @@ -511,11 +512,36 @@ def test_empty_df_head_tail_index(n): -pd.Index(np.arange(10)), None, ), - (pd.Index([1, 2, np.nan]), pd.Index([1, 2, np.nan]) == 4, None, None,), - (pd.Index([1, 2, np.nan]), pd.Index([1, 2, np.nan]) != 4, None, None,), - (pd.Index([-2, 3, -4, -79]), [True, True, True], None, ValueError,), - (pd.Index([-2, 3, -4, -79]), [True, True, True, False], None, None,), - (pd.Index([-2, 3, -4, -79]), [True, True, True, False], 17, None,), + ( + pd.Index([1, 2, np.nan]), + pd.Index([1, 2, np.nan]) == 4, + None, + None, + ), + ( + pd.Index([1, 2, np.nan]), + pd.Index([1, 2, np.nan]) != 4, + None, + None, + ), + ( + pd.Index([-2, 3, -4, -79]), + [True, True, True], + None, + ValueError, + ), + ( + pd.Index([-2, 3, -4, -79]), + [True, True, True, False], + None, + None, + ), + ( + pd.Index([-2, 3, -4, -79]), + [True, True, True, False], + 17, + None, + ), (pd.Index(list("abcdgh")), pd.Index(list("abcdgh")) != "g", "3", None), ( pd.Index(list("abcdgh")), @@ -1818,7 +1844,8 @@ def test_index_rangeindex_search_range(): @pytest.mark.parametrize( - "rge", [(1, 10, 1), (1, 10, 3), (10, -17, -1), (10, -17, -3)], + "rge", + [(1, 10, 1), (1, 10, 3), (10, -17, -1), (10, -17, -3)], ) def test_index_rangeindex_get_item_basic(rge): pridx = pd.RangeIndex(*rge) @@ -1829,7 +1856,8 @@ def test_index_rangeindex_get_item_basic(rge): @pytest.mark.parametrize( - "rge", [(1, 10, 3), (10, 1, -3)], + "rge", + [(1, 10, 3), (10, 1, -3)], ) def test_index_rangeindex_get_item_out_of_bounds(rge): gridx = cudf.RangeIndex(*rge) @@ -1838,7 +1866,8 @@ def test_index_rangeindex_get_item_out_of_bounds(rge): @pytest.mark.parametrize( - "rge", [(10, 1, 1), (-17, 10, -3)], + "rge", + [(10, 1, 1), (-17, 10, -3)], ) def test_index_rangeindex_get_item_null_range(rge): gridx = cudf.RangeIndex(*rge) @@ -1945,7 +1974,8 @@ def test_get_loc_single_unique_numeric(idx, key, method): @pytest.mark.parametrize( - "idx", [pd.RangeIndex(3, 100, 4)], + "idx", + [pd.RangeIndex(3, 100, 4)], ) @pytest.mark.parametrize("key", list(range(1, 110, 3))) @pytest.mark.parametrize("method", [None, "ffill"]) diff --git a/python/cudf/cudf/tests/test_indexing.py b/python/cudf/cudf/tests/test_indexing.py index c3b414c2d4a..740c32a8a26 100644 --- a/python/cudf/cudf/tests/test_indexing.py +++ b/python/cudf/cudf/tests/test_indexing.py @@ -1379,7 +1379,8 @@ def test_dataframe_sliced(gdf_kwargs, slice): ], ) @pytest.mark.parametrize( - "slice", [slice(6), slice(1), slice(7), slice(1, 3)], + "slice", + [slice(6), slice(1), slice(7), slice(1, 3)], ) def test_dataframe_iloc_index(gdf, slice): pdf = gdf.to_pandas() @@ -1481,7 +1482,7 @@ def test_iloc_decimal(): cudf.Decimal64Dtype(scale=2, precision=3) ) got = sr.iloc[[3, 2, 1, 0]] - expect = cudf.Series(["4.00", "3.00", "2.00", "1.00"],).astype( - cudf.Decimal64Dtype(scale=2, precision=3) - ) + expect = cudf.Series( + ["4.00", "3.00", "2.00", "1.00"], + ).astype(cudf.Decimal64Dtype(scale=2, precision=3)) assert_eq(expect.reset_index(drop=True), got.reset_index(drop=True)) diff --git a/python/cudf/cudf/tests/test_interval.py b/python/cudf/cudf/tests/test_interval.py index fc193441113..e1104829914 100644 --- a/python/cudf/cudf/tests/test_interval.py +++ b/python/cudf/cudf/tests/test_interval.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-2022, NVIDIA CORPORATION. import pandas as pd import pytest @@ -8,7 +8,8 @@ @pytest.mark.parametrize( - "data1, data2", [(1, 2), (1.0, 2.0), (3, 4.0)], + "data1, data2", + [(1, 2), (1.0, 2.0), (3, 4.0)], ) @pytest.mark.parametrize("data3, data4", [(6, 10), (5.0, 9.0), (2, 6.0)]) @pytest.mark.parametrize("closed", ["left", "right", "both", "neither"]) @@ -48,7 +49,8 @@ def test_create_interval_series(data1, data2, data3, data4, closed): @pytest.mark.parametrize( - "data1, data2", [(1, 2), (1.0, 2.0), (3, 4.0)], + "data1, data2", + [(1, 2), (1.0, 2.0), (3, 4.0)], ) @pytest.mark.parametrize("data3, data4", [(6, 10), (5.0, 9.0), (2, 6.0)]) @pytest.mark.parametrize("closed", ["left", "right", "both", "neither"]) diff --git a/python/cudf/cudf/tests/test_joining.py b/python/cudf/cudf/tests/test_joining.py index f478216cdcf..c03d26a0ed2 100644 --- a/python/cudf/cudf/tests/test_joining.py +++ b/python/cudf/cudf/tests/test_joining.py @@ -1248,10 +1248,12 @@ def test_decimal_typecast_outer(dtype): @pytest.mark.parametrize( - "dtype_l", [Decimal64Dtype(7, 3), Decimal64Dtype(9, 5)], + "dtype_l", + [Decimal64Dtype(7, 3), Decimal64Dtype(9, 5)], ) @pytest.mark.parametrize( - "dtype_r", [Decimal64Dtype(8, 3), Decimal64Dtype(11, 6)], + "dtype_r", + [Decimal64Dtype(8, 3), Decimal64Dtype(11, 6)], ) def test_mixed_decimal_typecast(dtype_l, dtype_r): other_data = ["a", "b", "c", "d"] @@ -1893,7 +1895,8 @@ def test_join_merge_with_on(lhs_col, lhs_idx, rhs_col, rhs_idx, on, how): @pytest.mark.parametrize( - "on", ["A", "L0"], + "on", + ["A", "L0"], ) @pytest.mark.parametrize( "how", ["left", "inner", "right", "outer", "leftanti", "leftsemi"] diff --git a/python/cudf/cudf/tests/test_list.py b/python/cudf/cudf/tests/test_list.py index 8cc65de739e..6a665a2b43c 100644 --- a/python/cudf/cudf/tests/test_list.py +++ b/python/cudf/cudf/tests/test_list.py @@ -301,12 +301,32 @@ def test_get_nulls(): @pytest.mark.parametrize( "data, scalar, expect", [ - ([[1, 2, 3], []], 1, [True, False],), - ([[1, 2, 3], [], [3, 4, 5]], 6, [False, False, False],), - ([[1.0, 2.0, 3.0], None, []], 2.0, [True, None, False],), - ([[None, "b", "c"], [], ["b", "e", "f"]], "b", [True, False, True],), + ( + [[1, 2, 3], []], + 1, + [True, False], + ), + ( + [[1, 2, 3], [], [3, 4, 5]], + 6, + [False, False, False], + ), + ( + [[1.0, 2.0, 3.0], None, []], + 2.0, + [True, None, False], + ), + ( + [[None, "b", "c"], [], ["b", "e", "f"]], + "b", + [True, False, True], + ), ([[None, 2, 3], None, []], 1, [False, None, False]), - ([[None, "b", "c"], [], ["b", "e", "f"]], "d", [False, False, False],), + ( + [[None, "b", "c"], [], ["b", "e", "f"]], + "d", + [False, False, False], + ), ], ) def test_contains_scalar(data, scalar, expect): @@ -319,11 +339,26 @@ def test_contains_scalar(data, scalar, expect): @pytest.mark.parametrize( "data, expect", [ - ([[1, 2, 3], []], [None, None],), - ([[1.0, 2.0, 3.0], None, []], [None, None, None],), - ([[None, 2, 3], [], None], [None, None, None],), - ([[1, 2, 3], [3, 4, 5]], [None, None],), - ([[], [], []], [None, None, None],), + ( + [[1, 2, 3], []], + [None, None], + ), + ( + [[1.0, 2.0, 3.0], None, []], + [None, None, None], + ), + ( + [[None, 2, 3], [], None], + [None, None, None], + ), + ( + [[1, 2, 3], [3, 4, 5]], + [None, None], + ), + ( + [[], [], []], + [None, None, None], + ), ], ) def test_contains_null_search_key(data, expect): diff --git a/python/cudf/cudf/tests/test_monotonic.py b/python/cudf/cudf/tests/test_monotonic.py index 7643bfdf050..4eb9ed44a98 100644 --- a/python/cudf/cudf/tests/test_monotonic.py +++ b/python/cudf/cudf/tests/test_monotonic.py @@ -1,4 +1,4 @@ -# Copyright (c) 2019, NVIDIA CORPORATION. +# Copyright (c) 2019-2022, NVIDIA CORPORATION. """ Tests related to is_unique and is_monotonic attributes @@ -261,7 +261,8 @@ def test_rangeindex_get_slice_bound_basic(bounds, indices, side, kind): [(3, 20, 5), (20, 3, -5), (20, 3, 5), (3, 20, -5), (0, 0, 2), (3, 3, 2)], ) @pytest.mark.parametrize( - "label", [3, 8, 13, 18, 20, 15, 10, 5, -1, 0, 19, 21, 6, 11, 17], + "label", + [3, 8, 13, 18, 20, 15, 10, 5, -1, 0, 19, 21, 6, 11, 17], ) @pytest.mark.parametrize("side", ["left", "right"]) @pytest.mark.parametrize("kind", ["getitem", "loc"]) diff --git a/python/cudf/cudf/tests/test_numerical.py b/python/cudf/cudf/tests/test_numerical.py index 21b179caa38..160db7053b9 100644 --- a/python/cudf/cudf/tests/test_numerical.py +++ b/python/cudf/cudf/tests/test_numerical.py @@ -21,7 +21,7 @@ def test_can_cast_safely_same_kind(): assert data.can_cast_safely(to_dtype) - data = cudf.Series([1, 2, 2 ** 31], dtype="int64")._column + data = cudf.Series([1, 2, 2**31], dtype="int64")._column assert not data.can_cast_safely(to_dtype) # 'u' -> 'u' @@ -35,7 +35,7 @@ def test_can_cast_safely_same_kind(): assert data.can_cast_safely(to_dtype) - data = cudf.Series([1, 2, 2 ** 33], dtype="uint64")._column + data = cudf.Series([1, 2, 2**33], dtype="uint64")._column assert not data.can_cast_safely(to_dtype) # 'f' -> 'f' @@ -56,7 +56,7 @@ def test_can_cast_safely_mixed_kind(): assert data.can_cast_safely(to_dtype) # too big to fit into f32 exactly - data = cudf.Series([1, 2, 2 ** 24 + 1], dtype="int32")._column + data = cudf.Series([1, 2, 2**24 + 1], dtype="int32")._column assert not data.can_cast_safely(to_dtype) data = cudf.Series([1, 2, 3], dtype="uint32")._column @@ -64,7 +64,7 @@ def test_can_cast_safely_mixed_kind(): assert data.can_cast_safely(to_dtype) # too big to fit into f32 exactly - data = cudf.Series([1, 2, 2 ** 24 + 1], dtype="uint32")._column + data = cudf.Series([1, 2, 2**24 + 1], dtype="uint32")._column assert not data.can_cast_safely(to_dtype) to_dtype = np.dtype("float64") @@ -82,7 +82,7 @@ def test_can_cast_safely_mixed_kind(): assert data.can_cast_safely(to_dtype) # float out of int range - data = cudf.Series([1.0, 2.0, 1.0 * (2 ** 31)], dtype="float32")._column + data = cudf.Series([1.0, 2.0, 1.0 * (2**31)], dtype="float32")._column assert not data.can_cast_safely(to_dtype) # negative signed integers casting to unsigned integers @@ -174,9 +174,9 @@ def test_to_numeric_basic_1d(data): @pytest.mark.parametrize( "data", [ - [1, 2 ** 11], - [1, 2 ** 33], - [1, 2 ** 63], + [1, 2**11], + [1, 2**33], + [1, 2**63], [np.iinfo(np.int64).max, np.iinfo(np.int64).min], ], ) @@ -196,12 +196,12 @@ def test_to_numeric_downcast_int(data, downcast): @pytest.mark.parametrize( "data", [ - [1.0, 2.0 ** 11], - [-1.0, -(2.0 ** 11)], - [1.0, 2.0 ** 33], - [-1.0, -(2.0 ** 33)], - [1.0, 2.0 ** 65], - [-1.0, -(2.0 ** 65)], + [1.0, 2.0**11], + [-1.0, -(2.0**11)], + [1.0, 2.0**33], + [-1.0, -(2.0**33)], + [1.0, 2.0**65], + [-1.0, -(2.0**65)], [1.0, float("inf")], [1.0, float("-inf")], [1.0, float("nan")], @@ -225,11 +225,11 @@ def test_to_numeric_downcast_float(data, downcast): @pytest.mark.parametrize( "data", [ - [1.0, 2.0 ** 129], - [1.0, 2.0 ** 257], + [1.0, 2.0**129], + [1.0, 2.0**257], [1.0, 1.79e308], - [-1.0, -(2.0 ** 129)], - [-1.0, -(2.0 ** 257)], + [-1.0, -(2.0**129)], + [-1.0, -(2.0**257)], [-1.0, -1.79e308], ], ) @@ -247,11 +247,11 @@ def test_to_numeric_downcast_large_float(data, downcast): @pytest.mark.parametrize( "data", [ - [1.0, 2.0 ** 129], - [1.0, 2.0 ** 257], + [1.0, 2.0**129], + [1.0, 2.0**257], [1.0, 1.79e308], - [-1.0, -(2.0 ** 129)], - [-1.0, -(2.0 ** 257)], + [-1.0, -(2.0**129)], + [-1.0, -(2.0**257)], [-1.0, -1.79e308], ], ) @@ -400,7 +400,8 @@ def test_series_construction_with_nulls(dtype, input_obj): @pytest.mark.parametrize( - "data", [[True, False, True]], + "data", + [[True, False, True]], ) @pytest.mark.parametrize( "downcast", ["signed", "integer", "unsigned", "float"] diff --git a/python/cudf/cudf/tests/test_onehot.py b/python/cudf/cudf/tests/test_onehot.py index 2b0422ffecb..41af6a64155 100644 --- a/python/cudf/cudf/tests/test_onehot.py +++ b/python/cudf/cudf/tests/test_onehot.py @@ -1,4 +1,4 @@ -# Copyright (c) 2018, NVIDIA CORPORATION. +# Copyright (c) 2018-2022, NVIDIA CORPORATION. from string import ascii_lowercase diff --git a/python/cudf/cudf/tests/test_orc.py b/python/cudf/cudf/tests/test_orc.py index bd7335c577c..62715ad7580 100644 --- a/python/cudf/cudf/tests/test_orc.py +++ b/python/cudf/cudf/tests/test_orc.py @@ -674,7 +674,10 @@ def test_orc_write_statistics(tmpdir, datadir, nrows, stats_freq): # Read back written ORC's statistics orc_file = pa.orc.ORCFile(fname) - (file_stats, stripes_stats,) = cudf.io.orc.read_orc_statistics([fname]) + ( + file_stats, + stripes_stats, + ) = cudf.io.orc.read_orc_statistics([fname]) # check file stats for col in gdf: @@ -726,7 +729,10 @@ def test_orc_write_bool_statistics(tmpdir, datadir, nrows): # Read back written ORC's statistics orc_file = pa.orc.ORCFile(fname) - (file_stats, stripes_stats,) = cudf.io.orc.read_orc_statistics([fname]) + ( + file_stats, + stripes_stats, + ) = cudf.io.orc.read_orc_statistics([fname]) # check file stats col = "col_bool" @@ -1070,7 +1076,10 @@ def test_skip_rows_for_nested_types(columns, list_struct_buff): RuntimeError, match="skip_rows is not supported by nested column" ): cudf.read_orc( - list_struct_buff, columns=columns, use_index=True, skiprows=5, + list_struct_buff, + columns=columns, + use_index=True, + skiprows=5, ) diff --git a/python/cudf/cudf/tests/test_parquet.py b/python/cudf/cudf/tests/test_parquet.py index 91b4009995b..58ba77d0b0e 100644 --- a/python/cudf/cudf/tests/test_parquet.py +++ b/python/cudf/cudf/tests/test_parquet.py @@ -1759,7 +1759,8 @@ def test_parquet_write_to_dataset(tmpdir_factory, cols): @pytest.mark.parametrize( - "pfilters", [[("b", "==", "b")], [("b", "==", "a"), ("c", "==", 1)]], + "pfilters", + [[("b", "==", "b")], [("b", "==", "a"), ("c", "==", 1)]], ) @pytest.mark.parametrize("selection", ["directory", "files", "row-groups"]) @pytest.mark.parametrize("use_cat", [True, False]) @@ -1821,12 +1822,20 @@ def test_read_parquet_partitioned_filtered( # backend will filter by row (and cudf can # only filter by column, for now) filters = [("a", "==", 10)] - got = cudf.read_parquet(read_path, filters=filters, row_groups=row_groups,) + got = cudf.read_parquet( + read_path, + filters=filters, + row_groups=row_groups, + ) assert len(got) < len(df) and 10 in got["a"] # Filter on both kinds of columns filters = [[("a", "==", 10)], [("c", "==", 1)]] - got = cudf.read_parquet(read_path, filters=filters, row_groups=row_groups,) + got = cudf.read_parquet( + read_path, + filters=filters, + row_groups=row_groups, + ) assert len(got) < len(df) and (1 in got["c"] and 10 in got["a"]) diff --git a/python/cudf/cudf/tests/test_query.py b/python/cudf/cudf/tests/test_query.py index 09129a43f07..46b48b8244c 100644 --- a/python/cudf/cudf/tests/test_query.py +++ b/python/cudf/cudf/tests/test_query.py @@ -1,4 +1,4 @@ -# Copyright (c) 2018, NVIDIA CORPORATION. +# Copyright (c) 2018-2022, NVIDIA CORPORATION. import datetime @@ -58,7 +58,7 @@ def test_query(data, fn, nulls): params_query_env_fn = [ (lambda a, b, c, d: a * c > b + d, "a * @c > b + @d"), ( - lambda a, b, c, d: ((a / c) < d) | ((b ** c) > d), + lambda a, b, c, d: ((a / c) < d) | ((b**c) > d), "((a / @c) < @d) | ((b ** @c) > @d)", ), ] diff --git a/python/cudf/cudf/tests/test_rank.py b/python/cudf/cudf/tests/test_rank.py index e1ca006e0ac..15a7eab738a 100644 --- a/python/cudf/cudf/tests/test_rank.py +++ b/python/cudf/cudf/tests/test_rank.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2021, NVIDIA CORPORATION. +# Copyright (c) 2020-2022, NVIDIA CORPORATION. from itertools import chain, combinations_with_replacement, product @@ -134,7 +134,8 @@ def test_rank_error_arguments(pdf): "elem,dtype", list( product( - combinations_with_replacement(sort_group_args, 4), sort_dtype_args, + combinations_with_replacement(sort_group_args, 4), + sort_dtype_args, ) ), ) diff --git a/python/cudf/cudf/tests/test_reductions.py b/python/cudf/cudf/tests/test_reductions.py index 7106ab54686..a24fef93f89 100644 --- a/python/cudf/cudf/tests/test_reductions.py +++ b/python/cudf/cudf/tests/test_reductions.py @@ -125,7 +125,7 @@ def test_sum_of_squares(dtype, nelem): got = sr.sum_of_squares() got_df = df.sum_of_squares() - expect = (data ** 2).sum() + expect = (data**2).sum() if cudf.dtype(dtype).kind in {"u", "i"}: if 0 <= expect <= np.iinfo(dtype).max: @@ -261,7 +261,7 @@ def test_sum_boolean(): def test_date_minmax(): - np_data = np.random.normal(size=10 ** 3) + np_data = np.random.normal(size=10**3) gdf_data = Series(np_data) np_casted = np_data.astype("datetime64[ms]") @@ -277,7 +277,8 @@ def test_date_minmax(): @pytest.mark.parametrize( - "op", ["sum", "product", "var", "kurt", "kurtosis", "skew"], + "op", + ["sum", "product", "var", "kurt", "kurtosis", "skew"], ) def test_datetime_unsupported_reductions(op): gsr = cudf.Series([1, 2, 3, None], dtype="datetime64[ns]") diff --git a/python/cudf/cudf/tests/test_replace.py b/python/cudf/cudf/tests/test_replace.py index 90429945cc5..14e81d6ad30 100644 --- a/python/cudf/cudf/tests/test_replace.py +++ b/python/cudf/cudf/tests/test_replace.py @@ -1057,7 +1057,14 @@ def test_replace_df_error(): @pytest.mark.parametrize( ("lower", "upper"), - [([2, 7.4], [4, 7.9]), ([2, 7.4], None), (None, [4, 7.9],)], + [ + ([2, 7.4], [4, 7.9]), + ([2, 7.4], None), + ( + None, + [4, 7.9], + ), + ], ) @pytest.mark.parametrize("inplace", [True, False]) def test_dataframe_clip(lower, upper, inplace): @@ -1076,7 +1083,8 @@ def test_dataframe_clip(lower, upper, inplace): @pytest.mark.parametrize( - ("lower", "upper"), [("b", "d"), ("b", None), (None, "c"), (None, None)], + ("lower", "upper"), + [("b", "d"), ("b", None), (None, "c"), (None, None)], ) @pytest.mark.parametrize("inplace", [True, False]) def test_dataframe_category_clip(lower, upper, inplace): @@ -1173,7 +1181,15 @@ def test_index_clip(data, lower, upper, inplace): @pytest.mark.parametrize( - ("lower", "upper"), [([2, 3], [4, 5]), ([2, 3], None), (None, [4, 5],)], + ("lower", "upper"), + [ + ([2, 3], [4, 5]), + ([2, 3], None), + ( + None, + [4, 5], + ), + ], ) @pytest.mark.parametrize("inplace", [True, False]) def test_multiindex_clip(lower, upper, inplace): @@ -1257,7 +1273,10 @@ def test_series_replace_errors(): gsr.replace([1, 2], ["a", "b"]) assert_exceptions_equal( - psr.replace, gsr.replace, ([{"a": 1}, 1],), ([{"a": 1}, 1],), + psr.replace, + gsr.replace, + ([{"a": 1}, 1],), + ([{"a": 1}, 1],), ) assert_exceptions_equal( diff --git a/python/cudf/cudf/tests/test_resampling.py b/python/cudf/cudf/tests/test_resampling.py index 3b8e807c3b6..f0101803995 100644 --- a/python/cudf/cudf/tests/test_resampling.py +++ b/python/cudf/cudf/tests/test_resampling.py @@ -1,3 +1,5 @@ +# Copyright (c) 2021-2022, NVIDIA CORPORATION. + import numpy as np import pandas as pd import pytest @@ -25,7 +27,8 @@ def test_series_downsample_simple(ts_resolution): gsr = cudf.from_pandas(psr) gsr.index = gsr.index.astype(f"datetime64[{ts_resolution}]") assert_resample_results_equal( - psr.resample("3T").sum(), gsr.resample("3T").sum(), + psr.resample("3T").sum(), + gsr.resample("3T").sum(), ) @@ -36,7 +39,8 @@ def test_series_upsample_simple(): psr = pd.Series(range(10), index=index) gsr = cudf.from_pandas(psr) assert_resample_results_equal( - psr.resample("3T").sum(), gsr.resample("3T").sum(), + psr.resample("3T").sum(), + gsr.resample("3T").sum(), ) diff --git a/python/cudf/cudf/tests/test_reshape.py b/python/cudf/cudf/tests/test_reshape.py index 2efa781c506..14fa4be7fed 100644 --- a/python/cudf/cudf/tests/test_reshape.py +++ b/python/cudf/cudf/tests/test_reshape.py @@ -460,7 +460,9 @@ def test_unstack_multiindex(level): ).set_index(["foo", "bar", "baz"]) gdf = cudf.from_pandas(pdf) assert_eq( - pdf.unstack(level=level), gdf.unstack(level=level), check_dtype=False, + pdf.unstack(level=level), + gdf.unstack(level=level), + check_dtype=False, ) diff --git a/python/cudf/cudf/tests/test_rolling.py b/python/cudf/cudf/tests/test_rolling.py index abf38f74b86..87d1faf33ca 100644 --- a/python/cudf/cudf/tests/test_rolling.py +++ b/python/cudf/cudf/tests/test_rolling.py @@ -365,7 +365,7 @@ def test_rolling_dataframe_numba_udf_basic(data, center): def some_func(A): b = 0 for a in A: - b = b + a ** 2 + b = b + a**2 return b / len(A) for window_size in range(1, len(data) + 1): diff --git a/python/cudf/cudf/tests/test_s3.py b/python/cudf/cudf/tests/test_s3.py index 4807879a730..d783483a8cb 100644 --- a/python/cudf/cudf/tests/test_s3.py +++ b/python/cudf/cudf/tests/test_s3.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-2022, NVIDIA CORPORATION. import os import shlex @@ -282,7 +282,12 @@ def test_read_parquet( @pytest.mark.parametrize("columns", [None, ["List", "Struct"]]) @pytest.mark.parametrize("index", [None, "Integer"]) def test_read_parquet_ext( - s3_base, s3so, pdf_ext, bytes_per_thread, columns, index, + s3_base, + s3so, + pdf_ext, + bytes_per_thread, + columns, + index, ): fname = "test_parquet_reader_ext.parquet" bname = "parquet" diff --git a/python/cudf/cudf/tests/test_series.py b/python/cudf/cudf/tests/test_series.py index 385f7f41f72..b5be0b208a0 100644 --- a/python/cudf/cudf/tests/test_series.py +++ b/python/cudf/cudf/tests/test_series.py @@ -560,7 +560,7 @@ def test_categorical_value_counts(dropna, normalize, num_elements): @pytest.mark.parametrize("dropna", [True, False]) @pytest.mark.parametrize("normalize", [True, False]) def test_series_value_counts(dropna, normalize): - for size in [10 ** x for x in range(5)]: + for size in [10**x for x in range(5)]: arr = np.random.randint(low=-1, high=10, size=size) mask = arr != -1 sr = cudf.Series.from_masked_array( @@ -867,8 +867,14 @@ def test_series_memory_usage(): ), ), ( - cudf.Series([1, 2, None, 10.2, None], dtype="float32",), - pd.Series([1, 2, None, 10.2, None], dtype=pd.Float32Dtype(),), + cudf.Series( + [1, 2, None, 10.2, None], + dtype="float32", + ), + pd.Series( + [1, 2, None, 10.2, None], + dtype=pd.Float32Dtype(), + ), ), ], ) @@ -1077,9 +1083,18 @@ def test_series_drop_index(ps, index, inplace): ("speed", 1), ("weight", 1), ("length", 1), - ("cow", None,), - ("lama", None,), - ("falcon", None,), + ( + "cow", + None, + ), + ( + "lama", + None, + ), + ( + "falcon", + None, + ), ], ) @pytest.mark.parametrize("inplace", [True, False]) @@ -1158,7 +1173,8 @@ def test_series_drop_raises(): @pytest.mark.parametrize( - "data", [[[1, 2, 3], None, [4], [], [5, 6]], [1, 2, 3, 4, 5]], + "data", + [[[1, 2, 3], None, [4], [], [5, 6]], [1, 2, 3, 4, 5]], ) @pytest.mark.parametrize("ignore_index", [True, False]) @pytest.mark.parametrize( @@ -1431,8 +1447,14 @@ def test_reset_index_dup_level_name_exceptions(): assert_exceptions_equal( lfunc=ps.reset_index, rfunc=gs.reset_index, - lfunc_args_and_kwargs=([], {"level": [None]},), - rfunc_args_and_kwargs=([], {"level": [None]},), + lfunc_args_and_kwargs=( + [], + {"level": [None]}, + ), + rfunc_args_and_kwargs=( + [], + {"level": [None]}, + ), expected_error_message="occurs multiple times, use a level number", ) @@ -1440,8 +1462,14 @@ def test_reset_index_dup_level_name_exceptions(): assert_exceptions_equal( lfunc=ps.reset_index, rfunc=gs.reset_index, - lfunc_args_and_kwargs=([], {"drop": False, "inplace": True},), - rfunc_args_and_kwargs=([], {"drop": False, "inplace": True},), + lfunc_args_and_kwargs=( + [], + {"drop": False, "inplace": True}, + ), + rfunc_args_and_kwargs=( + [], + {"drop": False, "inplace": True}, + ), ) # Pandas raises the above exception should these two inputs crosses. @@ -1518,7 +1546,8 @@ def test_series_transpose(data): @pytest.mark.parametrize( - "data", [1, 3, 5, 7, 7], + "data", + [1, 3, 5, 7, 7], ) def test_series_nunique(data): cd_s = cudf.Series(data) @@ -1531,7 +1560,8 @@ def test_series_nunique(data): @pytest.mark.parametrize( - "data", [1, 3, 5, 7, 7], + "data", + [1, 3, 5, 7, 7], ) def test_series_nunique_index(data): cd_s = cudf.Series(data) diff --git a/python/cudf/cudf/tests/test_seriesmap.py b/python/cudf/cudf/tests/test_seriesmap.py index d4ef3ba235d..f1a51a45779 100644 --- a/python/cudf/cudf/tests/test_seriesmap.py +++ b/python/cudf/cudf/tests/test_seriesmap.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-2022, NVIDIA CORPORATION. from itertools import product from math import floor @@ -37,8 +37,8 @@ def test_series_map_callable_numeric_basic(): gd2 = cudf.Series([1, 2, 3, 4, np.nan]) pdf2 = gd2.to_pandas() - expected_function = pdf2.map(lambda x: x ** 2) - actual_function = gd2.map(lambda x: x ** 2) + expected_function = pdf2.map(lambda x: x**2) + actual_function = gd2.map(lambda x: x**2) assert_eq(expected_function, actual_function) diff --git a/python/cudf/cudf/tests/test_stats.py b/python/cudf/cudf/tests/test_stats.py index 98e3b255aaf..977a01952db 100644 --- a/python/cudf/cudf/tests/test_stats.py +++ b/python/cudf/cudf/tests/test_stats.py @@ -81,7 +81,7 @@ def test_series_std(ddof): def test_series_unique(): - for size in [10 ** x for x in range(5)]: + for size in [10**x for x in range(5)]: arr = np.random.randint(low=-1, high=10, size=size) mask = arr != -1 sr = cudf.Series(arr) diff --git a/python/cudf/cudf/tests/test_string.py b/python/cudf/cudf/tests/test_string.py index f5bfcd8c9d2..d5d21f0b3c5 100644 --- a/python/cudf/cudf/tests/test_string.py +++ b/python/cudf/cudf/tests/test_string.py @@ -244,7 +244,8 @@ def test_string_empty_to_decimal(): gs = cudf.Series(["", "-85", ""], dtype="str") got = gs.astype(cudf.Decimal64Dtype(scale=0, precision=5)) expected = cudf.Series( - [0, -85, 0], dtype=cudf.Decimal64Dtype(scale=0, precision=5), + [0, -85, 0], + dtype=cudf.Decimal64Dtype(scale=0, precision=5), ) assert_eq(expected, got) @@ -272,7 +273,8 @@ def test_string_from_decimal(data, scale, precision, decimal_dtype): else: decimal_data.append(Decimal(d)) fp = cudf.Series( - decimal_data, dtype=decimal_dtype(scale=scale, precision=precision), + decimal_data, + dtype=decimal_dtype(scale=scale, precision=precision), ) gs = fp.astype("str") got = gs.astype(decimal_dtype(scale=scale, precision=precision)) @@ -532,7 +534,8 @@ def _cat_convert_seq_to_cudf(others): @pytest.mark.parametrize("sep", [None, "", " ", "|", ",", "|||"]) @pytest.mark.parametrize("na_rep", [None, "", "null", "a"]) @pytest.mark.parametrize( - "index", [["1", "2", "3", "4", "5"]], + "index", + [["1", "2", "3", "4", "5"]], ) def test_string_cat(ps_gs, others, sep, na_rep, index): ps, gs = ps_gs @@ -682,12 +685,15 @@ def test_string_index_str_cat(data, others, sep, na_rep, name): got = gi.str.cat(others=gd_others, sep=sep, na_rep=na_rep) assert_eq( - expect, got, exact=False, + expect, + got, + exact=False, ) @pytest.mark.parametrize( - "data", [["a", None, "c", None, "e"], ["a", "b", "c", "d", "a"]], + "data", + [["a", None, "c", None, "e"], ["a", "b", "c", "d", "a"]], ) @pytest.mark.parametrize( "others", @@ -869,7 +875,8 @@ def test_string_contains(ps_gs, pat, regex, flags, flags_raise, na, na_raise): @pytest.mark.parametrize( - "data", [["hello", "world", None, "", "!"]], + "data", + [["hello", "world", None, "", "!"]], ) @pytest.mark.parametrize( "repeats", @@ -1207,7 +1214,8 @@ def test_string_get(string, index): gds = cudf.Series(string) assert_eq( - pds.str.get(index).fillna(""), gds.str.get(index).fillna(""), + pds.str.get(index).fillna(""), + gds.str.get(index).fillna(""), ) @@ -1220,10 +1228,12 @@ def test_string_get(string, index): ], ) @pytest.mark.parametrize( - "number", [-10, 0, 1, 3, 10], + "number", + [-10, 0, 1, 3, 10], ) @pytest.mark.parametrize( - "diff", [0, 2, 5, 9], + "diff", + [0, 2, 5, 9], ) def test_string_slice_str(string, number, diff): pds = pd.Series(string) @@ -1719,7 +1729,8 @@ def test_strings_zfill_tests(data, width): ) @pytest.mark.parametrize("width", [0, 1, 4, 9, 100]) @pytest.mark.parametrize( - "side", ["left", "right", "both"], + "side", + ["left", "right", "both"], ) @pytest.mark.parametrize("fillchar", [" ", ".", "\n", "+", "\t"]) def test_strings_pad_tests(data, width, side, fillchar): @@ -1920,7 +1931,8 @@ def test_string_table_view_creation(): ], ) @pytest.mark.parametrize( - "pat", ["", None, " ", "a", "abc", "cat", "$", "\n"], + "pat", + ["", None, " ", "a", "abc", "cat", "$", "\n"], ) def test_string_starts_ends(data, pat): ps = pd.Series(data) @@ -1996,7 +2008,8 @@ def test_string_starts_ends_list_like_pat(data, pat): ], ) @pytest.mark.parametrize( - "sub", ["", " ", "a", "abc", "cat", "$", "\n"], + "sub", + ["", " ", "a", "abc", "cat", "$", "\n"], ) def test_string_find(data, sub): ps = pd.Series(data) @@ -2005,49 +2018,65 @@ def test_string_find(data, sub): got = gs.str.find(sub) expect = ps.str.find(sub) assert_eq( - expect, got, check_dtype=False, + expect, + got, + check_dtype=False, ) got = gs.str.find(sub, start=1) expect = ps.str.find(sub, start=1) assert_eq( - expect, got, check_dtype=False, + expect, + got, + check_dtype=False, ) got = gs.str.find(sub, end=10) expect = ps.str.find(sub, end=10) assert_eq( - expect, got, check_dtype=False, + expect, + got, + check_dtype=False, ) got = gs.str.find(sub, start=2, end=10) expect = ps.str.find(sub, start=2, end=10) assert_eq( - expect, got, check_dtype=False, + expect, + got, + check_dtype=False, ) got = gs.str.rfind(sub) expect = ps.str.rfind(sub) assert_eq( - expect, got, check_dtype=False, + expect, + got, + check_dtype=False, ) got = gs.str.rfind(sub, start=1) expect = ps.str.rfind(sub, start=1) assert_eq( - expect, got, check_dtype=False, + expect, + got, + check_dtype=False, ) got = gs.str.rfind(sub, end=10) expect = ps.str.rfind(sub, end=10) assert_eq( - expect, got, check_dtype=False, + expect, + got, + check_dtype=False, ) got = gs.str.rfind(sub, start=2, end=10) expect = ps.str.rfind(sub, start=2, end=10) assert_eq( - expect, got, check_dtype=False, + expect, + got, + check_dtype=False, ) @@ -2176,7 +2205,8 @@ def test_string_contains_multi(data, sub, expect): # Pandas does not allow 'case' or 'flags' if 'pat' is re.Pattern # This covers contains, match, count, and replace @pytest.mark.parametrize( - "pat", [re.compile("[n-z]"), re.compile("[A-Z]"), re.compile("de"), "A"], + "pat", + [re.compile("[n-z]"), re.compile("[A-Z]"), re.compile("de"), "A"], ) @pytest.mark.parametrize("repl", ["xyz", "", " "]) def test_string_compiled_re(ps_gs, pat, repl): diff --git a/python/cudf/cudf/tests/test_testing.py b/python/cudf/cudf/tests/test_testing.py index 4dc4d86d94c..efb3ce96838 100644 --- a/python/cudf/cudf/tests/test_testing.py +++ b/python/cudf/cudf/tests/test_testing.py @@ -43,7 +43,12 @@ def arrow_arrays(request): "dtype", NUMERIC_TYPES + OTHER_TYPES + ["datetime64[ns]"] ) def test_basic_assert_index_equal( - rdata, exact, check_names, rname, check_categorical, dtype, + rdata, + exact, + check_names, + rname, + check_categorical, + dtype, ): p_left = pd.Index([1, 2, 3], name="a", dtype=dtype) p_right = pd.Index(rdata, name=rname, dtype=dtype) @@ -100,7 +105,12 @@ def test_basic_assert_index_equal( "dtype", NUMERIC_TYPES + OTHER_TYPES + ["datetime64[ns]"] ) def test_basic_assert_series_equal( - rdata, rname, check_names, check_category_order, check_categorical, dtype, + rdata, + rname, + check_names, + check_category_order, + check_categorical, + dtype, ): p_left = pd.Series([1, 2, 3], name="a", dtype=dtype) diff --git a/python/cudf/cudf/tests/test_timedelta.py b/python/cudf/cudf/tests/test_timedelta.py index 2623b755cfb..71c30e0aaa5 100644 --- a/python/cudf/cudf/tests/test_timedelta.py +++ b/python/cudf/cudf/tests/test_timedelta.py @@ -318,7 +318,8 @@ def test_timedelta_ops_misc_inputs(data, other, dtype, ops): @pytest.mark.parametrize("datetime_dtype", utils.DATETIME_TYPES) @pytest.mark.parametrize("timedelta_dtype", utils.TIMEDELTA_TYPES) @pytest.mark.parametrize( - "ops", ["add", "sub"], + "ops", + ["add", "sub"], ) def test_timedelta_ops_datetime_inputs( datetime_data, timedelta_data, datetime_dtype, timedelta_dtype, ops @@ -645,7 +646,8 @@ def test_timedelta_reduction_ops(data, dtype, reduction_op): @pytest.mark.parametrize( - "data", _TIMEDELTA_DATA, + "data", + _TIMEDELTA_DATA, ) @pytest.mark.parametrize("dtype", utils.TIMEDELTA_TYPES) def test_timedelta_dt_components(data, dtype): @@ -662,7 +664,8 @@ def test_timedelta_dt_components(data, dtype): @pytest.mark.parametrize( - "data", _TIMEDELTA_DATA, + "data", + _TIMEDELTA_DATA, ) @pytest.mark.parametrize("dtype", utils.TIMEDELTA_TYPES) def test_timedelta_dt_properties(data, dtype): @@ -697,7 +700,8 @@ def local_assert(expected, actual): @pytest.mark.parametrize( - "data", _TIMEDELTA_DATA, + "data", + _TIMEDELTA_DATA, ) @pytest.mark.parametrize("dtype", utils.TIMEDELTA_TYPES) def test_timedelta_index(data, dtype): diff --git a/python/cudf/cudf/tests/test_transform.py b/python/cudf/cudf/tests/test_transform.py index bd7ee45fbf8..b5bcf9df8f5 100644 --- a/python/cudf/cudf/tests/test_transform.py +++ b/python/cudf/cudf/tests/test_transform.py @@ -1,4 +1,4 @@ -# Copyright (c) 2018-2020, NVIDIA CORPORATION. +# Copyright (c) 2018-2022, NVIDIA CORPORATION. import numpy as np @@ -11,14 +11,14 @@ def _generic_function(a): - return a ** 3 + return a**3 @pytest.mark.parametrize("dtype", supported_types) @pytest.mark.parametrize( "udf,testfunc", [ - (_generic_function, lambda ser: ser ** 3), + (_generic_function, lambda ser: ser**3), (lambda x: x in [1, 2, 3, 4], lambda ser: np.isin(ser, [1, 2, 3, 4])), ], ) diff --git a/python/cudf/cudf/tests/test_udf_binops.py b/python/cudf/cudf/tests/test_udf_binops.py index 173515509cd..1ad45e721a3 100644 --- a/python/cudf/cudf/tests/test_udf_binops.py +++ b/python/cudf/cudf/tests/test_udf_binops.py @@ -1,4 +1,4 @@ -# Copyright (c) 2018, NVIDIA CORPORATION. +# Copyright (c) 2018-2022, NVIDIA CORPORATION. import numpy as np import pytest @@ -33,7 +33,7 @@ def test_generic_ptx(dtype): rhs_col = Series(rhs_arr)._column def generic_function(a, b): - return a ** 3 + b + return a**3 + b nb_type = numpy_support.from_dtype(cudf.dtype(dtype)) type_signature = (nb_type, nb_type) @@ -46,6 +46,6 @@ def generic_function(a, b): out_col = libcudf.binaryop.binaryop_udf(lhs_col, rhs_col, ptx_code, dtype) - result = lhs_arr ** 3 + rhs_arr + result = lhs_arr**3 + rhs_arr np.testing.assert_almost_equal(result, out_col.values_host) diff --git a/python/cudf/cudf/tests/test_udf_masked_ops.py b/python/cudf/cudf/tests/test_udf_masked_ops.py index faaea6eec08..36750adf6ee 100644 --- a/python/cudf/cudf/tests/test_udf_masked_ops.py +++ b/python/cudf/cudf/tests/test_udf_masked_ops.py @@ -644,16 +644,16 @@ def test_masked_udf_caching(): # recompile data = cudf.Series([1, 2, 3]) - expect = data ** 2 - got = data.applymap(lambda x: x ** 2) + expect = data**2 + got = data.applymap(lambda x: x**2) assert_eq(expect, got, check_dtype=False) # update the constant value being used and make sure # it does not result in a cache hit - expect = data ** 3 - got = data.applymap(lambda x: x ** 3) + expect = data**3 + got = data.applymap(lambda x: x**3) assert_eq(expect, got, check_dtype=False) # make sure we get a hit when reapplying diff --git a/python/cudf/cudf/utils/hash_vocab_utils.py b/python/cudf/cudf/utils/hash_vocab_utils.py index 11029cbfe5e..cecf0c36bc2 100644 --- a/python/cudf/cudf/utils/hash_vocab_utils.py +++ b/python/cudf/cudf/utils/hash_vocab_utils.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-2022, NVIDIA CORPORATION. # This function is from the rapidsai/clx repo at below link # https://github.com/rapidsai/clx/blob/267c6d30805c9dcbf80840f222bf31c5c4b7068a/python/clx/analytics/_perfect_hash.py import numpy as np @@ -10,16 +10,16 @@ A_SECOND_LEVEL_POW = np.uint8(48) B_SECOND_LEVEL_POW = np.uint8(7) -A_LBOUND_SECOND_LEVEL_HASH = 2 ** 16 -A_HBOUND_SECOND_LEVEL_HASH = 2 ** A_SECOND_LEVEL_POW +A_LBOUND_SECOND_LEVEL_HASH = 2**16 +A_HBOUND_SECOND_LEVEL_HASH = 2**A_SECOND_LEVEL_POW B_LBOUND_SECOND_LEVEL_HASH = 0 -B_HBOUND_SECOND_LEVEL_HASH = 2 ** B_SECOND_LEVEL_POW +B_HBOUND_SECOND_LEVEL_HASH = 2**B_SECOND_LEVEL_POW # Extremely generous and should not ever happen. This limit is imposed # To ensure we can bit pack all the information needed for the bin hash # functions - a, b and table size -MAX_SIZE_FOR_INITIAL_BIN = 2 ** 8 - 1 +MAX_SIZE_FOR_INITIAL_BIN = 2**8 - 1 # Shifts for bit packing @@ -71,8 +71,8 @@ def _get_space_util(bins, init_bins): def _pick_initial_a_b(data, max_constant, init_bins): while True: - a = np.random.randint(2 ** 12, 2 ** 15) - b = np.random.randint(2 ** 12, 2 ** 15) + a = np.random.randint(2**12, 2**15) + b = np.random.randint(2**12, 2**15) bins = _make_bins(data, init_bins, a, b) score = _get_space_util(bins, init_bins) / len(data) diff --git a/python/cudf/cudf/utils/ioutils.py b/python/cudf/cudf/utils/ioutils.py index 8f8a40ae4ab..cfe1957dfd6 100644 --- a/python/cudf/cudf/utils/ioutils.py +++ b/python/cudf/cudf/utils/ioutils.py @@ -1,4 +1,4 @@ -# Copyright (c) 2019-2021, NVIDIA CORPORATION. +# Copyright (c) 2019-2022, NVIDIA CORPORATION. import datetime import os @@ -1396,13 +1396,18 @@ def get_filepath_or_buffer( else: if use_python_file_object: path_or_data = _open_remote_files( - paths, fs, **(open_file_options or {}), + paths, + fs, + **(open_file_options or {}), ) else: path_or_data = [ BytesIO( _fsspec_data_transfer( - fpath, fs=fs, mode=mode, **kwargs, + fpath, + fs=fs, + mode=mode, + **kwargs, ) ) for fpath in paths @@ -1685,7 +1690,11 @@ def _fsspec_data_transfer( for b in range(0, file_size, bytes_per_thread) ] _read_byte_ranges( - path_or_fob, byte_ranges, buf, fs=fs, **kwargs, + path_or_fob, + byte_ranges, + buf, + fs=fs, + **kwargs, ) return buf.tobytes() @@ -1717,19 +1726,25 @@ def _assign_block(fs, path_or_fob, local_buffer, offset, nbytes): # We have an open fsspec file object path_or_fob.seek(offset) local_buffer[offset : offset + nbytes] = np.frombuffer( - path_or_fob.read(nbytes), dtype="b", + path_or_fob.read(nbytes), + dtype="b", ) else: # We have an fsspec filesystem and a path with fs.open(path_or_fob, mode="rb", cache_type="none") as fob: fob.seek(offset) local_buffer[offset : offset + nbytes] = np.frombuffer( - fob.read(nbytes), dtype="b", + fob.read(nbytes), + dtype="b", ) def _read_byte_ranges( - path_or_fob, ranges, local_buffer, fs=None, **kwargs, + path_or_fob, + ranges, + local_buffer, + fs=None, + **kwargs, ): # Simple utility to copy remote byte ranges # into a local buffer for IO in libcudf diff --git a/python/cudf/setup.py b/python/cudf/setup.py index e4e43bc1595..9d7b3a36235 100644 --- a/python/cudf/setup.py +++ b/python/cudf/setup.py @@ -1,4 +1,4 @@ -# Copyright (c) 2018-2021, NVIDIA CORPORATION. +# Copyright (c) 2018-2022, NVIDIA CORPORATION. import os import re @@ -253,7 +253,8 @@ def run(self): ext_modules=extensions, packages=find_packages(include=["cudf", "cudf.*"]), package_data=dict.fromkeys( - find_packages(include=["cudf._lib*"]), ["*.pxd"], + find_packages(include=["cudf._lib*"]), + ["*.pxd"], ), cmdclass=cmdclass, install_requires=install_requires, diff --git a/python/cudf_kafka/setup.py b/python/cudf_kafka/setup.py index 824babfa10a..4aff8ca7990 100644 --- a/python/cudf_kafka/setup.py +++ b/python/cudf_kafka/setup.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-2022, NVIDIA CORPORATION. import os import shutil import sysconfig @@ -104,7 +104,8 @@ ), packages=find_packages(include=["cudf_kafka", "cudf_kafka.*"]), package_data=dict.fromkeys( - find_packages(include=["cudf_kafka._lib*"]), ["*.pxd"], + find_packages(include=["cudf_kafka._lib*"]), + ["*.pxd"], ), cmdclass=versioneer.get_cmdclass(), install_requires=install_requires, diff --git a/python/cudf_kafka/versioneer.py b/python/cudf_kafka/versioneer.py index c7dbfd76734..a3b0246e785 100644 --- a/python/cudf_kafka/versioneer.py +++ b/python/cudf_kafka/versioneer.py @@ -1123,7 +1123,8 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command): fmt = "tag '%s' doesn't start with prefix '%s'" print(fmt % (full_tag, tag_prefix)) pieces["error"] = "tag '{}' doesn't start with prefix '{}'".format( - full_tag, tag_prefix, + full_tag, + tag_prefix, ) return pieces pieces["closest-tag"] = full_tag[len(tag_prefix) :] diff --git a/python/dask_cudf/dask_cudf/backends.py b/python/dask_cudf/dask_cudf/backends.py index dbb1109b7d3..d1edfb071a2 100644 --- a/python/dask_cudf/dask_cudf/backends.py +++ b/python/dask_cudf/dask_cudf/backends.py @@ -342,7 +342,6 @@ def percentile_cudf(a, q, interpolation="linear"): n, ) - except ImportError: pass diff --git a/python/dask_cudf/dask_cudf/core.py b/python/dask_cudf/dask_cudf/core.py index 4d193f34b9f..5a21068feac 100644 --- a/python/dask_cudf/dask_cudf/core.py +++ b/python/dask_cudf/dask_cudf/core.py @@ -456,7 +456,7 @@ class Index(Series, dd.core.Index): def _naive_var(ddf, meta, skipna, ddof, split_every, out): num = ddf._get_numeric_data() x = 1.0 * num.sum(skipna=skipna, split_every=split_every) - x2 = 1.0 * (num ** 2).sum(skipna=skipna, split_every=split_every) + x2 = 1.0 * (num**2).sum(skipna=skipna, split_every=split_every) n = num.count(split_every=split_every) name = ddf._token_prefix + "var" result = map_partitions( @@ -489,7 +489,7 @@ def _aggregate_var(parts): n = n_a + n_b avg = (n_a * avg_a + n_b * avg_b) / n delta = avg_b - avg_a - m2 = m2_a + m2_b + delta ** 2 * n_a * n_b / n + m2 = m2_a + m2_b + delta**2 * n_a * n_b / n return n, avg, m2 def _finalize_var(vals): diff --git a/python/dask_cudf/dask_cudf/groupby.py b/python/dask_cudf/dask_cudf/groupby.py index 76533706030..684b1f71099 100644 --- a/python/dask_cudf/dask_cudf/groupby.py +++ b/python/dask_cudf/dask_cudf/groupby.py @@ -46,11 +46,19 @@ def __init__(self, *args, **kwargs): def __getitem__(self, key): if isinstance(key, list): g = CudfDataFrameGroupBy( - self.obj, by=self.by, slice=key, sort=self.sort, **self.dropna, + self.obj, + by=self.by, + slice=key, + sort=self.sort, + **self.dropna, ) else: g = CudfSeriesGroupBy( - self.obj, by=self.by, slice=key, sort=self.sort, **self.dropna, + self.obj, + by=self.by, + slice=key, + sort=self.sort, + **self.dropna, ) g._meta = g._meta[key] @@ -540,7 +548,7 @@ def _var_agg(df, col, count_name, sum_name, pow2_sum_name, ddof=1): x2 = df[pow2_sum_name] # Use sum-squared approach to get variance - var = x2 - x ** 2 / n + var = x2 - x**2 / n div = n - ddof div[div < 1] = 1 # Avoid division by 0 var /= div diff --git a/python/dask_cudf/dask_cudf/io/parquet.py b/python/dask_cudf/dask_cudf/io/parquet.py index ac5795fa2ec..042759f68cf 100644 --- a/python/dask_cudf/dask_cudf/io/parquet.py +++ b/python/dask_cudf/dask_cudf/io/parquet.py @@ -1,4 +1,4 @@ -# Copyright (c) 2019-2020, NVIDIA CORPORATION. +# Copyright (c) 2019-2022, NVIDIA CORPORATION. import warnings from contextlib import ExitStack from functools import partial @@ -130,7 +130,8 @@ def _read_paths( # Build the column from `codes` directly # (since the category is often a larger dtype) codes = as_column( - partitions[i].keys.index(index2), length=len(df), + partitions[i].keys.index(index2), + length=len(df), ) df[name] = build_categorical_column( categories=partitions[i].keys, diff --git a/python/dask_cudf/dask_cudf/io/tests/test_parquet.py b/python/dask_cudf/dask_cudf/io/tests/test_parquet.py index c5d3cf293fd..d9b8ee4595a 100644 --- a/python/dask_cudf/dask_cudf/io/tests/test_parquet.py +++ b/python/dask_cudf/dask_cudf/io/tests/test_parquet.py @@ -408,7 +408,10 @@ def test_row_groups_per_part(tmpdir, row_groups, index): write_metadata_file=True, ) - ddf2 = dask_cudf.read_parquet(str(tmpdir), row_groups_per_part=row_groups,) + ddf2 = dask_cudf.read_parquet( + str(tmpdir), + row_groups_per_part=row_groups, + ) dd.assert_eq(ddf1, ddf2, check_divisions=False) @@ -426,7 +429,9 @@ def test_create_metadata_file(tmpdir, partition_on): df1.index.name = "myindex" ddf1 = dask_cudf.from_cudf(df1, npartitions=10) ddf1.to_parquet( - tmpdir, write_metadata_file=False, partition_on=partition_on, + tmpdir, + write_metadata_file=False, + partition_on=partition_on, ) # Add global _metadata file @@ -435,7 +440,8 @@ def test_create_metadata_file(tmpdir, partition_on): else: fns = glob.glob(os.path.join(tmpdir, "*.parquet")) dask_cudf.io.parquet.create_metadata_file( - fns, split_every=3, # Force tree reduction + fns, + split_every=3, # Force tree reduction ) # Check that we can now read the ddf diff --git a/python/dask_cudf/dask_cudf/tests/test_accessor.py b/python/dask_cudf/dask_cudf/tests/test_accessor.py index db4b655fcbd..84c0e0e9b39 100644 --- a/python/dask_cudf/dask_cudf/tests/test_accessor.py +++ b/python/dask_cudf/dask_cudf/tests/test_accessor.py @@ -351,7 +351,8 @@ def test_create_list_series(data): @pytest.mark.parametrize( - "data", [data_test_1(), data_test_2(), data_test_non_numeric()], + "data", + [data_test_1(), data_test_2(), data_test_non_numeric()], ) def test_unique(data): expect = Series(data).list.unique() @@ -360,7 +361,8 @@ def test_unique(data): @pytest.mark.parametrize( - "data", [data_test_2(), data_test_non_numeric()], + "data", + [data_test_2(), data_test_non_numeric()], ) def test_len(data): expect = Series(data).list.len() @@ -369,7 +371,8 @@ def test_len(data): @pytest.mark.parametrize( - "data, search_key", [(data_test_2(), 1)], + "data, search_key", + [(data_test_2(), 1)], ) def test_contains(data, search_key): expect = Series(data).list.contains(search_key) @@ -394,7 +397,8 @@ def test_get(data, index, expectation): @pytest.mark.parametrize( - "data", [data_test_1(), data_test_2(), data_test_nested()], + "data", + [data_test_1(), data_test_2(), data_test_nested()], ) def test_leaves(data): expect = Series(data).list.leaves @@ -459,7 +463,8 @@ def test_sorting(data, ascending, na_position, ignore_index): @pytest.mark.parametrize( - "data", struct_accessor_data_params, + "data", + struct_accessor_data_params, ) def test_create_struct_series(data): expect = pd.Series(data) @@ -468,7 +473,8 @@ def test_create_struct_series(data): @pytest.mark.parametrize( - "data", struct_accessor_data_params, + "data", + struct_accessor_data_params, ) def test_struct_field_str(data): for test_key in ["a", "b"]: @@ -478,7 +484,8 @@ def test_struct_field_str(data): @pytest.mark.parametrize( - "data", struct_accessor_data_params, + "data", + struct_accessor_data_params, ) def test_struct_field_integer(data): for test_key in [0, 1]: @@ -488,7 +495,8 @@ def test_struct_field_integer(data): @pytest.mark.parametrize( - "data", struct_accessor_data_params, + "data", + struct_accessor_data_params, ) def test_dask_struct_field_Key_Error(data): got = dgd.from_cudf(Series(data), 2) @@ -498,7 +506,8 @@ def test_dask_struct_field_Key_Error(data): @pytest.mark.parametrize( - "data", struct_accessor_data_params, + "data", + struct_accessor_data_params, ) def test_dask_struct_field_Int_Error(data): # breakpoint() diff --git a/python/dask_cudf/dask_cudf/tests/test_core.py b/python/dask_cudf/dask_cudf/tests/test_core.py index 67fed62c582..89326b60f37 100644 --- a/python/dask_cudf/dask_cudf/tests/test_core.py +++ b/python/dask_cudf/dask_cudf/tests/test_core.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021, NVIDIA CORPORATION. +# Copyright (c) 2021-2022, NVIDIA CORPORATION. import random @@ -720,7 +720,9 @@ def test_series_describe(): pdsr = dd.from_pandas(psr, npartitions=4) dd.assert_eq( - dsr.describe(), pdsr.describe(), check_less_precise=3, + dsr.describe(), + pdsr.describe(), + check_less_precise=3, ) diff --git a/python/dask_cudf/dask_cudf/tests/test_groupby.py b/python/dask_cudf/dask_cudf/tests/test_groupby.py index 274c6670426..e3545149c24 100644 --- a/python/dask_cudf/dask_cudf/tests/test_groupby.py +++ b/python/dask_cudf/dask_cudf/tests/test_groupby.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021, NVIDIA CORPORATION. +# Copyright (c) 2021-2022, NVIDIA CORPORATION. import numpy as np import pandas as pd @@ -316,7 +316,8 @@ def test_groupby_multiindex_reset_index(npartitions): gr_out[("b", "count")] = gr_out[("b", "count")].astype("int64") dd.assert_eq( - gr_out, pr.compute().sort_values(by=["a", "c"]).reset_index(drop=True), + gr_out, + pr.compute().sort_values(by=["a", "c"]).reset_index(drop=True), ) @@ -464,7 +465,8 @@ def test_groupby_categorical_key(): @pytest.mark.parametrize("npartitions", [1, 10]) def test_groupby_agg_params(npartitions, split_every, split_out, as_index): df = cudf.datasets.randomdata( - nrows=150, dtypes={"name": str, "a": int, "b": int, "c": float}, + nrows=150, + dtypes={"name": str, "a": int, "b": int, "c": float}, ) df["a"] = [0, 1, 2] * 50 ddf = dask_cudf.from_cudf(df, npartitions) @@ -480,7 +482,11 @@ def test_groupby_agg_params(npartitions, split_every, split_out, as_index): if split_out == 1: gf = ( ddf.groupby(["name", "a"], sort=True, as_index=as_index) - .aggregate(agg_dict, split_every=split_every, split_out=split_out,) + .aggregate( + agg_dict, + split_every=split_every, + split_out=split_out, + ) .compute() ) if as_index: @@ -499,10 +505,14 @@ def test_groupby_agg_params(npartitions, split_every, split_out, as_index): # Full check (`sort=False`) gr = ddf.groupby(["name", "a"], sort=False, as_index=as_index).aggregate( - agg_dict, split_every=split_every, split_out=split_out, + agg_dict, + split_every=split_every, + split_out=split_out, ) pr = pddf.groupby(["name", "a"], sort=False).agg( - agg_dict, split_every=split_every, split_out=split_out, + agg_dict, + split_every=split_every, + split_out=split_out, ) # Test `as_index` argument @@ -573,7 +583,8 @@ def test_groupby_unique_lists(): gddf.groupby("a").b.unique().compute(), ) dd.assert_eq( - gdf.groupby("a").b.unique(), gddf.groupby("a").b.unique().compute(), + gdf.groupby("a").b.unique(), + gddf.groupby("a").b.unique().compute(), ) diff --git a/python/dask_cudf/dask_cudf/tests/test_onehot.py b/python/dask_cudf/dask_cudf/tests/test_onehot.py index a9d88b5203c..6453d843467 100644 --- a/python/dask_cudf/dask_cudf/tests/test_onehot.py +++ b/python/dask_cudf/dask_cudf/tests/test_onehot.py @@ -1,3 +1,5 @@ +# Copyright (c) 2019-2022, NVIDIA CORPORATION. + import pandas as pd import pytest @@ -118,5 +120,6 @@ def test_get_dummies_categorical(): got = dd.get_dummies(gddf, columns=["B"]) dd.assert_eq( - expect, got, + expect, + got, ) From 8103a9159ce9dd7f5869dc9634a1a32d56b79404 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Mon, 28 Mar 2022 14:21:57 -0700 Subject: [PATCH 011/246] add accidentally removed comment. (#10526) Adds back a comment that was accidentally removed in #10523. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - GALI PREM SAGAR (https://github.com/galipremsagar) URL: https://github.com/rapidsai/cudf/pull/10526 --- python/cudf/cudf/_lib/column.pyi | 1 + 1 file changed, 1 insertion(+) diff --git a/python/cudf/cudf/_lib/column.pyi b/python/cudf/cudf/_lib/column.pyi index 0d61e4f02e5..c38c560b982 100644 --- a/python/cudf/cudf/_lib/column.pyi +++ b/python/cudf/cudf/_lib/column.pyi @@ -73,5 +73,6 @@ class Column: def _mimic_inplace( self, other_col: ColumnBase, inplace=False ) -> Optional[ColumnBase]: ... + # TODO: The val parameter should be Scalar, not ScalarLike @staticmethod def from_scalar(val: ScalarLike, size: int) -> ColumnBase: ... From 71501069d91826d2788e3bfe244036275eedd7c3 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Mon, 28 Mar 2022 14:59:35 -0700 Subject: [PATCH 012/246] Fix Series.str.findall behavior for expand=False. (#10459) Resolves #10226. Depends on #10491. The default behavior of `Series.str.findall` should be to return list columns instead of an expanded DataFrame with a number of columns equal to the maximum number of matches found. This PR takes some steps towards that goal: - [x] Fix the behavior of `expand=False` to use `findall_records` and return a list column of strings (currently `expand=False` raises an error). - [x] Deprecate the use of `expand` so that the parameter can be removed in the future. - [x] Update tests. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - GALI PREM SAGAR (https://github.com/galipremsagar) URL: https://github.com/rapidsai/cudf/pull/10459 --- python/cudf/cudf/_lib/strings/__init__.py | 2 +- python/cudf/cudf/core/column/string.py | 17 ++++++++++---- python/cudf/cudf/tests/test_string.py | 28 ++++++++++++++++++++++- 3 files changed, 41 insertions(+), 6 deletions(-) diff --git a/python/cudf/cudf/_lib/strings/__init__.py b/python/cudf/cudf/_lib/strings/__init__.py index 9fccd61c82d..15d5949b2cb 100644 --- a/python/cudf/cudf/_lib/strings/__init__.py +++ b/python/cudf/cudf/_lib/strings/__init__.py @@ -61,7 +61,7 @@ startswith, startswith_multiple, ) -from cudf._lib.strings.findall import findall +from cudf._lib.strings.findall import findall, findall_record from cudf._lib.strings.json import get_json_object from cudf._lib.strings.padding import PadSide, center, ljust, pad, rjust, zfill from cudf._lib.strings.repeat import repeat_scalar, repeat_sequence diff --git a/python/cudf/cudf/core/column/string.py b/python/cudf/cudf/core/column/string.py index c1ef33be975..88033fe700c 100644 --- a/python/cudf/cudf/core/column/string.py +++ b/python/cudf/cudf/core/column/string.py @@ -3537,10 +3537,19 @@ def findall( "unsupported value for `flags` parameter" ) - data, index = libstrings.findall(self._column, pat, flags) - return self._return_or_inplace( - cudf.core.frame.Frame(data, index), expand=expand - ) + if expand: + warnings.warn( + "The expand parameter is deprecated and will be removed in a " + "future version. Set expand=False to match future behavior.", + FutureWarning, + ) + data, index = libstrings.findall(self._column, pat, flags) + return self._return_or_inplace( + cudf.core.frame.Frame(data, index), expand=expand + ) + else: + data = libstrings.findall_record(self._column, pat, flags) + return self._return_or_inplace(data, expand=expand) def isempty(self) -> SeriesOrIndex: """ diff --git a/python/cudf/cudf/tests/test_string.py b/python/cudf/cudf/tests/test_string.py index d5d21f0b3c5..493098cd494 100644 --- a/python/cudf/cudf/tests/test_string.py +++ b/python/cudf/cudf/tests/test_string.py @@ -1823,7 +1823,33 @@ def test_string_count(data, pat, flags): assert_eq(as_index(gs).str.count(pat=pat), pd.Index(ps).str.count(pat=pat)) -def test_string_findall(): +@pytest.mark.parametrize( + "pat, flags", + [ + ("Monkey", 0), + ("on", 0), + ("b", 0), + ("on$", 0), + ("on$", re.MULTILINE), + ("o.*k", re.DOTALL), + ], +) +def test_string_findall(pat, flags): + test_data = ["Lion", "Monkey", "Rabbit", "Don\nkey"] + ps = pd.Series(test_data) + gs = cudf.Series(test_data) + + # TODO: Update this test to remove "expand=False" when removing the expand + # parameter from Series.str.findall. + assert_eq( + ps.str.findall(pat, flags), gs.str.findall(pat, flags, expand=False) + ) + + +@pytest.mark.filterwarnings("ignore:The expand parameter is deprecated") +def test_string_findall_expand_True(): + # TODO: Remove this test when removing the expand parameter from + # Series.str.findall. test_data = ["Lion", "Monkey", "Rabbit", "Don\nkey"] ps = pd.Series(test_data) gs = cudf.Series(test_data) From 19f324cdeeb9d7c289529d60597fc202c48aa2d2 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Mon, 28 Mar 2022 15:05:01 -0700 Subject: [PATCH 013/246] Update conda environment. (#10525) This is a follow-up to #10523 that updates the conda environment now that the [conda-forge package should be available](https://github.com/conda-forge/black-feedstock/pull/42). Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - GALI PREM SAGAR (https://github.com/galipremsagar) - https://github.com/jakirkham - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/cudf/pull/10525 --- conda/environments/cudf_dev_cuda11.5.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conda/environments/cudf_dev_cuda11.5.yml b/conda/environments/cudf_dev_cuda11.5.yml index 2a3f729db37..e9d018a2d18 100644 --- a/conda/environments/cudf_dev_cuda11.5.yml +++ b/conda/environments/cudf_dev_cuda11.5.yml @@ -37,7 +37,7 @@ dependencies: - cuda-python >=11.5,<12.0 - pip - flake8=3.8.3 - - black=19.10 + - black=22.3.0 - isort=5.6.4 - mypy=0.782 - pydocstyle=6.1.1 From 62360cbc93f3b265f29b948ca061d5fd51aaef3c Mon Sep 17 00:00:00 2001 From: brandon-b-miller <53796099+brandon-b-miller@users.noreply.github.com> Date: Mon, 28 Mar 2022 19:52:14 -0500 Subject: [PATCH 014/246] Fix temp data cleanup in `test_text.py` (#10524) Noticed that when running pytests, cuDF was leaving a temporary file used for a specific test in the testing data folder without removing it. I think our tests mostly write to `tmp` to avoid this issue. In switching it to point to `tmp` I noticed the intended data is not being actually written to the file, instead it was writing the string `__repr__` of the generator. I also shrunk the data size by many orders of magnitude, because in the intended case where the data is meant to be truly generated, 30 mil ends up being a little cumbersome and slow. Authors: - https://github.com/brandon-b-miller Approvers: - GALI PREM SAGAR (https://github.com/galipremsagar) URL: https://github.com/rapidsai/cudf/pull/10524 --- python/cudf/cudf/tests/test_text.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/python/cudf/cudf/tests/test_text.py b/python/cudf/cudf/tests/test_text.py index c332924fd8b..21c22110910 100644 --- a/python/cudf/cudf/tests/test_text.py +++ b/python/cudf/cudf/tests/test_text.py @@ -822,10 +822,10 @@ def test_read_text_byte_range(datadir): assert_eq(expected, actual) -def test_read_text_byte_range_large(datadir): - content = str(("\n" if x % 5 == 0 else "x") for x in range(0, 300000000)) +def test_read_text_byte_range_large(tmpdir): + content = str([["\n" if x % 5 == 0 else "x"] for x in range(0, 3000)]) delimiter = "1." - temp_file = str(datadir) + "/temp.txt" + temp_file = str(tmpdir) + "/temp.txt" with open(temp_file, "w") as f: f.write(content) From a0495f46f9662b2dab88ddb787cc66d491374780 Mon Sep 17 00:00:00 2001 From: brandon-b-miller <53796099+brandon-b-miller@users.noreply.github.com> Date: Tue, 29 Mar 2022 09:25:55 -0500 Subject: [PATCH 015/246] Deprecate `Series.applymap` (#10497) Part of https://github.com/rapidsai/cudf/issues/10169 Authors: - https://github.com/brandon-b-miller Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/cudf/pull/10497 --- python/cudf/cudf/core/series.py | 11 ++++++++++- python/cudf/cudf/tests/test_applymap.py | 12 +++++++----- python/cudf/cudf/tests/test_transform.py | 3 ++- python/cudf/cudf/tests/test_udf_masked_ops.py | 6 ++++-- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/python/cudf/cudf/core/series.py b/python/cudf/cudf/core/series.py index 1f79672f30f..0ea02edb924 100644 --- a/python/cudf/cudf/core/series.py +++ b/python/cudf/cudf/core/series.py @@ -5,6 +5,7 @@ import functools import inspect import pickle +import warnings from collections import abc as abc from shutil import get_terminal_size from typing import Any, Dict, MutableMapping, Optional, Set, Tuple, Type, Union @@ -1012,7 +1013,10 @@ def map(self, arg, na_action=None) -> "Series": result.name = self.name result.index = self.index else: - result = self.applymap(arg) + # TODO: switch to `apply` + with warnings.catch_warnings(): + warnings.simplefilter("ignore", category=FutureWarning) + result = self.applymap(arg) return result @_cudf_nvtx_annotate @@ -2210,6 +2214,11 @@ def applymap(self, udf, out_dtype=None): 4 105 dtype: int64 """ + warnings.warn( + "Series.applymap is deprecated and will be removed " + "in a future cuDF release. Use Series.apply instead.", + FutureWarning, + ) if not callable(udf): raise ValueError("Input UDF must be a callable object.") return self._from_data({self.name: self._unaryop(udf)}, self._index) diff --git a/python/cudf/cudf/tests/test_applymap.py b/python/cudf/cudf/tests/test_applymap.py index ff6e79e7804..bd322a28a08 100644 --- a/python/cudf/cudf/tests/test_applymap.py +++ b/python/cudf/cudf/tests/test_applymap.py @@ -1,4 +1,4 @@ -# Copyright (c) 2018-2021, NVIDIA CORPORATION. +# Copyright (c) 2018-2022, NVIDIA CORPORATION. from itertools import product from math import floor @@ -29,9 +29,10 @@ def test_applymap_round(nelem, masked): sr = Series(data) # Call applymap - out = sr.applymap( - lambda x: (floor(x) + 1 if x - floor(x) >= 0.5 else floor(x)) - ) + with pytest.warns(FutureWarning): + out = sr.applymap( + lambda x: (floor(x) + 1 if x - floor(x) >= 0.5 else floor(x)) + ) if masked: # Fill masked values @@ -50,7 +51,8 @@ def test_applymap_change_out_dtype(): sr = Series(data) - out = sr.applymap(lambda x: float(x), out_dtype=float) + with pytest.warns(FutureWarning): + out = sr.applymap(lambda x: float(x), out_dtype=float) # Check expect = np.array(data, dtype=float) diff --git a/python/cudf/cudf/tests/test_transform.py b/python/cudf/cudf/tests/test_transform.py index b5bcf9df8f5..4b4537514d6 100644 --- a/python/cudf/cudf/tests/test_transform.py +++ b/python/cudf/cudf/tests/test_transform.py @@ -29,6 +29,7 @@ def test_applymap_python_lambda(dtype, udf, testfunc): lhs_arr = np.random.random(size).astype(dtype) lhs_ser = Series(lhs_arr) - out_ser = lhs_ser.applymap(udf) + with pytest.warns(FutureWarning): + out_ser = lhs_ser.applymap(udf) result = testfunc(lhs_arr) np.testing.assert_almost_equal(result, out_ser.to_numpy()) diff --git a/python/cudf/cudf/tests/test_udf_masked_ops.py b/python/cudf/cudf/tests/test_udf_masked_ops.py index 36750adf6ee..b68a7562b6b 100644 --- a/python/cudf/cudf/tests/test_udf_masked_ops.py +++ b/python/cudf/cudf/tests/test_udf_masked_ops.py @@ -645,7 +645,8 @@ def test_masked_udf_caching(): data = cudf.Series([1, 2, 3]) expect = data**2 - got = data.applymap(lambda x: x**2) + with pytest.warns(FutureWarning): + got = data.applymap(lambda x: x**2) assert_eq(expect, got, check_dtype=False) @@ -653,7 +654,8 @@ def test_masked_udf_caching(): # it does not result in a cache hit expect = data**3 - got = data.applymap(lambda x: x**3) + with pytest.warns(FutureWarning): + got = data.applymap(lambda x: x**3) assert_eq(expect, got, check_dtype=False) # make sure we get a hit when reapplying From b926f51dde17db1c591fa5d25c41a9f6b989233b Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Tue, 29 Mar 2022 10:46:51 -0400 Subject: [PATCH 016/246] Consolidate C++ `conda` recipes and add `libcudf-tests` package (#10326) This PR includes the following changes: - Adds a `libcudf-tests` package to the `libcudf` recipe - This is a prerequisite for removing "Project Flash" from our build/CI scripts - The `libcudf-tests` package was added as an additional output to the existing `libcudf` recipe (which was renamed to `libcudf-split`) - Consolidates remaining C++ recipes into `libcudf-split` recipe - This gets rid of a lot of duplicate code between the recipes and reduces the number of times we have to call `conda build` in our CI scripts The result of consolidating the C++ recipes into a single `libcudf-split` recipe is that one top-level build occurs, which builds all of the C++ components (in `conda/recipes/libcudf/build.sh`) but does _not_ install them. The installation for each package occurs in the corresponding `conda/recipes/libcudf/install_libcudf.sh`, `conda/recipes/libcudf/install_libcudf_kafka.sh`, etc. scripts. There are some implications to these changes. Namely that **any top-level `host` requirement which includes a `run_exports` value (i.e. shared libraries) must now be manually specified in the `run` dependencies of the corresponding `outputs` package.** To help keep things DRY, dependency version specs can be specified in `conda/recipes/librmm/conda_build_config.yaml`. The exception here is the version spec used for `cudatoolkit` since that comes from an environment variable in the CI process. Authors: - AJ Schmidt (https://github.com/ajschmidt8) Approvers: - Vyas Ramasubramani (https://github.com/vyasr) - Jordan Jacobelli (https://github.com/Ethyling) - https://github.com/jakirkham - Jason Lowe (https://github.com/jlowe) URL: https://github.com/rapidsai/cudf/pull/10326 --- ci/checks/headers_test.sh | 4 +- ci/cpu/build.sh | 19 +- ci/cpu/prebuild.sh | 3 +- ci/cpu/upload.sh | 30 +- ci/gpu/build.sh | 27 +- ci/gpu/java.sh | 17 +- conda/recipes/libcudf/build.sh | 11 +- conda/recipes/libcudf/conda_build_config.yaml | 14 + conda/recipes/libcudf/install_libcudf.sh | 4 + .../libcudf/install_libcudf_example.sh | 4 + .../recipes/libcudf/install_libcudf_kafka.sh | 4 + .../recipes/libcudf/install_libcudf_tests.sh | 5 + conda/recipes/libcudf/meta.yaml | 542 ++++++++++-------- conda/recipes/libcudf_example/build.sh | 4 - conda/recipes/libcudf_example/meta.yaml | 35 -- conda/recipes/libcudf_kafka/build.sh | 8 - conda/recipes/libcudf_kafka/meta.yaml | 45 -- cpp/examples/build.sh | 5 +- java/src/main/native/CMakeLists.txt | 20 +- 19 files changed, 370 insertions(+), 431 deletions(-) create mode 100644 conda/recipes/libcudf/conda_build_config.yaml create mode 100644 conda/recipes/libcudf/install_libcudf.sh create mode 100644 conda/recipes/libcudf/install_libcudf_example.sh create mode 100644 conda/recipes/libcudf/install_libcudf_kafka.sh create mode 100644 conda/recipes/libcudf/install_libcudf_tests.sh delete mode 100644 conda/recipes/libcudf_example/build.sh delete mode 100644 conda/recipes/libcudf_example/meta.yaml delete mode 100644 conda/recipes/libcudf_kafka/build.sh delete mode 100644 conda/recipes/libcudf_kafka/meta.yaml diff --git a/ci/checks/headers_test.sh b/ci/checks/headers_test.sh index c9dd7bb6957..ebfc4b2965e 100755 --- a/ci/checks/headers_test.sh +++ b/ci/checks/headers_test.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-2022, NVIDIA CORPORATION. ##################################### # conda existence test for headers # ##################################### @@ -10,7 +10,7 @@ DIRNAMES="cudf cudf_test" # existence tests for lib${LIBNAME} for DIRNAME in ${DIRNAMES[@]}; do - HEADERS=`cd cpp && find include/${DIRNAME}/ -type f \( -iname "*.h" -o -iname "*.hpp" \) -printf " - test -f \\\$PREFIX/%p\n" | sort` + HEADERS=`cd cpp && find include/${DIRNAME}/ -type f \( -iname "*.h" -o -iname "*.hpp" \) -printf " - test -f \\\$PREFIX/%p\n" | sort` META_TESTS=`grep -E "test -f .*/include/${DIRNAME}/.*\.h(pp)?" conda/recipes/lib${LIBNAME}/meta.yaml | sort` HEADER_DIFF=`diff <(echo "$HEADERS") <(echo "$META_TESTS")` LIB_RETVAL=$? diff --git a/ci/cpu/build.sh b/ci/cpu/build.sh index 465a6eae7e4..0eab3a6789e 100755 --- a/ci/cpu/build.sh +++ b/ci/cpu/build.sh @@ -6,7 +6,10 @@ set -e # Set path and build parallel level -export PATH=/opt/conda/bin:/usr/local/cuda/bin:$PATH +# FIXME: PATH variable shouldn't be necessary. +# This should be removed once we either stop using the `remote-docker-plugin` +# or the following issue is addressed: https://github.com/gpuopenanalytics/remote-docker-plugin/issues/47 +export PATH=/usr/local/gcc9/bin:/opt/conda/bin:/usr/local/cuda/bin:$PATH export PARALLEL_LEVEL=${PARALLEL_LEVEL:-4} # Set home to the job's workspace @@ -31,10 +34,6 @@ if [[ "$BUILD_MODE" = "branch" && "$SOURCE_BRANCH" = branch-* ]] ; then export VERSION_SUFFIX=`date +%y%m%d` fi -export CMAKE_CUDA_COMPILER_LAUNCHER="sccache" -export CMAKE_CXX_COMPILER_LAUNCHER="sccache" -export CMAKE_C_COMPILER_LAUNCHER="sccache" - ################################################################################ # SETUP - Check environment ################################################################################ @@ -94,16 +93,6 @@ if [ "$BUILD_LIBCUDF" == '1' ]; then cp "$LIBCUDF_BUILD_DIR/ninja_log.html" "$WORKSPACE/build-metrics/BuildMetrics.html" cp "$LIBCUDF_BUILD_DIR/ninja.log" "$WORKSPACE/build-metrics/ninja.log" fi - - gpuci_logger "Build conda pkg for libcudf_kafka" - gpuci_conda_retry build --no-build-id --croot ${CONDA_BLD_DIR} conda/recipes/libcudf_kafka $CONDA_BUILD_ARGS - mkdir -p ${CONDA_BLD_DIR}/libcudf_kafka/work - cp -r ${CONDA_BLD_DIR}/work/* ${CONDA_BLD_DIR}/libcudf_kafka/work - - gpuci_logger "Building libcudf examples" - gpuci_conda_retry build --no-build-id --croot ${CONDA_BLD_DIR} conda/recipes/libcudf_example $CONDA_BUILD_ARGS - mkdir -p ${CONDA_BLD_DIR}/libcudf_example/work - cp -r ${CONDA_BLD_DIR}/work/* ${CONDA_BLD_DIR}/libcudf_example/work fi if [ "$BUILD_CUDF" == '1' ]; then diff --git a/ci/cpu/prebuild.sh b/ci/cpu/prebuild.sh index 1699fc16a47..32589042f7f 100755 --- a/ci/cpu/prebuild.sh +++ b/ci/cpu/prebuild.sh @@ -1,13 +1,12 @@ #!/usr/bin/env bash -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-2022, NVIDIA CORPORATION. set -e #Always upload cudf packages export UPLOAD_CUDF=1 export UPLOAD_LIBCUDF=1 export UPLOAD_CUDF_KAFKA=1 -export UPLOAD_LIBCUDF_KAFKA=1 if [[ -z "$PROJECT_FLASH" || "$PROJECT_FLASH" == "0" ]]; then #If project flash is not activate, always build both diff --git a/ci/cpu/upload.sh b/ci/cpu/upload.sh index f2f67e9e000..88a48ea2e3b 100755 --- a/ci/cpu/upload.sh +++ b/ci/cpu/upload.sh @@ -1,5 +1,5 @@ #!/bin/bash -# +# Copyright (c) 2018-2022, NVIDIA CORPORATION. # Adopted from https://github.com/tmcdonell/travis-scripts/blob/dfaac280ac2082cd6bcaba3217428347899f2975/update-accelerate-buildbot.sh set -e @@ -29,45 +29,31 @@ fi gpuci_logger "Starting conda uploads" if [[ "$BUILD_LIBCUDF" == "1" && "$UPLOAD_LIBCUDF" == "1" ]]; then - export LIBCUDF_FILE=$(conda build --no-build-id --croot "${CONDA_BLD_DIR}" conda/recipes/libcudf --output) - test -e ${LIBCUDF_FILE} - echo "Upload libcudf" - echo ${LIBCUDF_FILE} - gpuci_retry anaconda -t ${MY_UPLOAD_KEY} upload -u ${CONDA_USERNAME:-rapidsai} ${LABEL_OPTION} --skip-existing ${LIBCUDF_FILE} --no-progress + export LIBCUDF_FILES=$(conda build --no-build-id --croot "${CONDA_BLD_DIR}" conda/recipes/libcudf --output) + LIBCUDF_FILES=$(echo "$LIBCUDF_FILES" | sed 's/.*libcudf-example.*//') # skip libcudf-example pkg upload + gpuci_retry anaconda -t ${MY_UPLOAD_KEY} upload -u ${CONDA_USERNAME:-rapidsai} ${LABEL_OPTION} --skip-existing --no-progress $LIBCUDF_FILES fi if [[ "$BUILD_CUDF" == "1" && "$UPLOAD_CUDF" == "1" ]]; then export CUDF_FILE=$(conda build --croot "${CONDA_BLD_DIR}" conda/recipes/cudf --python=$PYTHON --output) test -e ${CUDF_FILE} - echo "Upload cudf" - echo ${CUDF_FILE} + echo "Upload cudf: ${CUDF_FILE}" gpuci_retry anaconda -t ${MY_UPLOAD_KEY} upload -u ${CONDA_USERNAME:-rapidsai} ${LABEL_OPTION} --skip-existing ${CUDF_FILE} --no-progress export DASK_CUDF_FILE=$(conda build --croot "${CONDA_BLD_DIR}" conda/recipes/dask-cudf --python=$PYTHON --output) test -e ${DASK_CUDF_FILE} - echo "Upload dask-cudf" - echo ${DASK_CUDF_FILE} + echo "Upload dask-cudf: ${DASK_CUDF_FILE}" gpuci_retry anaconda -t ${MY_UPLOAD_KEY} upload -u ${CONDA_USERNAME:-rapidsai} ${LABEL_OPTION} --skip-existing ${DASK_CUDF_FILE} --no-progress export CUSTREAMZ_FILE=$(conda build --croot "${CONDA_BLD_DIR}" conda/recipes/custreamz --python=$PYTHON --output) test -e ${CUSTREAMZ_FILE} - echo "Upload custreamz" - echo ${CUSTREAMZ_FILE} + echo "Upload custreamz: ${CUSTREAMZ_FILE}" gpuci_retry anaconda -t ${MY_UPLOAD_KEY} upload -u ${CONDA_USERNAME:-rapidsai} ${LABEL_OPTION} --skip-existing ${CUSTREAMZ_FILE} --no-progress fi -if [[ "$BUILD_LIBCUDF" == "1" && "$UPLOAD_LIBCUDF_KAFKA" == "1" ]]; then - export LIBCUDF_KAFKA_FILE=$(conda build --no-build-id --croot "${CONDA_BLD_DIR}" conda/recipes/libcudf_kafka --output) - test -e ${LIBCUDF_KAFKA_FILE} - echo "Upload libcudf_kafka" - echo ${LIBCUDF_KAFKA_FILE} - gpuci_retry anaconda -t ${MY_UPLOAD_KEY} upload -u ${CONDA_USERNAME:-rapidsai} ${LABEL_OPTION} --skip-existing ${LIBCUDF_KAFKA_FILE} --no-progress -fi - if [[ "$BUILD_CUDF" == "1" && "$UPLOAD_CUDF_KAFKA" == "1" ]]; then export CUDF_KAFKA_FILE=$(conda build --croot "${CONDA_BLD_DIR}" conda/recipes/cudf_kafka --python=$PYTHON --output) test -e ${CUDF_KAFKA_FILE} - echo "Upload cudf_kafka" - echo ${CUDF_KAFKA_FILE} + echo "Upload cudf_kafka: ${CUDF_KAFKA_FILE}" gpuci_retry anaconda -t ${MY_UPLOAD_KEY} upload -u ${CONDA_USERNAME:-rapidsai} ${LABEL_OPTION} --skip-existing ${CUDF_KAFKA_FILE} --no-progress fi diff --git a/ci/gpu/build.sh b/ci/gpu/build.sh index 6dbcb339f3f..b1d649db8f9 100755 --- a/ci/gpu/build.sh +++ b/ci/gpu/build.sh @@ -36,10 +36,6 @@ export INSTALL_DASK_MAIN=1 # ucx-py version export UCX_PY_VERSION='0.26.*' -export CMAKE_CUDA_COMPILER_LAUNCHER="sccache" -export CMAKE_CXX_COMPILER_LAUNCHER="sccache" -export CMAKE_C_COMPILER_LAUNCHER="sccache" - ################################################################################ # TRAP - Setup trap for removing jitify cache ################################################################################ @@ -166,8 +162,6 @@ if [[ -z "$PROJECT_FLASH" || "$PROJECT_FLASH" == "0" ]]; then fi else #Project Flash - export LIB_BUILD_DIR="$WORKSPACE/ci/artifacts/cudf/cpu/libcudf_work/cpp/build" - export LD_LIBRARY_PATH="$LIB_BUILD_DIR:$CONDA_PREFIX/lib:$LD_LIBRARY_PATH" if hasArg --skip-tests; then gpuci_logger "Skipping Tests" @@ -177,17 +171,16 @@ else gpuci_logger "Check GPU usage" nvidia-smi - set -x - cd $LIB_BUILD_DIR + gpuci_mamba_retry install -y -c ${CONDA_ARTIFACT_PATH} libcudf libcudf_kafka libcudf-tests gpuci_logger "GoogleTests" - - for gt in gtests/* ; do - test_name=$(basename ${gt}) + # Run libcudf and libcudf_kafka gtests from libcudf-tests package + for gt in "$CONDA_PREFIX/bin/gtests/libcudf"*/* ; do echo "Running GoogleTest $test_name" ${gt} --gtest_output=xml:"$WORKSPACE/test-results/" done + export LIB_BUILD_DIR="$WORKSPACE/ci/artifacts/cudf/cpu/libcudf_work/cpp/build" # Copy libcudf build time results echo "Checking for build time log $LIB_BUILD_DIR/ninja_log.xml" if [[ -f "$LIB_BUILD_DIR/ninja_log.xml" ]]; then @@ -204,7 +197,7 @@ else export GTEST_CUDF_RMM_MODE=cuda COMPUTE_SANITIZER_CMD="compute-sanitizer --tool memcheck" mkdir -p "$WORKSPACE/test-results/" - for gt in gtests/*; do + for gt in "$CONDA_PREFIX/bin/gtests/libcudf"*/* ; do test_name=$(basename ${gt}) if [[ "$test_name" == "ERROR_TEST" ]]; then continue @@ -217,16 +210,6 @@ else fi fi - CUDF_CONDA_FILE=`find ${CONDA_ARTIFACT_PATH} -name "libcudf-*.tar.bz2"` - CUDF_CONDA_FILE=`basename "$CUDF_CONDA_FILE" .tar.bz2` #get filename without extension - CUDF_CONDA_FILE=${CUDF_CONDA_FILE//-/=} #convert to conda install - KAFKA_CONDA_FILE=`find ${CONDA_ARTIFACT_PATH} -name "libcudf_kafka-*.tar.bz2"` - KAFKA_CONDA_FILE=`basename "$KAFKA_CONDA_FILE" .tar.bz2` #get filename without extension - KAFKA_CONDA_FILE=${KAFKA_CONDA_FILE//-/=} #convert to conda install - - gpuci_logger "Installing $CUDF_CONDA_FILE & $KAFKA_CONDA_FILE" - gpuci_mamba_retry install -c ${CONDA_ARTIFACT_PATH} "$CUDF_CONDA_FILE" "$KAFKA_CONDA_FILE" - install_dask gpuci_logger "Build python libs from source" diff --git a/ci/gpu/java.sh b/ci/gpu/java.sh index fd449c44622..1d378824b01 100755 --- a/ci/gpu/java.sh +++ b/ci/gpu/java.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2018-2020, NVIDIA CORPORATION. +# Copyright (c) 2018-2022, NVIDIA CORPORATION. ############################################## # cuDF GPU build and test script for CI # ############################################## @@ -122,19 +122,8 @@ function install_dask { # INSTALL - Install libcudf artifacts ################################################################################ -export LIB_BUILD_DIR="$WORKSPACE/ci/artifacts/cudf/cpu/libcudf_work/cpp/build" -export CUDF_ROOT=${LIB_BUILD_DIR} -export LD_LIBRARY_PATH="$LIB_BUILD_DIR:$CONDA_PREFIX/lib:$LD_LIBRARY_PATH" - -CUDF_CONDA_FILE=`find ${CONDA_ARTIFACT_PATH} -name "libcudf-*.tar.bz2"` -CUDF_CONDA_FILE=`basename "$CUDF_CONDA_FILE" .tar.bz2` #get filename without extension -CUDF_CONDA_FILE=${CUDF_CONDA_FILE//-/=} #convert to conda install -KAFKA_CONDA_FILE=`find ${CONDA_ARTIFACT_PATH} -name "libcudf_kafka-*.tar.bz2"` -KAFKA_CONDA_FILE=`basename "$KAFKA_CONDA_FILE" .tar.bz2` #get filename without extension -KAFKA_CONDA_FILE=${KAFKA_CONDA_FILE//-/=} #convert to conda install - -gpuci_logger "Installing $CUDF_CONDA_FILE & $KAFKA_CONDA_FILE" -gpuci_mamba_retry install -c ${CONDA_ARTIFACT_PATH} "$CUDF_CONDA_FILE" "$KAFKA_CONDA_FILE" +gpuci_logger "Installing libcudf & libcudf_kafka" +gpuci_mamba_retry install -c ${CONDA_ARTIFACT_PATH} libcudf libcudf_kafka install_dask diff --git a/conda/recipes/libcudf/build.sh b/conda/recipes/libcudf/build.sh index c3730b3241a..8201b4d97be 100644 --- a/conda/recipes/libcudf/build.sh +++ b/conda/recipes/libcudf/build.sh @@ -1,8 +1,5 @@ -# Copyright (c) 2018-2019, NVIDIA CORPORATION. +#!/bin/bash +# Copyright (c) 2018-2022, NVIDIA CORPORATION. -if [[ -z "$PROJECT_FLASH" || "$PROJECT_FLASH" == "0" ]]; then - # This assumes the script is executed from the root of the repo directory - ./build.sh -v libcudf --allgpuarch --cmake-args=\"-DCMAKE_INSTALL_LIBDIR=lib\" -else - ./build.sh -v libcudf tests --allgpuarch --build_metrics --incl_cache_stats --cmake-args=\"-DCMAKE_INSTALL_LIBDIR=lib\" -fi +export cudf_ROOT="$(realpath ./cpp/build)" +./build.sh -n -v libcudf libcudf_kafka benchmarks tests --cmake-args=\"-DCMAKE_INSTALL_LIBDIR=lib\" diff --git a/conda/recipes/libcudf/conda_build_config.yaml b/conda/recipes/libcudf/conda_build_config.yaml new file mode 100644 index 00000000000..0a533e5c5fe --- /dev/null +++ b/conda/recipes/libcudf/conda_build_config.yaml @@ -0,0 +1,14 @@ +cmake_version: + - ">=3.20.1" + +gtest_version: + - "=1.10.0" + +arrow_cpp_version: + - ">=6.0.1,<6.0.2.0a0" + +dlpack_version: + - ">=0.5,<0.6.0a0" + +librdkafka_version: + - ">=1.7.0,<1.8.0a0" diff --git a/conda/recipes/libcudf/install_libcudf.sh b/conda/recipes/libcudf/install_libcudf.sh new file mode 100644 index 00000000000..173f8cfa90f --- /dev/null +++ b/conda/recipes/libcudf/install_libcudf.sh @@ -0,0 +1,4 @@ +#!/bin/bash +# Copyright (c) 2018-2022, NVIDIA CORPORATION. + +cmake --install cpp/build diff --git a/conda/recipes/libcudf/install_libcudf_example.sh b/conda/recipes/libcudf/install_libcudf_example.sh new file mode 100644 index 00000000000..e249688a03b --- /dev/null +++ b/conda/recipes/libcudf/install_libcudf_example.sh @@ -0,0 +1,4 @@ +#!/bin/bash +# Copyright (c) 2018-2022, NVIDIA CORPORATION. + +./cpp/examples/build.sh diff --git a/conda/recipes/libcudf/install_libcudf_kafka.sh b/conda/recipes/libcudf/install_libcudf_kafka.sh new file mode 100644 index 00000000000..9eae2510027 --- /dev/null +++ b/conda/recipes/libcudf/install_libcudf_kafka.sh @@ -0,0 +1,4 @@ +#!/bin/bash +# Copyright (c) 2018-2022, NVIDIA CORPORATION. + +cmake --install cpp/libcudf_kafka/build diff --git a/conda/recipes/libcudf/install_libcudf_tests.sh b/conda/recipes/libcudf/install_libcudf_tests.sh new file mode 100644 index 00000000000..069462eec9d --- /dev/null +++ b/conda/recipes/libcudf/install_libcudf_tests.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Copyright (c) 2018-2022, NVIDIA CORPORATION. + +cmake --install cpp/build --component testing +cmake --install cpp/libcudf_kafka/build --component testing diff --git a/conda/recipes/libcudf/meta.yaml b/conda/recipes/libcudf/meta.yaml index 4ea4ace11da..fdd9011ae34 100644 --- a/conda/recipes/libcudf/meta.yaml +++ b/conda/recipes/libcudf/meta.yaml @@ -1,27 +1,23 @@ # Copyright (c) 2018-2022, NVIDIA CORPORATION. {% set version = environ.get('GIT_DESCRIBE_TAG', '0.0.0.dev').lstrip('v') + environ.get('VERSION_SUFFIX', '') %} -{% set minor_version = version.split('.')[0] + '.' + version.split('.')[1] %} -{% set cuda_version='.'.join(environ.get('CUDA', '11.5').split('.')[:2]) %} -{% set cuda_major=cuda_version.split('.')[0] %} +{% set minor_version = version.split('.')[0] + '.' + version.split('.')[1] %} +{% set cuda_version = '.'.join(environ.get('CUDA', '11.5').split('.')[:2]) %} +{% set cuda_major = cuda_version.split('.')[0] %} +{% set cuda_spec = ">=" + cuda_major ~ ",<" + (cuda_major | int + 1) ~ ".0a0" %} # i.e. >=11,<12.0a0 package: - name: libcudf - version: {{ version }} + name: libcudf-split source: git_url: ../../.. build: - number: {{ GIT_DESCRIBE_NUMBER }} - string: cuda{{ cuda_major }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }} script_env: - CC - CXX - CUDAHOSTCXX - PARALLEL_LEVEL - - VERSION_SUFFIX - - PROJECT_FLASH - CMAKE_GENERATOR - CMAKE_C_COMPILER_LAUNCHER - CMAKE_CXX_COMPILER_LAUNCHER @@ -31,239 +27,311 @@ build: - SCCACHE_BUCKET=rapids-sccache - SCCACHE_REGION=us-west-2 - SCCACHE_IDLE_TIMEOUT=32768 - run_exports: - - {{ pin_subpackage("libcudf", max_pin="x.x") }} requirements: build: - - cmake >=3.20.1 + - cmake {{ cmake_version }} host: - librmm {{ minor_version }}.* - cudatoolkit {{ cuda_version }}.* - - arrow-cpp 6.0.1 *cuda + - arrow-cpp {{ arrow_cpp_version }} *cuda - arrow-cpp-proc * cuda - - dlpack>=0.5,<0.6.0a0 - run: - - {{ pin_compatible('cudatoolkit', max_pin='x', min_pin='x') }} - - arrow-cpp * *cuda - - arrow-cpp-proc * cuda - - {{ pin_compatible('dlpack', max_pin='x.x') }} - -test: - commands: - - test -f $PREFIX/lib/libcudf.so - - test -f $PREFIX/lib/libcudftestutil.a - - test -f $PREFIX/include/cudf/aggregation.hpp - - test -f $PREFIX/include/cudf/ast/detail/expression_parser.hpp - - test -f $PREFIX/include/cudf/ast/detail/operators.hpp - - test -f $PREFIX/include/cudf/ast/expressions.hpp - - test -f $PREFIX/include/cudf/binaryop.hpp - - test -f $PREFIX/include/cudf/column/column_factories.hpp - - test -f $PREFIX/include/cudf/column/column.hpp - - test -f $PREFIX/include/cudf/column/column_view.hpp - - test -f $PREFIX/include/cudf/concatenate.hpp - - test -f $PREFIX/include/cudf/copying.hpp - - test -f $PREFIX/include/cudf/datetime.hpp - - test -f $PREFIX/include/cudf/detail/aggregation/aggregation.hpp - - test -f $PREFIX/include/cudf/detail/aggregation/result_cache.hpp - - test -f $PREFIX/include/cudf/detail/label_bins.hpp - - test -f $PREFIX/include/cudf/detail/binaryop.hpp - - test -f $PREFIX/include/cudf/detail/calendrical_month_sequence.cuh - - test -f $PREFIX/include/cudf/detail/concatenate.hpp - - test -f $PREFIX/include/cudf/detail/copy.hpp - - test -f $PREFIX/include/cudf/detail/datetime.hpp - - test -f $PREFIX/include/cudf/detail/fill.hpp - - test -f $PREFIX/include/cudf/detail/gather.hpp - - test -f $PREFIX/include/cudf/detail/groupby.hpp - - test -f $PREFIX/include/cudf/detail/groupby/sort_helper.hpp - - test -f $PREFIX/include/cudf/detail/groupby/group_replace_nulls.hpp - - test -f $PREFIX/include/cudf/detail/hashing.hpp - - test -f $PREFIX/include/cudf/detail/interop.hpp - - test -f $PREFIX/include/cudf/detail/is_element_valid.hpp - - test -f $PREFIX/include/cudf/detail/null_mask.hpp - - test -f $PREFIX/include/cudf/detail/nvtx/nvtx3.hpp - - test -f $PREFIX/include/cudf/detail/nvtx/ranges.hpp - - test -f $PREFIX/include/cudf/detail/quantiles.hpp - - test -f $PREFIX/include/cudf/detail/reduction_functions.hpp - - test -f $PREFIX/include/cudf/detail/repeat.hpp - - test -f $PREFIX/include/cudf/detail/replace.hpp - - test -f $PREFIX/include/cudf/detail/reshape.hpp - - test -f $PREFIX/include/cudf/detail/rolling.hpp - - test -f $PREFIX/include/cudf/detail/round.hpp - - test -f $PREFIX/include/cudf/detail/scan.hpp - - test -f $PREFIX/include/cudf/detail/scatter.hpp - - test -f $PREFIX/include/cudf/detail/search.hpp - - test -f $PREFIX/include/cudf/detail/sequence.hpp - - test -f $PREFIX/include/cudf/detail/sorting.hpp - - test -f $PREFIX/include/cudf/detail/stream_compaction.hpp - - test -f $PREFIX/include/cudf/detail/structs/utilities.hpp - - test -f $PREFIX/include/cudf/detail/tdigest/tdigest.hpp - - test -f $PREFIX/include/cudf/detail/transform.hpp - - test -f $PREFIX/include/cudf/detail/transpose.hpp - - test -f $PREFIX/include/cudf/detail/unary.hpp - - test -f $PREFIX/include/cudf/detail/utilities/alignment.hpp - - test -f $PREFIX/include/cudf/detail/utilities/integer_utils.hpp - - test -f $PREFIX/include/cudf/detail/utilities/int_fastdiv.h - - test -f $PREFIX/include/cudf/detail/utilities/vector_factories.hpp - - test -f $PREFIX/include/cudf/detail/utilities/visitor_overload.hpp - - test -f $PREFIX/include/cudf/dictionary/detail/concatenate.hpp - - test -f $PREFIX/include/cudf/dictionary/detail/encode.hpp - - test -f $PREFIX/include/cudf/dictionary/detail/merge.hpp - - test -f $PREFIX/include/cudf/dictionary/detail/replace.hpp - - test -f $PREFIX/include/cudf/dictionary/detail/search.hpp - - test -f $PREFIX/include/cudf/dictionary/detail/update_keys.hpp - - test -f $PREFIX/include/cudf/dictionary/dictionary_column_view.hpp - - test -f $PREFIX/include/cudf/dictionary/dictionary_factories.hpp - - test -f $PREFIX/include/cudf/dictionary/encode.hpp - - test -f $PREFIX/include/cudf/dictionary/search.hpp - - test -f $PREFIX/include/cudf/dictionary/update_keys.hpp - - test -f $PREFIX/include/cudf/filling.hpp - - test -f $PREFIX/include/cudf/fixed_point/fixed_point.hpp - - test -f $PREFIX/include/cudf/fixed_point/temporary.hpp - - test -f $PREFIX/include/cudf/groupby.hpp - - test -f $PREFIX/include/cudf/hashing.hpp - - test -f $PREFIX/include/cudf/interop.hpp - - test -f $PREFIX/include/cudf/io/avro.hpp - - test -f $PREFIX/include/cudf/io/csv.hpp - - test -f $PREFIX/include/cudf/io/data_sink.hpp - - test -f $PREFIX/include/cudf/io/datasource.hpp - - test -f $PREFIX/include/cudf/io/detail/avro.hpp - - test -f $PREFIX/include/cudf/io/detail/csv.hpp - - test -f $PREFIX/include/cudf/io/detail/json.hpp - - test -f $PREFIX/include/cudf/io/detail/orc.hpp - - test -f $PREFIX/include/cudf/io/detail/parquet.hpp - - test -f $PREFIX/include/cudf/io/detail/utils.hpp - - test -f $PREFIX/include/cudf/io/json.hpp - - test -f $PREFIX/include/cudf/io/orc_metadata.hpp - - test -f $PREFIX/include/cudf/io/orc.hpp - - test -f $PREFIX/include/cudf/io/parquet.hpp - - test -f $PREFIX/include/cudf/io/text/byte_range_info.hpp - - test -f $PREFIX/include/cudf/io/text/data_chunk_source_factories.hpp - - test -f $PREFIX/include/cudf/io/text/data_chunk_source.hpp - - test -f $PREFIX/include/cudf/io/text/detail/multistate.hpp - - test -f $PREFIX/include/cudf/io/text/detail/tile_state.hpp - - test -f $PREFIX/include/cudf/io/text/detail/trie.hpp - - test -f $PREFIX/include/cudf/io/text/multibyte_split.hpp - - test -f $PREFIX/include/cudf/io/types.hpp - - test -f $PREFIX/include/cudf/ipc.hpp - - test -f $PREFIX/include/cudf/join.hpp - - test -f $PREFIX/include/cudf/labeling/label_bins.hpp - - test -f $PREFIX/include/cudf/lists/detail/combine.hpp - - test -f $PREFIX/include/cudf/lists/detail/concatenate.hpp - - test -f $PREFIX/include/cudf/lists/detail/contains.hpp - - test -f $PREFIX/include/cudf/lists/detail/copying.hpp - - test -f $PREFIX/include/cudf/lists/detail/extract.hpp - - test -f $PREFIX/include/cudf/lists/lists_column_factories.hpp - - test -f $PREFIX/include/cudf/lists/detail/drop_list_duplicates.hpp - - test -f $PREFIX/include/cudf/lists/detail/interleave_columns.hpp - - test -f $PREFIX/include/cudf/lists/detail/sorting.hpp - - test -f $PREFIX/include/cudf/lists/detail/scatter_helper.cuh - - test -f $PREFIX/include/cudf/lists/combine.hpp - - test -f $PREFIX/include/cudf/lists/count_elements.hpp - - test -f $PREFIX/include/cudf/lists/explode.hpp - - test -f $PREFIX/include/cudf/lists/drop_list_duplicates.hpp - - test -f $PREFIX/include/cudf/lists/extract.hpp - - test -f $PREFIX/include/cudf/lists/filling.hpp - - test -f $PREFIX/include/cudf/lists/contains.hpp - - test -f $PREFIX/include/cudf/lists/gather.hpp - - test -f $PREFIX/include/cudf/lists/lists_column_view.hpp - - test -f $PREFIX/include/cudf/lists/sorting.hpp - - test -f $PREFIX/include/cudf/merge.hpp - - test -f $PREFIX/include/cudf/null_mask.hpp - - test -f $PREFIX/include/cudf/partitioning.hpp - - test -f $PREFIX/include/cudf/quantiles.hpp - - test -f $PREFIX/include/cudf/reduction.hpp - - test -f $PREFIX/include/cudf/replace.hpp - - test -f $PREFIX/include/cudf/reshape.hpp - - test -f $PREFIX/include/cudf/rolling.hpp - - test -f $PREFIX/include/cudf/rolling/range_window_bounds.hpp - - test -f $PREFIX/include/cudf/round.hpp - - test -f $PREFIX/include/cudf/scalar/scalar_factories.hpp - - test -f $PREFIX/include/cudf/scalar/scalar.hpp - - test -f $PREFIX/include/cudf/search.hpp - - test -f $PREFIX/include/cudf/sorting.hpp - - test -f $PREFIX/include/cudf/stream_compaction.hpp - - test -f $PREFIX/include/cudf/strings/attributes.hpp - - test -f $PREFIX/include/cudf/strings/capitalize.hpp - - test -f $PREFIX/include/cudf/strings/case.hpp - - test -f $PREFIX/include/cudf/strings/char_types/char_cases.hpp - - test -f $PREFIX/include/cudf/strings/char_types/char_types.hpp - - test -f $PREFIX/include/cudf/strings/combine.hpp - - test -f $PREFIX/include/cudf/strings/contains.hpp - - test -f $PREFIX/include/cudf/strings/convert/convert_booleans.hpp - - test -f $PREFIX/include/cudf/strings/convert/convert_datetime.hpp - - test -f $PREFIX/include/cudf/strings/convert/convert_durations.hpp - - test -f $PREFIX/include/cudf/strings/convert/convert_fixed_point.hpp - - test -f $PREFIX/include/cudf/strings/convert/convert_floats.hpp - - test -f $PREFIX/include/cudf/strings/convert/convert_integers.hpp - - test -f $PREFIX/include/cudf/strings/convert/convert_ipv4.hpp - - test -f $PREFIX/include/cudf/strings/convert/convert_lists.hpp - - test -f $PREFIX/include/cudf/strings/convert/convert_urls.hpp - - test -f $PREFIX/include/cudf/strings/detail/combine.hpp - - test -f $PREFIX/include/cudf/strings/detail/concatenate.hpp - - test -f $PREFIX/include/cudf/strings/detail/converters.hpp - - test -f $PREFIX/include/cudf/strings/detail/copying.hpp - - test -f $PREFIX/include/cudf/strings/detail/fill.hpp - - test -f $PREFIX/include/cudf/strings/detail/json.hpp - - test -f $PREFIX/include/cudf/strings/detail/replace.hpp - - test -f $PREFIX/include/cudf/strings/detail/utf8.hpp - - test -f $PREFIX/include/cudf/strings/detail/utilities.hpp - - test -f $PREFIX/include/cudf/strings/extract.hpp - - test -f $PREFIX/include/cudf/strings/findall.hpp - - test -f $PREFIX/include/cudf/strings/find.hpp - - test -f $PREFIX/include/cudf/strings/find_multiple.hpp - - test -f $PREFIX/include/cudf/strings/json.hpp - - test -f $PREFIX/include/cudf/strings/padding.hpp - - test -f $PREFIX/include/cudf/strings/regex/flags.hpp - - test -f $PREFIX/include/cudf/strings/repeat_strings.hpp - - test -f $PREFIX/include/cudf/strings/replace.hpp - - test -f $PREFIX/include/cudf/strings/replace_re.hpp - - test -f $PREFIX/include/cudf/strings/split/partition.hpp - - test -f $PREFIX/include/cudf/strings/split/split.hpp - - test -f $PREFIX/include/cudf/strings/split/split_re.hpp - - test -f $PREFIX/include/cudf/strings/string_view.hpp - - test -f $PREFIX/include/cudf/strings/strings_column_view.hpp - - test -f $PREFIX/include/cudf/strings/strip.hpp - - test -f $PREFIX/include/cudf/strings/substring.hpp - - test -f $PREFIX/include/cudf/strings/translate.hpp - - test -f $PREFIX/include/cudf/strings/wrap.hpp - - test -f $PREFIX/include/cudf/structs/structs_column_view.hpp - - test -f $PREFIX/include/cudf/structs/struct_view.hpp - - test -f $PREFIX/include/cudf/structs/detail/concatenate.hpp - - test -f $PREFIX/include/cudf/table/table.hpp - - test -f $PREFIX/include/cudf/table/table_view.hpp - - test -f $PREFIX/include/cudf/tdigest/tdigest_column_view.cuh - - test -f $PREFIX/include/cudf/transform.hpp - - test -f $PREFIX/include/cudf/transpose.hpp - - test -f $PREFIX/include/cudf/types.hpp - - test -f $PREFIX/include/cudf/unary.hpp - - test -f $PREFIX/include/cudf/utilities/bit.hpp - - test -f $PREFIX/include/cudf/utilities/span.hpp - - test -f $PREFIX/include/cudf/utilities/error.hpp - - test -f $PREFIX/include/cudf/utilities/traits.hpp - - test -f $PREFIX/include/cudf/utilities/type_dispatcher.hpp - - test -f $PREFIX/include/cudf/utilities/type_checks.hpp - - test -f $PREFIX/include/cudf/utilities/default_stream.hpp - - test -f $PREFIX/include/cudf/wrappers/dictionary.hpp - - test -f $PREFIX/include/cudf/wrappers/durations.hpp - - test -f $PREFIX/include/cudf/wrappers/timestamps.hpp - - test -f $PREFIX/include/cudf_test/detail/column_utilities.hpp - - test -f $PREFIX/include/cudf_test/base_fixture.hpp - - test -f $PREFIX/include/cudf_test/column_utilities.hpp - - test -f $PREFIX/include/cudf_test/column_wrapper.hpp - - test -f $PREFIX/include/cudf_test/cudf_gtest.hpp - - test -f $PREFIX/include/cudf_test/cxxopts.hpp - - test -f $PREFIX/include/cudf_test/file_utilities.hpp - - test -f $PREFIX/include/cudf_test/io_metadata_utilities.hpp - - test -f $PREFIX/include/cudf_test/iterator_utilities.hpp - - test -f $PREFIX/include/cudf_test/table_utilities.hpp - - test -f $PREFIX/include/cudf_test/timestamp_utilities.cuh - - test -f $PREFIX/include/cudf_test/type_list_utilities.hpp - - test -f $PREFIX/include/cudf_test/type_lists.hpp + - dlpack {{ dlpack_version }} + - librdkafka {{ librdkafka_version }} -about: - home: http://rapids.ai/ - license: Apache-2.0 - license_family: Apache - license_file: LICENSE - summary: libcudf library +outputs: + - name: libcudf + version: {{ version }} + script: install_libcudf.sh + build: + number: {{ GIT_DESCRIBE_NUMBER }} + string: cuda{{ cuda_major }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }} + run_exports: + - {{ pin_subpackage("libcudf", max_pin="x.x") }} + requirements: + build: + - cmake {{ cmake_version }} + run: + - cudatoolkit {{ cuda_spec }} + - librmm {{ minor_version }}.* + - arrow-cpp {{ arrow_cpp_version }} *cuda + - arrow-cpp-proc * cuda + - dlpack {{ dlpack_version }} + test: + commands: + - test -f $PREFIX/lib/libcudf.so + - test -f $PREFIX/lib/libcudftestutil.a + - test -f $PREFIX/include/cudf/aggregation.hpp + - test -f $PREFIX/include/cudf/ast/detail/expression_parser.hpp + - test -f $PREFIX/include/cudf/ast/detail/operators.hpp + - test -f $PREFIX/include/cudf/ast/expressions.hpp + - test -f $PREFIX/include/cudf/binaryop.hpp + - test -f $PREFIX/include/cudf/column/column_factories.hpp + - test -f $PREFIX/include/cudf/column/column.hpp + - test -f $PREFIX/include/cudf/column/column_view.hpp + - test -f $PREFIX/include/cudf/concatenate.hpp + - test -f $PREFIX/include/cudf/copying.hpp + - test -f $PREFIX/include/cudf/datetime.hpp + - test -f $PREFIX/include/cudf/detail/aggregation/aggregation.hpp + - test -f $PREFIX/include/cudf/detail/aggregation/result_cache.hpp + - test -f $PREFIX/include/cudf/detail/label_bins.hpp + - test -f $PREFIX/include/cudf/detail/binaryop.hpp + - test -f $PREFIX/include/cudf/detail/calendrical_month_sequence.cuh + - test -f $PREFIX/include/cudf/detail/concatenate.hpp + - test -f $PREFIX/include/cudf/detail/copy.hpp + - test -f $PREFIX/include/cudf/detail/datetime.hpp + - test -f $PREFIX/include/cudf/detail/fill.hpp + - test -f $PREFIX/include/cudf/detail/gather.hpp + - test -f $PREFIX/include/cudf/detail/groupby.hpp + - test -f $PREFIX/include/cudf/detail/groupby/sort_helper.hpp + - test -f $PREFIX/include/cudf/detail/groupby/group_replace_nulls.hpp + - test -f $PREFIX/include/cudf/detail/hashing.hpp + - test -f $PREFIX/include/cudf/detail/interop.hpp + - test -f $PREFIX/include/cudf/detail/is_element_valid.hpp + - test -f $PREFIX/include/cudf/detail/null_mask.hpp + - test -f $PREFIX/include/cudf/detail/nvtx/nvtx3.hpp + - test -f $PREFIX/include/cudf/detail/nvtx/ranges.hpp + - test -f $PREFIX/include/cudf/detail/quantiles.hpp + - test -f $PREFIX/include/cudf/detail/reduction_functions.hpp + - test -f $PREFIX/include/cudf/detail/repeat.hpp + - test -f $PREFIX/include/cudf/detail/replace.hpp + - test -f $PREFIX/include/cudf/detail/reshape.hpp + - test -f $PREFIX/include/cudf/detail/rolling.hpp + - test -f $PREFIX/include/cudf/detail/round.hpp + - test -f $PREFIX/include/cudf/detail/scan.hpp + - test -f $PREFIX/include/cudf/detail/scatter.hpp + - test -f $PREFIX/include/cudf/detail/search.hpp + - test -f $PREFIX/include/cudf/detail/sequence.hpp + - test -f $PREFIX/include/cudf/detail/sorting.hpp + - test -f $PREFIX/include/cudf/detail/stream_compaction.hpp + - test -f $PREFIX/include/cudf/detail/structs/utilities.hpp + - test -f $PREFIX/include/cudf/detail/tdigest/tdigest.hpp + - test -f $PREFIX/include/cudf/detail/transform.hpp + - test -f $PREFIX/include/cudf/detail/transpose.hpp + - test -f $PREFIX/include/cudf/detail/unary.hpp + - test -f $PREFIX/include/cudf/detail/utilities/alignment.hpp + - test -f $PREFIX/include/cudf/detail/utilities/integer_utils.hpp + - test -f $PREFIX/include/cudf/detail/utilities/int_fastdiv.h + - test -f $PREFIX/include/cudf/detail/utilities/vector_factories.hpp + - test -f $PREFIX/include/cudf/detail/utilities/visitor_overload.hpp + - test -f $PREFIX/include/cudf/dictionary/detail/concatenate.hpp + - test -f $PREFIX/include/cudf/dictionary/detail/encode.hpp + - test -f $PREFIX/include/cudf/dictionary/detail/merge.hpp + - test -f $PREFIX/include/cudf/dictionary/detail/replace.hpp + - test -f $PREFIX/include/cudf/dictionary/detail/search.hpp + - test -f $PREFIX/include/cudf/dictionary/detail/update_keys.hpp + - test -f $PREFIX/include/cudf/dictionary/dictionary_column_view.hpp + - test -f $PREFIX/include/cudf/dictionary/dictionary_factories.hpp + - test -f $PREFIX/include/cudf/dictionary/encode.hpp + - test -f $PREFIX/include/cudf/dictionary/search.hpp + - test -f $PREFIX/include/cudf/dictionary/update_keys.hpp + - test -f $PREFIX/include/cudf/filling.hpp + - test -f $PREFIX/include/cudf/fixed_point/fixed_point.hpp + - test -f $PREFIX/include/cudf/fixed_point/temporary.hpp + - test -f $PREFIX/include/cudf/groupby.hpp + - test -f $PREFIX/include/cudf/hashing.hpp + - test -f $PREFIX/include/cudf/interop.hpp + - test -f $PREFIX/include/cudf/io/avro.hpp + - test -f $PREFIX/include/cudf/io/csv.hpp + - test -f $PREFIX/include/cudf/io/data_sink.hpp + - test -f $PREFIX/include/cudf/io/datasource.hpp + - test -f $PREFIX/include/cudf/io/detail/avro.hpp + - test -f $PREFIX/include/cudf/io/detail/csv.hpp + - test -f $PREFIX/include/cudf/io/detail/json.hpp + - test -f $PREFIX/include/cudf/io/detail/orc.hpp + - test -f $PREFIX/include/cudf/io/detail/parquet.hpp + - test -f $PREFIX/include/cudf/io/detail/utils.hpp + - test -f $PREFIX/include/cudf/io/json.hpp + - test -f $PREFIX/include/cudf/io/orc_metadata.hpp + - test -f $PREFIX/include/cudf/io/orc.hpp + - test -f $PREFIX/include/cudf/io/parquet.hpp + - test -f $PREFIX/include/cudf/io/text/byte_range_info.hpp + - test -f $PREFIX/include/cudf/io/text/data_chunk_source_factories.hpp + - test -f $PREFIX/include/cudf/io/text/data_chunk_source.hpp + - test -f $PREFIX/include/cudf/io/text/detail/multistate.hpp + - test -f $PREFIX/include/cudf/io/text/detail/tile_state.hpp + - test -f $PREFIX/include/cudf/io/text/detail/trie.hpp + - test -f $PREFIX/include/cudf/io/text/multibyte_split.hpp + - test -f $PREFIX/include/cudf/io/types.hpp + - test -f $PREFIX/include/cudf/ipc.hpp + - test -f $PREFIX/include/cudf/join.hpp + - test -f $PREFIX/include/cudf/labeling/label_bins.hpp + - test -f $PREFIX/include/cudf/lists/detail/combine.hpp + - test -f $PREFIX/include/cudf/lists/detail/concatenate.hpp + - test -f $PREFIX/include/cudf/lists/detail/contains.hpp + - test -f $PREFIX/include/cudf/lists/detail/copying.hpp + - test -f $PREFIX/include/cudf/lists/detail/extract.hpp + - test -f $PREFIX/include/cudf/lists/lists_column_factories.hpp + - test -f $PREFIX/include/cudf/lists/detail/drop_list_duplicates.hpp + - test -f $PREFIX/include/cudf/lists/detail/interleave_columns.hpp + - test -f $PREFIX/include/cudf/lists/detail/sorting.hpp + - test -f $PREFIX/include/cudf/lists/detail/scatter_helper.cuh + - test -f $PREFIX/include/cudf/lists/combine.hpp + - test -f $PREFIX/include/cudf/lists/count_elements.hpp + - test -f $PREFIX/include/cudf/lists/explode.hpp + - test -f $PREFIX/include/cudf/lists/drop_list_duplicates.hpp + - test -f $PREFIX/include/cudf/lists/extract.hpp + - test -f $PREFIX/include/cudf/lists/filling.hpp + - test -f $PREFIX/include/cudf/lists/contains.hpp + - test -f $PREFIX/include/cudf/lists/gather.hpp + - test -f $PREFIX/include/cudf/lists/lists_column_view.hpp + - test -f $PREFIX/include/cudf/lists/sorting.hpp + - test -f $PREFIX/include/cudf/merge.hpp + - test -f $PREFIX/include/cudf/null_mask.hpp + - test -f $PREFIX/include/cudf/partitioning.hpp + - test -f $PREFIX/include/cudf/quantiles.hpp + - test -f $PREFIX/include/cudf/reduction.hpp + - test -f $PREFIX/include/cudf/replace.hpp + - test -f $PREFIX/include/cudf/reshape.hpp + - test -f $PREFIX/include/cudf/rolling.hpp + - test -f $PREFIX/include/cudf/rolling/range_window_bounds.hpp + - test -f $PREFIX/include/cudf/round.hpp + - test -f $PREFIX/include/cudf/scalar/scalar_factories.hpp + - test -f $PREFIX/include/cudf/scalar/scalar.hpp + - test -f $PREFIX/include/cudf/search.hpp + - test -f $PREFIX/include/cudf/sorting.hpp + - test -f $PREFIX/include/cudf/stream_compaction.hpp + - test -f $PREFIX/include/cudf/strings/attributes.hpp + - test -f $PREFIX/include/cudf/strings/capitalize.hpp + - test -f $PREFIX/include/cudf/strings/case.hpp + - test -f $PREFIX/include/cudf/strings/char_types/char_cases.hpp + - test -f $PREFIX/include/cudf/strings/char_types/char_types.hpp + - test -f $PREFIX/include/cudf/strings/combine.hpp + - test -f $PREFIX/include/cudf/strings/contains.hpp + - test -f $PREFIX/include/cudf/strings/convert/convert_booleans.hpp + - test -f $PREFIX/include/cudf/strings/convert/convert_datetime.hpp + - test -f $PREFIX/include/cudf/strings/convert/convert_durations.hpp + - test -f $PREFIX/include/cudf/strings/convert/convert_fixed_point.hpp + - test -f $PREFIX/include/cudf/strings/convert/convert_floats.hpp + - test -f $PREFIX/include/cudf/strings/convert/convert_integers.hpp + - test -f $PREFIX/include/cudf/strings/convert/convert_ipv4.hpp + - test -f $PREFIX/include/cudf/strings/convert/convert_lists.hpp + - test -f $PREFIX/include/cudf/strings/convert/convert_urls.hpp + - test -f $PREFIX/include/cudf/strings/detail/combine.hpp + - test -f $PREFIX/include/cudf/strings/detail/concatenate.hpp + - test -f $PREFIX/include/cudf/strings/detail/converters.hpp + - test -f $PREFIX/include/cudf/strings/detail/copying.hpp + - test -f $PREFIX/include/cudf/strings/detail/fill.hpp + - test -f $PREFIX/include/cudf/strings/detail/json.hpp + - test -f $PREFIX/include/cudf/strings/detail/replace.hpp + - test -f $PREFIX/include/cudf/strings/detail/utf8.hpp + - test -f $PREFIX/include/cudf/strings/detail/utilities.hpp + - test -f $PREFIX/include/cudf/strings/extract.hpp + - test -f $PREFIX/include/cudf/strings/findall.hpp + - test -f $PREFIX/include/cudf/strings/find.hpp + - test -f $PREFIX/include/cudf/strings/find_multiple.hpp + - test -f $PREFIX/include/cudf/strings/json.hpp + - test -f $PREFIX/include/cudf/strings/padding.hpp + - test -f $PREFIX/include/cudf/strings/regex/flags.hpp + - test -f $PREFIX/include/cudf/strings/repeat_strings.hpp + - test -f $PREFIX/include/cudf/strings/replace.hpp + - test -f $PREFIX/include/cudf/strings/replace_re.hpp + - test -f $PREFIX/include/cudf/strings/split/partition.hpp + - test -f $PREFIX/include/cudf/strings/split/split.hpp + - test -f $PREFIX/include/cudf/strings/split/split_re.hpp + - test -f $PREFIX/include/cudf/strings/string_view.hpp + - test -f $PREFIX/include/cudf/strings/strings_column_view.hpp + - test -f $PREFIX/include/cudf/strings/strip.hpp + - test -f $PREFIX/include/cudf/strings/substring.hpp + - test -f $PREFIX/include/cudf/strings/translate.hpp + - test -f $PREFIX/include/cudf/strings/wrap.hpp + - test -f $PREFIX/include/cudf/structs/structs_column_view.hpp + - test -f $PREFIX/include/cudf/structs/struct_view.hpp + - test -f $PREFIX/include/cudf/structs/detail/concatenate.hpp + - test -f $PREFIX/include/cudf/table/table.hpp + - test -f $PREFIX/include/cudf/table/table_view.hpp + - test -f $PREFIX/include/cudf/tdigest/tdigest_column_view.cuh + - test -f $PREFIX/include/cudf/transform.hpp + - test -f $PREFIX/include/cudf/transpose.hpp + - test -f $PREFIX/include/cudf/types.hpp + - test -f $PREFIX/include/cudf/unary.hpp + - test -f $PREFIX/include/cudf/utilities/bit.hpp + - test -f $PREFIX/include/cudf/utilities/span.hpp + - test -f $PREFIX/include/cudf/utilities/error.hpp + - test -f $PREFIX/include/cudf/utilities/traits.hpp + - test -f $PREFIX/include/cudf/utilities/type_dispatcher.hpp + - test -f $PREFIX/include/cudf/utilities/type_checks.hpp + - test -f $PREFIX/include/cudf/utilities/default_stream.hpp + - test -f $PREFIX/include/cudf/wrappers/dictionary.hpp + - test -f $PREFIX/include/cudf/wrappers/durations.hpp + - test -f $PREFIX/include/cudf/wrappers/timestamps.hpp + - test -f $PREFIX/include/cudf_test/detail/column_utilities.hpp + - test -f $PREFIX/include/cudf_test/base_fixture.hpp + - test -f $PREFIX/include/cudf_test/column_utilities.hpp + - test -f $PREFIX/include/cudf_test/column_wrapper.hpp + - test -f $PREFIX/include/cudf_test/cudf_gtest.hpp + - test -f $PREFIX/include/cudf_test/cxxopts.hpp + - test -f $PREFIX/include/cudf_test/file_utilities.hpp + - test -f $PREFIX/include/cudf_test/io_metadata_utilities.hpp + - test -f $PREFIX/include/cudf_test/iterator_utilities.hpp + - test -f $PREFIX/include/cudf_test/table_utilities.hpp + - test -f $PREFIX/include/cudf_test/timestamp_utilities.cuh + - test -f $PREFIX/include/cudf_test/type_list_utilities.hpp + - test -f $PREFIX/include/cudf_test/type_lists.hpp + about: + home: http://rapids.ai/ + license: Apache-2.0 + license_family: Apache + license_file: LICENSE + summary: libcudf library + - name: libcudf_kafka + version: {{ version }} + script: install_libcudf_kafka.sh + build: + number: {{ GIT_DESCRIBE_NUMBER }} + string: {{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }} + requirements: + build: + - cmake {{ cmake_version }} + run: + - librdkafka {{ librdkafka_version }} + - {{ pin_subpackage('libcudf', exact=True) }} + test: + commands: + - test -f $PREFIX/lib/libcudf_kafka.so + about: + home: http://rapids.ai/ + license: Apache-2.0 + license_family: Apache + license_file: LICENSE + summary: libcudf_kafka library + - name: libcudf-example + version: {{ version }} + script: install_libcudf_example.sh + build: + number: {{ GIT_DESCRIBE_NUMBER }} + string: {{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }} + requirements: + build: + - cmake {{ cmake_version }} + host: + - {{ pin_subpackage('libcudf', exact=True) }} + run: + - {{ pin_subpackage('libcudf', exact=True) }} + about: + home: http://rapids.ai/ + license: Apache-2.0 + license_family: Apache + license_file: LICENSE + summary: libcudf_example library + - name: libcudf-tests + version: {{ version }} + script: install_libcudf_tests.sh + build: + number: {{ GIT_DESCRIBE_NUMBER }} + string: cuda{{ cuda_major }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }} + requirements: + build: + - cmake {{ cmake_version }} + run: + - {{ pin_subpackage('libcudf', exact=True) }} + - {{ pin_subpackage('libcudf_kafka', exact=True) }} + - cudatoolkit {{ cuda_spec }} + - gtest {{ gtest_version }} + - gmock {{ gtest_version }} + about: + home: http://rapids.ai/ + license: Apache-2.0 + license_family: Apache + license_file: LICENSE + summary: libcudf test & benchmark executables diff --git a/conda/recipes/libcudf_example/build.sh b/conda/recipes/libcudf_example/build.sh deleted file mode 100644 index 4df9550f1a2..00000000000 --- a/conda/recipes/libcudf_example/build.sh +++ /dev/null @@ -1,4 +0,0 @@ -# Copyright (c) 2021, NVIDIA CORPORATION. - -# This assumes the script is executed from the root of the repo directory -./cpp/examples/build.sh diff --git a/conda/recipes/libcudf_example/meta.yaml b/conda/recipes/libcudf_example/meta.yaml deleted file mode 100644 index c20a62c44c7..00000000000 --- a/conda/recipes/libcudf_example/meta.yaml +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright (c) 2021, NVIDIA CORPORATION. - -{% set version = environ.get('GIT_DESCRIBE_TAG', '0.0.0.dev').lstrip('v') + environ.get('VERSION_SUFFIX', '') %} -{% set minor_version = version.split('.')[0] + '.' + version.split('.')[1] %} - -package: - name: libcudf_example - version: {{ version }} - -source: - git_url: ../../.. - -build: - number: {{ GIT_DESCRIBE_NUMBER }} - string: {{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }} - script_env: - - CC - - CXX - - CUDAHOSTCXX - - PARALLEL_LEVEL - - PROJECT_FLASH - - WORKSPACE - -requirements: - build: - - cmake >=3.20.1 - host: - - libcudf {{ version }} - -about: - home: http://rapids.ai/ - license: Apache-2.0 - license_family: Apache - license_file: LICENSE - summary: libcudf_example library diff --git a/conda/recipes/libcudf_kafka/build.sh b/conda/recipes/libcudf_kafka/build.sh deleted file mode 100644 index b656f55a64e..00000000000 --- a/conda/recipes/libcudf_kafka/build.sh +++ /dev/null @@ -1,8 +0,0 @@ -# Copyright (c) 2020-2022, NVIDIA CORPORATION. - -if [[ -z "$PROJECT_FLASH" || "$PROJECT_FLASH" == "0" ]]; then - # This assumes the script is executed from the root of the repo directory - ./build.sh -v libcudf_kafka -else - ./build.sh -v libcudf_kafka tests -fi diff --git a/conda/recipes/libcudf_kafka/meta.yaml b/conda/recipes/libcudf_kafka/meta.yaml deleted file mode 100644 index d5864a7d68c..00000000000 --- a/conda/recipes/libcudf_kafka/meta.yaml +++ /dev/null @@ -1,45 +0,0 @@ -# Copyright (c) 2018-2022, NVIDIA CORPORATION. - -{% set version = environ.get('GIT_DESCRIBE_TAG', '0.0.0.dev').lstrip('v') + environ.get('VERSION_SUFFIX', '') %} -{% set minor_version = version.split('.')[0] + '.' + version.split('.')[1] %} - -package: - name: libcudf_kafka - version: {{ version }} - -source: - git_url: ../../.. - -build: - number: {{ GIT_DESCRIBE_NUMBER }} - string: {{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }} - script_env: - - CC - - CXX - - CUDAHOSTCXX - - PARALLEL_LEVEL - - VERSION_SUFFIX - - PROJECT_FLASH - # libcudf's run_exports pinning is looser than we would like - ignore_run_exports: - - libcudf - -requirements: - build: - - cmake >=3.20.1 - host: - - libcudf {{version}} - - librdkafka >=1.7.0,<1.8.0a0 - run: - - libcudf {{version}} - -test: - commands: - - test -f $PREFIX/lib/libcudf_kafka.so - -about: - home: http://rapids.ai/ - license: Apache-2.0 - license_family: Apache - license_file: LICENSE - summary: libcudf_kafka library diff --git a/cpp/examples/build.sh b/cpp/examples/build.sh index d896d19ad26..079f7358872 100755 --- a/cpp/examples/build.sh +++ b/cpp/examples/build.sh @@ -1,6 +1,6 @@ #!/bin/bash -# Copyright (c) 2021, NVIDIA CORPORATION. +# Copyright (c) 2021-2022, NVIDIA CORPORATION. # libcudf examples build script @@ -8,7 +8,8 @@ PARALLEL_LEVEL=${PARALLEL_LEVEL:-4} # Root of examples -EXAMPLES_DIR=${WORKSPACE}/cpp/examples +EXAMPLES_DIR=$(dirname "$(realpath "$0")") +LIB_BUILD_DIR=${LIB_BUILD_DIR:-$(readlink -f "${EXAMPLES_DIR}/../build")} ################################################################################ # Add individual libcudf examples build scripts down below diff --git a/java/src/main/native/CMakeLists.txt b/java/src/main/native/CMakeLists.txt index 2f0e07c9982..f34b998d01e 100755 --- a/java/src/main/native/CMakeLists.txt +++ b/java/src/main/native/CMakeLists.txt @@ -17,6 +17,8 @@ include(../../../../fetch_rapids.cmake) include(rapids-cmake) include(rapids-cuda) include(rapids-find) +include(rapids-cpm) +rapids_cpm_init() # Use GPU_ARCHS if it is defined if(DEFINED GPU_ARCHS) @@ -89,20 +91,7 @@ rapids_cmake_build_type("Release") # ################################################################################################## # * Thrust/CUB # ------------------------------------------------------------------------------------ -find_path( - THRUST_INCLUDE "thrust" - HINTS "$ENV{CUDF_ROOT}/_deps/thrust-src" "${CUDF_CPP_BUILD_DIR}/_deps/thrust-src" - "$ENV{CONDA_PREFIX}/include" -) - -message(STATUS "THRUST: THRUST_INCLUDE set to ${THRUST_INCLUDE}") - -find_path( - CUB_INCLUDE "cub" HINTS "$ENV{CUDF_ROOT}/_deps/thrust-src" - "${CUDF_CPP_BUILD_DIR}/_deps/thrust-src" "$ENV{CONDA_PREFIX}/include" -) - -message(STATUS "CUB: CUB_INCLUDE set to ${CUB_INCLUDE}") +include(${CUDF_SOURCE_DIR}/cmake/thirdparty/get_thrust.cmake) # ################################################################################################## # * CUDF ------------------------------------------------------------------------------------------ @@ -260,8 +249,7 @@ endif() target_include_directories( cudfjni - PUBLIC "${THRUST_INCLUDE}" - "${CUB_INCLUDE}" + PUBLIC cudf::Thrust "${LIBCUDACXX_INCLUDE}" "${CUDAToolkit_INCLUDE_DIRS}" "${NVCOMP_INCLUDE}" From cc986f714ecd51e22f14a8e7914ff6e26bf0f33b Mon Sep 17 00:00:00 2001 From: Jason Lowe Date: Tue, 29 Mar 2022 13:41:00 -0500 Subject: [PATCH 017/246] Remove statically linked CUDA runtime check in Java build (#10532) #9873 added static linking of the CUDA runtime by default in Java cudf builds from the `build-in-docker.sh`. At the end of the script is a sanity check that the CUDA runtime is _not_ statically linked which should have been removed, but it fails to trigger due to an empty `.so` file found during the build that causes an error in `readelf` and prevents the script from exiting early. This PR removes the check since a statically linked CUDA runtime is supported and tested. Authors: - Jason Lowe (https://github.com/jlowe) Approvers: - Jim Brennan (https://github.com/jbrennan333) - Gera Shegalov (https://github.com/gerashegalov) URL: https://github.com/rapidsai/cudf/pull/10532 --- java/ci/build-in-docker.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/java/ci/build-in-docker.sh b/java/ci/build-in-docker.sh index ac8b2584091..75435319c91 100755 --- a/java/ci/build-in-docker.sh +++ b/java/ci/build-in-docker.sh @@ -1,7 +1,7 @@ #!/bin/bash # -# Copyright (c) 2020-2021, NVIDIA CORPORATION. All rights reserved. +# Copyright (c) 2020-2022, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -93,9 +93,6 @@ fi cd "$WORKSPACE/java" mvn -B clean package $BUILD_ARG -###### Sanity test: fail if static cudart found ###### -find . -name '*.so' | xargs -I{} readelf -Ws {} | grep cuInit && echo "Found statically linked CUDA runtime, this is currently not tested" && exit 1 - ###### Stash Jar files ###### rm -rf $OUT_PATH mkdir -p $OUT_PATH From bc6239b2738b17ba5f4e59a966ea3b41f0fca791 Mon Sep 17 00:00:00 2001 From: Vukasin Milovanovic Date: Tue, 29 Mar 2022 15:11:13 -0700 Subject: [PATCH 018/246] Remove deprecated `decimal_cols_as_float` in the ORC reader (#10515) Closes #10129 Authors: - Vukasin Milovanovic (https://github.com/vuule) Approvers: - GALI PREM SAGAR (https://github.com/galipremsagar) - Bradley Dice (https://github.com/bdice) - Nghia Truong (https://github.com/ttnghia) URL: https://github.com/rapidsai/cudf/pull/10515 --- cpp/include/cudf/io/orc.hpp | 38 ------------------- cpp/src/io/orc/reader_impl.cu | 49 ++++++++++-------------- cpp/src/io/orc/reader_impl.hpp | 3 +- cpp/src/io/orc/stripe_data.cu | 56 +++++++++------------------- cpp/tests/io/orc_test.cpp | 12 +----- python/cudf/cudf/_lib/cpp/io/orc.pxd | 6 +-- python/cudf/cudf/_lib/orc.pyx | 10 +---- python/cudf/cudf/io/orc.py | 8 ---- python/cudf/cudf/tests/test_orc.py | 27 +------------- python/cudf/cudf/utils/ioutils.py | 3 -- 10 files changed, 44 insertions(+), 168 deletions(-) diff --git a/cpp/include/cudf/io/orc.hpp b/cpp/include/cudf/io/orc.hpp index c2187f056cf..9e8fd1244d0 100644 --- a/cpp/include/cudf/io/orc.hpp +++ b/cpp/include/cudf/io/orc.hpp @@ -67,9 +67,6 @@ class orc_reader_options { // Cast timestamp columns to a specific type data_type _timestamp_type{type_id::EMPTY}; - // Columns that should be converted from Decimal to Float64 - std::vector _decimal_cols_as_float; - // Columns that should be read as Decimal128 std::vector _decimal128_columns; @@ -138,14 +135,6 @@ class orc_reader_options { */ data_type get_timestamp_type() const { return _timestamp_type; } - /** - * @brief Fully qualified names of columns that should be converted from Decimal to Float64. - */ - std::vector const& get_decimal_cols_as_float() const - { - return _decimal_cols_as_float; - } - /** * @brief Fully qualified names of columns that should be read as 128-bit Decimal. */ @@ -215,18 +204,6 @@ class orc_reader_options { */ void set_timestamp_type(data_type type) { _timestamp_type = type; } - /** - * @brief Set columns that should be converted from Decimal to Float64 - * - * @param val Vector of fully qualified column names. - */ - [[deprecated( - "Decimal to float conversion is deprecated and will be remove in future release")]] void - set_decimal_cols_as_float(std::vector val) - { - _decimal_cols_as_float = std::move(val); - } - /** * @brief Set columns that should be read as 128-bit Decimal * @@ -340,21 +317,6 @@ class orc_reader_options_builder { return *this; } - /** - * @brief Columns that should be converted from decimals to float64. - * - * @param val Vector of column names. - * @return this for chaining. - */ - [[deprecated( - "Decimal to float conversion is deprecated and will be remove in future " - "release")]] orc_reader_options_builder& - decimal_cols_as_float(std::vector val) - { - options._decimal_cols_as_float = std::move(val); - return *this; - } - /** * @brief Columns that should be read as 128-bit Decimal * diff --git a/cpp/src/io/orc/reader_impl.cu b/cpp/src/io/orc/reader_impl.cu index 081ae69e48f..7f9badad9a9 100644 --- a/cpp/src/io/orc/reader_impl.cu +++ b/cpp/src/io/orc/reader_impl.cu @@ -231,30 +231,22 @@ size_t gather_stream_info(const size_t stripe_index, /** * @brief Determines cuDF type of an ORC Decimal column. */ -auto decimal_column_type(std::vector const& float64_columns, - std::vector const& decimal128_columns, +auto decimal_column_type(std::vector const& decimal128_columns, cudf::io::orc::detail::aggregate_orc_metadata const& metadata, int column_index) { - if (metadata.get_col_type(column_index).kind != DECIMAL) return type_id::EMPTY; + if (metadata.get_col_type(column_index).kind != DECIMAL) { return type_id::EMPTY; } - auto const& column_path = metadata.column_path(0, column_index); - auto is_column_in = [&](const std::vector& cols) { - return std::find(cols.cbegin(), cols.cend(), column_path) != cols.end(); - }; - - auto const user_selected_float64 = is_column_in(float64_columns); - auto const user_selected_decimal128 = is_column_in(decimal128_columns); - CUDF_EXPECTS(not user_selected_float64 or not user_selected_decimal128, - "Both decimal128 and float64 types selected for column " + column_path); - - if (user_selected_float64) return type_id::FLOAT64; - if (user_selected_decimal128) return type_id::DECIMAL128; + if (std::find(decimal128_columns.cbegin(), + decimal128_columns.cend(), + metadata.column_path(0, column_index)) != decimal128_columns.end()) { + return type_id::DECIMAL128; + } auto const precision = metadata.get_col_type(column_index) .precision.value_or(cuda::std::numeric_limits::digits10); - if (precision <= cuda::std::numeric_limits::digits10) return type_id::DECIMAL32; - if (precision <= cuda::std::numeric_limits::digits10) return type_id::DECIMAL64; + if (precision <= cuda::std::numeric_limits::digits10) { return type_id::DECIMAL32; } + if (precision <= cuda::std::numeric_limits::digits10) { return type_id::DECIMAL64; } return type_id::DECIMAL128; } @@ -786,12 +778,11 @@ std::unique_ptr reader::impl::create_empty_column(const size_type orc_co rmm::cuda_stream_view stream) { schema_info.name = _metadata.column_name(0, orc_col_id); - auto const type = to_type_id( - _metadata.get_schema(orc_col_id), - _use_np_dtypes, - _timestamp_type.id(), - decimal_column_type(_decimal_cols_as_float, decimal128_columns, _metadata, orc_col_id)); - int32_t scale = 0; + auto const type = to_type_id(_metadata.get_schema(orc_col_id), + _use_np_dtypes, + _timestamp_type.id(), + decimal_column_type(decimal128_columns, _metadata, orc_col_id)); + int32_t scale = 0; std::vector> child_columns; std::unique_ptr out_col = nullptr; auto kind = _metadata.get_col_type(orc_col_id).kind; @@ -933,8 +924,7 @@ reader::impl::impl(std::vector>&& sources, _use_np_dtypes = options.is_enabled_use_np_dtypes(); // Control decimals conversion - _decimal_cols_as_float = options.get_decimal_cols_as_float(); - decimal128_columns = options.get_decimal128_columns(); + decimal128_columns = options.get_decimal128_columns(); } timezone_table reader::impl::compute_timezone_table( @@ -994,11 +984,10 @@ table_with_metadata reader::impl::read(size_type skip_rows, // Get a list of column data types std::vector column_types; for (auto& col : columns_level) { - auto col_type = to_type_id( - _metadata.get_col_type(col.id), - _use_np_dtypes, - _timestamp_type.id(), - decimal_column_type(_decimal_cols_as_float, decimal128_columns, _metadata, col.id)); + auto col_type = to_type_id(_metadata.get_col_type(col.id), + _use_np_dtypes, + _timestamp_type.id(), + decimal_column_type(decimal128_columns, _metadata, col.id)); CUDF_EXPECTS(col_type != type_id::EMPTY, "Unknown type"); if (col_type == type_id::DECIMAL32 or col_type == type_id::DECIMAL64 or col_type == type_id::DECIMAL128) { diff --git a/cpp/src/io/orc/reader_impl.hpp b/cpp/src/io/orc/reader_impl.hpp index 1e586bcde00..103093f055f 100644 --- a/cpp/src/io/orc/reader_impl.hpp +++ b/cpp/src/io/orc/reader_impl.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2020, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -221,7 +221,6 @@ class reader::impl { bool _use_index{true}; bool _use_np_dtypes{true}; - std::vector _decimal_cols_as_float; std::vector decimal128_columns; data_type _timestamp_type{type_id::EMPTY}; reader_column_meta _col_meta{}; diff --git a/cpp/src/io/orc/stripe_data.cu b/cpp/src/io/orc/stripe_data.cu index dc09b3e7dd8..b4cbb5d9037 100644 --- a/cpp/src/io/orc/stripe_data.cu +++ b/cpp/src/io/orc/stripe_data.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -962,15 +962,6 @@ static __device__ uint32_t Byte_RLE(orc_bytestream_s* bs, return rle->num_vals; } -/** - * @brief Powers of 10 - */ -static const __device__ __constant__ double kPow10[40] = { - 1.0, 1.e1, 1.e2, 1.e3, 1.e4, 1.e5, 1.e6, 1.e7, 1.e8, 1.e9, 1.e10, 1.e11, 1.e12, 1.e13, - 1.e14, 1.e15, 1.e16, 1.e17, 1.e18, 1.e19, 1.e20, 1.e21, 1.e22, 1.e23, 1.e24, 1.e25, 1.e26, 1.e27, - 1.e28, 1.e29, 1.e30, 1.e31, 1.e32, 1.e33, 1.e34, 1.e35, 1.e36, 1.e37, 1.e38, 1.e39, -}; - static const __device__ __constant__ int64_t kPow5i[28] = {1, 5, 25, @@ -1045,34 +1036,24 @@ static __device__ int Decode_Decimals(orc_bytestream_s* bs, auto const pos = static_cast(vals.i64[2 * t]); __int128_t v = decode_varint128(bs, pos); - if (dtype_id == type_id::FLOAT64) { - double f = v; - int32_t scale = (t < numvals) ? val_scale : 0; - if (scale >= 0) - vals.f64[t] = f / kPow10[min(scale, 39)]; - else - vals.f64[t] = f * kPow10[min(-scale, 39)]; - } else { - auto const scaled_value = [&]() { - // Since cuDF column stores just one scale, value needs to be adjusted to col_scale from - // val_scale. So the difference of them will be used to add 0s or remove digits. - int32_t scale = (t < numvals) ? col_scale - val_scale : 0; - if (scale >= 0) { - scale = min(scale, 27); - return (v * kPow5i[scale]) << scale; - } else // if (scale < 0) - { - scale = min(-scale, 27); - return (v / kPow5i[scale]) >> scale; - } - }(); - if (dtype_id == type_id::DECIMAL32) { - vals.i32[t] = scaled_value; - } else if (dtype_id == type_id::DECIMAL64) { - vals.i64[t] = scaled_value; + auto const scaled_value = [&]() { + // Since cuDF column stores just one scale, value needs to be adjusted to col_scale from + // val_scale. So the difference of them will be used to add 0s or remove digits. + int32_t const scale = (t < numvals) ? col_scale - val_scale : 0; + if (scale >= 0) { + auto const abs_scale = min(scale, 27); + return (v * kPow5i[abs_scale]) << abs_scale; } else { - vals.i128[t] = scaled_value; + auto const abs_scale = min(-scale, 27); + return (v / kPow5i[abs_scale]) >> abs_scale; } + }(); + if (dtype_id == type_id::DECIMAL32) { + vals.i32[t] = scaled_value; + } else if (dtype_id == type_id::DECIMAL64) { + vals.i64[t] = scaled_value; + } else { + vals.i128[t] = scaled_value; } } // There is nothing to read, so break @@ -1711,8 +1692,7 @@ __global__ void __launch_bounds__(block_size) case DECIMAL: if (s->chunk.dtype_id == type_id::DECIMAL32) { static_cast(data_out)[row] = s->vals.u32[t + vals_skipped]; - } else if (s->chunk.dtype_id == type_id::FLOAT64 or - s->chunk.dtype_id == type_id::DECIMAL64) { + } else if (s->chunk.dtype_id == type_id::DECIMAL64) { static_cast(data_out)[row] = s->vals.u64[t + vals_skipped]; } else { // decimal128 diff --git a/cpp/tests/io/orc_test.cpp b/cpp/tests/io/orc_test.cpp index bac5bf1f55b..5823a859f7b 100644 --- a/cpp/tests/io/orc_test.cpp +++ b/cpp/tests/io/orc_test.cpp @@ -1421,17 +1421,9 @@ TEST_F(OrcReaderTest, DecimalOptions) cudf_io::orc_reader_options valid_opts = cudf_io::orc_reader_options::builder(cudf_io::source_info{filepath}) - .decimal128_columns({"dec", "fake_name"}) - .decimal_cols_as_float({"decc", "fake_name"}); - // Should not throw, even with "fake name" in both options + .decimal128_columns({"dec", "fake_name"}); + // Should not throw, even with "fake name" EXPECT_NO_THROW(cudf_io::read_orc(valid_opts)); - - cudf_io::orc_reader_options invalid_opts = - cudf_io::orc_reader_options::builder(cudf_io::source_info{filepath}) - .decimal128_columns({"dec", "fake_name"}) - .decimal_cols_as_float({"dec", "fake_name"}); - // Should throw, options overlap - EXPECT_THROW(cudf_io::read_orc(invalid_opts), cudf::logic_error); } TEST_F(OrcWriterTest, DecimalOptionsNested) diff --git a/python/cudf/cudf/_lib/cpp/io/orc.pxd b/python/cudf/cudf/_lib/cpp/io/orc.pxd index 0c2f971a26c..62ff5eb4f53 100644 --- a/python/cudf/cudf/_lib/cpp/io/orc.pxd +++ b/python/cudf/cudf/_lib/cpp/io/orc.pxd @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2021, NVIDIA CORPORATION. +# Copyright (c) 2020-2022, NVIDIA CORPORATION. from libc.stdint cimport uint8_t from libcpp cimport bool @@ -36,7 +36,6 @@ cdef extern from "cudf/io/orc.hpp" \ void enable_use_index(bool val) except+ void enable_use_np_dtypes(bool val) except+ void set_timestamp_type(data_type type) except+ - void set_decimal_cols_as_float(vector[string] val) except+ @staticmethod orc_reader_options_builder builder( @@ -55,9 +54,6 @@ cdef extern from "cudf/io/orc.hpp" \ orc_reader_options_builder& use_index(bool val) except+ orc_reader_options_builder& use_np_dtypes(bool val) except+ orc_reader_options_builder& timestamp_type(data_type type) except+ - orc_reader_options_builder& decimal_cols_as_float( - vector[string] val - ) except+ orc_reader_options build() except+ diff --git a/python/cudf/cudf/_lib/orc.pyx b/python/cudf/cudf/_lib/orc.pyx index 127e3a612dc..8331f9c3d17 100644 --- a/python/cudf/cudf/_lib/orc.pyx +++ b/python/cudf/cudf/_lib/orc.pyx @@ -93,7 +93,6 @@ cpdef read_orc(object filepaths_or_buffers, object skip_rows=None, object num_rows=None, bool use_index=True, - object decimal_cols_as_float=None, object timestamp_type=None): """ Cython function to call into libcudf API, see `read_orc`. @@ -120,7 +119,6 @@ cpdef read_orc(object filepaths_or_buffers, ) ), use_index, - decimal_cols_as_float or [], ) cdef table_with_metadata c_result @@ -319,8 +317,7 @@ cdef orc_reader_options make_orc_reader_options( size_type skip_rows, size_type num_rows, type_id timestamp_type, - bool use_index, - object decimal_cols_as_float + bool use_index ) except*: for i, datasource in enumerate(filepaths_or_buffers): @@ -333,10 +330,6 @@ cdef orc_reader_options make_orc_reader_options( c_column_names.push_back(str(col).encode()) cdef orc_reader_options opts cdef source_info src = make_source_info(filepaths_or_buffers) - cdef vector[string] c_decimal_cols_as_float - c_decimal_cols_as_float.reserve(len(decimal_cols_as_float)) - for decimal_col in decimal_cols_as_float: - c_decimal_cols_as_float.push_back(str(decimal_col).encode()) opts = move( orc_reader_options.builder(src) .columns(c_column_names) @@ -345,7 +338,6 @@ cdef orc_reader_options make_orc_reader_options( .num_rows(num_rows) .timestamp_type(data_type(timestamp_type)) .use_index(use_index) - .decimal_cols_as_float(c_decimal_cols_as_float) .build() ) diff --git a/python/cudf/cudf/io/orc.py b/python/cudf/cudf/io/orc.py index 0ac0e02e4d1..6a2ffef52db 100644 --- a/python/cudf/cudf/io/orc.py +++ b/python/cudf/cudf/io/orc.py @@ -287,18 +287,11 @@ def read_orc( skiprows=None, num_rows=None, use_index=True, - decimal_cols_as_float=None, timestamp_type=None, use_python_file_object=True, **kwargs, ): """{docstring}""" - if decimal_cols_as_float is not None: - warnings.warn( - "`decimal_cols_as_float` is deprecated and will be removed in " - "the future", - FutureWarning, - ) from cudf import DataFrame # Multiple sources are passed as a list. If a single source is passed, @@ -365,7 +358,6 @@ def read_orc( skiprows, num_rows, use_index, - decimal_cols_as_float, timestamp_type, ) ) diff --git a/python/cudf/cudf/tests/test_orc.py b/python/cudf/cudf/tests/test_orc.py index 62715ad7580..5082fb08b92 100644 --- a/python/cudf/cudf/tests/test_orc.py +++ b/python/cudf/cudf/tests/test_orc.py @@ -1266,10 +1266,7 @@ def test_map_type_read(columns, num_rows, use_index): assert_eq(expected_tbl.to_pandas(), gdf) -@pytest.mark.parametrize( - "data", [["_col0"], ["FakeName", "_col0", "TerriblyFakeColumnName"]] -) -def test_orc_reader_decimal(datadir, data): +def test_orc_reader_decimal(datadir): path = datadir / "TestOrcFile.decimal.orc" try: orcfile = pa.orc.ORCFile(path) @@ -1277,28 +1274,8 @@ def test_orc_reader_decimal(datadir, data): pytest.skip(".orc file is not found: %s" % e) pdf = orcfile.read().to_pandas() - gdf = cudf.read_orc(path, decimal_cols_as_float=data).to_pandas() - - # Convert the decimal dtype from PyArrow to float64 for comparison to cuDF - # This is because cuDF returns as float64 - pdf = pdf.apply(pd.to_numeric) - - assert_eq(pdf, gdf) - - -@pytest.mark.parametrize("data", [["InvalidColumnName"]]) -def test_orc_reader_decimal_invalid_column(datadir, data): - path = datadir / "TestOrcFile.decimal.orc" - try: - orcfile = pa.orc.ORCFile(path) - except pa.ArrowIOError as e: - pytest.skip(".orc file is not found: %s" % e) - - pdf = orcfile.read().to_pandas() - gdf = cudf.read_orc(path, decimal_cols_as_float=data).to_pandas() + gdf = cudf.read_orc(path).to_pandas() - # Since the `decimal_cols_as_float` column name - # is invalid, this should be a decimal assert_eq(pdf, gdf) diff --git a/python/cudf/cudf/utils/ioutils.py b/python/cudf/cudf/utils/ioutils.py index cfe1957dfd6..5f348563243 100644 --- a/python/cudf/cudf/utils/ioutils.py +++ b/python/cudf/cudf/utils/ioutils.py @@ -392,9 +392,6 @@ If not None, the total number of rows to read. use_index : bool, default True If True, use row index if available for faster seeking. -decimal_cols_as_float: list, default None - If specified, names of the columns that should be converted from - Decimal to Float64 in the resulting dataframe. use_python_file_object : boolean, default True If True, Arrow-backed PythonFile objects will be used in place of fsspec AbstractBufferedFile objects at IO time. This option is likely to improve From 1f0967ecade501b592e348bab3fde4808d6ed3a9 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Wed, 30 Mar 2022 14:10:50 -0700 Subject: [PATCH 019/246] Remove Click pinnings that are unnecessary after upgrading black. (#10541) This PR undoes #10535 (which was just a patch for cudf 22.04) on cudf 22.06 since we have implemented the longer term solution in #10523. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - AJ Schmidt (https://github.com/ajschmidt8) - Ashwin Srinath (https://github.com/shwina) URL: https://github.com/rapidsai/cudf/pull/10541 --- .pre-commit-config.yaml | 2 -- conda/environments/cudf_dev_cuda11.5.yml | 1 - 2 files changed, 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1220b211019..21f15ade458 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -32,8 +32,6 @@ repos: hooks: - id: black files: python/.* - additional_dependencies: - - click==8.0.4 - repo: https://github.com/PyCQA/flake8 rev: 3.8.3 hooks: diff --git a/conda/environments/cudf_dev_cuda11.5.yml b/conda/environments/cudf_dev_cuda11.5.yml index ec1492894cd..e9d018a2d18 100644 --- a/conda/environments/cudf_dev_cuda11.5.yml +++ b/conda/environments/cudf_dev_cuda11.5.yml @@ -10,7 +10,6 @@ channels: dependencies: - clang=11.1.0 - clang-tools=11.1.0 - - click=8.0.4 - cupy>=9.5.0,<11.0.0a0 - rmm=22.06.* - cmake>=3.20.1 From 4f3ab29619522c2eec55a63c1dbfdda2c4fe64b4 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Wed, 30 Mar 2022 16:22:33 -0700 Subject: [PATCH 020/246] Remove pip requirements files. (#10543) This PR removes some pip requirements files that are no longer used. These were previously introduced to support #7647 but that Dockerfile is no longer maintained in this repository. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - https://github.com/brandon-b-miller - GALI PREM SAGAR (https://github.com/galipremsagar) - https://github.com/jakirkham URL: https://github.com/rapidsai/cudf/pull/10543 --- .../cuda-11.0/dev_requirements.txt | 41 ------------------- .../cuda-11.2/dev_requirements.txt | 41 ------------------- python/cudf_kafka/dev_requirements.txt | 11 ----- python/custreamz/dev_requirements.txt | 12 ------ python/dask_cudf/dev_requirements.txt | 14 ------- 5 files changed, 119 deletions(-) delete mode 100644 python/cudf/requirements/cuda-11.0/dev_requirements.txt delete mode 100644 python/cudf/requirements/cuda-11.2/dev_requirements.txt delete mode 100644 python/cudf_kafka/dev_requirements.txt delete mode 100644 python/custreamz/dev_requirements.txt delete mode 100644 python/dask_cudf/dev_requirements.txt diff --git a/python/cudf/requirements/cuda-11.0/dev_requirements.txt b/python/cudf/requirements/cuda-11.0/dev_requirements.txt deleted file mode 100644 index d8dce276820..00000000000 --- a/python/cudf/requirements/cuda-11.0/dev_requirements.txt +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright (c) 2021, NVIDIA CORPORATION. - -# pyarrow gpu package will have to be built from source : -# https://arrow.apache.org/docs/python/install.html#installing-from-source - -cupy-cuda110 -cachetools -cmake -cmake-setuptools>=0.1.3 -cython>=0.29,<0.30 -dlpack -fastavro>=0.22.9 -python-snappy>=0.6.0 -fsspec>=0.6.0 -hypothesis -mimesis<4.1 -mypy==0.782 -nbsphinx -numba>=0.53.1 -numpy -numpydoc -nvtx>=0.2.1 -packaging -pandas>=1.0,<1.4.0dev0 -pandoc==2.0a4 -protobuf -pydata-sphinx-theme -pyorc -pytest -pytest-benchmark -pytest-xdist -rapidjson -recommonmark -setuptools -sphinx -sphinx-copybutton -sphinx-markdown-tables -sphinxcontrib-websupport -transformers<=4.10.3 -typing_extensions -wheel diff --git a/python/cudf/requirements/cuda-11.2/dev_requirements.txt b/python/cudf/requirements/cuda-11.2/dev_requirements.txt deleted file mode 100644 index c11d108360d..00000000000 --- a/python/cudf/requirements/cuda-11.2/dev_requirements.txt +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright (c) 2021, NVIDIA CORPORATION. - -# pyarrow gpu package will have to be built from source : -# https://arrow.apache.org/docs/python/install.html#installing-from-source - -cupy-cuda112 -cachetools -cmake -cmake-setuptools>=0.1.3 -cython>=0.29,<0.30 -dlpack -fastavro>=0.22.9 -python-snappy>=0.6.0 -fsspec>=0.6.0 -hypothesis -mimesis<4.1 -mypy==0.782 -nbsphinx -numba>=0.53.1 -numpy -numpydoc -nvtx>=0.2.1 -packaging -pandas>=1.0,<1.4.0dev0 -pandoc==2.0a4 -protobuf -pydata-sphinx-theme -pyorc -pytest -pytest-benchmark -pytest-xdist -rapidjson -recommonmark -setuptools -sphinx -sphinx-copybutton -sphinx-markdown-tables -sphinxcontrib-websupport -transformers<=4.10.3 -typing_extensions -wheel diff --git a/python/cudf_kafka/dev_requirements.txt b/python/cudf_kafka/dev_requirements.txt deleted file mode 100644 index af52659e08e..00000000000 --- a/python/cudf_kafka/dev_requirements.txt +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright (c) 2021, NVIDIA CORPORATION. - -flake8==3.8.3 -black==19.10b0 -isort==5.6.4 -python-confluent-kafka -pytest -setuptools -wheel -cython>=0.29,<0.30 -python-confluent-kafka diff --git a/python/custreamz/dev_requirements.txt b/python/custreamz/dev_requirements.txt deleted file mode 100644 index a6b44c640f6..00000000000 --- a/python/custreamz/dev_requirements.txt +++ /dev/null @@ -1,12 +0,0 @@ -# Copyright (c) 2021, NVIDIA CORPORATION. - -flake8==3.8.3 -black==19.10b0 -isort==5.6.4 -dask==2022.03.0 -distributed==2022.03.0 -streamz -python-confluent-kafka -pytest -setuptools -wheel diff --git a/python/dask_cudf/dev_requirements.txt b/python/dask_cudf/dev_requirements.txt deleted file mode 100644 index 438317adf87..00000000000 --- a/python/dask_cudf/dev_requirements.txt +++ /dev/null @@ -1,14 +0,0 @@ -# Copyright (c) 2021, NVIDIA CORPORATION. - -dask==2022.03.0 -distributed==2022.03.0 -fsspec>=0.6.0 -numba>=0.53.1 -numpy -pandas>=1.0,<1.4.0dev0 -pytest -setuptools -wheel -flake8==3.8.3 -black==19.10b0 -isort==5.6.4 From 13551916d874c42ad02a8b3090bc97e02b35a5fa Mon Sep 17 00:00:00 2001 From: GALI PREM SAGAR Date: Wed, 30 Mar 2022 19:46:49 -0500 Subject: [PATCH 021/246] Refactor `memory_usage` to improve performance (#10537) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refactored `Frame.memory_usage` to return a tuple of lists: (column_names, memory_usages). Motivation for this change is to remove redundent steps i.e., `dict`(`Frame.memory_usage`)->`unpack & dict` (`DataFrame.memory_usage`)->`unpack dict`(in `Series.init`). Choosing to remove `dict` being returned by `Frame.memory_usage` will now result in a 10% faster execution of external API. Not a huge speedup but it quickly adds up when `dask_cudf` is used. ```python In [1]: import cudf In [2]: df = cudf.DataFrame({'a':[1, 2, 3], 'b':['a', 'b', 'c'], 'd':[111, 123, 123]}) # THIS PR In [3]: %timeit df.memory_usage() 198 µs ± 3.44 µs per loop (mean ± std. dev. of 7 runs, 1,000 loops each) # branch-22.06 In [3]: %timeit df.memory_usage() 219 µs ± 726 ns per loop (mean ± std. dev. of 7 runs, 1,000 loops each) # branch-22.06 In [4]: %timeit dask_cudf.backends.sizeof_cudf_dataframe(df) 377 µs ± 5.67 µs per loop (mean ± std. dev. of 7 runs, 1,000 loops each) # this PR In [6]: %timeit dask_cudf.backends.sizeof_cudf_dataframe(df) 1.8 µs ± 14 ns per loop (mean ± std. dev. of 7 runs, 1,000,000 loops each) ``` Authors: - GALI PREM SAGAR (https://github.com/galipremsagar) Approvers: - Bradley Dice (https://github.com/bdice) - Vyas Ramasubramani (https://github.com/vyasr) - Ashwin Srinath (https://github.com/shwina) URL: https://github.com/rapidsai/cudf/pull/10537 --- python/cudf/cudf/core/dataframe.py | 10 ++++++++-- python/cudf/cudf/core/frame.py | 7 +------ python/cudf/cudf/core/index.py | 2 +- python/cudf/cudf/core/indexed_frame.py | 5 +---- python/cudf/cudf/core/multiindex.py | 2 +- python/cudf/cudf/core/series.py | 4 +++- python/dask_cudf/dask_cudf/backends.py | 5 ++++- 7 files changed, 19 insertions(+), 16 deletions(-) diff --git a/python/cudf/cudf/core/dataframe.py b/python/cudf/cudf/core/dataframe.py index 17cac3593a3..08a30729e7c 100644 --- a/python/cudf/cudf/core/dataframe.py +++ b/python/cudf/cudf/core/dataframe.py @@ -1339,8 +1339,14 @@ def _slice(self: T, arg: slice) -> T: @_cudf_nvtx_annotate def memory_usage(self, index=True, deep=False): - return Series( - {str(k): v for k, v in super().memory_usage(index, deep).items()} + mem_usage = [col.memory_usage for col in self._data.columns] + names = [str(name) for name in self._data.names] + if index: + mem_usage.append(self._index.memory_usage()) + names.append("Index") + return Series._from_data( + data={None: as_column(mem_usage)}, + index=as_index(names), ) @_cudf_nvtx_annotate diff --git a/python/cudf/cudf/core/frame.py b/python/cudf/cudf/core/frame.py index a84606b0953..75c6e4d0964 100644 --- a/python/cudf/cudf/core/frame.py +++ b/python/cudf/cudf/core/frame.py @@ -339,12 +339,7 @@ def memory_usage(self, deep=False): ------- The total bytes used. """ - if deep: - warnings.warn( - "The deep parameter is ignored and is only included " - "for pandas compatibility." - ) - return {name: col.memory_usage for name, col in self._data.items()} + raise NotImplementedError def __len__(self): return self._num_rows diff --git a/python/cudf/cudf/core/index.py b/python/cudf/cudf/core/index.py index 7df5be3f692..a31fe4c3b99 100644 --- a/python/cudf/cudf/core/index.py +++ b/python/cudf/cudf/core/index.py @@ -914,7 +914,7 @@ def _concat(cls, objs): @_cudf_nvtx_annotate def memory_usage(self, deep=False): - return sum(super().memory_usage(deep=deep).values()) + return self._column.memory_usage @_cudf_nvtx_annotate def equals(self, other, **kwargs): diff --git a/python/cudf/cudf/core/indexed_frame.py b/python/cudf/cudf/core/indexed_frame.py index c5c2322d95a..458fc16c511 100644 --- a/python/cudf/cudf/core/indexed_frame.py +++ b/python/cudf/cudf/core/indexed_frame.py @@ -704,10 +704,7 @@ def memory_usage(self, index=True, deep=False): >>> s.memory_usage(index=False) 24 """ - usage = super().memory_usage(deep=deep) - if index: - usage["Index"] = self.index.memory_usage() - return usage + raise NotImplementedError def hash_values(self, method="murmur3"): """Compute the hash of values in this column. diff --git a/python/cudf/cudf/core/multiindex.py b/python/cudf/cudf/core/multiindex.py index 39228f034d4..d80fb00942b 100644 --- a/python/cudf/cudf/core/multiindex.py +++ b/python/cudf/cudf/core/multiindex.py @@ -1474,7 +1474,7 @@ def _clean_nulls_from_index(self): @_cudf_nvtx_annotate def memory_usage(self, deep=False): - usage = sum(super().memory_usage(deep=deep).values()) + usage = sum(col.memory_usage for col in self._data.columns) if self.levels: for level in self.levels: usage += level.memory_usage(deep=deep) diff --git a/python/cudf/cudf/core/series.py b/python/cudf/cudf/core/series.py index 0ea02edb924..8748b9775be 100644 --- a/python/cudf/cudf/core/series.py +++ b/python/cudf/cudf/core/series.py @@ -856,7 +856,9 @@ def to_frame(self, name=None): @_cudf_nvtx_annotate def memory_usage(self, index=True, deep=False): - return sum(super().memory_usage(index, deep).values()) + return self._column.memory_usage + ( + self._index.memory_usage() if index else 0 + ) @_cudf_nvtx_annotate def __array_function__(self, func, types, args, kwargs): diff --git a/python/dask_cudf/dask_cudf/backends.py b/python/dask_cudf/dask_cudf/backends.py index d1edfb071a2..36e3416c8a3 100644 --- a/python/dask_cudf/dask_cudf/backends.py +++ b/python/dask_cudf/dask_cudf/backends.py @@ -398,7 +398,10 @@ def group_split_cudf(df, c, k, ignore_index=False): @sizeof_dispatch.register(cudf.DataFrame) @_dask_cudf_nvtx_annotate def sizeof_cudf_dataframe(df): - return int(df.memory_usage().sum()) + return int( + sum(col.memory_usage for col in df._data.columns) + + df._index.memory_usage() + ) @sizeof_dispatch.register((cudf.Series, cudf.BaseIndex)) From bc8f57843d2427ed07101faa86a40b162883d032 Mon Sep 17 00:00:00 2001 From: Alfred Xu Date: Thu, 31 Mar 2022 09:49:20 +0800 Subject: [PATCH 022/246] Adjust the valid range of group index for replace_with_backrefs (#10530) Current PR is to adjust to the valid range of group index for cuDF API `cudf::strings::replace_with_backrefs`. 1. enable 0 as group index For now, the range of group index starts with 1, which doesn't include the special value 0. Zero-value as backref index usually refers the entire matching pattern. So does cuDF regexp system. Therefore, what we only need to do is lifting the restrictions to allow zero-value passed as the group index of back references. Example of zero-value index: input: `aa-11 b2b-345` pattern: `([a-z]+)-([0-9]+)` replacement: `${0}:${1}:${2};` output: ```aa-11:aa:11; b2b-345:b:345;``` 2. group index should not exceed group count For now, group indices can exceed group count. The exceeding ones will end up to be empty string. IMHO, it is better to throw an exception under this circumstance instead of ignoring these overflow indices. Authors: - Alfred Xu (https://github.com/sperlingxx) Approvers: - Jason Lowe (https://github.com/jlowe) - David Wendt (https://github.com/davidwendt) URL: https://github.com/rapidsai/cudf/pull/10530 --- cpp/include/cudf/strings/replace_re.hpp | 5 ++-- cpp/src/strings/replace/backref_re.cu | 9 +++++--- cpp/tests/strings/replace_regex_tests.cpp | 23 +++++++++++++++++-- .../java/ai/rapids/cudf/ColumnVectorTest.java | 16 +++++++++++++ 4 files changed, 46 insertions(+), 7 deletions(-) diff --git a/cpp/include/cudf/strings/replace_re.hpp b/cpp/include/cudf/strings/replace_re.hpp index 0e904958d15..0ab3953470d 100644 --- a/cpp/include/cudf/strings/replace_re.hpp +++ b/cpp/include/cudf/strings/replace_re.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -86,7 +86,8 @@ std::unique_ptr replace_re( * * See the @ref md_regex "Regex Features" page for details on patterns supported by this API. * - * @throw cudf::logic_error if capture index values in `replacement` are not in range 1-99 + * @throw cudf::logic_error if capture index values in `replacement` are not in range 0-99, and also + * if the index exceeds the group count specified in the pattern * * @param strings Strings instance for this operation. * @param pattern The regular expression patterns to search within each string. diff --git a/cpp/src/strings/replace/backref_re.cu b/cpp/src/strings/replace/backref_re.cu index 27e0bd4fac9..384813d6e3d 100644 --- a/cpp/src/strings/replace/backref_re.cu +++ b/cpp/src/strings/replace/backref_re.cu @@ -68,7 +68,8 @@ std::string get_backref_pattern(std::string const& repl) * For example, for input string 'hello \2 and \1' the returned `backref_type` vector * contains `[(2,6),(1,11)]` and the returned string is 'hello and '. */ -std::pair> parse_backrefs(std::string const& repl) +std::pair> parse_backrefs(std::string const& repl, + int const group_count) { std::vector backrefs; std::string str = repl; // make a modifiable copy @@ -79,7 +80,8 @@ std::pair> parse_backrefs(std::string con while (std::regex_search(str, m, ex) && !m.empty()) { // parse the back-ref index number size_type const index = static_cast(std::atoi(std::string{m[1]}.c_str())); - CUDF_EXPECTS(index > 0 && index < 100, "Group index numbers must be in the range 1-99"); + CUDF_EXPECTS(index >= 0 && index <= group_count, + "Group index numbers must be in the range 0 to group count"); // store the new byte offset and index value size_type const position = static_cast(m.position(0)); @@ -146,7 +148,8 @@ std::unique_ptr replace_with_backrefs( reprog_device::create(pattern, flags, get_character_flags_table(), input.size(), stream); // parse the repl string for back-ref indicators - auto const parse_result = parse_backrefs(replacement); + auto group_count = std::min(99, d_prog->group_counts()); // group count should NOT exceed 99 + auto const parse_result = parse_backrefs(replacement, group_count); rmm::device_uvector backrefs = cudf::detail::make_device_uvector_async(parse_result.second, stream); string_scalar repl_scalar(parse_result.first, true, stream); diff --git a/cpp/tests/strings/replace_regex_tests.cpp b/cpp/tests/strings/replace_regex_tests.cpp index ddbd9f5b3d6..aac99c79721 100644 --- a/cpp/tests/strings/replace_regex_tests.cpp +++ b/cpp/tests/strings/replace_regex_tests.cpp @@ -279,13 +279,32 @@ TEST_F(StringsReplaceRegexTest, BackrefWithGreedyQuantifier) CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected); } +TEST_F(StringsReplaceRegexTest, ReplaceBackrefsRegexZeroIndexTest) +{ + cudf::test::strings_column_wrapper strings( + {"TEST123", "TEST1TEST2", "TEST2-TEST1122", "TEST1-TEST-T", "TES3"}); + auto strings_view = cudf::strings_column_view(strings); + std::string pattern = "(TEST)(\\d+)"; + std::string repl_template = "${0}: ${1}, ${2}; "; + auto results = cudf::strings::replace_with_backrefs(strings_view, pattern, repl_template); + + cudf::test::strings_column_wrapper expected({ + "TEST123: TEST, 123; ", + "TEST1: TEST, 1; TEST2: TEST, 2; ", + "TEST2: TEST, 2; -TEST1122: TEST, 1122; ", + "TEST1: TEST, 1; -TEST-T", + "TES3", + }); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected); +} + TEST_F(StringsReplaceRegexTest, ReplaceBackrefsRegexErrorTest) { cudf::test::strings_column_wrapper strings({"this string left intentionally blank"}); auto view = cudf::strings_column_view(strings); - EXPECT_THROW(cudf::strings::replace_with_backrefs(view, "(\\w)", "\\0"), cudf::logic_error); - EXPECT_THROW(cudf::strings::replace_with_backrefs(view, "(\\w)", "\\123"), cudf::logic_error); + // group index(3) exceeds the group count(2) + EXPECT_THROW(cudf::strings::replace_with_backrefs(view, "(\\w).(\\w)", "\\3"), cudf::logic_error); EXPECT_THROW(cudf::strings::replace_with_backrefs(view, "", "\\1"), cudf::logic_error); EXPECT_THROW(cudf::strings::replace_with_backrefs(view, "(\\w)", ""), cudf::logic_error); } diff --git a/java/src/test/java/ai/rapids/cudf/ColumnVectorTest.java b/java/src/test/java/ai/rapids/cudf/ColumnVectorTest.java index d1509f14c6e..58901d5743b 100644 --- a/java/src/test/java/ai/rapids/cudf/ColumnVectorTest.java +++ b/java/src/test/java/ai/rapids/cudf/ColumnVectorTest.java @@ -4987,6 +4987,22 @@ void testStringReplaceWithBackrefs() { assertColumnsAreEqual(expected, actual); } + // test zero as group index + try (ColumnVector v = ColumnVector.fromStrings("aa-11 b2b-345", "aa-11a 1c-2b2 b2-c3", "11-aa", null); + ColumnVector expected = ColumnVector.fromStrings("aa-11:aa:11; b2b-345:b:345;", + "aa-11:aa:11;a 1c-2:c:2;b2 b2-c3", "11-aa", null); + ColumnVector actual = v.stringReplaceWithBackrefs( + "([a-z]+)-([0-9]+)", "${0}:${1}:${2};")) { + assertColumnsAreEqual(expected, actual); + } + + // group index exceeds group count + assertThrows(CudfException.class, () -> { + try (ColumnVector v = ColumnVector.fromStrings("ABC123defgh"); + ColumnVector r = v.stringReplaceWithBackrefs("([A-Z]+)([0-9]+)([a-z]+)", "\\4")) { + } + }); + } @Test From d50d1ef08db4441bdb972a30d20b73e06fc2c8a2 Mon Sep 17 00:00:00 2001 From: David Wendt <45795991+davidwendt@users.noreply.github.com> Date: Thu, 31 Mar 2022 19:09:23 -0400 Subject: [PATCH 023/246] Re-enable Build Metrics Report (#10562) The Build Metrics Report was accidentally disabled in #10326. This will add the flags back to the `build.sh` that are required to generate the report during CI. Authors: - David Wendt (https://github.com/davidwendt) Approvers: - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/cudf/pull/10562 --- conda/recipes/libcudf/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conda/recipes/libcudf/build.sh b/conda/recipes/libcudf/build.sh index 8201b4d97be..c7b5d1bd7fd 100644 --- a/conda/recipes/libcudf/build.sh +++ b/conda/recipes/libcudf/build.sh @@ -2,4 +2,4 @@ # Copyright (c) 2018-2022, NVIDIA CORPORATION. export cudf_ROOT="$(realpath ./cpp/build)" -./build.sh -n -v libcudf libcudf_kafka benchmarks tests --cmake-args=\"-DCMAKE_INSTALL_LIBDIR=lib\" +./build.sh -n -v libcudf libcudf_kafka benchmarks tests --build_metrics --incl_cache_stats --cmake-args=\"-DCMAKE_INSTALL_LIBDIR=lib\" From ee03c1a0c27ee83ba764812ac7ff373c508b52f2 Mon Sep 17 00:00:00 2001 From: David Wendt <45795991+davidwendt@users.noreply.github.com> Date: Fri, 1 Apr 2022 08:25:12 -0400 Subject: [PATCH 024/246] Add Replace Backreferences section to Regex Features page (#10560) Adds Replace Backreferences section to the [Regex Features](https://docs.rapids.ai/api/libcudf/stable/md_regex.html) page to help document the replacement template patterns for `cudf::strings::replace_with_backref` API. Also, adds `cudf::strings::split_re` and `cudf::strings::split_record_re` to the regex APIs listed at the top of the page. And add a link to `regex_flags` where the line anchors and the `dot` pattern character are described. Authors: - David Wendt (https://github.com/davidwendt) Approvers: - Nghia Truong (https://github.com/ttnghia) - Vukasin Milovanovic (https://github.com/vuule) URL: https://github.com/rapidsai/cudf/pull/10560 --- cpp/doxygen/regex.md | 20 +++++++++++++++----- cpp/include/cudf/strings/split/split_re.hpp | 4 ++++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/cpp/doxygen/regex.md b/cpp/doxygen/regex.md index 68a446846ce..bfa5745e269 100644 --- a/cpp/doxygen/regex.md +++ b/cpp/doxygen/regex.md @@ -11,6 +11,8 @@ This page specifies which regular expression (regex) features are currently supp - cudf::strings::findall_record() - cudf::strings::replace_re() - cudf::strings::replace_with_backrefs() +- cudf::strings::split_re() +- cudf::strings::split_record_re() The details are based on features documented at https://www.regular-expressions.info/reference.html @@ -43,7 +45,7 @@ The details are based on features documented at https://www.regular-expressions. | Feature | Syntax | Description | Example | | ---------- | ------------- | ------------- | ------------- | -| Dot | . (dot) | Matches any single character except line break characters. Optionally match line break characters. | . matches x or (almost) any other character | +| Dot | . (dot) | Matches any single character except line break characters. Optionally match line break characters. The behavior of the dot when encountering a `\n` character can be controlled by cudf::strings::regex_flags for some regex APIs. | . matches x or (almost) any other character | | Alternation | `⎮` (pipe) | Causes the regex engine to match either the part on the left side, or the part on the right side. Can be strung together into a series of alternations. | `abc⎮def⎮xyz` matches `abc`, `def` or `xyz` | @@ -79,8 +81,8 @@ The details are based on features documented at https://www.regular-expressions. | ---------- | ------------- | ------------- | ------------- | | String anchor | `^` (caret) | Matches at the start of the string | `^.` matches `a` in `abcdef` | | String anchor | `$` (dollar) | Matches at the end of the string | `.$` matches `f` in `abcdef` | -| Line anchor | `^` (caret) | Matches after each line break in addition to matching at the start of the string, thus matching at the start of each line in the string. | `^.` matches `a` and `d` in `abc\ndef` | -| Line anchor | `$` (dollar) | Matches before each line break in addition to matching at the end of the string, thus matching at the end of each line in the string. | `.$` matches `c` and `f` in `abc\ndef` | +| Line anchor | `^` (caret) | Matches after each line break in addition to matching at the start of the string, thus matching at the start of each line in the string. The behavior of this anchor can be controlled by cudf::strings::regex_flags for some regex APIs. | `^.` matches `a` and `d` in `abc\ndef` | +| Line anchor | `$` (dollar) | Matches before each line break in addition to matching at the end of the string, thus matching at the end of each line in the string. The behavior of this anchor can be controlled by cudf::strings::regex_flags for some regex APIs. | `.$` matches `c` and `f` in `abc\ndef` | | String anchor | `\A` | Matches at the start of the string | `\A\w` matches only `a` in `abc` | | String anchor | `\Z` | Matches at the end of the string | `\w\Z` matches `f` in `abc\ndef` but fails to match `abc\ndef\n` or `abc\ndef\n\n` | @@ -111,5 +113,13 @@ The details are based on features documented at https://www.regular-expressions. | Feature | Syntax | Description | Example | | ---------- | ------------- | ------------- | ------------- | -| Capturing group | `(`regex`)` | Parentheses group the regex between them. They capture the text matched by the regex inside them into a numbered group. They allow you to apply regex operators to the entire grouped regex. | `(abc⎮def)ghi` matches `abcghi` or `defghi` | -| Non-capturing group | `(?:`regex`)` | Non-capturing parentheses group the regex so you can apply regex operators, but do not capture anything. | `(?:abc⎮def)ghi` matches `abcghi` or `defghi` | +| Capturing group | `(regex)` | Parentheses group the regex between them. They capture the text matched by the regex inside them into a numbered group. They allow you to apply regex operators to the entire grouped regex. | `(abc⎮def)ghi` matches `abcghi` or `defghi` | +| Non-capturing group | `(?:regex)` | Non-capturing parentheses group the regex so you can apply regex operators, but do not capture anything. | `(?:abc⎮def)ghi` matches `abcghi` or `defghi` | + +### Replacement Backreferences + +| Feature | Syntax | Description | Example | +| ---------- | ------------- | ------------- | ------------- | +| Backreference | `\1` through `\99` | Insert the text matched by capturing groups 1 through 99 | Replacing `(a)(b)(c)` with `\3\3\1` in `abc` yields `cca` | +| Backreference | `${1}` through `${99}` | Insert the text matched by capturing groups 1 through 99 | Replacing `(a)(b)(c)` with `${2}.${2}:{$3}` in `abc` yields `b.b:c` | +| Whole match | `${0}` | Insert the whole regex match | Replacing `(\d)(a)` with `[${0}]:-${2}_${1};` in `123abc` yields `12[3a]:-a_3;bc` diff --git a/cpp/include/cudf/strings/split/split_re.hpp b/cpp/include/cudf/strings/split/split_re.hpp index 320d1bdc9b4..9f40956722d 100644 --- a/cpp/include/cudf/strings/split/split_re.hpp +++ b/cpp/include/cudf/strings/split/split_re.hpp @@ -162,6 +162,8 @@ std::unique_ptr
rsplit_re( * * @throw cudf::logic_error if `pattern` is empty. * + * See the @ref md_regex "Regex Features" page for details on patterns supported by this API. + * * @param input A column of string elements to be split. * @param pattern The regex pattern for delimiting characters within each string. * @param maxsplit Maximum number of splits to perform. @@ -212,6 +214,8 @@ std::unique_ptr split_record_re( * ["ab_cd", ""] ] * @endcode * + * See the @ref md_regex "Regex Features" page for details on patterns supported by this API. + * * @throw cudf::logic_error if `pattern` is empty. * * @param input A column of string elements to be split. From b614a9a1094add8a4e0887a42d1d7568020e9aaf Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Fri, 1 Apr 2022 12:05:14 -0400 Subject: [PATCH 025/246] pin more cmake versions (#10570) Pin the CMake version for the cudf_kafka and libcudf yaml file Authors: - Robert Maynard (https://github.com/robertmaynard) Approvers: - AJ Schmidt (https://github.com/ajschmidt8) - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/cudf/pull/10570 --- conda/recipes/cudf_kafka/meta.yaml | 2 +- conda/recipes/libcudf/conda_build_config.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/conda/recipes/cudf_kafka/meta.yaml b/conda/recipes/cudf_kafka/meta.yaml index 56f2730db7a..9e77d44c15d 100644 --- a/conda/recipes/cudf_kafka/meta.yaml +++ b/conda/recipes/cudf_kafka/meta.yaml @@ -25,7 +25,7 @@ build: requirements: build: - - cmake >=3.20.1 + - cmake >=3.20.1,<3.23 host: - python - cython >=0.29,<0.30 diff --git a/conda/recipes/libcudf/conda_build_config.yaml b/conda/recipes/libcudf/conda_build_config.yaml index 0a533e5c5fe..64eb5d287ef 100644 --- a/conda/recipes/libcudf/conda_build_config.yaml +++ b/conda/recipes/libcudf/conda_build_config.yaml @@ -1,5 +1,5 @@ cmake_version: - - ">=3.20.1" + - ">=3.20.1,<3.23" gtest_version: - "=1.10.0" From ca952f8355810c46bb132f0b50a67e4109108ccb Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Fri, 1 Apr 2022 09:46:42 -0700 Subject: [PATCH 026/246] Update to Thrust 1.16 (#10489) This PR updates the version of Thrust from 1.15 to 1.16 ([changelog](https://github.com/NVIDIA/thrust/blob/main/CHANGELOG.md#thrust-1160)). This update is needed to fix compilation with GCC 11, because of some warnings-as-errors present in Thrust 1.15 with GCC 11 (such as this one from Thrust's copy of cub: https://github.com/NVIDIA/cub/pull/418). Notably, Thrust reduced the number of internal header inclusions: > [#1572](https://github.com/NVIDIA/thrust/pull/1572) Removed several unnecessary header includes. Downstream projects may need to update their includes if they were relying on this behavior. This change illuminated many missing includes in libcudf, so I added `#include ` for all thrust features used in each file (with help from a Python script). I included raw benchmarks that I recorded below.
Benchmarks: ``` Benchmark Time CPU Time Old Time New CPU Old CPU New -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- CopyIfElse/int16_no_nulls/4096/manual_time +0.0581 +0.0307 0 0 0 0 CopyIfElse/uint32_no_nulls/4096/manual_time +0.1308 +0.0463 0 0 0 0 CopyIfElse/uint32_no_nulls/32768/manual_time +0.1043 +0.0485 0 0 0 0 CopyIfElse/float64_no_nulls/4096/manual_time +0.0894 +0.0422 0 0 0 0 StringDateTime/from_days/32768/manual_time +0.0529 +0.0491 93 98 112 118 StringDateTime/to_days/1024/manual_time +0.0596 +0.0493 35 37 54 57 StringDateTime/to_days/32768/manual_time +0.0547 +0.0460 37 39 55 58 StringToDurations/to_durations_ms/1024/manual_time +0.0516 +0.0426 30 31 49 51 StringToDurations/to_durations_ms/32768/manual_time +0.0542 +0.0506 32 34 52 55 StringToDurations/to_durations_us/32768/manual_time +0.0520 +0.0440 32 34 52 55 StringsFromFixedPoint/strings_from_decimal64/16384/manual_time +0.0530 +0.0508 94 99 113 119 StringsToNumeric/strings_to_float32/1024/manual_time +0.0521 +0.0451 31 32 50 52 StringsToNumeric/strings_to_float64/16384/manual_time +0.0517 +0.0437 32 34 51 53 StringsToNumeric/strings_to_float64/65536/manual_time +0.0505 +0.0496 35 36 53 56 StringsToNumeric/strings_to_uint8/4096/manual_time +0.0559 +0.0466 24 25 43 45 StringsToNumeric/strings_to_uint8/65536/manual_time +0.0563 +0.0458 26 27 44 46 StringCopy/gather/4096/32/manual_time +0.0652 +0.0574 0 0 0 0 StringCopy/gather/4096/128/manual_time +0.0706 +0.0615 0 0 0 0 StringCopy/gather/4096/512/manual_time +0.0547 +0.0476 0 0 0 0 StringCopy/gather/32768/32/manual_time +0.0538 +0.0492 0 0 0 0 StringCopy/gather/32768/128/manual_time +0.0540 +0.0477 0 0 0 0 StringCopy/scatter/4096/32/manual_time +0.0571 +0.0526 0 0 0 0 StringCopy/scatter/32768/32/manual_time +0.0541 +0.0509 0 0 0 0 StringFindScalar/find_multi/4096/32/manual_time +0.0525 +0.0460 0 0 0 0 StringFindScalar/find_multi/32768/32/manual_time +0.0538 +0.0489 0 0 0 0 StringFindScalar/contains/4096/32/manual_time +0.0502 +0.0471 0 0 0 0 StringFindScalar/starts_with/4096/32/manual_time +0.0528 +0.0476 0 0 0 0 StringFindScalar/starts_with/4096/2048/manual_time +0.0575 +0.0475 0 0 0 0 StringFindScalar/starts_with/4096/8192/manual_time +0.0606 +0.0515 0 0 0 0 StringFindScalar/starts_with/32768/32/manual_time +0.0690 +0.0592 0 0 0 0 StringFindScalar/starts_with/32768/128/manual_time +0.0589 +0.0499 0 0 0 0 StringFindScalar/starts_with/32768/512/manual_time +0.0567 +0.0521 0 0 0 0 StringFindScalar/starts_with/32768/2048/manual_time +0.0517 +0.0501 0 0 0 0 StringFindScalar/starts_with/262144/32/manual_time +0.0555 +0.0525 0 0 0 0 StringFindScalar/ends_with/4096/2048/manual_time +0.0526 +0.0446 0 0 0 0 StringFindScalar/ends_with/4096/8192/manual_time +0.0568 +0.0485 0 0 0 0 StringFindScalar/ends_with/32768/32/manual_time +0.0654 +0.0567 0 0 0 0 StringFindScalar/ends_with/32768/512/manual_time +0.0546 +0.0502 0 0 0 0 StringFindScalar/ends_with/262144/32/manual_time +0.0523 +0.0517 0 0 0 0 RepeatStrings/scalar_times/256/16/manual_time +0.0555 +0.0501 0 0 0 0 RepeatStrings/scalar_times/1024/16/manual_time +0.0562 +0.0519 0 0 0 0 RepeatStrings/column_times/256/16/manual_time +0.0645 +0.0579 0 0 0 0 RepeatStrings/column_times/256/64/manual_time +0.0506 +0.0472 0 0 0 0 RepeatStrings/column_times/1024/16/manual_time +0.0643 +0.0578 0 0 0 0 RepeatStrings/column_times/4096/16/manual_time +0.0537 +0.0502 0 0 0 0 RepeatStrings/column_times/16384/16/manual_time +0.0565 +0.0514 0 0 0 0 RepeatStrings/compute_output_strings_sizes/256/16/manual_time +0.0626 +0.0490 0 0 0 0 RepeatStrings/compute_output_strings_sizes/256/64/manual_time +0.0539 +0.0434 0 0 0 0 RepeatStrings/compute_output_strings_sizes/256/256/manual_time +0.0694 +0.0525 0 0 0 0 RepeatStrings/compute_output_strings_sizes/1024/16/manual_time +0.0526 +0.0422 0 0 0 0 RepeatStrings/compute_output_strings_sizes/1024/64/manual_time +0.0630 +0.0493 0 0 0 0 RepeatStrings/compute_output_strings_sizes/1024/256/manual_time +0.0533 +0.0460 0 0 0 0 RepeatStrings/precomputed_sizes/256/16/manual_time +0.0674 +0.0602 0 0 0 0 RepeatStrings/precomputed_sizes/1024/16/manual_time +0.0544 +0.0488 0 0 0 0 RepeatStrings/precomputed_sizes/4096/16/manual_time +0.0531 +0.0492 0 0 0 0 RepeatStrings/precomputed_sizes/16384/16/manual_time +0.0522 +0.0470 0 0 0 0 StringReplace/slice/4096/32/manual_time +0.0559 +0.0534 0 0 0 0 StringReplace/slice/32768/32/manual_time +0.0509 +0.0472 0 0 0 0 StringSplit/split_ws/4096/32/manual_time +0.0507 +0.0493 0 0 0 0 StringSubstring/multi_position/4096/32/manual_time +0.0560 +0.0515 0 0 0 0 StringSubstring/delimiter/4096/32/manual_time +0.0532 +0.0504 0 0 0 0 StringSubstring/delimiter/32768/128/manual_time +0.0531 +0.0535 0 0 0 0 StringSubstring/multi_delimiter/4096/32/manual_time +0.0544 +0.0522 0 0 0 0 CsvWrite/string_file_output/23/0/manual_time -0.3111 -0.0110 1421 979 842 833 Shift/shift_ten_percent_nullable_out/32768/manual_time -0.0786 -0.0650 0 0 0 0 Shift/shift_full_nullable_out/1073741824/manual_time +0.0511 +0.0510 11 11 11 11 TypeDispatcher/fp64_bandwidth_host/8/1024/1/manual_time +0.1281 +0.0638 18970 21400 37938 40357 TypeDispatcher/fp64_bandwidth_host/4/2048/1/manual_time +0.0928 +0.0345 11556 12629 30463 31513 TypeDispatcher/fp64_bandwidth_host/2/4096/1/manual_time +0.0768 +0.0270 7421 7991 26234 26943 TypeDispatcher/fp64_bandwidth_host/1/8192/1/manual_time +0.0729 +0.0209 5029 5396 24111 24615 TypeDispatcher/fp64_bandwidth_device/8/1024/1/manual_time +0.1176 +0.0632 16518 18460 35703 37961 TypeDispatcher/fp64_bandwidth_device/4/2048/1/manual_time +0.0787 +0.0457 14424 15559 33546 35079 TypeDispatcher/fp64_bandwidth_device/2/4096/1/manual_time +0.0500 +0.0327 13594 14274 32740 33811 TypeDispatcher/fp64_bandwidth_no/2/1024/1/manual_time +0.0590 +0.0131 5065 5364 23966 24281 TypeDispatcher/fp64_bandwidth_no/8/1024/1/manual_time +0.2305 +0.0699 6912 8506 25803 27607 TypeDispatcher/fp64_bandwidth_no/1/2048/1/manual_time +0.0574 +0.0120 4854 5133 23782 24067 TypeDispatcher/fp64_bandwidth_no/4/2048/1/manual_time +0.1602 +0.0461 6010 6973 24906 26054 TypeDispatcher/fp64_bandwidth_no/2/4096/1/manual_time +0.0949 +0.0330 5583 6113 24469 25275 TypeDispatcher/fp64_bandwidth_no/4/4096/1/manual_time +0.0623 +0.0175 6991 7427 26088 26545 TypeDispatcher/fp64_bandwidth_no/8/4096/1/manual_time +0.0521 +0.0173 8953 9419 28000 28484 TypeDispatcher/fp64_bandwidth_no/1/8192/1/manual_time +0.0607 +0.0257 5225 5542 24107 24727 TypeDispatcher/fp64_bandwidth_no/2/8192/1/manual_time +0.0588 +0.0115 5964 6315 25052 25341 TypeDispatcher/fp64_bandwidth_no/1/16384/1/manual_time +0.0541 +0.0119 5443 5737 24515 24806 TextTokenize/ngrams/2097152/128/manual_time +0.0624 +0.0623 10 10 10 10 MultibyteSplitBenchmark/multibyte_split_simple/1/1/1/32768/manual_time +0.4019 +0.4024 8 12 8 12 MultibyteSplitBenchmark/multibyte_split_simple/2/1/1/32768/manual_time +0.4099 +0.4073 8 12 8 12 MultibyteSplitBenchmark/multibyte_split_simple/1/4/1/32768/manual_time +0.3999 +0.3961 8 12 8 12 MultibyteSplitBenchmark/multibyte_split_simple/2/4/1/32768/manual_time +0.3969 +0.3980 8 12 8 12 MultibyteSplitBenchmark/multibyte_split_simple/1/7/1/32768/manual_time +0.4107 +0.3971 8 12 8 12 MultibyteSplitBenchmark/multibyte_split_simple/2/7/1/32768/manual_time +0.3833 +0.3948 8 12 8 12 MultibyteSplitBenchmark/multibyte_split_simple/1/1/25/32768/manual_time +0.3807 +0.3772 9 12 9 12 MultibyteSplitBenchmark/multibyte_split_simple/2/1/25/32768/manual_time +0.3834 +0.3702 9 12 9 12 MultibyteSplitBenchmark/multibyte_split_simple/1/4/25/32768/manual_time +0.3646 +0.3661 9 12 9 12 MultibyteSplitBenchmark/multibyte_split_simple/2/4/25/32768/manual_time +0.3722 +0.3743 9 12 9 12 MultibyteSplitBenchmark/multibyte_split_simple/1/7/25/32768/manual_time +0.3575 +0.3664 9 12 9 12 MultibyteSplitBenchmark/multibyte_split_simple/2/7/25/32768/manual_time +0.3761 +0.3744 9 12 9 12 MultibyteSplitBenchmark/multibyte_split_simple/1/4/1/1073741824/manual_time -0.1017 -0.1040 1681 1510 1681 1506 MultibyteSplitBenchmark/multibyte_split_simple/2/4/1/1073741824/manual_time -0.1817 -0.1817 4102 3357 4101 3356 MultibyteSplitBenchmark/multibyte_split_simple/0/7/25/1073741824/manual_time -0.0704 -0.0704 345 320 345 320 OVERALL_GEOMEAN +0.0974 +0.0970 0 0 0 0 Groupby/BasicSumScan/100000000/manual_time +0.2947 +0.2947 135 175 135 175 CsvRead/decimal_file_input/35/0/manual_time +0.0508 +0.0511 151 159 151 159 ReductionScan/double_nulls/100000/manual_time +0.0721 +0.0609 22874 24524 40726 43206 OrcWrite/integral_file_output/30/0/32/1/0/manual_time -0.1923 -0.0371 913 738 763 735 OrcWrite/integral_file_output/30/0/1/0/0/manual_time +0.2668 -0.0297 754 955 722 701 OrcWrite/integral_file_output/30/1000/1/0/0/manual_time -0.1090 -0.0510 986 878 725 688 OrcWrite/integral_file_output/30/0/32/0/0/manual_time +0.0594 -0.0575 981 1039 738 696 OrcWrite/integral_buffer_output/30/1000/32/1/1/manual_time +0.0882 +0.0885 85 92 85 92 OrcWrite/integral_buffer_output/30/1000/32/0/1/manual_time -0.0966 -0.0955 98 89 98 89 OrcWrite/floats_file_output/31/0/1/1/0/manual_time +0.0600 -0.0538 737 781 737 697 OrcWrite/floats_file_output/31/0/32/1/0/manual_time +0.0670 +0.0021 1203 1284 715 717 OrcWrite/floats_file_output/31/0/1/0/0/manual_time -0.2406 -0.0605 865 657 698 656 OrcWrite/floats_file_output/31/1000/1/0/0/manual_time -0.2006 -0.0642 1122 897 706 660 OrcWrite/floats_file_output/31/0/32/0/0/manual_time -0.1759 -0.0563 1131 932 708 668 OrcWrite/floats_file_output/31/1000/32/0/0/manual_time -0.1600 -0.0640 1095 919 702 657 OrcWrite/decimal_file_output/35/1000/1/0/0/manual_time +0.1622 -0.0865 1110 1290 588 537 OrcWrite/timestamps_file_output/33/0/1/0/0/manual_time +0.1884 -0.0494 552 657 552 524 OrcWrite/timestamps_file_output/33/1000/1/0/0/manual_time +0.1409 +0.0064 650 742 541 544 OrcWrite/list_file_output/24/0/1/0/0/manual_time -0.0723 -0.0788 713 661 711 655 OrcWrite/list_file_output/24/1000/1/0/0/manual_time +0.0935 -0.0468 696 761 689 657 Concatenate/BM_concatenate_nullable_false/4096/2/manual_time +0.1055 +0.0672 0 0 0 0 Concatenate/BM_concatenate_nullable_false/512/8/manual_time +0.0548 +0.0379 0 0 0 0 Concatenate/BM_concatenate_nullable_true/32768/8/manual_time +0.0501 +0.0415 0 0 0 0 Concatenate/BM_concatenate_nullable_true/64/64/manual_time +0.0570 +0.0400 0 0 0 0 Concatenate/BM_concatenate_nullable_true/512/64/manual_time +0.0894 +0.0606 0 0 0 0 Concatenate/BM_concatenate_tables_nullable_false/4096/2/2/manual_time +0.1086 +0.0771 0 0 0 0 Concatenate/BM_concatenate_tables_nullable_false/512/8/2/manual_time +0.0920 +0.0828 0 0 0 0 Concatenate/BM_concatenate_tables_nullable_false/4096/8/2/manual_time +0.0549 +0.0502 0 0 0 0 Concatenate/BM_concatenate_tables_nullable_false/256/32/2/manual_time +0.1036 +0.1009 1 1 1 1 Concatenate/BM_concatenate_tables_nullable_false/512/32/2/manual_time +0.0827 +0.0813 1 1 1 1 Concatenate/BM_concatenate_tables_nullable_false/4096/32/2/manual_time +0.0788 +0.0768 1 1 1 1 Concatenate/BM_concatenate_tables_nullable_false/256/8/64/manual_time +0.0525 +0.0490 0 0 0 0 ParquetRead/integral_buffer_input/29/1000/1/0/1/manual_time +0.0929 +0.0928 46 50 46 50 ParquetRead/timestamps_file_input/33/0/32/0/0/manual_time -0.0896 -0.0897 127 116 128 116 OrcRead/integral_buffer_input/30/1000/1/0/1/manual_time +0.1087 +0.1087 88 97 88 97 OrcRead/floats_file_input/31/0/1/1/0/manual_time +0.1528 +0.1526 134 155 134 155 OrcRead/floats_buffer_input/31/1000/1/0/1/manual_time +0.1349 +0.1350 75 85 75 85 OrcRead/decimal_buffer_input/35/0/1/0/1/manual_time -0.1137 -0.1137 264 234 264 234 OrcRead/string_file_input/23/0/1/0/0/manual_time -0.0750 -0.0750 162 150 162 150 OrcRead/string_file_input/23/0/32/0/0/manual_time -0.0963 -0.0963 163 147 163 147 OrcRead/string_buffer_input/23/0/32/0/1/manual_time -0.1586 -0.0139 114 96 97 96 OrcRead/list_file_input/24/1000/1/0/0/manual_time +0.0515 +0.0517 176 185 176 185 OrcRead/list_file_input/24/0/32/0/0/manual_time +0.0925 +0.0922 173 189 173 189 OrcRead/list_buffer_input/24/0/1/1/1/manual_time -0.1288 -0.1291 139 121 139 121 BINARYOP/binaryop_int32_imbalanced_reuse/100000/2/manual_time +0.0533 +0.0381 0 0 0 0 COMPILED_BINARYOP/NULL_MAX_decimal32_decimal32_decimal32/100000/manual_time +0.0509 +0.0320 13 14 32 33 COMPILED_BINARYOP/NULL_MIN_timestamp_D_timestamp_s_timestamp_s/10000/manual_time +0.0509 +0.0374 11 12 30 31 ParquetWrite/integral_file_output/29/0/1/1/0/manual_time +0.3011 +0.0605 726 945 726 770 ParquetWrite/integral_file_output/29/1000/1/1/0/manual_time +0.0812 +0.0804 311 336 310 335 ParquetWrite/integral_file_output/29/0/32/1/0/manual_time +0.3497 +0.0714 948 1279 734 786 ParquetWrite/integral_file_output/29/1000/32/1/0/manual_time +0.0559 +0.0558 62 65 62 65 ParquetWrite/integral_file_output/29/0/1/0/0/manual_time +0.1829 +0.0679 702 830 700 748 ParquetWrite/integral_file_output/29/1000/1/0/0/manual_time +0.0829 +0.0852 284 307 283 307 ParquetWrite/integral_file_output/29/0/32/0/0/manual_time -0.3273 +0.0451 1063 715 683 714 ParquetWrite/integral_file_output/29/1000/32/0/0/manual_time +0.0835 +0.0834 58 63 58 63 ParquetWrite/integral_buffer_output/29/0/1/1/1/manual_time +0.0608 +0.0609 874 927 874 927 ParquetWrite/floats_file_output/31/0/1/1/0/manual_time +0.1916 +0.0634 694 827 693 737 ParquetWrite/floats_file_output/31/1000/1/1/0/manual_time +0.0560 +0.0553 217 229 217 229 ParquetWrite/floats_file_output/31/0/32/1/0/manual_time +0.0517 +0.0546 1020 1073 721 760 ParquetWrite/floats_file_output/31/1000/32/1/0/manual_time +0.1149 +0.0631 45 50 39 42 ParquetWrite/floats_file_output/31/0/1/0/0/manual_time +0.1165 +0.0471 880 983 664 695 ParquetWrite/floats_file_output/31/1000/1/0/0/manual_time +0.3996 +0.0038 237 331 219 219 ParquetWrite/floats_file_output/31/0/32/0/0/manual_time +0.3109 +0.0673 666 873 666 710 ParquetWrite/floats_file_output/31/1000/32/0/0/manual_time +0.0798 +0.0790 38 41 38 41 ParquetWrite/floats_buffer_output/31/1000/1/1/1/manual_time +0.0710 +0.0709 208 223 208 223 ParquetWrite/floats_buffer_output/31/0/32/1/1/manual_time +0.0677 +0.0673 732 782 732 782 ParquetWrite/floats_buffer_output/31/0/1/0/1/manual_time +0.0663 +0.0659 682 728 682 727 ParquetWrite/floats_buffer_output/31/1000/1/0/1/manual_time +0.0785 +0.0780 188 203 188 203 ParquetWrite/decimal_file_output/35/0/1/1/0/manual_time +0.0655 +0.0636 277 296 277 295 ParquetWrite/decimal_file_output/35/1000/1/1/0/manual_time +0.0657 +0.0634 242 258 242 257 ParquetWrite/decimal_file_output/35/0/32/1/0/manual_time +0.1194 +0.0577 291 325 290 307 ParquetWrite/decimal_file_output/35/1000/32/1/0/manual_time +0.0852 +0.0836 170 185 170 184 ParquetWrite/decimal_file_output/35/0/1/0/0/manual_time +0.3802 +0.0372 346 477 325 337 ParquetWrite/decimal_file_output/35/1000/1/0/0/manual_time +0.8101 +0.1543 374 677 373 431 ParquetWrite/decimal_file_output/35/0/32/0/0/manual_time +1.4742 +0.0541 328 812 327 344 ParquetWrite/decimal_file_output/35/1000/32/0/0/manual_time +0.5398 +0.0463 391 603 390 409 ParquetWrite/decimal_buffer_output/35/0/1/1/1/manual_time +0.0571 +0.0570 301 318 301 318 ParquetWrite/decimal_buffer_output/35/1000/1/1/1/manual_time +0.1955 +0.1953 253 302 253 302 ParquetWrite/decimal_buffer_output/35/0/32/1/1/manual_time +0.0655 +0.0641 306 326 306 325 ParquetWrite/decimal_buffer_output/35/0/1/0/1/manual_time +0.0595 +0.0591 381 404 381 404 ParquetWrite/decimal_buffer_output/35/1000/1/0/1/manual_time +0.0650 +0.0643 515 548 515 548 ParquetWrite/decimal_buffer_output/35/0/32/0/1/manual_time +0.0595 +0.0591 386 409 386 409 ParquetWrite/decimal_buffer_output/35/1000/32/0/1/manual_time +0.0595 +0.0590 517 547 516 547 ParquetWrite/timestamps_file_output/33/0/1/1/0/manual_time +0.0566 +0.0580 724 765 721 762 ParquetWrite/timestamps_file_output/33/1000/1/1/0/manual_time -0.6229 -0.0258 526 198 203 198 ParquetWrite/timestamps_file_output/33/0/32/1/0/manual_time -0.0955 +0.0444 928 840 733 766 ParquetWrite/timestamps_file_output/33/1000/32/1/0/manual_time +0.0794 +0.0725 36 39 36 39 ParquetWrite/timestamps_file_output/33/0/1/0/0/manual_time +0.2140 +0.0788 626 760 626 676 ParquetWrite/timestamps_file_output/33/1000/1/0/0/manual_time +0.0778 +0.0760 174 188 174 187 ParquetWrite/timestamps_file_output/33/0/32/0/0/manual_time +0.4682 +0.0758 636 934 636 684 ParquetWrite/timestamps_file_output/33/1000/32/0/0/manual_time +0.0938 +0.0929 34 38 34 38 ParquetWrite/timestamps_buffer_output/33/0/1/1/1/manual_time +0.0559 +0.0559 837 884 837 884 ParquetWrite/timestamps_buffer_output/33/0/1/0/1/manual_time +0.0612 +0.0612 714 758 714 758 ParquetWrite/timestamps_buffer_output/33/1000/1/0/1/manual_time -0.2022 -0.2021 229 183 229 183 ParquetWrite/timestamps_buffer_output/33/0/32/0/1/manual_time +0.0609 +0.0596 721 765 721 764 ParquetWrite/string_file_output/23/0/1/1/0/manual_time +0.1674 +0.1004 1231 1437 869 956 ParquetWrite/string_file_output/23/1000/1/1/0/manual_time +0.0748 +0.0675 124 133 107 114 ParquetWrite/string_file_output/23/0/32/1/0/manual_time +0.0497 +0.0541 1197 1256 893 942 ParquetWrite/string_file_output/23/1000/32/1/0/manual_time +0.0822 +0.0551 38 41 34 35 ParquetWrite/string_file_output/23/0/1/0/0/manual_time +0.3477 +0.0668 892 1202 828 883 ParquetWrite/string_file_output/23/1000/1/0/0/manual_time +0.1446 +0.1474 98 113 98 113 ParquetWrite/string_file_output/23/1000/32/0/0/manual_time +0.0596 +0.0590 33 35 33 35 ParquetWrite/string_buffer_output/23/1000/1/0/1/manual_time +0.0598 +0.0594 104 110 104 110 ParquetWrite/string_void_output/23/1000/32/0/2/manual_time -0.3901 +0.0015 34 21 21 21 ParquetWrite/list_file_output/24/0/1/0/0/manual_time -0.1313 +0.0831 1033 897 828 897 ParquetWrite/list_file_output/24/1000/1/0/0/manual_time +0.0559 +0.0537 521 550 521 549 ParquetWrite/list_file_output/24/0/32/0/0/manual_time -0.1942 -0.0129 1183 954 888 877 ContiguousSplit/1Gb512ColsValidity/1073741824/512/256/1/iterations:8/manual_time +0.0660 +0.0659 30 32 30 32 AST/ast_int32_imbalanced_unique_nulls/1000000/1/manual_time +0.0540 +0.0453 0 0 0 0 AST/ast_int32_imbalanced_unique_nulls/10000000/1/manual_time +0.0657 +0.0642 1 1 1 1 AST/ast_int32_imbalanced_unique_nulls/100000000/1/manual_time +0.0704 +0.0702 8 9 8 9 AST/ast_int32_imbalanced_reuse_nulls/1000000/1/manual_time +0.0549 +0.0473 0 0 0 0 AST/ast_int32_imbalanced_reuse_nulls/10000000/1/manual_time +0.0745 +0.0723 1 1 1 1 AST/ast_int32_imbalanced_reuse_nulls/100000000/1/manual_time +0.0758 +0.0755 7 8 7 8 AST/ast_double_imbalanced_unique_nulls/10000000/1/manual_time +0.0534 +0.0522 1 1 1 1 AST/ast_double_imbalanced_unique_nulls/10000000/10/manual_time +0.0610 +0.0606 3 3 3 3 AST/ast_double_imbalanced_unique_nulls/100000000/1/manual_time +0.0538 +0.0537 9 10 9 10 AST/ast_double_imbalanced_unique_nulls/100000000/10/manual_time +0.0579 +0.0579 26 27 26 27 Rank/nulls/1024/manual_time +0.7608 +0.6280 0 0 0 0 Rank/nulls/4096/manual_time +0.2739 +0.2437 0 0 0 0 Rank/nulls/32768/manual_time +0.1599 +0.1469 0 0 0 0 Rank/nulls/262144/manual_time +0.0813 +0.0793 0 0 0 0 Rank/nulls/2097152/manual_time -0.4178 -0.4162 5 3 5 3 Rank/nulls/16777216/manual_time -0.3688 -0.3686 45 28 45 28 Rank/nulls/67108864/manual_time -0.3576 -0.3576 181 117 181 117 Sort/unstable_no_nulls/1024/8/manual_time +0.2655 +0.2554 1 1 1 1 Sort/unstable_no_nulls/4096/8/manual_time +0.3212 +0.3081 0 1 1 1 Sort/unstable_no_nulls/32768/8/manual_time +0.1430 +0.1395 1 1 1 1 Sort/unstable_no_nulls/262144/8/manual_time +0.1080 +0.1064 1 1 1 2 Sort/unstable_no_nulls/2097152/8/manual_time -0.0740 -0.0740 15 14 15 14 Sort/unstable_no_nulls/16777216/8/manual_time -0.0882 -0.0882 215 196 215 196 Sort/unstable_no_nulls/67108864/8/manual_time -0.0848 -0.0848 1170 1071 1170 1071 Sort/stable_no_nulls/1024/8/manual_time +0.2656 +0.2553 1 1 1 1 Sort/stable_no_nulls/4096/8/manual_time +0.3215 +0.3081 0 1 1 1 Sort/stable_no_nulls/32768/8/manual_time +0.1427 +0.1392 1 1 1 1 Sort/stable_no_nulls/262144/8/manual_time +0.1082 +0.1066 1 1 1 2 Sort/stable_no_nulls/2097152/8/manual_time -0.0737 -0.0735 15 14 15 14 Sort/stable_no_nulls/16777216/8/manual_time -0.0889 -0.0887 215 196 215 196 Sort/stable_no_nulls/67108864/8/manual_time -0.0848 -0.0846 1170 1071 1170 1071 Sort/unstable/1024/1/manual_time +0.8698 +0.7017 0 0 0 0 Sort/unstable/4096/1/manual_time +0.2846 +0.2506 0 0 0 0 Sort/unstable/32768/1/manual_time +0.1640 +0.1492 0 0 0 0 Sort/unstable/262144/1/manual_time +0.0818 +0.0794 0 0 0 0 Sort/unstable/2097152/1/manual_time -0.4431 -0.4414 5 3 5 3 Sort/unstable/16777216/1/manual_time -0.4282 -0.4280 38 22 38 22 Sort/unstable/67108864/1/manual_time -0.4168 -0.4168 155 90 155 90 Sort/unstable/1024/8/manual_time +0.2213 +0.2142 1 1 1 1 Sort/unstable/4096/8/manual_time +0.2784 +0.2687 1 1 1 1 Sort/unstable/32768/8/manual_time +0.1115 +0.1094 1 1 1 1 Sort/unstable/262144/8/manual_time +0.1030 +0.1016 2 2 2 2 Sort/stable/1024/1/manual_time +0.8684 +0.7016 0 0 0 0 Sort/stable/4096/1/manual_time +0.2860 +0.2517 0 0 0 0 Sort/stable/32768/1/manual_time +0.1638 +0.1497 0 0 0 0 Sort/stable/262144/1/manual_time +0.0817 +0.0798 0 0 0 0 Sort/stable/2097152/1/manual_time -0.4431 -0.4415 5 3 5 3 Sort/stable/16777216/1/manual_time -0.4279 -0.4277 38 22 38 22 Sort/stable/67108864/1/manual_time -0.4176 -0.4176 155 90 155 90 Sort/stable/1024/8/manual_time +0.2211 +0.2138 1 1 1 1 Sort/stable/4096/8/manual_time +0.2808 +0.2706 1 1 1 1 Sort/stable/32768/8/manual_time +0.1117 +0.1096 1 1 1 1 Sort/stable/262144/8/manual_time +0.1029 +0.1013 2 2 2 2 Sort/strings/262144/manual_time -0.0781 -0.0777 4 4 4 4 Scatter/double_coalesce_x/2048/2/manual_time +0.0614 +0.0472 27988 29705 46846 49057 Scatter/double_coalesce_x/32768/2/manual_time +0.0637 +0.0522 30209 32133 47991 50496 Scatter/double_coalesce_x/131072/2/manual_time +0.0558 +0.0444 37821 39932 54883 57321 Scatter/double_coalesce_x/1024/4/manual_time +0.0811 +0.0663 53699 58053 72617 77434 Scatter/double_coalesce_x/2048/4/manual_time +0.0535 +0.0468 56040 59038 74848 78348 Scatter/double_coalesce_x/4096/4/manual_time +0.0514 +0.0449 56187 59073 74930 78291 Scatter/double_coalesce_x/8192/4/manual_time +0.0516 +0.0452 56747 59674 75140 78533 Scatter/double_coalesce_x/16384/4/manual_time +0.0520 +0.0479 57412 60400 75292 78895 Scatter/double_coalesce_x/32768/4/manual_time +0.0610 +0.0544 58151 61699 75398 79499 Scatter/double_coalesce_x/1024/8/manual_time +0.0526 +0.0486 110089 115882 129032 135301 Scatter/double_coalesce_x/2048/8/manual_time +0.0546 +0.0506 110864 116921 129784 136352 Scatter/double_coalesce_x/4096/8/manual_time +0.0612 +0.0554 110733 117506 129306 136465 Scatter/double_coalesce_x/8192/8/manual_time +0.0635 +0.0579 111614 118703 129727 137233 Scatter/double_coalesce_x/16384/8/manual_time +0.0665 +0.0604 111918 119366 129458 137275 Scatter/double_coalesce_x/32768/8/manual_time +0.0545 +0.0543 114993 121260 131951 139113 Scatter/double_coalesce_x/65536/8/manual_time +0.0619 +0.0560 119167 126540 136092 143717 Scatter/double_coalesce_o/2048/2/manual_time +0.0542 +0.0418 29300 30889 48197 50211 Scatter/double_coalesce_o/32768/2/manual_time +0.0556 +0.0464 32069 33851 49914 52229 Scatter/double_coalesce_o/1024/4/manual_time +0.0684 +0.0569 56480 60346 75468 79761 Scatter/double_coalesce_o/8192/4/manual_time +0.0572 +0.0497 59554 62960 77958 81834 Scatter/double_coalesce_o/16384/4/manual_time +0.0572 +0.0525 59839 63260 77704 81781 Scatter/double_coalesce_o/32768/4/manual_time +0.0564 +0.0514 62493 66015 79779 83883 Scatter/double_coalesce_o/1024/8/manual_time +0.0566 +0.0515 112968 119360 131925 138723 Scatter/double_coalesce_o/2048/8/manual_time +0.0565 +0.0518 113151 119548 132028 138870 Scatter/double_coalesce_o/4096/8/manual_time +0.0594 +0.0545 114566 121374 133078 140333 Scatter/double_coalesce_o/8192/8/manual_time +0.0587 +0.0534 116146 122963 134282 141449 Scatter/double_coalesce_o/16384/8/manual_time +0.0663 +0.0597 116445 124161 134038 142046 Scatter/double_coalesce_o/32768/8/manual_time +0.0555 +0.0566 122258 129043 139016 146891 Scatter/double_coalesce_o/65536/8/manual_time +0.0553 +0.0498 133373 140749 150403 157896 Quantiles/no_nulls/65536/4/1/manual_time +0.1394 +0.1370 1 1 1 1 Quantiles/no_nulls/262144/4/1/manual_time +0.1372 +0.1348 1 1 1 1 Quantiles/no_nulls/1048576/4/1/manual_time -0.0944 -0.0943 6 5 6 5 Quantiles/no_nulls/4194304/4/1/manual_time -0.1068 -0.1070 35 32 35 32 Quantiles/no_nulls/16777216/4/1/manual_time -0.0882 -0.0884 210 191 210 191 Quantiles/no_nulls/67108864/4/1/manual_time -0.0855 -0.0858 1148 1050 1148 1050 Quantiles/no_nulls/65536/8/1/manual_time +0.1312 +0.1290 1 1 1 1 Quantiles/no_nulls/262144/8/1/manual_time +0.1058 +0.1044 1 2 1 2 Quantiles/no_nulls/4194304/8/1/manual_time -0.0982 -0.0984 37 33 37 33 Quantiles/no_nulls/16777216/8/1/manual_time -0.0886 -0.0888 215 196 215 196 Quantiles/no_nulls/67108864/8/1/manual_time -0.0866 -0.0868 1173 1071 1173 1071 Quantiles/no_nulls/65536/4/4/manual_time +0.1413 +0.1385 1 1 1 1 Quantiles/no_nulls/262144/4/4/manual_time +0.1355 +0.1332 1 1 1 1 Quantiles/no_nulls/1048576/4/4/manual_time -0.0944 -0.0943 6 5 6 5 Quantiles/no_nulls/4194304/4/4/manual_time -0.1061 -0.1063 35 32 35 32 Quantiles/no_nulls/16777216/4/4/manual_time -0.0877 -0.0879 210 191 210 191 Quantiles/no_nulls/67108864/4/4/manual_time -0.0863 -0.0865 1149 1050 1149 1049 Quantiles/no_nulls/65536/8/4/manual_time +0.1328 +0.1308 1 1 1 1 Quantiles/no_nulls/262144/8/4/manual_time +0.1058 +0.1047 1 2 1 2 Quantiles/no_nulls/4194304/8/4/manual_time -0.0970 -0.0970 37 33 37 33 Quantiles/no_nulls/16777216/8/4/manual_time -0.0886 -0.0888 215 196 215 196 Quantiles/no_nulls/67108864/8/4/manual_time -0.0863 -0.0865 1172 1071 1172 1071 Quantiles/no_nulls/65536/4/12/manual_time +0.1411 +0.1384 1 1 1 1 Quantiles/no_nulls/262144/4/12/manual_time +0.1360 +0.1338 1 1 1 1 Quantiles/no_nulls/1048576/4/12/manual_time -0.0953 -0.0952 6 5 6 5 Quantiles/no_nulls/4194304/4/12/manual_time -0.1054 -0.1056 35 32 35 32 Quantiles/no_nulls/16777216/4/12/manual_time -0.0871 -0.0873 210 191 210 191 Quantiles/no_nulls/67108864/4/12/manual_time -0.0858 -0.0860 1148 1050 1148 1049 Quantiles/no_nulls/65536/8/12/manual_time +0.1323 +0.1302 1 1 1 1 Quantiles/no_nulls/262144/8/12/manual_time +0.1060 +0.1047 1 2 1 2 Quantiles/no_nulls/1048576/8/12/manual_time -0.0702 -0.0703 6 6 6 6 Quantiles/no_nulls/4194304/8/12/manual_time -0.0971 -0.0973 37 33 37 33 Quantiles/no_nulls/16777216/8/12/manual_time -0.0885 -0.0887 215 196 215 196 Quantiles/no_nulls/67108864/8/12/manual_time -0.0865 -0.0866 1173 1071 1172 1071 Quantiles/nulls/65536/1/1/manual_time +0.0958 +0.0916 0 0 0 0 Quantiles/nulls/262144/1/1/manual_time +0.0750 +0.0728 0 0 0 0 Quantiles/nulls/1048576/1/1/manual_time -0.1901 -0.1874 2 1 2 1 Quantiles/nulls/4194304/1/1/manual_time -0.4297 -0.4288 10 5 10 6 Quantiles/nulls/16777216/1/1/manual_time -0.4270 -0.4268 38 22 38 22 Quantiles/nulls/67108864/1/1/manual_time -0.4151 -0.4152 155 90 155 90 Quantiles/nulls/65536/4/1/manual_time +0.1027 +0.1007 1 1 1 1 Quantiles/nulls/262144/4/1/manual_time +0.1119 +0.1103 1 1 1 1 Quantiles/nulls/65536/8/1/manual_time +0.1193 +0.1174 1 2 1 2 Quantiles/nulls/262144/8/1/manual_time +0.0973 +0.0963 2 2 2 2 Quantiles/nulls/65536/1/4/manual_time +0.0973 +0.0928 0 0 0 0 Quantiles/nulls/262144/1/4/manual_time +0.0759 +0.0731 0 0 0 0 Quantiles/nulls/1048576/1/4/manual_time -0.1906 -0.1879 2 1 2 1 Quantiles/nulls/4194304/1/4/manual_time -0.4296 -0.4287 10 5 10 5 Quantiles/nulls/16777216/1/4/manual_time -0.4278 -0.4277 38 22 38 22 Quantiles/nulls/67108864/1/4/manual_time -0.4153 -0.4154 155 90 155 90 Quantiles/nulls/65536/4/4/manual_time +0.1047 +0.1027 1 1 1 1 Quantiles/nulls/262144/4/4/manual_time +0.1116 +0.1100 1 1 1 1 Quantiles/nulls/65536/8/4/manual_time +0.1194 +0.1175 1 2 1 2 Quantiles/nulls/262144/8/4/manual_time +0.0975 +0.0964 2 2 2 2 Quantiles/nulls/65536/1/12/manual_time +0.0954 +0.0909 0 0 0 0 Quantiles/nulls/262144/1/12/manual_time +0.0779 +0.0749 0 0 0 0 Quantiles/nulls/1048576/1/12/manual_time -0.1873 -0.1848 2 1 2 1 Quantiles/nulls/4194304/1/12/manual_time -0.4304 -0.4295 10 5 10 5 Quantiles/nulls/16777216/1/12/manual_time -0.4277 -0.4276 38 22 38 22 Quantiles/nulls/67108864/1/12/manual_time -0.4144 -0.4145 154 90 154 90 Quantiles/nulls/65536/4/12/manual_time +0.1006 +0.0987 1 1 1 1 Quantiles/nulls/262144/4/12/manual_time +0.1120 +0.1104 1 1 1 1 Quantiles/nulls/65536/8/12/manual_time +0.1193 +0.1174 1 2 1 2 Quantiles/nulls/262144/8/12/manual_time +0.0953 +0.0942 2 2 2 2 ```
Additional (preliminary?) benchmarking from @randerzander and @GregoryKimball indicate that sort and quantile benchmarks show improvements for large data sizes, as much as 34% reduction in time for "Rank nulls 67108864." The benchmark "Quantiles nulls 67108864" shows roughly a 6% reduction in runtime. Small sizes sometimes showed slowdowns, like "Rank nulls 1024" going from 98 microseconds to 177 microseconds. However, these small data sizes are typically not the cases we are optimizing for. Authors: - Bradley Dice (https://github.com/bdice) - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Vyas Ramasubramani (https://github.com/vyasr) - Jason Lowe (https://github.com/jlowe) URL: https://github.com/rapidsai/cudf/pull/10489 --- cpp/benchmarks/column/concatenate.cpp | 2 ++ cpp/benchmarks/common/generate_input.cu | 4 +++ cpp/benchmarks/copying/contiguous_split.cu | 2 ++ cpp/benchmarks/copying/gather.cu | 2 ++ cpp/benchmarks/copying/scatter.cu | 2 ++ cpp/benchmarks/io/text/multibyte_split.cpp | 1 + cpp/benchmarks/iterator/iterator.cu | 7 +++- cpp/benchmarks/join/join_common.hpp | 1 + cpp/benchmarks/quantiles/quantiles.cpp | 1 + cpp/benchmarks/string/copy.cu | 3 ++ cpp/benchmarks/string/factory.cu | 1 + cpp/benchmarks/string/url_decode.cu | 2 ++ cpp/cmake/thirdparty/get_thrust.cmake | 4 +-- .../cudf/ast/detail/expression_parser.hpp | 3 +- .../cudf/column/column_device_view.cuh | 1 + cpp/include/cudf/column/column_factories.hpp | 4 ++- .../cudf/detail/aggregation/aggregation.cuh | 2 ++ .../detail/calendrical_month_sequence.cuh | 3 ++ cpp/include/cudf/detail/copy_if.cuh | 5 ++- cpp/include/cudf/detail/copy_if_else.cuh | 5 ++- cpp/include/cudf/detail/gather.cuh | 3 +- cpp/include/cudf/detail/indexalator.cuh | 5 +++ cpp/include/cudf/detail/iterator.cuh | 4 ++- cpp/include/cudf/detail/merge.cuh | 6 +++- cpp/include/cudf/detail/null_mask.cuh | 2 ++ cpp/include/cudf/detail/replace/nulls.cuh | 3 +- cpp/include/cudf/detail/scatter.cuh | 10 +++++- cpp/include/cudf/detail/unary.hpp | 4 ++- .../cudf/detail/utilities/hash_functions.cuh | 4 +++ .../detail/utilities/vector_factories.hpp | 2 ++ .../cudf/dictionary/detail/iterator.cuh | 4 ++- cpp/include/cudf/lists/detail/gather.cuh | 5 ++- cpp/include/cudf/lists/detail/scatter.cuh | 10 +++++- cpp/include/cudf/lists/list_device_view.cuh | 5 ++- .../cudf/strings/detail/copy_if_else.cuh | 7 +++- .../cudf/strings/detail/copy_range.cuh | 3 +- cpp/include/cudf/strings/detail/gather.cuh | 6 +++- cpp/include/cudf/strings/detail/merge.cuh | 7 +++- cpp/include/cudf/strings/detail/scatter.cuh | 4 ++- .../detail/strings_column_factories.cuh | 9 ++++- cpp/include/cudf/strings/detail/utilities.cuh | 5 ++- cpp/include/cudf/strings/string.cuh | 5 ++- cpp/include/cudf/strings/string_view.cuh | 1 + cpp/include/cudf/table/row_operators.cuh | 2 ++ cpp/include/cudf/utilities/span.hpp | 1 + cpp/include/cudf_test/column_utilities.hpp | 1 + cpp/include/cudf_test/column_wrapper.hpp | 2 ++ cpp/include/cudf_test/iterator_utilities.hpp | 3 +- cpp/include/cudf_test/tdigest_utilities.cuh | 8 ++++- cpp/src/binaryop/compiled/binary_ops.cu | 5 +++ cpp/src/column/column_device_view.cu | 5 ++- cpp/src/column/column_factories.cu | 4 ++- cpp/src/copying/concatenate.cu | 6 ++++ cpp/src/copying/contiguous_split.cu | 10 ++++++ cpp/src/copying/copy.cu | 6 +++- cpp/src/copying/gather.cu | 4 ++- cpp/src/copying/sample.cu | 3 +- cpp/src/copying/scatter.cu | 4 +++ cpp/src/copying/segmented_shift.cu | 3 +- cpp/src/copying/slice.cu | 4 ++- cpp/src/datetime/datetime_ops.cu | 2 ++ cpp/src/dictionary/detail/concatenate.cu | 8 +++++ cpp/src/dictionary/detail/merge.cu | 4 ++- cpp/src/dictionary/remove_keys.cu | 4 ++- cpp/src/dictionary/search.cu | 3 +- cpp/src/dictionary/set_keys.cu | 8 ++++- cpp/src/filling/fill.cu | 4 ++- cpp/src/filling/repeat.cu | 3 ++ cpp/src/filling/sequence.cu | 3 ++ cpp/src/groupby/hash/groupby.cu | 7 +++- cpp/src/groupby/hash/groupby_kernels.cuh | 4 ++- cpp/src/groupby/sort/group_collect.cu | 5 +++ cpp/src/groupby/sort/group_correlation.cu | 4 ++- cpp/src/groupby/sort/group_count.cu | 5 ++- cpp/src/groupby/sort/group_merge_m2.cu | 7 +++- cpp/src/groupby/sort/group_nth_element.cu | 8 ++++- cpp/src/groupby/sort/group_nunique.cu | 3 ++ cpp/src/groupby/sort/group_quantiles.cu | 2 ++ cpp/src/groupby/sort/group_rank_scan.cu | 5 +++ cpp/src/groupby/sort/group_replace_nulls.cu | 5 ++- cpp/src/groupby/sort/group_scan_util.cuh | 4 ++- cpp/src/groupby/sort/group_std.cu | 3 ++ cpp/src/groupby/sort/sort_helper.cu | 6 +++- cpp/src/hash/hashing.cu | 1 + cpp/src/hash/md5_hash.cu | 1 + cpp/src/hash/unordered_multiset.cuh | 7 +++- cpp/src/interop/to_arrow.cu | 1 + cpp/src/io/avro/reader_impl.cu | 9 +++-- cpp/src/io/csv/csv_gpu.cu | 2 ++ cpp/src/io/csv/datetime.cuh | 9 ++--- cpp/src/io/csv/durations.cu | 6 +++- cpp/src/io/csv/reader_impl.cu | 2 ++ cpp/src/io/csv/writer_impl.cu | 2 ++ cpp/src/io/json/json_gpu.cu | 6 ++++ cpp/src/io/json/reader_impl.cu | 10 +++++- cpp/src/io/orc/orc.h | 2 ++ cpp/src/io/orc/reader_impl.cu | 10 ++++++ cpp/src/io/orc/stripe_enc.cu | 7 +++- cpp/src/io/orc/writer_impl.cu | 11 ++++++ cpp/src/io/orc/writer_impl.hpp | 2 ++ cpp/src/io/parquet/page_data.cu | 6 ++++ cpp/src/io/parquet/page_enc.cu | 17 +++++++-- cpp/src/io/parquet/reader_impl.cu | 5 +++ cpp/src/io/parquet/writer_impl.cu | 4 +++ .../io/statistics/typed_statistics_chunk.cuh | 4 ++- cpp/src/io/text/multibyte_split.cu | 1 + cpp/src/io/utilities/column_buffer.hpp | 2 ++ cpp/src/io/utilities/parsing_utils.cuh | 3 ++ cpp/src/join/hash_join.cu | 10 ++++-- cpp/src/join/hash_join.cuh | 1 + cpp/src/join/join_utils.cu | 5 ++- cpp/src/join/mixed_join.cu | 3 ++ cpp/src/join/mixed_join_semi.cu | 4 +++ cpp/src/join/semi_join.cu | 3 +- cpp/src/labeling/label_bins.cu | 3 +- .../combine/concatenate_list_elements.cu | 7 +++- cpp/src/lists/combine/concatenate_rows.cu | 3 +- cpp/src/lists/contains.cu | 13 +++++++ cpp/src/lists/copying/concatenate.cu | 4 ++- cpp/src/lists/copying/copying.cu | 3 +- cpp/src/lists/copying/gather.cu | 6 +++- cpp/src/lists/copying/scatter_helper.cu | 7 +++- cpp/src/lists/copying/segmented_gather.cu | 3 +- cpp/src/lists/count_elements.cu | 3 +- cpp/src/lists/drop_list_duplicates.cu | 6 ++++ cpp/src/lists/explode.cu | 8 ++++- cpp/src/lists/extract.cu | 1 + cpp/src/lists/interleave_columns.cu | 7 +++- cpp/src/lists/segmented_sort.cu | 4 ++- cpp/src/lists/sequences.cu | 5 ++- cpp/src/merge/merge.cu | 4 ++- cpp/src/partitioning/partitioning.cu | 6 +++- cpp/src/partitioning/round_robin.cu | 5 ++- cpp/src/quantiles/quantile.cu | 3 ++ cpp/src/quantiles/quantiles.cu | 5 ++- cpp/src/quantiles/tdigest/tdigest.cu | 9 +++++ .../quantiles/tdigest/tdigest_aggregation.cu | 18 ++++++++-- cpp/src/reductions/all.cu | 5 +++ cpp/src/reductions/any.cu | 5 +++ cpp/src/reductions/compound.cuh | 2 ++ cpp/src/reductions/minmax.cu | 7 +++- cpp/src/reductions/nth_element.cu | 4 ++- cpp/src/reductions/scan/rank_scan.cu | 1 + cpp/src/reductions/scan/scan_inclusive.cu | 3 ++ cpp/src/reductions/simple.cuh | 2 ++ cpp/src/reductions/struct_minmax_util.cuh | 3 ++ cpp/src/replace/clamp.cu | 8 ++++- cpp/src/replace/nans.cu | 2 ++ cpp/src/replace/nulls.cu | 2 ++ cpp/src/replace/replace.cu | 6 +++- cpp/src/reshape/byte_cast.cu | 5 +++ cpp/src/reshape/interleave_columns.cu | 5 +++ cpp/src/rolling/grouped_rolling.cu | 10 +++++- cpp/src/rolling/lead_lag_nested_detail.cuh | 5 ++- cpp/src/rolling/rolling.cu | 5 ++- cpp/src/rolling/rolling_collect_list.cu | 8 ++++- cpp/src/rolling/rolling_collect_list.cuh | 5 ++- cpp/src/rolling/rolling_detail.cuh | 1 + cpp/src/round/round.cu | 4 ++- cpp/src/scalar/scalar.cpp | 4 ++- cpp/src/search/search.cu | 5 +++ cpp/src/sort/is_sorted.cu | 3 +- cpp/src/sort/rank.cu | 11 +++++- cpp/src/sort/sort.cu | 2 ++ cpp/src/sort/sort_column.cu | 4 +++ cpp/src/sort/sort_impl.cuh | 1 + cpp/src/sort/stable_sort_column.cu | 3 ++ cpp/src/stream_compaction/distinct.cu | 2 ++ cpp/src/stream_compaction/distinct_count.cu | 1 + cpp/src/stream_compaction/drop_nans.cu | 2 ++ cpp/src/stream_compaction/drop_nulls.cu | 4 ++- .../stream_compaction_common.cuh | 1 + cpp/src/stream_compaction/unique.cu | 2 ++ cpp/src/stream_compaction/unique_count.cu | 1 + cpp/src/strings/attributes.cu | 6 +++- cpp/src/strings/capitalize.cu | 6 +++- cpp/src/strings/char_types/char_types.cu | 4 ++- cpp/src/strings/combine/concatenate.cu | 4 ++- cpp/src/strings/combine/join.cu | 5 ++- cpp/src/strings/combine/join_list_elements.cu | 4 ++- cpp/src/strings/contains.cu | 1 + cpp/src/strings/convert/convert_booleans.cu | 3 +- cpp/src/strings/convert/convert_datetime.cu | 7 +++- cpp/src/strings/convert/convert_durations.cu | 8 ++++- .../strings/convert/convert_fixed_point.cu | 5 ++- cpp/src/strings/convert/convert_floats.cu | 3 ++ cpp/src/strings/convert/convert_hex.cu | 2 ++ cpp/src/strings/convert/convert_integers.cu | 3 ++ cpp/src/strings/convert/convert_ipv4.cu | 5 ++- cpp/src/strings/convert/convert_urls.cu | 4 ++- cpp/src/strings/copying/concatenate.cu | 5 ++- cpp/src/strings/copying/copying.cu | 4 ++- cpp/src/strings/count_matches.cu | 1 + cpp/src/strings/extract/extract.cu | 6 ++++ cpp/src/strings/extract/extract_all.cu | 2 ++ cpp/src/strings/filling/fill.cu | 6 +++- cpp/src/strings/filter_chars.cu | 5 ++- cpp/src/strings/json/json_path.cu | 5 ++- cpp/src/strings/padding.cu | 6 +++- cpp/src/strings/regex/regex.inl | 2 ++ cpp/src/strings/repeat_strings.cu | 5 ++- cpp/src/strings/replace/backref_re.cuh | 6 +++- cpp/src/strings/replace/multi_re.cu | 3 ++ cpp/src/strings/replace/replace.cu | 8 ++++- cpp/src/strings/search/find.cu | 3 +- cpp/src/strings/search/find_multiple.cu | 1 + cpp/src/strings/search/findall.cu | 3 ++ cpp/src/strings/search/findall_record.cu | 3 ++ cpp/src/strings/split/partition.cu | 6 +++- cpp/src/strings/split/split.cu | 17 +++++---- cpp/src/strings/split/split_re.cu | 5 +++ cpp/src/strings/split/split_record.cu | 5 ++- cpp/src/strings/split/split_utils.cuh | 4 ++- cpp/src/strings/strings_column_factories.cu | 5 ++- cpp/src/strings/strip.cu | 3 +- cpp/src/strings/substring.cu | 5 ++- cpp/src/strings/translate.cu | 5 ++- cpp/src/strings/utilities.cu | 4 ++- cpp/src/strings/wrap.cu | 5 ++- cpp/src/structs/utilities.cpp | 3 +- cpp/src/table/table_view.cpp | 2 ++ cpp/src/text/detokenize.cu | 5 ++- cpp/src/text/edit_distance.cu | 7 +++- cpp/src/text/generate_ngrams.cu | 6 +++- cpp/src/text/ngrams_tokenize.cu | 5 ++- cpp/src/text/normalize.cu | 2 ++ cpp/src/text/replace.cu | 6 +++- cpp/src/text/stemmer.cu | 4 ++- cpp/src/text/subword/bpe_tokenizer.cu | 7 ++++ cpp/src/text/subword/data_normalizer.cu | 4 +++ cpp/src/text/subword/load_hash_file.cu | 2 ++ cpp/src/text/subword/load_merges_file.cu | 2 ++ cpp/src/text/subword/subword_tokenize.cu | 2 ++ cpp/src/text/subword/wordpiece_tokenizer.cu | 5 +++ cpp/src/text/tokenize.cu | 6 +++- cpp/src/text/utilities/tokenize_ops.cuh | 5 ++- cpp/src/transform/mask_to_bools.cu | 3 +- cpp/src/transform/nans_to_nulls.cu | 2 ++ cpp/src/transform/row_bit_count.cu | 3 +- cpp/src/transpose/transpose.cu | 5 ++- cpp/src/unary/cast_ops.cu | 2 ++ cpp/src/unary/math_ops.cu | 2 ++ cpp/src/unary/null_ops.cu | 4 ++- cpp/src/unary/unary_ops.cuh | 4 ++- cpp/tests/ast/transform_tests.cpp | 4 ++- .../binop-compiled-fixed_point-test.cpp | 2 ++ cpp/tests/binaryop/binop-compiled-test.cpp | 2 ++ cpp/tests/bitmask/set_nullmask_tests.cu | 4 ++- cpp/tests/bitmask/valid_if_tests.cu | 4 ++- cpp/tests/column/column_device_view_test.cu | 4 ++- cpp/tests/column/column_test.cu | 6 ++-- cpp/tests/column/compound_test.cu | 3 +- cpp/tests/column/factories_test.cpp | 4 ++- cpp/tests/copying/concatenate_tests.cu | 2 ++ cpp/tests/copying/copy_range_tests.cpp | 3 +- cpp/tests/copying/copy_tests.cpp | 3 ++ cpp/tests/copying/detail_gather_tests.cu | 5 ++- cpp/tests/copying/get_value_tests.cpp | 4 ++- cpp/tests/copying/reverse_tests.cpp | 4 ++- cpp/tests/copying/split_tests.cpp | 3 ++ cpp/tests/copying/utility_tests.cpp | 5 ++- cpp/tests/datetime/datetime_ops_test.cpp | 4 ++- .../device_atomics/device_atomics_test.cu | 2 ++ cpp/tests/dictionary/factories_test.cpp | 4 ++- cpp/tests/dictionary/remove_keys_test.cpp | 4 ++- cpp/tests/dictionary/set_keys_test.cpp | 4 ++- cpp/tests/groupby/tdigest_tests.cu | 2 ++ cpp/tests/hash_map/map_test.cu | 4 ++- cpp/tests/hash_map/multimap_test.cu | 4 ++- cpp/tests/interop/dlpack_test.cpp | 2 ++ cpp/tests/interop/to_arrow_test.cpp | 2 ++ cpp/tests/io/parquet_test.cpp | 2 ++ cpp/tests/iterator/indexalator_test.cu | 6 +++- cpp/tests/iterator/iterator_tests.cuh | 5 ++- cpp/tests/iterator/optional_iterator_test.cuh | 5 ++- .../optional_iterator_test_numeric.cu | 6 +++- cpp/tests/iterator/pair_iterator_test.cuh | 5 ++- .../iterator/pair_iterator_test_numeric.cu | 6 +++- cpp/tests/iterator/scalar_iterator_test.cu | 5 ++- cpp/tests/iterator/value_iterator_test.cuh | 4 ++- .../iterator/value_iterator_test_strings.cu | 6 +++- .../iterator/value_iterator_test_transform.cu | 6 +++- cpp/tests/join/conditional_join_tests.cu | 3 +- cpp/tests/lists/count_elements_tests.cpp | 5 ++- cpp/tests/lists/extract_tests.cpp | 4 ++- cpp/tests/merge/merge_test.cpp | 35 ++++++++++--------- .../partitioning/hash_partition_test.cpp | 5 ++- cpp/tests/quantiles/percentile_approx_test.cu | 4 +++ cpp/tests/quantiles/tdigest_utilities.cu | 5 +++ cpp/tests/reductions/rank_tests.cpp | 2 ++ cpp/tests/reductions/scan_tests.cpp | 2 ++ .../reductions/segmented_reduction_tests.cpp | 2 ++ cpp/tests/replace/clamp_test.cpp | 4 ++- cpp/tests/replace/replace_nulls_tests.cpp | 3 +- cpp/tests/replace/replace_tests.cpp | 3 +- cpp/tests/rolling/collect_ops_test.cpp | 3 +- cpp/tests/rolling/grouped_rolling_test.cpp | 4 ++- .../rolling/range_rolling_window_test.cpp | 4 ++- cpp/tests/rolling/rolling_test.cpp | 1 + cpp/tests/search/search_test.cpp | 4 ++- cpp/tests/sort/rank_test.cpp | 5 ++- cpp/tests/sort/sort_test.cpp | 3 ++ cpp/tests/sort/stable_sort_tests.cpp | 3 ++ .../apply_boolean_mask_tests.cpp | 5 ++- cpp/tests/strings/array_tests.cpp | 3 +- cpp/tests/strings/contains_tests.cpp | 4 +++ cpp/tests/strings/datetime_tests.cpp | 6 ++-- cpp/tests/strings/extract_tests.cpp | 2 ++ cpp/tests/strings/factories_test.cu | 4 ++- cpp/tests/strings/fill_tests.cpp | 4 ++- cpp/tests/strings/find_multiple_tests.cpp | 2 ++ cpp/tests/strings/find_tests.cpp | 4 ++- cpp/tests/strings/findall_tests.cpp | 2 ++ cpp/tests/strings/floats_tests.cpp | 4 ++- cpp/tests/strings/integers_tests.cpp | 5 ++- cpp/tests/strings/ipv4_tests.cpp | 4 ++- cpp/tests/strings/pad_tests.cpp | 4 ++- cpp/tests/strings/replace_regex_tests.cpp | 2 ++ cpp/tests/strings/replace_tests.cpp | 5 ++- cpp/tests/strings/split_tests.cpp | 2 ++ cpp/tests/strings/strip_tests.cpp | 4 ++- cpp/tests/strings/substring_tests.cpp | 7 ++-- cpp/tests/strings/translate_tests.cpp | 4 ++- cpp/tests/strings/urls_tests.cpp | 4 ++- cpp/tests/table/table_view_tests.cu | 5 ++- cpp/tests/text/edit_distance_tests.cpp | 4 ++- cpp/tests/text/ngrams_tests.cpp | 4 ++- cpp/tests/text/ngrams_tokenize_tests.cpp | 4 ++- cpp/tests/text/normalize_tests.cpp | 4 ++- cpp/tests/text/replace_tests.cpp | 4 ++- cpp/tests/text/stemmer_tests.cpp | 4 ++- cpp/tests/text/tokenize_tests.cpp | 4 ++- cpp/tests/transform/bools_to_mask_test.cpp | 4 ++- cpp/tests/transform/row_bit_count_test.cu | 6 +++- cpp/tests/unary/cast_tests.cpp | 3 ++ cpp/tests/unary/unary_ops_test.cpp | 4 ++- cpp/tests/utilities/column_utilities.cu | 8 +++++ .../column_utilities_tests.cpp | 3 +- cpp/tests/utilities_tests/span_tests.cu | 3 ++ cpp/tests/wrappers/timestamps_test.cu | 3 ++ .../test/java/ai/rapids/cudf/TableTest.java | 16 ++++----- 341 files changed, 1259 insertions(+), 245 deletions(-) diff --git a/cpp/benchmarks/column/concatenate.cpp b/cpp/benchmarks/column/concatenate.cpp index 89f5fcb27a6..21e5db8ca8f 100644 --- a/cpp/benchmarks/column/concatenate.cpp +++ b/cpp/benchmarks/column/concatenate.cpp @@ -24,6 +24,8 @@ #include #include +#include +#include #include #include diff --git a/cpp/benchmarks/common/generate_input.cu b/cpp/benchmarks/common/generate_input.cu index 460483e37a4..3af64b0945a 100644 --- a/cpp/benchmarks/common/generate_input.cu +++ b/cpp/benchmarks/common/generate_input.cu @@ -43,9 +43,13 @@ #include #include #include +#include #include +#include #include #include +#include +#include #include #include diff --git a/cpp/benchmarks/copying/contiguous_split.cu b/cpp/benchmarks/copying/contiguous_split.cu index 9f691e903f7..6b129a4a435 100644 --- a/cpp/benchmarks/copying/contiguous_split.cu +++ b/cpp/benchmarks/copying/contiguous_split.cu @@ -22,6 +22,8 @@ #include #include +#include + template void BM_contiguous_split_common(benchmark::State& state, std::vector& src_cols, diff --git a/cpp/benchmarks/copying/gather.cu b/cpp/benchmarks/copying/gather.cu index 1dd4cefb338..29d625ae9d3 100644 --- a/cpp/benchmarks/copying/gather.cu +++ b/cpp/benchmarks/copying/gather.cu @@ -21,6 +21,8 @@ #include #include +#include +#include #include #include diff --git a/cpp/benchmarks/copying/scatter.cu b/cpp/benchmarks/copying/scatter.cu index 977937beaa2..d4bd852cbb3 100644 --- a/cpp/benchmarks/copying/scatter.cu +++ b/cpp/benchmarks/copying/scatter.cu @@ -21,6 +21,8 @@ #include #include +#include +#include #include #include diff --git a/cpp/benchmarks/io/text/multibyte_split.cpp b/cpp/benchmarks/io/text/multibyte_split.cpp index 8c4b10d928d..ada8856e8e5 100644 --- a/cpp/benchmarks/io/text/multibyte_split.cpp +++ b/cpp/benchmarks/io/text/multibyte_split.cpp @@ -31,6 +31,7 @@ #include +#include #include #include diff --git a/cpp/benchmarks/iterator/iterator.cu b/cpp/benchmarks/iterator/iterator.cu index b4bb99abdde..595775ddf00 100644 --- a/cpp/benchmarks/iterator/iterator.cu +++ b/cpp/benchmarks/iterator/iterator.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -26,6 +26,11 @@ #include +#include +#include +#include +#include + #include #include diff --git a/cpp/benchmarks/join/join_common.hpp b/cpp/benchmarks/join/join_common.hpp index c1957db7929..27339248968 100644 --- a/cpp/benchmarks/join/join_common.hpp +++ b/cpp/benchmarks/join/join_common.hpp @@ -34,6 +34,7 @@ #include +#include #include #include #include diff --git a/cpp/benchmarks/quantiles/quantiles.cpp b/cpp/benchmarks/quantiles/quantiles.cpp index cc7dfa08c59..16e8abd4a57 100644 --- a/cpp/benchmarks/quantiles/quantiles.cpp +++ b/cpp/benchmarks/quantiles/quantiles.cpp @@ -20,6 +20,7 @@ #include +#include #include class Quantiles : public cudf::benchmark { diff --git a/cpp/benchmarks/string/copy.cu b/cpp/benchmarks/string/copy.cu index 00eb818256c..a8f9eb111fc 100644 --- a/cpp/benchmarks/string/copy.cu +++ b/cpp/benchmarks/string/copy.cu @@ -24,6 +24,9 @@ #include #include +#include +#include +#include #include class StringCopy : public cudf::benchmark { diff --git a/cpp/benchmarks/string/factory.cu b/cpp/benchmarks/string/factory.cu index 47356af129e..2e0bf4afb36 100644 --- a/cpp/benchmarks/string/factory.cu +++ b/cpp/benchmarks/string/factory.cu @@ -29,6 +29,7 @@ #include #include +#include #include #include diff --git a/cpp/benchmarks/string/url_decode.cu b/cpp/benchmarks/string/url_decode.cu index c460820d788..7971d44536d 100644 --- a/cpp/benchmarks/string/url_decode.cu +++ b/cpp/benchmarks/string/url_decode.cu @@ -32,7 +32,9 @@ #include #include #include +#include #include +#include struct url_string_generator { char* chars; diff --git a/cpp/cmake/thirdparty/get_thrust.cmake b/cpp/cmake/thirdparty/get_thrust.cmake index fcf9f0d73ee..295617c9996 100644 --- a/cpp/cmake/thirdparty/get_thrust.cmake +++ b/cpp/cmake/thirdparty/get_thrust.cmake @@ -1,5 +1,5 @@ # ============================================================================= -# Copyright (c) 2020-2021, NVIDIA CORPORATION. +# Copyright (c) 2020-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 @@ -80,6 +80,6 @@ function(find_and_configure_thrust VERSION) endif() endfunction() -set(CUDF_MIN_VERSION_Thrust 1.15.0) +set(CUDF_MIN_VERSION_Thrust 1.16.0) find_and_configure_thrust(${CUDF_MIN_VERSION_Thrust}) diff --git a/cpp/include/cudf/ast/detail/expression_parser.hpp b/cpp/include/cudf/ast/detail/expression_parser.hpp index 0b54dc7e4f0..ace60b70bf9 100644 --- a/cpp/include/cudf/ast/detail/expression_parser.hpp +++ b/cpp/include/cudf/ast/detail/expression_parser.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -21,6 +21,7 @@ #include #include +#include #include #include diff --git a/cpp/include/cudf/column/column_device_view.cuh b/cpp/include/cudf/column/column_device_view.cuh index 3ee73282438..ec3795238b0 100644 --- a/cpp/include/cudf/column/column_device_view.cuh +++ b/cpp/include/cudf/column/column_device_view.cuh @@ -33,6 +33,7 @@ #include #include #include +#include #include diff --git a/cpp/include/cudf/column/column_factories.hpp b/cpp/include/cudf/column/column_factories.hpp index 5e89e1c7baf..312ea0f5f8d 100644 --- a/cpp/include/cudf/column/column_factories.hpp +++ b/cpp/include/cudf/column/column_factories.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -22,6 +22,8 @@ #include +#include + namespace cudf { /** * @addtogroup column_factories diff --git a/cpp/include/cudf/detail/aggregation/aggregation.cuh b/cpp/include/cudf/detail/aggregation/aggregation.cuh index 02121957184..818e8cd7cc6 100644 --- a/cpp/include/cudf/detail/aggregation/aggregation.cuh +++ b/cpp/include/cudf/detail/aggregation/aggregation.cuh @@ -28,6 +28,8 @@ #include #include +#include + namespace cudf { namespace detail { /** diff --git a/cpp/include/cudf/detail/calendrical_month_sequence.cuh b/cpp/include/cudf/detail/calendrical_month_sequence.cuh index 321cc3d19ef..9dba0ba8961 100644 --- a/cpp/include/cudf/detail/calendrical_month_sequence.cuh +++ b/cpp/include/cudf/detail/calendrical_month_sequence.cuh @@ -26,6 +26,9 @@ #include #include +#include +#include + namespace cudf { namespace detail { struct calendrical_month_sequence_functor { diff --git a/cpp/include/cudf/detail/copy_if.cuh b/cpp/include/cudf/detail/copy_if.cuh index fb4c636fcb0..0087dd1b173 100644 --- a/cpp/include/cudf/detail/copy_if.cuh +++ b/cpp/include/cudf/detail/copy_if.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -38,6 +38,9 @@ #include #include +#include +#include + #include #include diff --git a/cpp/include/cudf/detail/copy_if_else.cuh b/cpp/include/cudf/detail/copy_if_else.cuh index 83c3b89717e..233fbd1d601 100644 --- a/cpp/include/cudf/detail/copy_if_else.cuh +++ b/cpp/include/cudf/detail/copy_if_else.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -24,6 +24,9 @@ #include +#include +#include + namespace cudf { namespace detail { namespace { // anonymous diff --git a/cpp/include/cudf/detail/gather.cuh b/cpp/include/cudf/detail/gather.cuh index 08dbdb6f1a0..63a62beca58 100644 --- a/cpp/include/cudf/detail/gather.cuh +++ b/cpp/include/cudf/detail/gather.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -43,6 +43,7 @@ #include #include #include +#include #include #include diff --git a/cpp/include/cudf/detail/indexalator.cuh b/cpp/include/cudf/detail/indexalator.cuh index a63faa40e1d..3657d700397 100644 --- a/cpp/include/cudf/detail/indexalator.cuh +++ b/cpp/include/cudf/detail/indexalator.cuh @@ -21,7 +21,12 @@ #include #include +#include +#include +#include #include +#include +#include namespace cudf { namespace detail { diff --git a/cpp/include/cudf/detail/iterator.cuh b/cpp/include/cudf/detail/iterator.cuh index 10d9cda55dd..4442af8fab1 100644 --- a/cpp/include/cudf/detail/iterator.cuh +++ b/cpp/include/cudf/detail/iterator.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -40,6 +40,8 @@ #include #include #include +#include +#include #include diff --git a/cpp/include/cudf/detail/merge.cuh b/cpp/include/cudf/detail/merge.cuh index 1debef17db7..e8e9b080a92 100644 --- a/cpp/include/cudf/detail/merge.cuh +++ b/cpp/include/cudf/detail/merge.cuh @@ -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. @@ -19,6 +19,10 @@ #include #include +#include +#include +#include + namespace cudf { namespace detail { /** diff --git a/cpp/include/cudf/detail/null_mask.cuh b/cpp/include/cudf/detail/null_mask.cuh index 78eaa4f2448..be010689847 100644 --- a/cpp/include/cudf/detail/null_mask.cuh +++ b/cpp/include/cudf/detail/null_mask.cuh @@ -34,6 +34,8 @@ #include #include #include +#include +#include #include #include diff --git a/cpp/include/cudf/detail/replace/nulls.cuh b/cpp/include/cudf/detail/replace/nulls.cuh index 88c10959dfb..d691ef5ce8e 100644 --- a/cpp/include/cudf/detail/replace/nulls.cuh +++ b/cpp/include/cudf/detail/replace/nulls.cuh @@ -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. @@ -18,6 +18,7 @@ #include #include +#include namespace cudf { namespace detail { diff --git a/cpp/include/cudf/detail/scatter.cuh b/cpp/include/cudf/detail/scatter.cuh index ec9078a4380..c80086a27f8 100644 --- a/cpp/include/cudf/detail/scatter.cuh +++ b/cpp/include/cudf/detail/scatter.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -33,6 +33,14 @@ #include #include +#include +#include +#include +#include +#include +#include +#include +#include #include namespace cudf { diff --git a/cpp/include/cudf/detail/unary.hpp b/cpp/include/cudf/detail/unary.hpp index e672cf01488..4219cd16bdd 100644 --- a/cpp/include/cudf/detail/unary.hpp +++ b/cpp/include/cudf/detail/unary.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2019, 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. @@ -22,6 +22,8 @@ #include #include +#include + namespace cudf { namespace detail { /** diff --git a/cpp/include/cudf/detail/utilities/hash_functions.cuh b/cpp/include/cudf/detail/utilities/hash_functions.cuh index 264c80f223c..09d94d10e79 100644 --- a/cpp/include/cudf/detail/utilities/hash_functions.cuh +++ b/cpp/include/cudf/detail/utilities/hash_functions.cuh @@ -25,7 +25,11 @@ #include #include +#include +#include #include +#include +#include using hash_value_type = uint32_t; diff --git a/cpp/include/cudf/detail/utilities/vector_factories.hpp b/cpp/include/cudf/detail/utilities/vector_factories.hpp index 2e8b4601062..e3f44ce0bee 100644 --- a/cpp/include/cudf/detail/utilities/vector_factories.hpp +++ b/cpp/include/cudf/detail/utilities/vector_factories.hpp @@ -28,6 +28,8 @@ #include #include +#include + #include namespace cudf { diff --git a/cpp/include/cudf/dictionary/detail/iterator.cuh b/cpp/include/cudf/dictionary/detail/iterator.cuh index 3f80d56ada9..58757d5e7c5 100644 --- a/cpp/include/cudf/dictionary/detail/iterator.cuh +++ b/cpp/include/cudf/dictionary/detail/iterator.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -18,6 +18,8 @@ #include #include +#include + namespace cudf { namespace dictionary { namespace detail { diff --git a/cpp/include/cudf/lists/detail/gather.cuh b/cpp/include/cudf/lists/detail/gather.cuh index 7c2979c56cd..c637ad041ba 100644 --- a/cpp/include/cudf/lists/detail/gather.cuh +++ b/cpp/include/cudf/lists/detail/gather.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -23,6 +23,9 @@ #include #include +#include +#include +#include #include namespace cudf { diff --git a/cpp/include/cudf/lists/detail/scatter.cuh b/cpp/include/cudf/lists/detail/scatter.cuh index 94b0e830b15..4d3f9cce963 100644 --- a/cpp/include/cudf/lists/detail/scatter.cuh +++ b/cpp/include/cudf/lists/detail/scatter.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -30,6 +30,14 @@ #include #include +#include +#include +#include +#include +#include +#include +#include + #include namespace cudf { diff --git a/cpp/include/cudf/lists/list_device_view.cuh b/cpp/include/cudf/lists/list_device_view.cuh index e4803f98e68..ae0a247f005 100644 --- a/cpp/include/cudf/lists/list_device_view.cuh +++ b/cpp/include/cudf/lists/list_device_view.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -20,6 +20,9 @@ #include #include +#include +#include + namespace cudf { /** diff --git a/cpp/include/cudf/strings/detail/copy_if_else.cuh b/cpp/include/cudf/strings/detail/copy_if_else.cuh index f2fc1889c4e..79cec779e02 100644 --- a/cpp/include/cudf/strings/detail/copy_if_else.cuh +++ b/cpp/include/cudf/strings/detail/copy_if_else.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -25,6 +25,11 @@ #include #include +#include +#include +#include +#include + namespace cudf { namespace strings { namespace detail { diff --git a/cpp/include/cudf/strings/detail/copy_range.cuh b/cpp/include/cudf/strings/detail/copy_range.cuh index 05dbdf18b64..e83f6dc0005 100644 --- a/cpp/include/cudf/strings/detail/copy_range.cuh +++ b/cpp/include/cudf/strings/detail/copy_range.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -27,6 +27,7 @@ #include #include +#include #include #include #include diff --git a/cpp/include/cudf/strings/detail/gather.cuh b/cpp/include/cudf/strings/detail/gather.cuh index eb7258830ce..1b10c70d6d6 100644 --- a/cpp/include/cudf/strings/detail/gather.cuh +++ b/cpp/include/cudf/strings/detail/gather.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -28,8 +28,12 @@ #include #include +#include +#include #include +#include #include +#include namespace cudf { namespace strings { diff --git a/cpp/include/cudf/strings/detail/merge.cuh b/cpp/include/cudf/strings/detail/merge.cuh index dba1c24be93..207c9e9cd9f 100644 --- a/cpp/include/cudf/strings/detail/merge.cuh +++ b/cpp/include/cudf/strings/detail/merge.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -26,6 +26,11 @@ #include #include +#include +#include +#include +#include + namespace cudf { namespace strings { namespace detail { diff --git a/cpp/include/cudf/strings/detail/scatter.cuh b/cpp/include/cudf/strings/detail/scatter.cuh index d1b16a5fe03..b6aa22cc316 100644 --- a/cpp/include/cudf/strings/detail/scatter.cuh +++ b/cpp/include/cudf/strings/detail/scatter.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -25,6 +25,8 @@ #include #include +#include + namespace cudf { namespace strings { namespace detail { diff --git a/cpp/include/cudf/strings/detail/strings_column_factories.cuh b/cpp/include/cudf/strings/detail/strings_column_factories.cuh index 9da3c6b0e91..4ffe12ba937 100644 --- a/cpp/include/cudf/strings/detail/strings_column_factories.cuh +++ b/cpp/include/cudf/strings/detail/strings_column_factories.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -26,8 +26,15 @@ #include #include +#include #include +#include +#include +#include +#include +#include #include +#include namespace cudf { namespace strings { diff --git a/cpp/include/cudf/strings/detail/utilities.cuh b/cpp/include/cudf/strings/detail/utilities.cuh index efd03d882e6..4b036fb7f0e 100644 --- a/cpp/include/cudf/strings/detail/utilities.cuh +++ b/cpp/include/cudf/strings/detail/utilities.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -24,6 +24,9 @@ #include #include +#include +#include +#include #include #include diff --git a/cpp/include/cudf/strings/string.cuh b/cpp/include/cudf/strings/string.cuh index a215a3f36c0..0cfcaeb913e 100644 --- a/cpp/include/cudf/strings/string.cuh +++ b/cpp/include/cudf/strings/string.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -16,6 +16,9 @@ #pragma once #include + +#include +#include #include namespace cudf { diff --git a/cpp/include/cudf/strings/string_view.cuh b/cpp/include/cudf/strings/string_view.cuh index 9ef361d6519..27ee5cf95cd 100644 --- a/cpp/include/cudf/strings/string_view.cuh +++ b/cpp/include/cudf/strings/string_view.cuh @@ -27,6 +27,7 @@ // or jitify2 source file. The jitify cannot include thrust headers at this time. #ifndef CUDF_JIT_UDF #include +#include #endif // This file should only include device code logic. diff --git a/cpp/include/cudf/table/row_operators.cuh b/cpp/include/cudf/table/row_operators.cuh index 20845818b0f..4eca03a800c 100644 --- a/cpp/include/cudf/table/row_operators.cuh +++ b/cpp/include/cudf/table/row_operators.cuh @@ -26,6 +26,8 @@ #include #include +#include +#include #include #include diff --git a/cpp/include/cudf/utilities/span.hpp b/cpp/include/cudf/utilities/span.hpp index 1172a5a68cd..f2686927cf7 100644 --- a/cpp/include/cudf/utilities/span.hpp +++ b/cpp/include/cudf/utilities/span.hpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include diff --git a/cpp/include/cudf_test/column_utilities.hpp b/cpp/include/cudf_test/column_utilities.hpp index cd96748f081..4c2d4d429eb 100644 --- a/cpp/include/cudf_test/column_utilities.hpp +++ b/cpp/include/cudf_test/column_utilities.hpp @@ -24,6 +24,7 @@ #include #include +#include #include namespace cudf { diff --git a/cpp/include/cudf_test/column_wrapper.hpp b/cpp/include/cudf_test/column_wrapper.hpp index 4005a4f9adc..8a5d4e5efcc 100644 --- a/cpp/include/cudf_test/column_wrapper.hpp +++ b/cpp/include/cudf_test/column_wrapper.hpp @@ -37,6 +37,8 @@ #include #include +#include +#include #include #include #include diff --git a/cpp/include/cudf_test/iterator_utilities.hpp b/cpp/include/cudf_test/iterator_utilities.hpp index 28799b07542..c2c6b3ae83d 100644 --- a/cpp/include/cudf_test/iterator_utilities.hpp +++ b/cpp/include/cudf_test/iterator_utilities.hpp @@ -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. @@ -19,6 +19,7 @@ #include #include +#include #include #include diff --git a/cpp/include/cudf_test/tdigest_utilities.cuh b/cpp/include/cudf_test/tdigest_utilities.cuh index 84e3feb82ed..657a1707629 100644 --- a/cpp/include/cudf_test/tdigest_utilities.cuh +++ b/cpp/include/cudf_test/tdigest_utilities.cuh @@ -25,7 +25,13 @@ #include +#include +#include #include +#include +#include +#include +#include #include @@ -496,4 +502,4 @@ void tdigest_merge_empty(MergeFunc merge_op) } } // namespace test -} // namespace cudf \ No newline at end of file +} // namespace cudf diff --git a/cpp/src/binaryop/compiled/binary_ops.cu b/cpp/src/binaryop/compiled/binary_ops.cu index c4538379836..c01359b80d0 100644 --- a/cpp/src/binaryop/compiled/binary_ops.cu +++ b/cpp/src/binaryop/compiled/binary_ops.cu @@ -26,6 +26,11 @@ #include #include +#include +#include +#include +#include + namespace cudf { namespace binops { namespace compiled { diff --git a/cpp/src/column/column_device_view.cu b/cpp/src/column/column_device_view.cu index 7c5d39c6f38..dd1803f4b90 100644 --- a/cpp/src/column/column_device_view.cu +++ b/cpp/src/column/column_device_view.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -21,6 +21,9 @@ #include +#include +#include + #include namespace cudf { diff --git a/cpp/src/column/column_factories.cu b/cpp/src/column/column_factories.cu index 6b74b37044b..90252fd6cf1 100644 --- a/cpp/src/column/column_factories.cu +++ b/cpp/src/column/column_factories.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. @@ -22,6 +22,8 @@ #include #include +#include + namespace cudf { namespace { diff --git a/cpp/src/copying/concatenate.cu b/cpp/src/copying/concatenate.cu index 82e189b5a36..8e9f505307c 100644 --- a/cpp/src/copying/concatenate.cu +++ b/cpp/src/copying/concatenate.cu @@ -33,7 +33,13 @@ #include #include +#include #include +#include +#include +#include +#include +#include #include #include diff --git a/cpp/src/copying/contiguous_split.cu b/cpp/src/copying/contiguous_split.cu index 7028ce36fc8..46470e69611 100644 --- a/cpp/src/copying/contiguous_split.cu +++ b/cpp/src/copying/contiguous_split.cu @@ -31,7 +31,17 @@ #include #include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include #include #include diff --git a/cpp/src/copying/copy.cu b/cpp/src/copying/copy.cu index 91fc5f02989..66656492f14 100644 --- a/cpp/src/copying/copy.cu +++ b/cpp/src/copying/copy.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -29,6 +29,10 @@ #include #include +#include +#include +#include + namespace cudf { namespace detail { namespace { diff --git a/cpp/src/copying/gather.cu b/cpp/src/copying/gather.cu index ac17c3b6ec9..99a440b5bb0 100644 --- a/cpp/src/copying/gather.cu +++ b/cpp/src/copying/gather.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2020, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -25,6 +25,8 @@ #include +#include + namespace cudf { namespace detail { diff --git a/cpp/src/copying/sample.cu b/cpp/src/copying/sample.cu index 3e0b27e9f19..0ed64fec57b 100644 --- a/cpp/src/copying/sample.cu +++ b/cpp/src/copying/sample.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -25,6 +25,7 @@ #include +#include #include #include #include diff --git a/cpp/src/copying/scatter.cu b/cpp/src/copying/scatter.cu index 98a90518bcb..61777c336fd 100644 --- a/cpp/src/copying/scatter.cu +++ b/cpp/src/copying/scatter.cu @@ -35,7 +35,11 @@ #include #include +#include #include +#include +#include +#include #include namespace cudf { diff --git a/cpp/src/copying/segmented_shift.cu b/cpp/src/copying/segmented_shift.cu index 6d3a005add0..dd2733cf7e9 100644 --- a/cpp/src/copying/segmented_shift.cu +++ b/cpp/src/copying/segmented_shift.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. @@ -26,6 +26,7 @@ #include #include +#include #include namespace cudf { diff --git a/cpp/src/copying/slice.cu b/cpp/src/copying/slice.cu index b2f05516e2c..ed77a8a0e7a 100644 --- a/cpp/src/copying/slice.cu +++ b/cpp/src/copying/slice.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -24,6 +24,8 @@ #include +#include + #include namespace cudf { diff --git a/cpp/src/datetime/datetime_ops.cu b/cpp/src/datetime/datetime_ops.cu index 1bac2df8d2b..866dae46327 100644 --- a/cpp/src/datetime/datetime_ops.cu +++ b/cpp/src/datetime/datetime_ops.cu @@ -36,6 +36,8 @@ #include #include +#include +#include namespace cudf { namespace datetime { diff --git a/cpp/src/dictionary/detail/concatenate.cu b/cpp/src/dictionary/detail/concatenate.cu index 055a20e4cfd..a9b2c21289a 100644 --- a/cpp/src/dictionary/detail/concatenate.cu +++ b/cpp/src/dictionary/detail/concatenate.cu @@ -32,6 +32,14 @@ #include #include +#include +#include +#include +#include +#include +#include +#include +#include #include #include diff --git a/cpp/src/dictionary/detail/merge.cu b/cpp/src/dictionary/detail/merge.cu index a194f4add2e..2fe21680873 100644 --- a/cpp/src/dictionary/detail/merge.cu +++ b/cpp/src/dictionary/detail/merge.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -26,6 +26,8 @@ #include #include +#include + namespace cudf { namespace dictionary { namespace detail { diff --git a/cpp/src/dictionary/remove_keys.cu b/cpp/src/dictionary/remove_keys.cu index 7e2a82a683c..c4b3bbc00e4 100644 --- a/cpp/src/dictionary/remove_keys.cu +++ b/cpp/src/dictionary/remove_keys.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -29,6 +29,8 @@ #include #include +#include +#include #include #include #include diff --git a/cpp/src/dictionary/search.cu b/cpp/src/dictionary/search.cu index 88e0de23290..fc7f1f05539 100644 --- a/cpp/src/dictionary/search.cu +++ b/cpp/src/dictionary/search.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -25,6 +25,7 @@ #include #include +#include #include namespace cudf { diff --git a/cpp/src/dictionary/set_keys.cu b/cpp/src/dictionary/set_keys.cu index a3bbbc37506..dfc6cbb78cc 100644 --- a/cpp/src/dictionary/set_keys.cu +++ b/cpp/src/dictionary/set_keys.cu @@ -32,9 +32,15 @@ #include #include +#include +#include +#include +#include +#include +#include + #include #include -#include namespace cudf { namespace dictionary { diff --git a/cpp/src/filling/fill.cu b/cpp/src/filling/fill.cu index 50f750e6416..8020284e4d7 100644 --- a/cpp/src/filling/fill.cu +++ b/cpp/src/filling/fill.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2020, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -36,6 +36,8 @@ #include #include +#include + #include namespace { diff --git a/cpp/src/filling/repeat.cu b/cpp/src/filling/repeat.cu index 188316d22cd..3e3fd597e59 100644 --- a/cpp/src/filling/repeat.cu +++ b/cpp/src/filling/repeat.cu @@ -34,10 +34,13 @@ #include #include +#include #include #include #include +#include #include +#include #include #include diff --git a/cpp/src/filling/sequence.cu b/cpp/src/filling/sequence.cu index e5bffcf21c1..45a4c590254 100644 --- a/cpp/src/filling/sequence.cu +++ b/cpp/src/filling/sequence.cu @@ -26,6 +26,9 @@ #include #include +#include +#include + namespace cudf { namespace detail { namespace { diff --git a/cpp/src/groupby/hash/groupby.cu b/cpp/src/groupby/hash/groupby.cu index 4f2cb4de14b..49ed0b7fc1d 100644 --- a/cpp/src/groupby/hash/groupby.cu +++ b/cpp/src/groupby/hash/groupby.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -48,6 +48,11 @@ #include +#include +#include +#include +#include + #include #include #include diff --git a/cpp/src/groupby/hash/groupby_kernels.cuh b/cpp/src/groupby/hash/groupby_kernels.cuh index 7238186b7d9..79286fb3839 100644 --- a/cpp/src/groupby/hash/groupby_kernels.cuh +++ b/cpp/src/groupby/hash/groupby_kernels.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -22,6 +22,8 @@ #include #include +#include + namespace cudf { namespace groupby { namespace detail { diff --git a/cpp/src/groupby/sort/group_collect.cu b/cpp/src/groupby/sort/group_collect.cu index 52cf4fe3bff..8b8a03f35a5 100644 --- a/cpp/src/groupby/sort/group_collect.cu +++ b/cpp/src/groupby/sort/group_collect.cu @@ -24,6 +24,11 @@ #include +#include +#include +#include +#include + #include namespace cudf { diff --git a/cpp/src/groupby/sort/group_correlation.cu b/cpp/src/groupby/sort/group_correlation.cu index 02b4f2af724..395d25caff0 100644 --- a/cpp/src/groupby/sort/group_correlation.cu +++ b/cpp/src/groupby/sort/group_correlation.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. @@ -30,6 +30,8 @@ #include #include #include +#include +#include #include diff --git a/cpp/src/groupby/sort/group_count.cu b/cpp/src/groupby/sort/group_count.cu index 6a2ff994b8b..e7274034f55 100644 --- a/cpp/src/groupby/sort/group_count.cu +++ b/cpp/src/groupby/sort/group_count.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -23,8 +23,11 @@ #include #include +#include #include #include +#include +#include namespace cudf { namespace groupby { diff --git a/cpp/src/groupby/sort/group_merge_m2.cu b/cpp/src/groupby/sort/group_merge_m2.cu index bde7c985df1..c87fa77a36d 100644 --- a/cpp/src/groupby/sort/group_merge_m2.cu +++ b/cpp/src/groupby/sort/group_merge_m2.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. @@ -26,8 +26,13 @@ #include #include +#include +#include #include +#include #include +#include +#include namespace cudf { namespace groupby { diff --git a/cpp/src/groupby/sort/group_nth_element.cu b/cpp/src/groupby/sort/group_nth_element.cu index 7e9bd4539ba..58d76a8ab43 100644 --- a/cpp/src/groupby/sort/group_nth_element.cu +++ b/cpp/src/groupby/sort/group_nth_element.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -29,6 +29,12 @@ #include #include +#include +#include +#include +#include +#include +#include #include namespace cudf { diff --git a/cpp/src/groupby/sort/group_nunique.cu b/cpp/src/groupby/sort/group_nunique.cu index 37d13d5aea3..478060cbd16 100644 --- a/cpp/src/groupby/sort/group_nunique.cu +++ b/cpp/src/groupby/sort/group_nunique.cu @@ -25,7 +25,10 @@ #include #include +#include #include +#include +#include namespace cudf { namespace groupby { diff --git a/cpp/src/groupby/sort/group_quantiles.cu b/cpp/src/groupby/sort/group_quantiles.cu index 86f35cb043a..31f0f7db107 100644 --- a/cpp/src/groupby/sort/group_quantiles.cu +++ b/cpp/src/groupby/sort/group_quantiles.cu @@ -30,7 +30,9 @@ #include #include +#include #include +#include namespace cudf { namespace groupby { diff --git a/cpp/src/groupby/sort/group_rank_scan.cu b/cpp/src/groupby/sort/group_rank_scan.cu index eae7d0b6129..77d68edaa3a 100644 --- a/cpp/src/groupby/sort/group_rank_scan.cu +++ b/cpp/src/groupby/sort/group_rank_scan.cu @@ -26,6 +26,11 @@ #include #include +#include +#include +#include +#include + namespace cudf { namespace groupby { namespace detail { diff --git a/cpp/src/groupby/sort/group_replace_nulls.cu b/cpp/src/groupby/sort/group_replace_nulls.cu index cb954eb7ce5..49557164230 100644 --- a/cpp/src/groupby/sort/group_replace_nulls.cu +++ b/cpp/src/groupby/sort/group_replace_nulls.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. @@ -26,6 +26,9 @@ #include #include #include +#include +#include +#include #include diff --git a/cpp/src/groupby/sort/group_scan_util.cuh b/cpp/src/groupby/sort/group_scan_util.cuh index 14e5195bb79..c90ee6dda2d 100644 --- a/cpp/src/groupby/sort/group_scan_util.cuh +++ b/cpp/src/groupby/sort/group_scan_util.cuh @@ -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. @@ -35,6 +35,8 @@ #include #include +#include +#include #include namespace cudf { diff --git a/cpp/src/groupby/sort/group_std.cu b/cpp/src/groupby/sort/group_std.cu index 4437e585d0d..87fd9f7e843 100644 --- a/cpp/src/groupby/sort/group_std.cu +++ b/cpp/src/groupby/sort/group_std.cu @@ -28,7 +28,10 @@ #include #include +#include +#include #include +#include #include namespace cudf { diff --git a/cpp/src/groupby/sort/sort_helper.cu b/cpp/src/groupby/sort/sort_helper.cu index 1048a6a71c8..10201782854 100644 --- a/cpp/src/groupby/sort/sort_helper.cu +++ b/cpp/src/groupby/sort/sort_helper.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -33,10 +33,14 @@ #include #include +#include +#include #include #include #include +#include #include +#include #include #include #include diff --git a/cpp/src/hash/hashing.cu b/cpp/src/hash/hashing.cu index cd1f254c1cc..33984ad5ce3 100644 --- a/cpp/src/hash/hashing.cu +++ b/cpp/src/hash/hashing.cu @@ -23,6 +23,7 @@ #include #include +#include #include #include diff --git a/cpp/src/hash/md5_hash.cu b/cpp/src/hash/md5_hash.cu index a1531a7b094..0b04cd86029 100644 --- a/cpp/src/hash/md5_hash.cu +++ b/cpp/src/hash/md5_hash.cu @@ -31,6 +31,7 @@ #include #include +#include #include diff --git a/cpp/src/hash/unordered_multiset.cuh b/cpp/src/hash/unordered_multiset.cuh index d28bf6f6fe5..6ed09510583 100644 --- a/cpp/src/hash/unordered_multiset.cuh +++ b/cpp/src/hash/unordered_multiset.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2019-2022, NVIDIA CORPORATION. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,6 +27,11 @@ #include #include +#include +#include +#include +#include + namespace cudf { namespace detail { /* diff --git a/cpp/src/interop/to_arrow.cu b/cpp/src/interop/to_arrow.cu index 27e47061b67..c7409978bb2 100644 --- a/cpp/src/interop/to_arrow.cu +++ b/cpp/src/interop/to_arrow.cu @@ -31,6 +31,7 @@ #include #include +#include #include #include diff --git a/cpp/src/io/avro/reader_impl.cu b/cpp/src/io/avro/reader_impl.cu index 0fa5680c5d2..b5b76c2def8 100644 --- a/cpp/src/io/avro/reader_impl.cu +++ b/cpp/src/io/avro/reader_impl.cu @@ -16,7 +16,6 @@ #include "avro.h" #include "avro_gpu.h" -#include "thrust/iterator/transform_output_iterator.h" #include #include @@ -31,15 +30,21 @@ #include #include -#include #include #include #include #include +#include +#include +#include +#include +#include + #include #include +#include #include #include #include diff --git a/cpp/src/io/csv/csv_gpu.cu b/cpp/src/io/csv/csv_gpu.cu index 4bbc04eecb4..97b2e01d1da 100644 --- a/cpp/src/io/csv/csv_gpu.cu +++ b/cpp/src/io/csv/csv_gpu.cu @@ -38,7 +38,9 @@ #include #include +#include #include +#include #include #include diff --git a/cpp/src/io/csv/datetime.cuh b/cpp/src/io/csv/datetime.cuh index 7778dff3d98..cb7f32bd380 100644 --- a/cpp/src/io/csv/datetime.cuh +++ b/cpp/src/io/csv/datetime.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -16,12 +16,13 @@ #pragma once -#include +#include +#include #include -#include -#include +#include +#include namespace cudf { namespace io { diff --git a/cpp/src/io/csv/durations.cu b/cpp/src/io/csv/durations.cu index a481da38d30..34abdcdfc68 100644 --- a/cpp/src/io/csv/durations.cu +++ b/cpp/src/io/csv/durations.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -26,6 +26,10 @@ #include +#include +#include +#include + namespace cudf { namespace io { namespace detail { diff --git a/cpp/src/io/csv/reader_impl.cu b/cpp/src/io/csv/reader_impl.cu index ace8e77afb5..ae9738164f3 100644 --- a/cpp/src/io/csv/reader_impl.cu +++ b/cpp/src/io/csv/reader_impl.cu @@ -42,6 +42,8 @@ #include +#include + #include #include #include diff --git a/cpp/src/io/csv/writer_impl.cu b/cpp/src/io/csv/writer_impl.cu index ac60c086241..cb2197cf755 100644 --- a/cpp/src/io/csv/writer_impl.cu +++ b/cpp/src/io/csv/writer_impl.cu @@ -44,8 +44,10 @@ #include #include +#include #include #include +#include #include #include diff --git a/cpp/src/io/json/json_gpu.cu b/cpp/src/io/json/json_gpu.cu index 21455e3ab93..d26831b9112 100644 --- a/cpp/src/io/json/json_gpu.cu +++ b/cpp/src/io/json/json_gpu.cu @@ -37,7 +37,13 @@ #include #include +#include #include +#include +#include +#include +#include +#include using cudf::device_span; diff --git a/cpp/src/io/json/reader_impl.cu b/cpp/src/io/json/reader_impl.cu index 319906111af..5ca947f3ee5 100644 --- a/cpp/src/io/json/reader_impl.cu +++ b/cpp/src/io/json/reader_impl.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -42,7 +42,15 @@ #include #include +#include +#include +#include +#include +#include #include +#include +#include +#include using cudf::host_span; diff --git a/cpp/src/io/orc/orc.h b/cpp/src/io/orc/orc.h index 47020023419..73eb8b382db 100644 --- a/cpp/src/io/orc/orc.h +++ b/cpp/src/io/orc/orc.h @@ -24,6 +24,8 @@ #include #include +#include + #include #include #include diff --git a/cpp/src/io/orc/reader_impl.cu b/cpp/src/io/orc/reader_impl.cu index 7f9badad9a9..059df283c94 100644 --- a/cpp/src/io/orc/reader_impl.cu +++ b/cpp/src/io/orc/reader_impl.cu @@ -42,6 +42,16 @@ #include +#include +#include +#include +#include +#include +#include +#include +#include +#include + #include #include diff --git a/cpp/src/io/orc/stripe_enc.cu b/cpp/src/io/orc/stripe_enc.cu index 02ae191d55a..f1d524058d2 100644 --- a/cpp/src/io/orc/stripe_enc.cu +++ b/cpp/src/io/orc/stripe_enc.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -30,6 +30,11 @@ #include +#include +#include +#include +#include + namespace cudf { namespace io { namespace orc { diff --git a/cpp/src/io/orc/writer_impl.cu b/cpp/src/io/orc/writer_impl.cu index c2cf873e5bf..30385d395f1 100644 --- a/cpp/src/io/orc/writer_impl.cu +++ b/cpp/src/io/orc/writer_impl.cu @@ -36,6 +36,17 @@ #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + #include #include diff --git a/cpp/src/io/orc/writer_impl.hpp b/cpp/src/io/orc/writer_impl.hpp index 69bb6029ee0..b3662bf309f 100644 --- a/cpp/src/io/orc/writer_impl.hpp +++ b/cpp/src/io/orc/writer_impl.hpp @@ -31,6 +31,8 @@ #include #include + +#include #include #include diff --git a/cpp/src/io/parquet/page_data.cu b/cpp/src/io/parquet/page_data.cu index 954ab5e159d..88c58be529c 100644 --- a/cpp/src/io/parquet/page_data.cu +++ b/cpp/src/io/parquet/page_data.cu @@ -24,9 +24,15 @@ #include #include +#include +#include #include #include +#include #include +#include +#include +#include #include constexpr int block_size = 128; diff --git a/cpp/src/io/parquet/page_enc.cu b/cpp/src/io/parquet/page_enc.cu index 2074304251f..da671d4c665 100644 --- a/cpp/src/io/parquet/page_enc.cu +++ b/cpp/src/io/parquet/page_enc.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -14,6 +14,7 @@ * limitations under the License. */ #include "parquet_gpu.hpp" + #include #include @@ -25,11 +26,23 @@ #include -#include #include + #include +#include +#include +#include #include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include namespace cudf { namespace io { diff --git a/cpp/src/io/parquet/reader_impl.cu b/cpp/src/io/parquet/reader_impl.cu index 9e7a48b7a69..33151102aec 100644 --- a/cpp/src/io/parquet/reader_impl.cu +++ b/cpp/src/io/parquet/reader_impl.cu @@ -40,6 +40,11 @@ #include +#include +#include +#include +#include + #include #include #include diff --git a/cpp/src/io/parquet/writer_impl.cu b/cpp/src/io/parquet/writer_impl.cu index 4ec7496e218..872ca6f6656 100644 --- a/cpp/src/io/parquet/writer_impl.cu +++ b/cpp/src/io/parquet/writer_impl.cu @@ -44,6 +44,10 @@ #include #include +#include +#include +#include +#include #include #include diff --git a/cpp/src/io/statistics/typed_statistics_chunk.cuh b/cpp/src/io/statistics/typed_statistics_chunk.cuh index 8e35fcf3c44..f725e0864c5 100644 --- a/cpp/src/io/statistics/typed_statistics_chunk.cuh +++ b/cpp/src/io/statistics/typed_statistics_chunk.cuh @@ -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. @@ -31,6 +31,8 @@ #include +#include + namespace cudf { namespace io { diff --git a/cpp/src/io/text/multibyte_split.cu b/cpp/src/io/text/multibyte_split.cu index 51622747831..0166040437b 100644 --- a/cpp/src/io/text/multibyte_split.cu +++ b/cpp/src/io/text/multibyte_split.cu @@ -35,6 +35,7 @@ #include #include #include +#include #include #include diff --git a/cpp/src/io/utilities/column_buffer.hpp b/cpp/src/io/utilities/column_buffer.hpp index 17df49009c2..34d8307b024 100644 --- a/cpp/src/io/utilities/column_buffer.hpp +++ b/cpp/src/io/utilities/column_buffer.hpp @@ -32,6 +32,8 @@ #include #include +#include + namespace cudf { namespace io { namespace detail { diff --git a/cpp/src/io/utilities/parsing_utils.cuh b/cpp/src/io/utilities/parsing_utils.cuh index 74b98eff010..6e85a271b54 100644 --- a/cpp/src/io/utilities/parsing_utils.cuh +++ b/cpp/src/io/utilities/parsing_utils.cuh @@ -24,6 +24,9 @@ #include +#include +#include + #include using cudf::device_span; diff --git a/cpp/src/join/hash_join.cu b/cpp/src/join/hash_join.cu index b89bcabf23e..086e1e49986 100644 --- a/cpp/src/join/hash_join.cu +++ b/cpp/src/join/hash_join.cu @@ -14,8 +14,6 @@ * limitations under the License. */ #include -#include -#include #include #include @@ -26,6 +24,14 @@ #include #include +#include +#include +#include +#include +#include +#include +#include + #include #include #include diff --git a/cpp/src/join/hash_join.cuh b/cpp/src/join/hash_join.cuh index 9c44aeebd59..e55de043372 100644 --- a/cpp/src/join/hash_join.cuh +++ b/cpp/src/join/hash_join.cuh @@ -32,6 +32,7 @@ #include #include +#include #include #include diff --git a/cpp/src/join/join_utils.cu b/cpp/src/join/join_utils.cu index 9e98f87e7f0..151db830962 100644 --- a/cpp/src/join/join_utils.cu +++ b/cpp/src/join/join_utils.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. @@ -19,9 +19,12 @@ #include #include +#include #include +#include #include #include +#include namespace cudf { namespace detail { diff --git a/cpp/src/join/mixed_join.cu b/cpp/src/join/mixed_join.cu index 0eb0a8de352..f9cbb2b5441 100644 --- a/cpp/src/join/mixed_join.cu +++ b/cpp/src/join/mixed_join.cu @@ -30,6 +30,9 @@ #include +#include +#include + #include #include diff --git a/cpp/src/join/mixed_join_semi.cu b/cpp/src/join/mixed_join_semi.cu index e492968b8a6..60cc74991ef 100644 --- a/cpp/src/join/mixed_join_semi.cu +++ b/cpp/src/join/mixed_join_semi.cu @@ -30,6 +30,10 @@ #include +#include +#include +#include + #include #include diff --git a/cpp/src/join/semi_join.cu b/cpp/src/join/semi_join.cu index 39fe0b60c8c..9e1aa27a4e7 100644 --- a/cpp/src/join/semi_join.cu +++ b/cpp/src/join/semi_join.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -34,6 +34,7 @@ #include #include +#include #include #include diff --git a/cpp/src/labeling/label_bins.cu b/cpp/src/labeling/label_bins.cu index 774027ed322..2d66001c20e 100644 --- a/cpp/src/labeling/label_bins.cu +++ b/cpp/src/labeling/label_bins.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. @@ -37,6 +37,7 @@ #include #include #include +#include #include diff --git a/cpp/src/lists/combine/concatenate_list_elements.cu b/cpp/src/lists/combine/concatenate_list_elements.cu index 240543db7bb..fecdec0b1b2 100644 --- a/cpp/src/lists/combine/concatenate_list_elements.cu +++ b/cpp/src/lists/combine/concatenate_list_elements.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. @@ -28,7 +28,12 @@ #include #include +#include +#include +#include +#include #include +#include #include #include diff --git a/cpp/src/lists/combine/concatenate_rows.cu b/cpp/src/lists/combine/concatenate_rows.cu index ca92e3c4e26..09f0b653466 100644 --- a/cpp/src/lists/combine/concatenate_rows.cu +++ b/cpp/src/lists/combine/concatenate_rows.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. @@ -25,6 +25,7 @@ #include #include +#include #include namespace cudf { diff --git a/cpp/src/lists/contains.cu b/cpp/src/lists/contains.cu index 5704ff81665..439b7dd9a37 100644 --- a/cpp/src/lists/contains.cu +++ b/cpp/src/lists/contains.cu @@ -26,9 +26,22 @@ #include #include #include + #include + +#include +#include +#include #include +#include +#include +#include #include +#include +#include +#include +#include + #include namespace cudf { diff --git a/cpp/src/lists/copying/concatenate.cu b/cpp/src/lists/copying/concatenate.cu index facf2827f56..22083f7ce99 100644 --- a/cpp/src/lists/copying/concatenate.cu +++ b/cpp/src/lists/copying/concatenate.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -27,6 +27,8 @@ #include #include +#include + #include namespace cudf { diff --git a/cpp/src/lists/copying/copying.cu b/cpp/src/lists/copying/copying.cu index e9d183bc073..be316bd644e 100644 --- a/cpp/src/lists/copying/copying.cu +++ b/cpp/src/lists/copying/copying.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -24,6 +24,7 @@ #include #include +#include #include diff --git a/cpp/src/lists/copying/gather.cu b/cpp/src/lists/copying/gather.cu index 8d2de8997d1..ae9fab4dda2 100644 --- a/cpp/src/lists/copying/gather.cu +++ b/cpp/src/lists/copying/gather.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -20,6 +20,10 @@ #include #include +#include +#include +#include +#include namespace cudf { namespace lists { diff --git a/cpp/src/lists/copying/scatter_helper.cu b/cpp/src/lists/copying/scatter_helper.cu index 5916837f97a..adc1b95a9e6 100644 --- a/cpp/src/lists/copying/scatter_helper.cu +++ b/cpp/src/lists/copying/scatter_helper.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. @@ -25,6 +25,11 @@ #include #include +#include +#include +#include +#include +#include namespace cudf { namespace lists { diff --git a/cpp/src/lists/copying/segmented_gather.cu b/cpp/src/lists/copying/segmented_gather.cu index 41187b96cdb..45a1b2c50fe 100644 --- a/cpp/src/lists/copying/segmented_gather.cu +++ b/cpp/src/lists/copying/segmented_gather.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -21,6 +21,7 @@ #include #include +#include #include diff --git a/cpp/src/lists/count_elements.cu b/cpp/src/lists/count_elements.cu index 84ca171d455..84e698b8f0b 100644 --- a/cpp/src/lists/count_elements.cu +++ b/cpp/src/lists/count_elements.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. @@ -27,6 +27,7 @@ #include #include +#include #include #include diff --git a/cpp/src/lists/drop_list_duplicates.cu b/cpp/src/lists/drop_list_duplicates.cu index e3c47649617..8a4704ad13b 100644 --- a/cpp/src/lists/drop_list_duplicates.cu +++ b/cpp/src/lists/drop_list_duplicates.cu @@ -36,8 +36,14 @@ #include #include +#include +#include +#include #include +#include +#include #include +#include #include #include #include diff --git a/cpp/src/lists/explode.cu b/cpp/src/lists/explode.cu index f1d5f8e61ac..19242764277 100644 --- a/cpp/src/lists/explode.cu +++ b/cpp/src/lists/explode.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. @@ -26,10 +26,16 @@ #include #include +#include #include +#include +#include +#include #include #include #include +#include +#include #include #include diff --git a/cpp/src/lists/extract.cu b/cpp/src/lists/extract.cu index 0e8659b54ff..73ab1935ad0 100644 --- a/cpp/src/lists/extract.cu +++ b/cpp/src/lists/extract.cu @@ -27,6 +27,7 @@ #include #include +#include #include #include diff --git a/cpp/src/lists/interleave_columns.cu b/cpp/src/lists/interleave_columns.cu index 913f2771a0e..b61620a4cbc 100644 --- a/cpp/src/lists/interleave_columns.cu +++ b/cpp/src/lists/interleave_columns.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. @@ -31,6 +31,11 @@ #include #include +#include +#include +#include +#include +#include #include namespace cudf { diff --git a/cpp/src/lists/segmented_sort.cu b/cpp/src/lists/segmented_sort.cu index b7e2b73329a..0d742211f98 100644 --- a/cpp/src/lists/segmented_sort.cu +++ b/cpp/src/lists/segmented_sort.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. @@ -35,6 +35,8 @@ #include #include +#include +#include #include diff --git a/cpp/src/lists/sequences.cu b/cpp/src/lists/sequences.cu index 5007918441b..2da4a02aecc 100644 --- a/cpp/src/lists/sequences.cu +++ b/cpp/src/lists/sequences.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. @@ -26,6 +26,9 @@ #include #include +#include +#include +#include #include #include diff --git a/cpp/src/merge/merge.cu b/cpp/src/merge/merge.cu index ff9401022b2..043c04b409e 100644 --- a/cpp/src/merge/merge.cu +++ b/cpp/src/merge/merge.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -35,6 +35,8 @@ #include #include #include +#include +#include #include "cudf/utilities/traits.hpp" #include diff --git a/cpp/src/partitioning/partitioning.cu b/cpp/src/partitioning/partitioning.cu index 66b26148ede..43686b7d257 100644 --- a/cpp/src/partitioning/partitioning.cu +++ b/cpp/src/partitioning/partitioning.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -30,6 +30,10 @@ #include #include +#include +#include +#include + namespace cudf { namespace { // Launch configuration for optimized hash partition diff --git a/cpp/src/partitioning/round_robin.cu b/cpp/src/partitioning/round_robin.cu index 0c0c2172485..193bb5a4353 100644 --- a/cpp/src/partitioning/round_robin.cu +++ b/cpp/src/partitioning/round_robin.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -31,10 +31,13 @@ #include #include +#include +#include #include #include #include #include +#include #include #include diff --git a/cpp/src/quantiles/quantile.cu b/cpp/src/quantiles/quantile.cu index ce748cdd6f9..a71fc862bf3 100644 --- a/cpp/src/quantiles/quantile.cu +++ b/cpp/src/quantiles/quantile.cu @@ -33,6 +33,9 @@ #include #include +#include +#include +#include #include #include diff --git a/cpp/src/quantiles/quantiles.cu b/cpp/src/quantiles/quantiles.cu index e591df0123c..0e22b12c8a4 100644 --- a/cpp/src/quantiles/quantiles.cu +++ b/cpp/src/quantiles/quantiles.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -27,6 +27,9 @@ #include +#include +#include + #include #include diff --git a/cpp/src/quantiles/tdigest/tdigest.cu b/cpp/src/quantiles/tdigest/tdigest.cu index 391cb3e215a..055e781447e 100644 --- a/cpp/src/quantiles/tdigest/tdigest.cu +++ b/cpp/src/quantiles/tdigest/tdigest.cu @@ -27,6 +27,15 @@ #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include using namespace cudf::tdigest; diff --git a/cpp/src/quantiles/tdigest/tdigest_aggregation.cu b/cpp/src/quantiles/tdigest/tdigest_aggregation.cu index 3c22a5d36a2..b3c3f26f32f 100644 --- a/cpp/src/quantiles/tdigest/tdigest_aggregation.cu +++ b/cpp/src/quantiles/tdigest/tdigest_aggregation.cu @@ -25,16 +25,30 @@ #include #include #include +#include #include #include -#include - #include #include +#include #include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include namespace cudf { namespace detail { diff --git a/cpp/src/reductions/all.cu b/cpp/src/reductions/all.cu index b43df279393..8e9becb96ec 100644 --- a/cpp/src/reductions/all.cu +++ b/cpp/src/reductions/all.cu @@ -19,6 +19,11 @@ #include #include +#include +#include +#include +#include + namespace cudf { namespace reduction { namespace detail { diff --git a/cpp/src/reductions/any.cu b/cpp/src/reductions/any.cu index bad7d581255..0057fb3d111 100644 --- a/cpp/src/reductions/any.cu +++ b/cpp/src/reductions/any.cu @@ -19,6 +19,11 @@ #include #include +#include +#include +#include +#include + namespace cudf { namespace reduction { namespace detail { diff --git a/cpp/src/reductions/compound.cuh b/cpp/src/reductions/compound.cuh index 89a95f5138c..05445e7eb62 100644 --- a/cpp/src/reductions/compound.cuh +++ b/cpp/src/reductions/compound.cuh @@ -22,6 +22,8 @@ #include #include +#include + namespace cudf { namespace reduction { namespace compound { diff --git a/cpp/src/reductions/minmax.cu b/cpp/src/reductions/minmax.cu index 161f892fbcb..61f728447e8 100644 --- a/cpp/src/reductions/minmax.cu +++ b/cpp/src/reductions/minmax.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -26,7 +26,12 @@ #include +#include +#include #include +#include +#include +#include #include #include diff --git a/cpp/src/reductions/nth_element.cu b/cpp/src/reductions/nth_element.cu index 2b8066a57ee..78c469ee767 100644 --- a/cpp/src/reductions/nth_element.cu +++ b/cpp/src/reductions/nth_element.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -25,6 +25,8 @@ #include #include +#include +#include std::unique_ptr cudf::reduction::nth_element(column_view const& col, size_type n, diff --git a/cpp/src/reductions/scan/rank_scan.cu b/cpp/src/reductions/scan/rank_scan.cu index 464a8688a2d..67b4b594f2e 100644 --- a/cpp/src/reductions/scan/rank_scan.cu +++ b/cpp/src/reductions/scan/rank_scan.cu @@ -26,6 +26,7 @@ #include #include +#include namespace cudf { namespace detail { diff --git a/cpp/src/reductions/scan/scan_inclusive.cu b/cpp/src/reductions/scan/scan_inclusive.cu index bc2f1d47311..9d07f340ebf 100644 --- a/cpp/src/reductions/scan/scan_inclusive.cu +++ b/cpp/src/reductions/scan/scan_inclusive.cu @@ -29,6 +29,9 @@ #include #include +#include +#include +#include #include #include diff --git a/cpp/src/reductions/simple.cuh b/cpp/src/reductions/simple.cuh index 807462d742f..231d814a376 100644 --- a/cpp/src/reductions/simple.cuh +++ b/cpp/src/reductions/simple.cuh @@ -33,6 +33,8 @@ #include #include +#include +#include #include namespace cudf { diff --git a/cpp/src/reductions/struct_minmax_util.cuh b/cpp/src/reductions/struct_minmax_util.cuh index b0f2d50b0f5..a25d78d162a 100644 --- a/cpp/src/reductions/struct_minmax_util.cuh +++ b/cpp/src/reductions/struct_minmax_util.cuh @@ -25,6 +25,9 @@ #include #include +#include +#include + namespace cudf { namespace reduction { namespace detail { diff --git a/cpp/src/replace/clamp.cu b/cpp/src/replace/clamp.cu index fae02805620..8b696854c25 100644 --- a/cpp/src/replace/clamp.cu +++ b/cpp/src/replace/clamp.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -37,6 +37,12 @@ #include #include +#include +#include +#include +#include +#include + namespace cudf { namespace detail { namespace { diff --git a/cpp/src/replace/nans.cu b/cpp/src/replace/nans.cu index 020e444cedc..cf2b4b75d1a 100644 --- a/cpp/src/replace/nans.cu +++ b/cpp/src/replace/nans.cu @@ -28,6 +28,8 @@ #include #include +#include +#include #include namespace cudf { diff --git a/cpp/src/replace/nulls.cu b/cpp/src/replace/nulls.cu index 8707a89d9c9..b53c93ad708 100644 --- a/cpp/src/replace/nulls.cu +++ b/cpp/src/replace/nulls.cu @@ -44,11 +44,13 @@ #include #include +#include #include #include #include #include #include +#include namespace { // anonymous diff --git a/cpp/src/replace/replace.cu b/cpp/src/replace/replace.cu index 3505fe1f5d7..d0acecbb484 100644 --- a/cpp/src/replace/replace.cu +++ b/cpp/src/replace/replace.cu @@ -17,7 +17,7 @@ * limitations under the License. */ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -54,7 +54,11 @@ #include #include +#include +#include #include +#include +#include namespace { // anonymous diff --git a/cpp/src/reshape/byte_cast.cu b/cpp/src/reshape/byte_cast.cu index 6bfd4938a96..81de5bc2ae2 100644 --- a/cpp/src/reshape/byte_cast.cu +++ b/cpp/src/reshape/byte_cast.cu @@ -25,6 +25,11 @@ #include #include +#include +#include +#include +#include + namespace cudf { namespace detail { namespace { diff --git a/cpp/src/reshape/interleave_columns.cu b/cpp/src/reshape/interleave_columns.cu index cd66cad392e..9954cb4a299 100644 --- a/cpp/src/reshape/interleave_columns.cu +++ b/cpp/src/reshape/interleave_columns.cu @@ -28,6 +28,11 @@ #include #include +#include +#include +#include +#include + namespace cudf { namespace detail { namespace { diff --git a/cpp/src/rolling/grouped_rolling.cu b/cpp/src/rolling/grouped_rolling.cu index 5a7f15148d8..411600fa8d7 100644 --- a/cpp/src/rolling/grouped_rolling.cu +++ b/cpp/src/rolling/grouped_rolling.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -25,6 +25,14 @@ #include #include +#include +#include +#include +#include +#include +#include +#include + namespace cudf { std::unique_ptr grouped_rolling_window(table_view const& group_keys, column_view const& input, diff --git a/cpp/src/rolling/lead_lag_nested_detail.cuh b/cpp/src/rolling/lead_lag_nested_detail.cuh index bde7101b9a9..a23786ec7f3 100644 --- a/cpp/src/rolling/lead_lag_nested_detail.cuh +++ b/cpp/src/rolling/lead_lag_nested_detail.cuh @@ -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. @@ -29,6 +29,9 @@ #include #include +#include +#include +#include #include diff --git a/cpp/src/rolling/rolling.cu b/cpp/src/rolling/rolling.cu index fdb9f09a812..005bc72c299 100644 --- a/cpp/src/rolling/rolling.cu +++ b/cpp/src/rolling/rolling.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -15,8 +15,11 @@ */ #include "rolling_detail.cuh" + #include +#include + namespace cudf { namespace detail { diff --git a/cpp/src/rolling/rolling_collect_list.cu b/cpp/src/rolling/rolling_collect_list.cu index 30c39bde7d2..5617995b348 100644 --- a/cpp/src/rolling/rolling_collect_list.cu +++ b/cpp/src/rolling/rolling_collect_list.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. @@ -22,9 +22,15 @@ #include #include +#include +#include +#include +#include #include +#include #include #include +#include namespace cudf { namespace detail { diff --git a/cpp/src/rolling/rolling_collect_list.cuh b/cpp/src/rolling/rolling_collect_list.cuh index 95eb1a124c6..94703e320d0 100644 --- a/cpp/src/rolling/rolling_collect_list.cuh +++ b/cpp/src/rolling/rolling_collect_list.cuh @@ -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. @@ -25,6 +25,9 @@ #include #include +#include +#include +#include #include namespace cudf { diff --git a/cpp/src/rolling/rolling_detail.cuh b/cpp/src/rolling/rolling_detail.cuh index 0ab8fff9a88..d704b18774f 100644 --- a/cpp/src/rolling/rolling_detail.cuh +++ b/cpp/src/rolling/rolling_detail.cuh @@ -55,6 +55,7 @@ #include #include +#include #include #include #include diff --git a/cpp/src/round/round.cu b/cpp/src/round/round.cu index 9a2b1002997..7849e3fe331 100644 --- a/cpp/src/round/round.cu +++ b/cpp/src/round/round.cu @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -33,7 +34,8 @@ #include #include -#include +#include +#include #include namespace cudf { diff --git a/cpp/src/scalar/scalar.cpp b/cpp/src/scalar/scalar.cpp index 4f6774be184..76ec171052a 100644 --- a/cpp/src/scalar/scalar.cpp +++ b/cpp/src/scalar/scalar.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -24,6 +24,8 @@ #include #include +#include + #include namespace cudf { diff --git a/cpp/src/search/search.cu b/cpp/src/search/search.cu index 81ed3cfbd51..477666d93ae 100644 --- a/cpp/src/search/search.cu +++ b/cpp/src/search/search.cu @@ -35,6 +35,11 @@ #include #include +#include +#include +#include +#include +#include namespace cudf { namespace { diff --git a/cpp/src/sort/is_sorted.cu b/cpp/src/sort/is_sorted.cu index a8820204c22..b971d505708 100644 --- a/cpp/src/sort/is_sorted.cu +++ b/cpp/src/sort/is_sorted.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -27,6 +27,7 @@ #include #include +#include #include namespace cudf { diff --git a/cpp/src/sort/rank.cu b/cpp/src/sort/rank.cu index e17a18997e8..077e8912746 100644 --- a/cpp/src/sort/rank.cu +++ b/cpp/src/sort/rank.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -29,9 +29,18 @@ #include #include +#include +#include #include #include +#include +#include +#include +#include +#include #include +#include +#include namespace cudf { namespace detail { diff --git a/cpp/src/sort/sort.cu b/cpp/src/sort/sort.cu index 5ce82cd3740..fcb5df7bc20 100644 --- a/cpp/src/sort/sort.cu +++ b/cpp/src/sort/sort.cu @@ -24,6 +24,8 @@ #include +#include + namespace cudf { namespace detail { std::unique_ptr sorted_order(table_view const& input, diff --git a/cpp/src/sort/sort_column.cu b/cpp/src/sort/sort_column.cu index 7a4072cf8ae..01ca36874e4 100644 --- a/cpp/src/sort/sort_column.cu +++ b/cpp/src/sort/sort_column.cu @@ -16,6 +16,10 @@ #include +#include +#include +#include + namespace cudf { namespace detail { namespace { diff --git a/cpp/src/sort/sort_impl.cuh b/cpp/src/sort/sort_impl.cuh index 2f093fd7d2d..7f84c49a417 100644 --- a/cpp/src/sort/sort_impl.cuh +++ b/cpp/src/sort/sort_impl.cuh @@ -32,6 +32,7 @@ #include #include +#include namespace cudf { namespace detail { diff --git a/cpp/src/sort/stable_sort_column.cu b/cpp/src/sort/stable_sort_column.cu index d79a691a580..7f8ab778f53 100644 --- a/cpp/src/sort/stable_sort_column.cu +++ b/cpp/src/sort/stable_sort_column.cu @@ -16,6 +16,9 @@ #include +#include +#include + namespace cudf { namespace detail { namespace { diff --git a/cpp/src/stream_compaction/distinct.cu b/cpp/src/stream_compaction/distinct.cu index d856e63b8cb..d74946406d8 100644 --- a/cpp/src/stream_compaction/distinct.cu +++ b/cpp/src/stream_compaction/distinct.cu @@ -38,6 +38,8 @@ #include #include +#include +#include #include #include diff --git a/cpp/src/stream_compaction/distinct_count.cu b/cpp/src/stream_compaction/distinct_count.cu index 9ff507a15c5..7ccc61f304b 100644 --- a/cpp/src/stream_compaction/distinct_count.cu +++ b/cpp/src/stream_compaction/distinct_count.cu @@ -34,6 +34,7 @@ #include #include +#include #include #include diff --git a/cpp/src/stream_compaction/drop_nans.cu b/cpp/src/stream_compaction/drop_nans.cu index 861b9ad8606..e6cf7332fb4 100644 --- a/cpp/src/stream_compaction/drop_nans.cu +++ b/cpp/src/stream_compaction/drop_nans.cu @@ -25,6 +25,8 @@ #include +#include + namespace { struct dispatch_is_not_nan { diff --git a/cpp/src/stream_compaction/drop_nulls.cu b/cpp/src/stream_compaction/drop_nulls.cu index 7eb8e1c9644..73d8aaeb3ed 100644 --- a/cpp/src/stream_compaction/drop_nulls.cu +++ b/cpp/src/stream_compaction/drop_nulls.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2020, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -24,6 +24,8 @@ #include +#include + namespace { // Returns true if the mask is true for index i in at least keep_threshold // columns diff --git a/cpp/src/stream_compaction/stream_compaction_common.cuh b/cpp/src/stream_compaction/stream_compaction_common.cuh index 1b0ef1b9e55..f49e17112c1 100644 --- a/cpp/src/stream_compaction/stream_compaction_common.cuh +++ b/cpp/src/stream_compaction/stream_compaction_common.cuh @@ -23,6 +23,7 @@ #include #include +#include #include namespace cudf { diff --git a/cpp/src/stream_compaction/unique.cu b/cpp/src/stream_compaction/unique.cu index e9015afbf61..3d482ee899f 100644 --- a/cpp/src/stream_compaction/unique.cu +++ b/cpp/src/stream_compaction/unique.cu @@ -37,7 +37,9 @@ #include #include +#include #include +#include #include #include diff --git a/cpp/src/stream_compaction/unique_count.cu b/cpp/src/stream_compaction/unique_count.cu index 91a2537cf97..8a793ef4729 100644 --- a/cpp/src/stream_compaction/unique_count.cu +++ b/cpp/src/stream_compaction/unique_count.cu @@ -34,6 +34,7 @@ #include #include +#include #include #include diff --git a/cpp/src/strings/attributes.cu b/cpp/src/strings/attributes.cu index 997265ecfed..1530f546824 100644 --- a/cpp/src/strings/attributes.cu +++ b/cpp/src/strings/attributes.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -28,6 +28,10 @@ #include #include +#include +#include +#include +#include #include #include diff --git a/cpp/src/strings/capitalize.cu b/cpp/src/strings/capitalize.cu index 84ae2b73bba..6c00b678368 100644 --- a/cpp/src/strings/capitalize.cu +++ b/cpp/src/strings/capitalize.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -30,6 +30,10 @@ #include +#include +#include +#include + namespace cudf { namespace strings { namespace detail { diff --git a/cpp/src/strings/char_types/char_types.cu b/cpp/src/strings/char_types/char_types.cu index 3d87197873f..49a2ad7b5d8 100644 --- a/cpp/src/strings/char_types/char_types.cu +++ b/cpp/src/strings/char_types/char_types.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -31,7 +31,9 @@ #include +#include #include +#include namespace cudf { namespace strings { diff --git a/cpp/src/strings/combine/concatenate.cu b/cpp/src/strings/combine/concatenate.cu index c4211fcf9fd..f2b1ed4ad95 100644 --- a/cpp/src/strings/combine/concatenate.cu +++ b/cpp/src/strings/combine/concatenate.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -31,6 +31,8 @@ #include #include +#include +#include #include #include diff --git a/cpp/src/strings/combine/join.cu b/cpp/src/strings/combine/join.cu index c8d3e728805..adfd24f1ca2 100644 --- a/cpp/src/strings/combine/join.cu +++ b/cpp/src/strings/combine/join.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -30,6 +30,9 @@ #include #include +#include +#include +#include #include namespace cudf { diff --git a/cpp/src/strings/combine/join_list_elements.cu b/cpp/src/strings/combine/join_list_elements.cu index 8f364f5c9bc..c4127ed8409 100644 --- a/cpp/src/strings/combine/join_list_elements.cu +++ b/cpp/src/strings/combine/join_list_elements.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. @@ -29,6 +29,8 @@ #include #include +#include + namespace cudf { namespace strings { namespace detail { diff --git a/cpp/src/strings/contains.cu b/cpp/src/strings/contains.cu index 23bc5cf2dfe..773430953c9 100644 --- a/cpp/src/strings/contains.cu +++ b/cpp/src/strings/contains.cu @@ -31,6 +31,7 @@ #include #include +#include #include namespace cudf { diff --git a/cpp/src/strings/convert/convert_booleans.cu b/cpp/src/strings/convert/convert_booleans.cu index 0691adc9eb7..2cd452d7a5b 100644 --- a/cpp/src/strings/convert/convert_booleans.cu +++ b/cpp/src/strings/convert/convert_booleans.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -31,6 +31,7 @@ #include #include +#include #include #include diff --git a/cpp/src/strings/convert/convert_datetime.cu b/cpp/src/strings/convert/convert_datetime.cu index cd3dc3b46f3..fed201cf726 100644 --- a/cpp/src/strings/convert/convert_datetime.cu +++ b/cpp/src/strings/convert/convert_datetime.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -34,9 +34,14 @@ #include #include +#include +#include #include +#include #include #include +#include +#include #include #include diff --git a/cpp/src/strings/convert/convert_durations.cu b/cpp/src/strings/convert/convert_durations.cu index 66e6f31cca2..ac3c4df6aeb 100644 --- a/cpp/src/strings/convert/convert_durations.cu +++ b/cpp/src/strings/convert/convert_durations.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -24,6 +24,12 @@ #include #include +#include +#include +#include +#include +#include +#include #include #include diff --git a/cpp/src/strings/convert/convert_fixed_point.cu b/cpp/src/strings/convert/convert_fixed_point.cu index 6944a8eb097..d8b49f76c22 100644 --- a/cpp/src/strings/convert/convert_fixed_point.cu +++ b/cpp/src/strings/convert/convert_fixed_point.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. @@ -34,6 +34,9 @@ #include #include +#include +#include +#include #include #include diff --git a/cpp/src/strings/convert/convert_floats.cu b/cpp/src/strings/convert/convert_floats.cu index 5316c0d46cb..bd54e20a0f0 100644 --- a/cpp/src/strings/convert/convert_floats.cu +++ b/cpp/src/strings/convert/convert_floats.cu @@ -31,7 +31,10 @@ #include #include +#include +#include #include +#include #include #include diff --git a/cpp/src/strings/convert/convert_hex.cu b/cpp/src/strings/convert/convert_hex.cu index 3bcfe92f364..8feb4bbca0f 100644 --- a/cpp/src/strings/convert/convert_hex.cu +++ b/cpp/src/strings/convert/convert_hex.cu @@ -29,6 +29,8 @@ #include #include +#include +#include #include #include #include diff --git a/cpp/src/strings/convert/convert_integers.cu b/cpp/src/strings/convert/convert_integers.cu index 7540154d93d..95ddf1822a7 100644 --- a/cpp/src/strings/convert/convert_integers.cu +++ b/cpp/src/strings/convert/convert_integers.cu @@ -32,7 +32,10 @@ #include #include +#include #include +#include +#include #include namespace cudf { diff --git a/cpp/src/strings/convert/convert_ipv4.cu b/cpp/src/strings/convert/convert_ipv4.cu index 9006a998b61..57bba1527da 100644 --- a/cpp/src/strings/convert/convert_ipv4.cu +++ b/cpp/src/strings/convert/convert_ipv4.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -27,6 +27,9 @@ #include #include +#include +#include +#include #include namespace cudf { diff --git a/cpp/src/strings/convert/convert_urls.cu b/cpp/src/strings/convert/convert_urls.cu index 20935febf21..5a612b73505 100644 --- a/cpp/src/strings/convert/convert_urls.cu +++ b/cpp/src/strings/convert/convert_urls.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -34,7 +34,9 @@ #include +#include #include +#include #include #include diff --git a/cpp/src/strings/copying/concatenate.cu b/cpp/src/strings/copying/concatenate.cu index 3822fa8bf5a..9fa033e9f9a 100644 --- a/cpp/src/strings/copying/concatenate.cu +++ b/cpp/src/strings/copying/concatenate.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -29,8 +29,11 @@ #include #include +#include #include #include +#include +#include #include namespace cudf { diff --git a/cpp/src/strings/copying/copying.cu b/cpp/src/strings/copying/copying.cu index e722ad520b3..23406444cfd 100644 --- a/cpp/src/strings/copying/copying.cu +++ b/cpp/src/strings/copying/copying.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -24,6 +24,8 @@ #include #include +#include + namespace cudf { namespace strings { namespace detail { diff --git a/cpp/src/strings/count_matches.cu b/cpp/src/strings/count_matches.cu index ae996cafd2c..5057df7f92b 100644 --- a/cpp/src/strings/count_matches.cu +++ b/cpp/src/strings/count_matches.cu @@ -24,6 +24,7 @@ #include +#include #include namespace cudf { diff --git a/cpp/src/strings/extract/extract.cu b/cpp/src/strings/extract/extract.cu index 7394cdac6bb..9e987cf5879 100644 --- a/cpp/src/strings/extract/extract.cu +++ b/cpp/src/strings/extract/extract.cu @@ -30,6 +30,12 @@ #include +#include +#include +#include +#include +#include + namespace cudf { namespace strings { namespace detail { diff --git a/cpp/src/strings/extract/extract_all.cu b/cpp/src/strings/extract/extract_all.cu index 1f1474c777b..fd2d280c5bc 100644 --- a/cpp/src/strings/extract/extract_all.cu +++ b/cpp/src/strings/extract/extract_all.cu @@ -31,6 +31,8 @@ #include #include +#include +#include #include namespace cudf { diff --git a/cpp/src/strings/filling/fill.cu b/cpp/src/strings/filling/fill.cu index eff010775dc..a858a3d6238 100644 --- a/cpp/src/strings/filling/fill.cu +++ b/cpp/src/strings/filling/fill.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -28,6 +28,10 @@ #include +#include +#include +#include + namespace cudf { namespace strings { namespace detail { diff --git a/cpp/src/strings/filter_chars.cu b/cpp/src/strings/filter_chars.cu index 7e45a609d34..82c803ff6c7 100644 --- a/cpp/src/strings/filter_chars.cu +++ b/cpp/src/strings/filter_chars.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -30,7 +30,10 @@ #include #include +#include #include +#include +#include #include diff --git a/cpp/src/strings/json/json_path.cu b/cpp/src/strings/json/json_path.cu index ae807db10e6..30e8770c3c2 100644 --- a/cpp/src/strings/json/json_path.cu +++ b/cpp/src/strings/json/json_path.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. @@ -35,6 +35,9 @@ #include #include +#include +#include +#include namespace cudf { namespace strings { diff --git a/cpp/src/strings/padding.cu b/cpp/src/strings/padding.cu index f2a27d1b11d..435125bfd5b 100644 --- a/cpp/src/strings/padding.cu +++ b/cpp/src/strings/padding.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -29,6 +29,10 @@ #include #include +#include +#include +#include + namespace cudf { namespace strings { namespace detail { diff --git a/cpp/src/strings/regex/regex.inl b/cpp/src/strings/regex/regex.inl index 50aab8c3ac4..01e773960e4 100644 --- a/cpp/src/strings/regex/regex.inl +++ b/cpp/src/strings/regex/regex.inl @@ -23,7 +23,9 @@ #include #include #include +#include #include +#include namespace cudf { namespace strings { diff --git a/cpp/src/strings/repeat_strings.cu b/cpp/src/strings/repeat_strings.cu index 7820e0064a6..c0673a5e2b5 100644 --- a/cpp/src/strings/repeat_strings.cu +++ b/cpp/src/strings/repeat_strings.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. @@ -26,7 +26,10 @@ #include +#include #include +#include +#include #include #include diff --git a/cpp/src/strings/replace/backref_re.cuh b/cpp/src/strings/replace/backref_re.cuh index eba5c3f1044..13a67e3b4d7 100644 --- a/cpp/src/strings/replace/backref_re.cuh +++ b/cpp/src/strings/replace/backref_re.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -23,6 +23,10 @@ #include +#include +#include +#include + namespace cudf { namespace strings { namespace detail { diff --git a/cpp/src/strings/replace/multi_re.cu b/cpp/src/strings/replace/multi_re.cu index 22f6d2cba39..3189739e492 100644 --- a/cpp/src/strings/replace/multi_re.cu +++ b/cpp/src/strings/replace/multi_re.cu @@ -31,6 +31,9 @@ #include +#include +#include + #include namespace cudf { diff --git a/cpp/src/strings/replace/replace.cu b/cpp/src/strings/replace/replace.cu index 4d32d91c1d4..c6646dfadf2 100644 --- a/cpp/src/strings/replace/replace.cu +++ b/cpp/src/strings/replace/replace.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -33,11 +33,17 @@ #include #include +#include #include #include +#include +#include +#include #include #include +#include #include +#include namespace cudf { namespace strings { diff --git a/cpp/src/strings/search/find.cu b/cpp/src/strings/search/find.cu index 45b23d848c0..15d89069ba3 100644 --- a/cpp/src/strings/search/find.cu +++ b/cpp/src/strings/search/find.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -28,6 +28,7 @@ #include #include +#include #include namespace cudf { diff --git a/cpp/src/strings/search/find_multiple.cu b/cpp/src/strings/search/find_multiple.cu index 5756c239f1c..7df77448be1 100644 --- a/cpp/src/strings/search/find_multiple.cu +++ b/cpp/src/strings/search/find_multiple.cu @@ -27,6 +27,7 @@ #include #include +#include #include namespace cudf { diff --git a/cpp/src/strings/search/findall.cu b/cpp/src/strings/search/findall.cu index 201556033ad..e874d1db192 100644 --- a/cpp/src/strings/search/findall.cu +++ b/cpp/src/strings/search/findall.cu @@ -32,6 +32,9 @@ #include #include +#include +#include +#include #include #include diff --git a/cpp/src/strings/search/findall_record.cu b/cpp/src/strings/search/findall_record.cu index 8ce7908f41e..7fb5982b307 100644 --- a/cpp/src/strings/search/findall_record.cu +++ b/cpp/src/strings/search/findall_record.cu @@ -33,6 +33,9 @@ #include #include +#include +#include +#include namespace cudf { namespace strings { diff --git a/cpp/src/strings/split/partition.cu b/cpp/src/strings/split/partition.cu index eef26691319..f6d611b45ec 100644 --- a/cpp/src/strings/split/partition.cu +++ b/cpp/src/strings/split/partition.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -27,6 +27,10 @@ #include #include +#include +#include +#include + #include namespace cudf { diff --git a/cpp/src/strings/split/split.cu b/cpp/src/strings/split/split.cu index aae911e8ed6..9989f724261 100644 --- a/cpp/src/strings/split/split.cu +++ b/cpp/src/strings/split/split.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -31,11 +31,16 @@ #include #include -#include // upper_bound() -#include // copy_if() -#include // count_if() -#include // maximum() -#include // transform() +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include namespace cudf { namespace strings { diff --git a/cpp/src/strings/split/split_re.cu b/cpp/src/strings/split/split_re.cu index a8a2467dd76..286492e53c5 100644 --- a/cpp/src/strings/split/split_re.cu +++ b/cpp/src/strings/split/split_re.cu @@ -32,7 +32,12 @@ #include +#include #include +#include +#include +#include +#include #include namespace cudf { diff --git a/cpp/src/strings/split/split_record.cu b/cpp/src/strings/split/split_record.cu index 929d21a024c..f6a4ca48597 100644 --- a/cpp/src/strings/split/split_record.cu +++ b/cpp/src/strings/split/split_record.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -28,6 +28,9 @@ #include +#include +#include +#include #include #include diff --git a/cpp/src/strings/split/split_utils.cuh b/cpp/src/strings/split/split_utils.cuh index a6afd1bef10..dca379f3e12 100644 --- a/cpp/src/strings/split/split_utils.cuh +++ b/cpp/src/strings/split/split_utils.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -16,6 +16,8 @@ #include +#include + namespace cudf { namespace strings { namespace detail { diff --git a/cpp/src/strings/strings_column_factories.cu b/cpp/src/strings/strings_column_factories.cu index e7ee8215b3d..d0f0a406f48 100644 --- a/cpp/src/strings/strings_column_factories.cu +++ b/cpp/src/strings/strings_column_factories.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -25,6 +25,9 @@ #include #include +#include +#include + namespace cudf { namespace { diff --git a/cpp/src/strings/strip.cu b/cpp/src/strings/strip.cu index 2b1e6969956..e3d39e40755 100644 --- a/cpp/src/strings/strip.cu +++ b/cpp/src/strings/strip.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -27,6 +27,7 @@ #include #include +#include #include #include diff --git a/cpp/src/strings/substring.cu b/cpp/src/strings/substring.cu index 7a193a16434..4c52708b3ab 100644 --- a/cpp/src/strings/substring.cu +++ b/cpp/src/strings/substring.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -30,6 +30,9 @@ #include +#include +#include + namespace cudf { namespace strings { namespace detail { diff --git a/cpp/src/strings/translate.cu b/cpp/src/strings/translate.cu index 8761deab4a4..8198dfd1728 100644 --- a/cpp/src/strings/translate.cu +++ b/cpp/src/strings/translate.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -29,6 +29,9 @@ #include #include +#include +#include +#include #include #include diff --git a/cpp/src/strings/utilities.cu b/cpp/src/strings/utilities.cu index cfe51824540..825f09c66e6 100644 --- a/cpp/src/strings/utilities.cu +++ b/cpp/src/strings/utilities.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -28,6 +28,8 @@ #include #include +#include +#include #include #include diff --git a/cpp/src/strings/wrap.cu b/cpp/src/strings/wrap.cu index ce3c383352d..5e6d36e4c1e 100644 --- a/cpp/src/strings/wrap.cu +++ b/cpp/src/strings/wrap.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -30,6 +30,9 @@ #include #include +#include +#include + namespace cudf { namespace strings { namespace detail { diff --git a/cpp/src/structs/utilities.cpp b/cpp/src/structs/utilities.cpp index afea8a55b16..852a32bed3d 100644 --- a/cpp/src/structs/utilities.cpp +++ b/cpp/src/structs/utilities.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -29,6 +29,7 @@ #include #include +#include #include #include diff --git a/cpp/src/table/table_view.cpp b/cpp/src/table/table_view.cpp index c89906f3480..a315da6faac 100644 --- a/cpp/src/table/table_view.cpp +++ b/cpp/src/table/table_view.cpp @@ -19,6 +19,8 @@ #include #include +#include + #include #include #include diff --git a/cpp/src/text/detokenize.cu b/cpp/src/text/detokenize.cu index 853b4820a5c..df4b486758a 100644 --- a/cpp/src/text/detokenize.cu +++ b/cpp/src/text/detokenize.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -36,6 +36,9 @@ #include #include +#include +#include +#include namespace nvtext { namespace detail { diff --git a/cpp/src/text/edit_distance.cu b/cpp/src/text/edit_distance.cu index e8953b58924..6ec364cc048 100644 --- a/cpp/src/text/edit_distance.cu +++ b/cpp/src/text/edit_distance.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -28,6 +28,11 @@ #include #include +#include +#include +#include +#include +#include #include #include diff --git a/cpp/src/text/generate_ngrams.cu b/cpp/src/text/generate_ngrams.cu index 87c288691dd..85c67f637d3 100644 --- a/cpp/src/text/generate_ngrams.cu +++ b/cpp/src/text/generate_ngrams.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -33,6 +33,10 @@ #include #include +#include +#include +#include +#include #include namespace nvtext { diff --git a/cpp/src/text/ngrams_tokenize.cu b/cpp/src/text/ngrams_tokenize.cu index 03f66609e18..ddd73635eb2 100644 --- a/cpp/src/text/ngrams_tokenize.cu +++ b/cpp/src/text/ngrams_tokenize.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -32,6 +32,9 @@ #include #include +#include +#include +#include #include #include diff --git a/cpp/src/text/normalize.cu b/cpp/src/text/normalize.cu index 62fd98d2027..482375c252a 100644 --- a/cpp/src/text/normalize.cu +++ b/cpp/src/text/normalize.cu @@ -36,7 +36,9 @@ #include +#include #include +#include #include #include diff --git a/cpp/src/text/replace.cu b/cpp/src/text/replace.cu index 9ca39bca995..56b5ad9e129 100644 --- a/cpp/src/text/replace.cu +++ b/cpp/src/text/replace.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -32,6 +32,10 @@ #include +#include +#include +#include + namespace nvtext { namespace detail { namespace { diff --git a/cpp/src/text/stemmer.cu b/cpp/src/text/stemmer.cu index a7bb03f389f..12941e0cd2a 100644 --- a/cpp/src/text/stemmer.cu +++ b/cpp/src/text/stemmer.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -31,6 +31,8 @@ #include #include +#include +#include namespace nvtext { namespace detail { diff --git a/cpp/src/text/subword/bpe_tokenizer.cu b/cpp/src/text/subword/bpe_tokenizer.cu index c9a1d685f2e..fb631b3f31f 100644 --- a/cpp/src/text/subword/bpe_tokenizer.cu +++ b/cpp/src/text/subword/bpe_tokenizer.cu @@ -33,8 +33,15 @@ #include #include #include +#include +#include +#include #include +#include +#include #include +#include +#include #include namespace nvtext { diff --git a/cpp/src/text/subword/data_normalizer.cu b/cpp/src/text/subword/data_normalizer.cu index 5af87f4de0e..2ed59c3ae0c 100644 --- a/cpp/src/text/subword/data_normalizer.cu +++ b/cpp/src/text/subword/data_normalizer.cu @@ -25,7 +25,11 @@ #include #include +#include +#include #include +#include +#include namespace nvtext { namespace detail { diff --git a/cpp/src/text/subword/load_hash_file.cu b/cpp/src/text/subword/load_hash_file.cu index 7cfdb4dea96..9ab769f9edd 100644 --- a/cpp/src/text/subword/load_hash_file.cu +++ b/cpp/src/text/subword/load_hash_file.cu @@ -27,6 +27,8 @@ #include #include +#include + #include #include #include diff --git a/cpp/src/text/subword/load_merges_file.cu b/cpp/src/text/subword/load_merges_file.cu index bdcbe45df64..31f579dc9d4 100644 --- a/cpp/src/text/subword/load_merges_file.cu +++ b/cpp/src/text/subword/load_merges_file.cu @@ -27,6 +27,8 @@ #include #include +#include + #include #include #include diff --git a/cpp/src/text/subword/subword_tokenize.cu b/cpp/src/text/subword/subword_tokenize.cu index 1ac7dd0d8a1..d6bc2fb2aac 100644 --- a/cpp/src/text/subword/subword_tokenize.cu +++ b/cpp/src/text/subword/subword_tokenize.cu @@ -27,6 +27,8 @@ #include #include +#include +#include #include namespace nvtext { diff --git a/cpp/src/text/subword/wordpiece_tokenizer.cu b/cpp/src/text/subword/wordpiece_tokenizer.cu index afd82f0bb5d..82bb50c6aaa 100644 --- a/cpp/src/text/subword/wordpiece_tokenizer.cu +++ b/cpp/src/text/subword/wordpiece_tokenizer.cu @@ -26,7 +26,12 @@ #include #include +#include +#include +#include #include +#include +#include #include #include diff --git a/cpp/src/text/tokenize.cu b/cpp/src/text/tokenize.cu index 961797e188f..311f5bd7035 100644 --- a/cpp/src/text/tokenize.cu +++ b/cpp/src/text/tokenize.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -32,6 +32,10 @@ #include #include +#include +#include +#include +#include #include namespace nvtext { diff --git a/cpp/src/text/utilities/tokenize_ops.cuh b/cpp/src/text/utilities/tokenize_ops.cuh index 75d6872a9ad..ea1f23b4a53 100644 --- a/cpp/src/text/utilities/tokenize_ops.cuh +++ b/cpp/src/text/utilities/tokenize_ops.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * Copyright (c) 2020-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,7 +17,10 @@ #include #include +#include +#include #include +#include namespace nvtext { namespace detail { diff --git a/cpp/src/transform/mask_to_bools.cu b/cpp/src/transform/mask_to_bools.cu index f4bdb2f50b2..a330ce8e17f 100644 --- a/cpp/src/transform/mask_to_bools.cu +++ b/cpp/src/transform/mask_to_bools.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -21,6 +21,7 @@ #include #include #include +#include #include #include diff --git a/cpp/src/transform/nans_to_nulls.cu b/cpp/src/transform/nans_to_nulls.cu index abe481ced70..ee63e6d366f 100644 --- a/cpp/src/transform/nans_to_nulls.cu +++ b/cpp/src/transform/nans_to_nulls.cu @@ -26,6 +26,8 @@ #include +#include + namespace cudf { namespace detail { struct dispatch_nan_to_null { diff --git a/cpp/src/transform/row_bit_count.cu b/cpp/src/transform/row_bit_count.cu index f6b10cfc583..0f06be0149e 100644 --- a/cpp/src/transform/row_bit_count.cu +++ b/cpp/src/transform/row_bit_count.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. @@ -24,6 +24,7 @@ #include #include +#include #include #include diff --git a/cpp/src/transpose/transpose.cu b/cpp/src/transpose/transpose.cu index d119bc36c73..b5b00b11a0f 100644 --- a/cpp/src/transpose/transpose.cu +++ b/cpp/src/transpose/transpose.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -26,6 +26,9 @@ #include +#include +#include + namespace cudf { namespace detail { std::pair, table_view> transpose(table_view const& input, diff --git a/cpp/src/unary/cast_ops.cu b/cpp/src/unary/cast_ops.cu index f77ab7aa3d9..dd103130a44 100644 --- a/cpp/src/unary/cast_ops.cu +++ b/cpp/src/unary/cast_ops.cu @@ -29,6 +29,8 @@ #include #include +#include + namespace cudf { namespace detail { namespace { // anonymous namespace diff --git a/cpp/src/unary/math_ops.cu b/cpp/src/unary/math_ops.cu index e92d5a1ca7e..c4a2eef9f68 100644 --- a/cpp/src/unary/math_ops.cu +++ b/cpp/src/unary/math_ops.cu @@ -25,6 +25,8 @@ #include +#include + #include #include diff --git a/cpp/src/unary/null_ops.cu b/cpp/src/unary/null_ops.cu index 6a967b4ecd7..9fb740bd3ae 100644 --- a/cpp/src/unary/null_ops.cu +++ b/cpp/src/unary/null_ops.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2020, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -23,6 +23,8 @@ #include +#include + namespace cudf { std::unique_ptr is_null(cudf::column_view const& input, rmm::mr::device_memory_resource* mr) { diff --git a/cpp/src/unary/unary_ops.cuh b/cpp/src/unary/unary_ops.cuh index c323ce8140c..19d78b010ec 100644 --- a/cpp/src/unary/unary_ops.cuh +++ b/cpp/src/unary/unary_ops.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2020, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -26,6 +26,8 @@ #include #include +#include + namespace cudf { namespace unary { template diff --git a/cpp/tests/ast/transform_tests.cpp b/cpp/tests/ast/transform_tests.cpp index 8cfd6d24fae..a8fe91170d1 100644 --- a/cpp/tests/ast/transform_tests.cpp +++ b/cpp/tests/ast/transform_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -33,6 +33,8 @@ #include +#include + #include #include #include diff --git a/cpp/tests/binaryop/binop-compiled-fixed_point-test.cpp b/cpp/tests/binaryop/binop-compiled-fixed_point-test.cpp index 335de93c976..64462669f90 100644 --- a/cpp/tests/binaryop/binop-compiled-fixed_point-test.cpp +++ b/cpp/tests/binaryop/binop-compiled-fixed_point-test.cpp @@ -30,6 +30,8 @@ #include #include +#include + namespace cudf::test::binop { template diff --git a/cpp/tests/binaryop/binop-compiled-test.cpp b/cpp/tests/binaryop/binop-compiled-test.cpp index 00408741653..72fbf8c22d1 100644 --- a/cpp/tests/binaryop/binop-compiled-test.cpp +++ b/cpp/tests/binaryop/binop-compiled-test.cpp @@ -30,6 +30,8 @@ #include #include +#include + #include namespace cudf::test::binop { diff --git a/cpp/tests/bitmask/set_nullmask_tests.cu b/cpp/tests/bitmask/set_nullmask_tests.cu index 91f72c8de5f..57563b180e4 100644 --- a/cpp/tests/bitmask/set_nullmask_tests.cu +++ b/cpp/tests/bitmask/set_nullmask_tests.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -26,6 +26,8 @@ #include #include +#include +#include #include struct valid_bit_functor { diff --git a/cpp/tests/bitmask/valid_if_tests.cu b/cpp/tests/bitmask/valid_if_tests.cu index a69f5609fef..816a89500da 100644 --- a/cpp/tests/bitmask/valid_if_tests.cu +++ b/cpp/tests/bitmask/valid_if_tests.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -23,6 +23,8 @@ #include #include +#include + struct ValidIfTest : public cudf::test::BaseFixture { }; diff --git a/cpp/tests/column/column_device_view_test.cu b/cpp/tests/column/column_device_view_test.cu index 09c29788932..1ea7dd86d21 100644 --- a/cpp/tests/column/column_device_view_test.cu +++ b/cpp/tests/column/column_device_view_test.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2020, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -28,6 +28,8 @@ #include #include +#include + struct ColumnDeviceViewTest : public cudf::test::BaseFixture { }; diff --git a/cpp/tests/column/column_test.cu b/cpp/tests/column/column_test.cu index 48de5c2e5c6..08e1001c72a 100644 --- a/cpp/tests/column/column_test.cu +++ b/cpp/tests/column/column_test.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -30,9 +30,11 @@ #include #include -#include +#include #include +#include + template struct TypedColumnTest : public cudf::test::BaseFixture { cudf::data_type type() { return cudf::data_type{cudf::type_to_id()}; } diff --git a/cpp/tests/column/compound_test.cu b/cpp/tests/column/compound_test.cu index 9a0259ee49a..eed6662b5a4 100644 --- a/cpp/tests/column/compound_test.cu +++ b/cpp/tests/column/compound_test.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -25,6 +25,7 @@ #include #include +#include #include #include diff --git a/cpp/tests/column/factories_test.cpp b/cpp/tests/column/factories_test.cpp index 728b0fdf7e5..4e0e70bf15c 100644 --- a/cpp/tests/column/factories_test.cpp +++ b/cpp/tests/column/factories_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -28,6 +28,8 @@ #include +#include + class ColumnFactoryTest : public cudf::test::BaseFixture { cudf::size_type _size{1000}; diff --git a/cpp/tests/copying/concatenate_tests.cu b/cpp/tests/copying/concatenate_tests.cu index ec7fae58f98..93e4e588e0e 100644 --- a/cpp/tests/copying/concatenate_tests.cu +++ b/cpp/tests/copying/concatenate_tests.cu @@ -30,7 +30,9 @@ #include +#include #include +#include #include #include diff --git a/cpp/tests/copying/copy_range_tests.cpp b/cpp/tests/copying/copy_range_tests.cpp index d3463fc3cc4..255b840751a 100644 --- a/cpp/tests/copying/copy_range_tests.cpp +++ b/cpp/tests/copying/copy_range_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -28,6 +28,7 @@ #include #include +#include auto all_valid = [](cudf::size_type row) { return true; }; auto even_valid = [](cudf::size_type row) { return (row % 2 == 0); }; diff --git a/cpp/tests/copying/copy_tests.cpp b/cpp/tests/copying/copy_tests.cpp index 62f1300c284..ccfd624e2d1 100644 --- a/cpp/tests/copying/copy_tests.cpp +++ b/cpp/tests/copying/copy_tests.cpp @@ -27,6 +27,9 @@ #include #include +#include +#include + template struct CopyTest : public cudf::test::BaseFixture { }; diff --git a/cpp/tests/copying/detail_gather_tests.cu b/cpp/tests/copying/detail_gather_tests.cu index da72bd3cc63..afb8cdab819 100644 --- a/cpp/tests/copying/detail_gather_tests.cu +++ b/cpp/tests/copying/detail_gather_tests.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -32,6 +32,9 @@ #include +#include +#include + template class GatherTest : public cudf::test::BaseFixture { }; diff --git a/cpp/tests/copying/get_value_tests.cpp b/cpp/tests/copying/get_value_tests.cpp index 32abd2dd71d..6d903cca020 100644 --- a/cpp/tests/copying/get_value_tests.cpp +++ b/cpp/tests/copying/get_value_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -32,6 +32,8 @@ #include #include +#include + using namespace cudf::test::iterators; namespace cudf { diff --git a/cpp/tests/copying/reverse_tests.cpp b/cpp/tests/copying/reverse_tests.cpp index 314b14dbcf5..e7195f0a91d 100644 --- a/cpp/tests/copying/reverse_tests.cpp +++ b/cpp/tests/copying/reverse_tests.cpp @@ -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. @@ -27,6 +27,8 @@ #include #include +#include +#include #include #include diff --git a/cpp/tests/copying/split_tests.cpp b/cpp/tests/copying/split_tests.cpp index b0278326e11..b4add7d4123 100644 --- a/cpp/tests/copying/split_tests.cpp +++ b/cpp/tests/copying/split_tests.cpp @@ -34,6 +34,9 @@ #include +#include +#include + std::vector splits_to_indices(std::vector splits, cudf::size_type size) { diff --git a/cpp/tests/copying/utility_tests.cpp b/cpp/tests/copying/utility_tests.cpp index 00a22b90197..67d7beb5f03 100644 --- a/cpp/tests/copying/utility_tests.cpp +++ b/cpp/tests/copying/utility_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -23,6 +23,9 @@ #include #include #include + +#include + #include template diff --git a/cpp/tests/datetime/datetime_ops_test.cpp b/cpp/tests/datetime/datetime_ops_test.cpp index 655fbf5679b..2898a649e36 100644 --- a/cpp/tests/datetime/datetime_ops_test.cpp +++ b/cpp/tests/datetime/datetime_ops_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -27,6 +27,8 @@ #include #include +#include + #define XXX false // stub for null values constexpr cudf::test::debug_output_level verbosity{cudf::test::debug_output_level::ALL_ERRORS}; diff --git a/cpp/tests/device_atomics/device_atomics_test.cu b/cpp/tests/device_atomics/device_atomics_test.cu index 31174d3fd72..581268f26f4 100644 --- a/cpp/tests/device_atomics/device_atomics_test.cu +++ b/cpp/tests/device_atomics/device_atomics_test.cu @@ -25,6 +25,8 @@ #include +#include + #include template diff --git a/cpp/tests/dictionary/factories_test.cpp b/cpp/tests/dictionary/factories_test.cpp index d8e70afb6f5..195c9794d21 100644 --- a/cpp/tests/dictionary/factories_test.cpp +++ b/cpp/tests/dictionary/factories_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -21,6 +21,8 @@ #include #include +#include + struct DictionaryFactoriesTest : public cudf::test::BaseFixture { }; diff --git a/cpp/tests/dictionary/remove_keys_test.cpp b/cpp/tests/dictionary/remove_keys_test.cpp index 6c2d941d7ee..6481f2ea9d9 100644 --- a/cpp/tests/dictionary/remove_keys_test.cpp +++ b/cpp/tests/dictionary/remove_keys_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -22,6 +22,8 @@ #include #include +#include + #include struct DictionaryRemoveKeysTest : public cudf::test::BaseFixture { diff --git a/cpp/tests/dictionary/set_keys_test.cpp b/cpp/tests/dictionary/set_keys_test.cpp index 9e15bc63740..ec8f6a0cdbf 100644 --- a/cpp/tests/dictionary/set_keys_test.cpp +++ b/cpp/tests/dictionary/set_keys_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -21,6 +21,8 @@ #include #include +#include + #include struct DictionarySetKeysTest : public cudf::test::BaseFixture { diff --git a/cpp/tests/groupby/tdigest_tests.cu b/cpp/tests/groupby/tdigest_tests.cu index 7e6199e73c5..a0f23ff40e7 100644 --- a/cpp/tests/groupby/tdigest_tests.cu +++ b/cpp/tests/groupby/tdigest_tests.cu @@ -25,7 +25,9 @@ #include #include +#include #include +#include namespace cudf { namespace test { diff --git a/cpp/tests/hash_map/map_test.cu b/cpp/tests/hash_map/map_test.cu index 54f7a97fb2b..d69aee57756 100644 --- a/cpp/tests/hash_map/map_test.cu +++ b/cpp/tests/hash_map/map_test.cu @@ -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. @@ -25,6 +25,8 @@ #include #include +#include +#include #include "rmm/exec_policy.hpp" #include diff --git a/cpp/tests/hash_map/multimap_test.cu b/cpp/tests/hash_map/multimap_test.cu index 456ba951a45..b8f35b4d404 100644 --- a/cpp/tests/hash_map/multimap_test.cu +++ b/cpp/tests/hash_map/multimap_test.cu @@ -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. @@ -24,6 +24,8 @@ #include +#include + #include // This is necessary to do a parametrized typed-test over multiple template diff --git a/cpp/tests/interop/dlpack_test.cpp b/cpp/tests/interop/dlpack_test.cpp index 48a3b82d9b5..2528c3e5a83 100644 --- a/cpp/tests/interop/dlpack_test.cpp +++ b/cpp/tests/interop/dlpack_test.cpp @@ -22,6 +22,8 @@ #include +#include + using namespace cudf::test; struct dlpack_deleter { diff --git a/cpp/tests/interop/to_arrow_test.cpp b/cpp/tests/interop/to_arrow_test.cpp index 52f2d5709d2..d1dc60119b6 100644 --- a/cpp/tests/interop/to_arrow_test.cpp +++ b/cpp/tests/interop/to_arrow_test.cpp @@ -34,6 +34,8 @@ #include +#include + using vector_of_columns = std::vector>; std::pair, std::shared_ptr> get_tables( diff --git a/cpp/tests/io/parquet_test.cpp b/cpp/tests/io/parquet_test.cpp index 02921bc5084..1f4a8a7e508 100644 --- a/cpp/tests/io/parquet_test.cpp +++ b/cpp/tests/io/parquet_test.cpp @@ -35,6 +35,8 @@ #include +#include + #include #include diff --git a/cpp/tests/iterator/indexalator_test.cu b/cpp/tests/iterator/indexalator_test.cu index fd2cae3d344..60e10b165c8 100644 --- a/cpp/tests/iterator/indexalator_test.cu +++ b/cpp/tests/iterator/indexalator_test.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. @@ -20,6 +20,10 @@ #include +#include +#include +#include + using TestingTypes = cudf::test::IntegralTypesNotBool; template diff --git a/cpp/tests/iterator/iterator_tests.cuh b/cpp/tests/iterator/iterator_tests.cuh index d93c1275122..697af0411d7 100644 --- a/cpp/tests/iterator/iterator_tests.cuh +++ b/cpp/tests/iterator/iterator_tests.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -26,8 +26,11 @@ #include #include +#include #include +#include #include +#include #include #include diff --git a/cpp/tests/iterator/optional_iterator_test.cuh b/cpp/tests/iterator/optional_iterator_test.cuh index d19c9e49ad9..7983aa85655 100644 --- a/cpp/tests/iterator/optional_iterator_test.cuh +++ b/cpp/tests/iterator/optional_iterator_test.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -15,6 +15,9 @@ #include +#include +#include + template void nonull_optional_iterator(IteratorTest& testFixture) { diff --git a/cpp/tests/iterator/optional_iterator_test_numeric.cu b/cpp/tests/iterator/optional_iterator_test_numeric.cu index e8102dee2a2..afc28b7e97c 100644 --- a/cpp/tests/iterator/optional_iterator_test_numeric.cu +++ b/cpp/tests/iterator/optional_iterator_test_numeric.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -14,6 +14,10 @@ */ #include +#include +#include +#include + using TestingTypes = cudf::test::NumericTypes; template diff --git a/cpp/tests/iterator/pair_iterator_test.cuh b/cpp/tests/iterator/pair_iterator_test.cuh index 4d0f3021d3c..69130ffd431 100644 --- a/cpp/tests/iterator/pair_iterator_test.cuh +++ b/cpp/tests/iterator/pair_iterator_test.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -15,6 +15,9 @@ #include +#include +#include + template void nonull_pair_iterator(IteratorTest& testFixture) { diff --git a/cpp/tests/iterator/pair_iterator_test_numeric.cu b/cpp/tests/iterator/pair_iterator_test_numeric.cu index 99c3bfc2eb4..41dd9b65e42 100644 --- a/cpp/tests/iterator/pair_iterator_test_numeric.cu +++ b/cpp/tests/iterator/pair_iterator_test_numeric.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -14,6 +14,10 @@ */ #include +#include +#include +#include + using TestingTypes = cudf::test::NumericTypes; template diff --git a/cpp/tests/iterator/scalar_iterator_test.cu b/cpp/tests/iterator/scalar_iterator_test.cu index 3a394d30f97..b867703535e 100644 --- a/cpp/tests/iterator/scalar_iterator_test.cu +++ b/cpp/tests/iterator/scalar_iterator_test.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -14,6 +14,9 @@ */ #include +#include +#include + using TestingTypes = cudf::test::FixedWidthTypesWithoutFixedPoint; TYPED_TEST_SUITE(IteratorTest, TestingTypes); diff --git a/cpp/tests/iterator/value_iterator_test.cuh b/cpp/tests/iterator/value_iterator_test.cuh index 8e542af643d..d99f055d331 100644 --- a/cpp/tests/iterator/value_iterator_test.cuh +++ b/cpp/tests/iterator/value_iterator_test.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -15,6 +15,8 @@ #include "cudf/detail/utilities/vector_factories.hpp" #include +#include + // tests for non-null iterator (pointer of device array) template void non_null_iterator(IteratorTest& testFixture) diff --git a/cpp/tests/iterator/value_iterator_test_strings.cu b/cpp/tests/iterator/value_iterator_test_strings.cu index c0ed9fa7480..5bddbfbd4aa 100644 --- a/cpp/tests/iterator/value_iterator_test_strings.cu +++ b/cpp/tests/iterator/value_iterator_test_strings.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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,6 +17,10 @@ #include "rmm/device_uvector.hpp" #include +#include +#include +#include + auto strings_to_string_views(std::vector& input_strings) { auto all_valid = cudf::detail::make_counting_transform_iterator(0, [](auto i) { return true; }); diff --git a/cpp/tests/iterator/value_iterator_test_transform.cu b/cpp/tests/iterator/value_iterator_test_transform.cu index 164872d236b..b8bb596b821 100644 --- a/cpp/tests/iterator/value_iterator_test_transform.cu +++ b/cpp/tests/iterator/value_iterator_test_transform.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -14,6 +14,10 @@ */ #include +#include +#include +#include + struct TransformedIteratorTest : public IteratorTest { }; diff --git a/cpp/tests/join/conditional_join_tests.cu b/cpp/tests/join/conditional_join_tests.cu index 702acb884e4..73b355d496d 100644 --- a/cpp/tests/join/conditional_join_tests.cu +++ b/cpp/tests/join/conditional_join_tests.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -25,6 +25,7 @@ #include +#include #include #include #include diff --git a/cpp/tests/lists/count_elements_tests.cpp b/cpp/tests/lists/count_elements_tests.cpp index 28d31d27ae5..58c780c37f4 100644 --- a/cpp/tests/lists/count_elements_tests.cpp +++ b/cpp/tests/lists/count_elements_tests.cpp @@ -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. @@ -22,6 +22,9 @@ #include #include +#include +#include + struct ListsElementsTest : public cudf::test::BaseFixture { }; diff --git a/cpp/tests/lists/extract_tests.cpp b/cpp/tests/lists/extract_tests.cpp index c7e8ba7e5de..210a5814ede 100644 --- a/cpp/tests/lists/extract_tests.cpp +++ b/cpp/tests/lists/extract_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -28,6 +28,8 @@ #include #include +#include +#include #include diff --git a/cpp/tests/merge/merge_test.cpp b/cpp/tests/merge/merge_test.cpp index c2cd6202dff..ea26cad3b59 100644 --- a/cpp/tests/merge/merge_test.cpp +++ b/cpp/tests/merge/merge_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -30,6 +30,9 @@ #include #include +#include +#include + #include template @@ -743,10 +746,10 @@ TEST_F(MergeTest, Structs) cudf::table_view t0({t0_col0, t0_col1}); cudf::table_view t1({t1_col0, t1_col1}); - + auto result = cudf::merge({t0, t1}, {0}, {cudf::order::ASCENDING}); - cudf::test::fixed_width_column_wrapper e_col0{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + cudf::test::fixed_width_column_wrapper e_col0{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; cudf::test::strings_column_wrapper e_scol0{"abc", "pqr", "def", "stu", "ghi", "vwx", "jkl", "yzz", "mno", "000"}; cudf::test::fixed_width_column_wrapper e_scol1{1, -1, 2, -2, 3, -3, 4, -4, 5, -5}; cudf::test::structs_column_wrapper e_col1({e_scol0, e_scol1}); @@ -774,7 +777,7 @@ TEST_F(MergeTest, StructsWithNulls) cudf::table_view t0({t0_col0, t0_col1}); cudf::table_view t1({t1_col0, t1_col1}); - + auto result = cudf::merge({t0, t1}, {0}, {cudf::order::ASCENDING}); cudf::test::fixed_width_column_wrapper e_col0{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; @@ -794,18 +797,18 @@ TEST_F(MergeTest, StructsWithNulls) TEST_F(MergeTest, StructsNested) { // clang-format off - - cudf::test::fixed_width_column_wrapper t0_col0{8, 6, 4, 2, 0}; + + cudf::test::fixed_width_column_wrapper t0_col0{8, 6, 4, 2, 0}; cudf::test::strings_column_wrapper t0_scol0{"mno", "jkl", "ghi", "def", "abc"}; - cudf::test::fixed_width_column_wrapper t0_scol1{5, 4, 3, 2, 1}; + cudf::test::fixed_width_column_wrapper t0_scol1{5, 4, 3, 2, 1}; cudf::test::strings_column_wrapper t0_sscol0{"5555", "4444", "333", "22", "1"}; cudf::test::fixed_width_column_wrapper t0_sscol1{50, 40, 30, 20, 10}; - cudf::test::structs_column_wrapper t0_scol2({t0_sscol0, t0_sscol1}); + cudf::test::structs_column_wrapper t0_scol2({t0_sscol0, t0_sscol1}); cudf::test::structs_column_wrapper t0_col1({t0_scol0, t0_scol1, t0_scol2}); cudf::test::fixed_width_column_wrapper t1_col0{9, 7, 5, 3, 1}; cudf::test::strings_column_wrapper t1_scol0{"000", "yzz", "vwx", "stu", "pqr"}; - cudf::test::fixed_width_column_wrapper t1_scol1{-5, -4, -3, -2, -1}; + cudf::test::fixed_width_column_wrapper t1_scol1{-5, -4, -3, -2, -1}; cudf::test::strings_column_wrapper t1_sscol0{"-5555", "-4444", "-333", "-22", "-1"}; cudf::test::fixed_width_column_wrapper t1_sscol1{-50, -40, -30, -20, -10}; cudf::test::structs_column_wrapper t1_scol2({t1_sscol0, t1_sscol1}); @@ -813,12 +816,12 @@ TEST_F(MergeTest, StructsNested) cudf::table_view t0({t0_col0 , t0_col1}); cudf::table_view t1({t1_col0 , t1_col1}); - + auto result = cudf::merge({t0, t1}, {0}, {cudf::order::DESCENDING}); cudf::test::fixed_width_column_wrapper e_col0{9, 8, 7, 6, 5, 4, 3, 2, 1, 0}; cudf::test::strings_column_wrapper e_scol0{"000", "mno", "yzz", "jkl", "vwx", "ghi", "stu", "def", "pqr", "abc"}; - cudf::test::fixed_width_column_wrapper e_scol1{-5, 5, -4, 4, -3, 3, -2, 2, -1, 1}; + cudf::test::fixed_width_column_wrapper e_scol1{-5, 5, -4, 4, -3, 3, -2, 2, -1, 1}; cudf::test::strings_column_wrapper e_sscol0{"-5555", "5555", "-4444", "4444", "-333", "333", "-22", "22", "-1", "1"}; cudf::test::fixed_width_column_wrapper e_sscol1{-50, 50, -40, 40, -30, 30, -20, 20, -10, 10}; cudf::test::structs_column_wrapper e_scol2({e_sscol0, e_sscol1}); @@ -834,13 +837,13 @@ TEST_F(MergeTest, StructsNested) TEST_F(MergeTest, StructsNestedWithNulls) { // clang-format off - - cudf::test::fixed_width_column_wrapper t0_col0{8, 6, 4, 2, 0}; + + cudf::test::fixed_width_column_wrapper t0_col0{8, 6, 4, 2, 0}; cudf::test::strings_column_wrapper t0_scol0{"mno", "jkl", "ghi", "def", "abc"}; - cudf::test::fixed_width_column_wrapper t0_scol1{{5, 4, 3, 2, 1}, {1, 1, 0, 1, 1}}; + cudf::test::fixed_width_column_wrapper t0_scol1{{5, 4, 3, 2, 1}, {1, 1, 0, 1, 1}}; cudf::test::strings_column_wrapper t0_sscol0{{"5555", "4444", "333", "22", "1"}, {1, 0, 1, 1, 0}}; cudf::test::fixed_width_column_wrapper t0_sscol1{50, 40, 30, 20, 10}; - cudf::test::structs_column_wrapper t0_scol2({t0_sscol0, t0_sscol1}, {0, 0, 1, 1, 1}); + cudf::test::structs_column_wrapper t0_scol2({t0_sscol0, t0_sscol1}, {0, 0, 1, 1, 1}); cudf::test::structs_column_wrapper t0_col1({t0_scol0, t0_scol1, t0_scol2}, {0, 0, 1, 1, 1}); cudf::test::fixed_width_column_wrapper t1_col0{9, 7, 5, 3, 1}; @@ -853,7 +856,7 @@ TEST_F(MergeTest, StructsNestedWithNulls) cudf::table_view t0({t0_col0 , t0_col1}); cudf::table_view t1({t1_col0 , t1_col1}); - + auto result = cudf::merge({t0, t1}, {0}, {cudf::order::DESCENDING}); cudf::test::fixed_width_column_wrapper e_col0{9, 8, 7, 6, 5, 4, 3, 2, 1, 0}; diff --git a/cpp/tests/partitioning/hash_partition_test.cpp b/cpp/tests/partitioning/hash_partition_test.cpp index ab8a394ab37..befd9884b11 100644 --- a/cpp/tests/partitioning/hash_partition_test.cpp +++ b/cpp/tests/partitioning/hash_partition_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -24,6 +24,9 @@ #include #include +#include +#include + using cudf::test::fixed_width_column_wrapper; using cudf::test::strings_column_wrapper; diff --git a/cpp/tests/quantiles/percentile_approx_test.cu b/cpp/tests/quantiles/percentile_approx_test.cu index 67bc9c68d6e..9af42e1589d 100644 --- a/cpp/tests/quantiles/percentile_approx_test.cu +++ b/cpp/tests/quantiles/percentile_approx_test.cu @@ -33,6 +33,10 @@ #include +#include +#include +#include + using namespace cudf; using namespace cudf::tdigest; diff --git a/cpp/tests/quantiles/tdigest_utilities.cu b/cpp/tests/quantiles/tdigest_utilities.cu index f5c05a6c244..d8fa2d842f7 100644 --- a/cpp/tests/quantiles/tdigest_utilities.cu +++ b/cpp/tests/quantiles/tdigest_utilities.cu @@ -25,6 +25,11 @@ #include +#include +#include +#include +#include + // for use with groupby and reduction aggregation tests. namespace cudf { diff --git a/cpp/tests/reductions/rank_tests.cpp b/cpp/tests/reductions/rank_tests.cpp index 52bffa3e4f9..fb2cd17fe30 100644 --- a/cpp/tests/reductions/rank_tests.cpp +++ b/cpp/tests/reductions/rank_tests.cpp @@ -25,6 +25,8 @@ #include #include +#include + using aggregation = cudf::aggregation; using cudf::null_policy; using cudf::scan_type; diff --git a/cpp/tests/reductions/scan_tests.cpp b/cpp/tests/reductions/scan_tests.cpp index 75ea5900ec8..d533a91f4d0 100644 --- a/cpp/tests/reductions/scan_tests.cpp +++ b/cpp/tests/reductions/scan_tests.cpp @@ -25,7 +25,9 @@ #include #include +#include #include +#include #include #include diff --git a/cpp/tests/reductions/segmented_reduction_tests.cpp b/cpp/tests/reductions/segmented_reduction_tests.cpp index 3a432cce801..f750c432efb 100644 --- a/cpp/tests/reductions/segmented_reduction_tests.cpp +++ b/cpp/tests/reductions/segmented_reduction_tests.cpp @@ -22,6 +22,8 @@ #include #include +#include + #include namespace cudf { diff --git a/cpp/tests/replace/clamp_test.cpp b/cpp/tests/replace/clamp_test.cpp index e315bdd9b16..c54ec5e8cc7 100644 --- a/cpp/tests/replace/clamp_test.cpp +++ b/cpp/tests/replace/clamp_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -27,6 +27,8 @@ #include +#include + struct ClampErrorTest : public cudf::test::BaseFixture { }; diff --git a/cpp/tests/replace/replace_nulls_tests.cpp b/cpp/tests/replace/replace_nulls_tests.cpp index effa026867e..8b8faa9d89e 100644 --- a/cpp/tests/replace/replace_nulls_tests.cpp +++ b/cpp/tests/replace/replace_nulls_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-2022, NVIDIA CORPORATION. * * Copyright 2018 BlazingDB, Inc. * Copyright 2018 Alexander Ocsa @@ -34,6 +34,7 @@ #include #include +#include #include using namespace cudf::test::iterators; diff --git a/cpp/tests/replace/replace_tests.cpp b/cpp/tests/replace/replace_tests.cpp index 7540dfd94c5..b6d3e4d05c8 100644 --- a/cpp/tests/replace/replace_tests.cpp +++ b/cpp/tests/replace/replace_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-2022, NVIDIA CORPORATION. * * Copyright 2018 BlazingDB, Inc. * Copyright 2018 Cristhian Alberto Gonzales Castillo @@ -29,6 +29,7 @@ #include #include +#include #include #include diff --git a/cpp/tests/rolling/collect_ops_test.cpp b/cpp/tests/rolling/collect_ops_test.cpp index ce778ec3bf2..9a7219a24cb 100644 --- a/cpp/tests/rolling/collect_ops_test.cpp +++ b/cpp/tests/rolling/collect_ops_test.cpp @@ -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. @@ -29,6 +29,7 @@ #include #include +#include #include #include diff --git a/cpp/tests/rolling/grouped_rolling_test.cpp b/cpp/tests/rolling/grouped_rolling_test.cpp index 529ae815ad9..f484661eee8 100644 --- a/cpp/tests/rolling/grouped_rolling_test.cpp +++ b/cpp/tests/rolling/grouped_rolling_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -30,7 +30,9 @@ #include #include +#include #include +#include #include #include diff --git a/cpp/tests/rolling/range_rolling_window_test.cpp b/cpp/tests/rolling/range_rolling_window_test.cpp index 8d92bf56180..2374e4aad21 100644 --- a/cpp/tests/rolling/range_rolling_window_test.cpp +++ b/cpp/tests/rolling/range_rolling_window_test.cpp @@ -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. @@ -30,6 +30,8 @@ #include #include +#include +#include #include #include diff --git a/cpp/tests/rolling/rolling_test.cpp b/cpp/tests/rolling/rolling_test.cpp index 6a16f1fc64b..c54fe073e3a 100644 --- a/cpp/tests/rolling/rolling_test.cpp +++ b/cpp/tests/rolling/rolling_test.cpp @@ -33,6 +33,7 @@ #include #include +#include #include #include diff --git a/cpp/tests/search/search_test.cpp b/cpp/tests/search/search_test.cpp index 41bc0af20d9..0a2533cd5f3 100644 --- a/cpp/tests/search/search_test.cpp +++ b/cpp/tests/search/search_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -22,6 +22,8 @@ #include #include +#include + struct SearchTest : public cudf::test::BaseFixture { }; diff --git a/cpp/tests/sort/rank_test.cpp b/cpp/tests/sort/rank_test.cpp index 926ad1e203e..c4d0b6b04f4 100644 --- a/cpp/tests/sort/rank_test.cpp +++ b/cpp/tests/sort/rank_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -25,6 +25,9 @@ #include #include #include + +#include + #include #include diff --git a/cpp/tests/sort/sort_test.cpp b/cpp/tests/sort/sort_test.cpp index ed86277cd2b..a6e1a25ec17 100644 --- a/cpp/tests/sort/sort_test.cpp +++ b/cpp/tests/sort/sort_test.cpp @@ -25,6 +25,9 @@ #include #include +#include +#include + #include #include diff --git a/cpp/tests/sort/stable_sort_tests.cpp b/cpp/tests/sort/stable_sort_tests.cpp index f80764e66a3..b6b7495136e 100644 --- a/cpp/tests/sort/stable_sort_tests.cpp +++ b/cpp/tests/sort/stable_sort_tests.cpp @@ -25,6 +25,9 @@ #include #include +#include +#include + #include #include diff --git a/cpp/tests/stream_compaction/apply_boolean_mask_tests.cpp b/cpp/tests/stream_compaction/apply_boolean_mask_tests.cpp index b78c3b9417f..036329ccd3d 100644 --- a/cpp/tests/stream_compaction/apply_boolean_mask_tests.cpp +++ b/cpp/tests/stream_compaction/apply_boolean_mask_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -27,6 +27,9 @@ #include #include +#include +#include + struct ApplyBooleanMask : public cudf::test::BaseFixture { }; diff --git a/cpp/tests/strings/array_tests.cpp b/cpp/tests/strings/array_tests.cpp index 2a13abfacfb..10cc4562be7 100644 --- a/cpp/tests/strings/array_tests.cpp +++ b/cpp/tests/strings/array_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -28,6 +28,7 @@ #include #include +#include #include diff --git a/cpp/tests/strings/contains_tests.cpp b/cpp/tests/strings/contains_tests.cpp index bacd62ac86e..4015c36b283 100644 --- a/cpp/tests/strings/contains_tests.cpp +++ b/cpp/tests/strings/contains_tests.cpp @@ -21,6 +21,10 @@ #include #include +#include +#include +#include + #include #include diff --git a/cpp/tests/strings/datetime_tests.cpp b/cpp/tests/strings/datetime_tests.cpp index 9375a29a078..eccf518e13d 100644 --- a/cpp/tests/strings/datetime_tests.cpp +++ b/cpp/tests/strings/datetime_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2020, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -26,6 +26,8 @@ #include #include +#include + #include struct StringsDatetimeTest : public cudf::test::BaseFixture { @@ -409,7 +411,7 @@ TEST_F(StringsDatetimeTest, FromTimestampDayOfYear) cudf::test::strings_column_wrapper format_names({"AM", "PM", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", - "January", "February", "March", "April", "May", "June", "July", + "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}); // clang-format on diff --git a/cpp/tests/strings/extract_tests.cpp b/cpp/tests/strings/extract_tests.cpp index 9a28dbf0697..49a0c51e14f 100644 --- a/cpp/tests/strings/extract_tests.cpp +++ b/cpp/tests/strings/extract_tests.cpp @@ -26,6 +26,8 @@ #include #include +#include + #include struct StringsExtractTests : public cudf::test::BaseFixture { diff --git a/cpp/tests/strings/factories_test.cu b/cpp/tests/strings/factories_test.cu index d35cb5c3b9d..0ba4b268c70 100644 --- a/cpp/tests/strings/factories_test.cu +++ b/cpp/tests/strings/factories_test.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -32,6 +32,8 @@ #include #include +#include +#include #include #include diff --git a/cpp/tests/strings/fill_tests.cpp b/cpp/tests/strings/fill_tests.cpp index 3952f02d5f3..721fb6d8d33 100644 --- a/cpp/tests/strings/fill_tests.cpp +++ b/cpp/tests/strings/fill_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -24,6 +24,8 @@ #include #include +#include + #include struct StringsFillTest : public cudf::test::BaseFixture { diff --git a/cpp/tests/strings/find_multiple_tests.cpp b/cpp/tests/strings/find_multiple_tests.cpp index 7b9f639f965..049cc254527 100644 --- a/cpp/tests/strings/find_multiple_tests.cpp +++ b/cpp/tests/strings/find_multiple_tests.cpp @@ -23,6 +23,8 @@ #include #include +#include + #include struct StringsFindMultipleTest : public cudf::test::BaseFixture { diff --git a/cpp/tests/strings/find_tests.cpp b/cpp/tests/strings/find_tests.cpp index 97b1dd716d7..177e6d97f7f 100644 --- a/cpp/tests/strings/find_tests.cpp +++ b/cpp/tests/strings/find_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -24,6 +24,8 @@ #include #include +#include + #include struct StringsFindTest : public cudf::test::BaseFixture { diff --git a/cpp/tests/strings/findall_tests.cpp b/cpp/tests/strings/findall_tests.cpp index 21c38565372..44fa0410184 100644 --- a/cpp/tests/strings/findall_tests.cpp +++ b/cpp/tests/strings/findall_tests.cpp @@ -22,6 +22,8 @@ #include #include +#include + #include struct StringsFindallTests : public cudf::test::BaseFixture { diff --git a/cpp/tests/strings/floats_tests.cpp b/cpp/tests/strings/floats_tests.cpp index 01dd19bf308..bec06f7e601 100644 --- a/cpp/tests/strings/floats_tests.cpp +++ b/cpp/tests/strings/floats_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -22,6 +22,8 @@ #include #include +#include + #include constexpr cudf::test::debug_output_level verbosity{cudf::test::debug_output_level::ALL_ERRORS}; diff --git a/cpp/tests/strings/integers_tests.cpp b/cpp/tests/strings/integers_tests.cpp index 81e45f2808e..7f8a31ef9bb 100644 --- a/cpp/tests/strings/integers_tests.cpp +++ b/cpp/tests/strings/integers_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -27,6 +27,9 @@ #include #include +#include +#include + #include #include diff --git a/cpp/tests/strings/ipv4_tests.cpp b/cpp/tests/strings/ipv4_tests.cpp index 6abe9a55da1..1bc726edea7 100644 --- a/cpp/tests/strings/ipv4_tests.cpp +++ b/cpp/tests/strings/ipv4_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -21,6 +21,8 @@ #include #include +#include + #include struct StringsConvertTest : public cudf::test::BaseFixture { diff --git a/cpp/tests/strings/pad_tests.cpp b/cpp/tests/strings/pad_tests.cpp index a07f298b3af..4ec4690cf00 100644 --- a/cpp/tests/strings/pad_tests.cpp +++ b/cpp/tests/strings/pad_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2020, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -26,6 +26,8 @@ #include #include +#include + #include struct StringsPadTest : public cudf::test::BaseFixture { diff --git a/cpp/tests/strings/replace_regex_tests.cpp b/cpp/tests/strings/replace_regex_tests.cpp index aac99c79721..2b9e8b7aae7 100644 --- a/cpp/tests/strings/replace_regex_tests.cpp +++ b/cpp/tests/strings/replace_regex_tests.cpp @@ -21,6 +21,8 @@ #include #include +#include + #include struct StringsReplaceRegexTest : public cudf::test::BaseFixture { diff --git a/cpp/tests/strings/replace_tests.cpp b/cpp/tests/strings/replace_tests.cpp index 63a65e178c7..75c6cfa70e4 100644 --- a/cpp/tests/strings/replace_tests.cpp +++ b/cpp/tests/strings/replace_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -24,6 +24,9 @@ #include #include +#include +#include + #include using algorithm = cudf::strings::detail::replace_algorithm; diff --git a/cpp/tests/strings/split_tests.cpp b/cpp/tests/strings/split_tests.cpp index f0d7315929b..a74de7c7986 100644 --- a/cpp/tests/strings/split_tests.cpp +++ b/cpp/tests/strings/split_tests.cpp @@ -28,6 +28,8 @@ #include #include +#include + #include struct StringsSplitTest : public cudf::test::BaseFixture { diff --git a/cpp/tests/strings/strip_tests.cpp b/cpp/tests/strings/strip_tests.cpp index 661444ff515..4c1d3b67600 100644 --- a/cpp/tests/strings/strip_tests.cpp +++ b/cpp/tests/strings/strip_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -23,6 +23,8 @@ #include #include +#include + #include struct StringsStripTest : public cudf::test::BaseFixture { diff --git a/cpp/tests/strings/substring_tests.cpp b/cpp/tests/strings/substring_tests.cpp index 4fa4686e887..1a90dc5fe38 100644 --- a/cpp/tests/strings/substring_tests.cpp +++ b/cpp/tests/strings/substring_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -24,8 +24,11 @@ #include #include -#include +#include +#include #include + +#include #include struct StringsSubstringsTest : public cudf::test::BaseFixture { diff --git a/cpp/tests/strings/translate_tests.cpp b/cpp/tests/strings/translate_tests.cpp index c516383b8a1..e928065dca4 100644 --- a/cpp/tests/strings/translate_tests.cpp +++ b/cpp/tests/strings/translate_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2020, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -25,6 +25,8 @@ #include #include +#include + #include struct StringsTranslateTest : public cudf::test::BaseFixture { diff --git a/cpp/tests/strings/urls_tests.cpp b/cpp/tests/strings/urls_tests.cpp index 86c94a85025..95a51bbaaeb 100644 --- a/cpp/tests/strings/urls_tests.cpp +++ b/cpp/tests/strings/urls_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -21,6 +21,8 @@ #include #include +#include + #include #include diff --git a/cpp/tests/table/table_view_tests.cu b/cpp/tests/table/table_view_tests.cu index a1c0c49a881..34b76b1765a 100644 --- a/cpp/tests/table/table_view_tests.cu +++ b/cpp/tests/table/table_view_tests.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2020, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -28,6 +28,9 @@ #include #include +#include +#include + #include // Compares two tables row by row, if table1 row is less than table2, then corresponding row value diff --git a/cpp/tests/text/edit_distance_tests.cpp b/cpp/tests/text/edit_distance_tests.cpp index 849039a0a06..4085e797ad8 100644 --- a/cpp/tests/text/edit_distance_tests.cpp +++ b/cpp/tests/text/edit_distance_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -22,6 +22,8 @@ #include #include +#include + #include struct TextEditDistanceTest : public cudf::test::BaseFixture { diff --git a/cpp/tests/text/ngrams_tests.cpp b/cpp/tests/text/ngrams_tests.cpp index 5c1e27eea3d..20ffd3baa41 100644 --- a/cpp/tests/text/ngrams_tests.cpp +++ b/cpp/tests/text/ngrams_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -24,6 +24,8 @@ #include +#include + #include struct TextGenerateNgramsTest : public cudf::test::BaseFixture { diff --git a/cpp/tests/text/ngrams_tokenize_tests.cpp b/cpp/tests/text/ngrams_tokenize_tests.cpp index ce9cd111396..92412d74678 100644 --- a/cpp/tests/text/ngrams_tokenize_tests.cpp +++ b/cpp/tests/text/ngrams_tokenize_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -23,6 +23,8 @@ #include #include +#include + #include struct TextNgramsTokenizeTest : public cudf::test::BaseFixture { diff --git a/cpp/tests/text/normalize_tests.cpp b/cpp/tests/text/normalize_tests.cpp index cdf0b7767bb..d8c8307f4ea 100644 --- a/cpp/tests/text/normalize_tests.cpp +++ b/cpp/tests/text/normalize_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -25,6 +25,8 @@ #include +#include + #include struct TextNormalizeTest : public cudf::test::BaseFixture { diff --git a/cpp/tests/text/replace_tests.cpp b/cpp/tests/text/replace_tests.cpp index 2d9ad659f66..00158cc9787 100644 --- a/cpp/tests/text/replace_tests.cpp +++ b/cpp/tests/text/replace_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -24,6 +24,8 @@ #include +#include + #include struct TextReplaceTest : public cudf::test::BaseFixture { diff --git a/cpp/tests/text/stemmer_tests.cpp b/cpp/tests/text/stemmer_tests.cpp index 59c6ede7c6a..f4e77ac19dd 100644 --- a/cpp/tests/text/stemmer_tests.cpp +++ b/cpp/tests/text/stemmer_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -24,6 +24,8 @@ #include +#include + #include struct TextStemmerTest : public cudf::test::BaseFixture { diff --git a/cpp/tests/text/tokenize_tests.cpp b/cpp/tests/text/tokenize_tests.cpp index 4d0e1f6e5b5..16c51354d08 100644 --- a/cpp/tests/text/tokenize_tests.cpp +++ b/cpp/tests/text/tokenize_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -23,6 +23,8 @@ #include #include +#include + #include struct TextTokenizeTest : public cudf::test::BaseFixture { diff --git a/cpp/tests/transform/bools_to_mask_test.cpp b/cpp/tests/transform/bools_to_mask_test.cpp index 52e03b8ffa6..d14f2a11b4f 100644 --- a/cpp/tests/transform/bools_to_mask_test.cpp +++ b/cpp/tests/transform/bools_to_mask_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -24,6 +24,8 @@ #include #include +#include + struct MaskToNullTest : public cudf::test::BaseFixture { void run_test(std::vector input, std::vector val) { diff --git a/cpp/tests/transform/row_bit_count_test.cu b/cpp/tests/transform/row_bit_count_test.cu index 43d63c9fd22..8ed50b6eae0 100644 --- a/cpp/tests/transform/row_bit_count_test.cu +++ b/cpp/tests/transform/row_bit_count_test.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. @@ -27,8 +27,12 @@ #include +#include #include +#include +#include #include +#include using namespace cudf; diff --git a/cpp/tests/unary/cast_tests.cpp b/cpp/tests/unary/cast_tests.cpp index ceaff4b7c58..f53498bccec 100644 --- a/cpp/tests/unary/cast_tests.cpp +++ b/cpp/tests/unary/cast_tests.cpp @@ -26,6 +26,9 @@ #include #include +#include +#include + #include #include diff --git a/cpp/tests/unary/unary_ops_test.cpp b/cpp/tests/unary/unary_ops_test.cpp index 664322a386f..dd938254041 100644 --- a/cpp/tests/unary/unary_ops_test.cpp +++ b/cpp/tests/unary/unary_ops_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -22,6 +22,8 @@ #include #include +#include + template cudf::test::fixed_width_column_wrapper create_fixed_columns(cudf::size_type start, cudf::size_type size, diff --git a/cpp/tests/utilities/column_utilities.cu b/cpp/tests/utilities/column_utilities.cu index 9daf70227f8..68626c2d4d3 100644 --- a/cpp/tests/utilities/column_utilities.cu +++ b/cpp/tests/utilities/column_utilities.cu @@ -39,11 +39,19 @@ #include #include +#include +#include #include #include +#include #include +#include #include +#include +#include +#include #include +#include #include #include diff --git a/cpp/tests/utilities_tests/column_utilities_tests.cpp b/cpp/tests/utilities_tests/column_utilities_tests.cpp index 082f493da7d..fb4125d1752 100644 --- a/cpp/tests/utilities_tests/column_utilities_tests.cpp +++ b/cpp/tests/utilities_tests/column_utilities_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -25,6 +25,7 @@ #include #include +#include #include diff --git a/cpp/tests/utilities_tests/span_tests.cu b/cpp/tests/utilities_tests/span_tests.cu index 044ac3e60f7..0fe9aa33790 100644 --- a/cpp/tests/utilities_tests/span_tests.cu +++ b/cpp/tests/utilities_tests/span_tests.cu @@ -24,6 +24,9 @@ #include #include +#include +#include + #include #include #include diff --git a/cpp/tests/wrappers/timestamps_test.cu b/cpp/tests/wrappers/timestamps_test.cu index 48500c84942..236224de84d 100644 --- a/cpp/tests/wrappers/timestamps_test.cu +++ b/cpp/tests/wrappers/timestamps_test.cu @@ -32,6 +32,9 @@ #include #include +#include +#include + template struct ChronoColumnTest : public cudf::test::BaseFixture { rmm::cuda_stream_view stream() { return rmm::cuda_stream_default; } diff --git a/java/src/test/java/ai/rapids/cudf/TableTest.java b/java/src/test/java/ai/rapids/cudf/TableTest.java index 9f34006043a..7be1ca2118b 100644 --- a/java/src/test/java/ai/rapids/cudf/TableTest.java +++ b/java/src/test/java/ai/rapids/cudf/TableTest.java @@ -8557,20 +8557,16 @@ void testExplodeOuterPosition() { @Test void testSample() { try (Table t = new Table.TestBuilder().column("s1", "s2", "s3", "s4", "s5").build()) { - try (Table ret = t.sample(3, false, 0); - Table expected = new Table.TestBuilder().column("s3", "s4", "s5").build()) { - assertTablesAreEqual(expected, ret); + try (Table ret = t.sample(3, false, 0)) { + assertEquals(ret.getRowCount(), 3); } - try (Table ret = t.sample(5, false, 0); - Table expected = new Table.TestBuilder().column("s3", "s4", "s5", "s2", "s1").build()) { - assertTablesAreEqual(expected, ret); + try (Table ret = t.sample(5, false, 0)) { + assertEquals(ret.getRowCount(), 5); } - try (Table ret = t.sample(8, true, 0); - Table expected = new Table.TestBuilder() - .column("s1", "s1", "s4", "s5", "s5", "s1", "s3", "s2").build()) { - assertTablesAreEqual(expected, ret); + try (Table ret = t.sample(8, true, 0)) { + assertEquals(ret.getRowCount(), 8); } } } From 291fbcfdf38c33641da277365fc2a40fa3ddb606 Mon Sep 17 00:00:00 2001 From: GALI PREM SAGAR Date: Fri, 1 Apr 2022 17:56:35 -0500 Subject: [PATCH 027/246] Upgrade `arrow-cpp` & `pyarrow` to `7.0.0` (#10503) This PR upgrades `arrow-cpp` & `pyarrow` to `7.0.0` from `6.0.1` Authors: - GALI PREM SAGAR (https://github.com/galipremsagar) Approvers: - Robert Maynard (https://github.com/robertmaynard) - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/cudf/pull/10503 --- conda/environments/cudf_dev_cuda11.5.yml | 4 ++-- conda/recipes/cudf/meta.yaml | 2 +- conda/recipes/libcudf/conda_build_config.yaml | 2 +- cpp/cmake/thirdparty/get_arrow.cmake | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/conda/environments/cudf_dev_cuda11.5.yml b/conda/environments/cudf_dev_cuda11.5.yml index 2225cbe0918..a085f1ee6c5 100644 --- a/conda/environments/cudf_dev_cuda11.5.yml +++ b/conda/environments/cudf_dev_cuda11.5.yml @@ -18,7 +18,7 @@ dependencies: - numba>=0.54 - numpy - pandas>=1.0,<1.4.0dev0 - - pyarrow=6.0.1=*cuda + - pyarrow=7.0.0=*cuda - fastavro>=0.22.9 - python-snappy>=0.6.0 - notebook>=0.5.0 @@ -46,7 +46,7 @@ dependencies: - dask==2022.03.0 - distributed==2022.03.0 - streamz - - arrow-cpp=6.0.1 + - arrow-cpp=7.0.0 - dlpack>=0.5,<0.6.0a0 - arrow-cpp-proc * cuda - double-conversion diff --git a/conda/recipes/cudf/meta.yaml b/conda/recipes/cudf/meta.yaml index 24432272693..84443a45567 100644 --- a/conda/recipes/cudf/meta.yaml +++ b/conda/recipes/cudf/meta.yaml @@ -34,7 +34,7 @@ requirements: - setuptools - numba >=0.54 - dlpack>=0.5,<0.6.0a0 - - pyarrow 6.0.1 *cuda + - pyarrow 7.0.0 *cuda - libcudf {{ version }} - rmm {{ minor_version }} - cudatoolkit {{ cuda_version }} diff --git a/conda/recipes/libcudf/conda_build_config.yaml b/conda/recipes/libcudf/conda_build_config.yaml index 64eb5d287ef..397feab067e 100644 --- a/conda/recipes/libcudf/conda_build_config.yaml +++ b/conda/recipes/libcudf/conda_build_config.yaml @@ -5,7 +5,7 @@ gtest_version: - "=1.10.0" arrow_cpp_version: - - ">=6.0.1,<6.0.2.0a0" + - "=7.0.0" dlpack_version: - ">=0.5,<0.6.0a0" diff --git a/cpp/cmake/thirdparty/get_arrow.cmake b/cpp/cmake/thirdparty/get_arrow.cmake index 83c5e4c3e8f..2b08e9f2d6c 100644 --- a/cpp/cmake/thirdparty/get_arrow.cmake +++ b/cpp/cmake/thirdparty/get_arrow.cmake @@ -308,7 +308,7 @@ function(find_and_configure_arrow VERSION BUILD_STATIC ENABLE_S3 ENABLE_ORC ENAB endfunction() -set(CUDF_VERSION_Arrow 6.0.1) +set(CUDF_VERSION_Arrow 7.0.0) find_and_configure_arrow( ${CUDF_VERSION_Arrow} ${CUDF_USE_ARROW_STATIC} ${CUDF_ENABLE_ARROW_S3} ${CUDF_ENABLE_ARROW_ORC} From d7602c3bdd59a8cb5104986547db451f3f868b7d Mon Sep 17 00:00:00 2001 From: "Mads R. B. Kristensen" Date: Mon, 4 Apr 2022 16:42:22 +0200 Subject: [PATCH 028/246] Update `Programming Language :: Python` Versions to 3.8 & 3.9 (#10579) Just noticed that the `classifiers` of the python packages doesn't include Python v3.9 but includes Python v3.7. Fixed. Authors: - Mads R. B. Kristensen (https://github.com/madsbk) Approvers: - GALI PREM SAGAR (https://github.com/galipremsagar) URL: https://github.com/rapidsai/cudf/pull/10579 --- python/cudf/setup.py | 2 +- python/cudf_kafka/setup.py | 2 +- python/custreamz/setup.py | 4 ++-- python/dask_cudf/setup.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/python/cudf/setup.py b/python/cudf/setup.py index 9d7b3a36235..2ec9909dd6f 100644 --- a/python/cudf/setup.py +++ b/python/cudf/setup.py @@ -245,8 +245,8 @@ def run(self): "Topic :: Scientific/Engineering", "License :: OSI Approved :: Apache Software License", "Programming Language :: Python", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", ], # Include the separately-compiled shared library setup_requires=["cython", "protobuf"], diff --git a/python/cudf_kafka/setup.py b/python/cudf_kafka/setup.py index 4aff8ca7990..48009b566bb 100644 --- a/python/cudf_kafka/setup.py +++ b/python/cudf_kafka/setup.py @@ -90,8 +90,8 @@ "Topic :: Apache Kafka", "License :: OSI Approved :: Apache Software License", "Programming Language :: Python", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", ], # Include the separately-compiled shared library setup_requires=["Cython>=0.29,<0.30"], diff --git a/python/custreamz/setup.py b/python/custreamz/setup.py index 07a6b92f65d..9f22b270a1b 100644 --- a/python/custreamz/setup.py +++ b/python/custreamz/setup.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-2022, NVIDIA CORPORATION. from setuptools import find_packages, setup @@ -20,8 +20,8 @@ "Topic :: Apache Kafka", "License :: OSI Approved :: Apache Software License", "Programming Language :: Python", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", ], packages=find_packages(include=["custreamz", "custreamz.*"]), cmdclass=versioneer.get_cmdclass(), diff --git a/python/dask_cudf/setup.py b/python/dask_cudf/setup.py index c534dc06602..5b5a3646700 100644 --- a/python/dask_cudf/setup.py +++ b/python/dask_cudf/setup.py @@ -84,8 +84,8 @@ def get_cuda_version_from_header(cuda_include_dir, delimeter=""): "Topic :: Scientific/Engineering", "License :: OSI Approved :: Apache Software License", "Programming Language :: Python", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", ], packages=find_packages(exclude=["tests", "tests.*"]), cmdclass=versioneer.get_cmdclass(), From adec5356b4177467512ba5b95d09f64e03762cdb Mon Sep 17 00:00:00 2001 From: David Wendt <45795991+davidwendt@users.noreply.github.com> Date: Mon, 4 Apr 2022 11:26:09 -0400 Subject: [PATCH 029/246] Fix doxygen Modules page for cudf::lists::sequences (#10561) Corrects the [Modules](https://docs.rapids.ai/api/libcudf/nightly/modules.html) page where the `lists_filling` group appears at the bottom: ![image](https://user-images.githubusercontent.com/45795991/161142554-b78b8c2b-49dd-4958-8d2f-df3aa1720b86.png) The `lists_filling` group is added to the appropriate section in the [`doxygen_groups.h`](https://github.com/rapidsai/cudf/blob/branch-22.06/cpp/include/doxygen_groups.h) file. Also added a doxygen description for `namespace lists` so it will appear in the [Namespace List](https://docs.rapids.ai/api/libcudf/nightly/namespaces.html) page. This becomes an easy way to find the documentation fo all the `lists` APIs. Authors: - David Wendt (https://github.com/davidwendt) Approvers: - Nghia Truong (https://github.com/ttnghia) - https://github.com/nvdbaranec URL: https://github.com/rapidsai/cudf/pull/10561 --- cpp/include/cudf/lists/combine.hpp | 4 +++- cpp/include/doxygen_groups.h | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cpp/include/cudf/lists/combine.hpp b/cpp/include/cudf/lists/combine.hpp index 61a81e8a745..7f7db131a93 100644 --- a/cpp/include/cudf/lists/combine.hpp +++ b/cpp/include/cudf/lists/combine.hpp @@ -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. @@ -19,6 +19,8 @@ #include namespace cudf { + +//! Lists column APIs namespace lists { /** * @addtogroup lists_combine diff --git a/cpp/include/doxygen_groups.h b/cpp/include/doxygen_groups.h index 5dbf5377396..0abaebc3b0c 100644 --- a/cpp/include/doxygen_groups.h +++ b/cpp/include/doxygen_groups.h @@ -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. @@ -146,6 +146,7 @@ * @{ * @defgroup lists_combine Combining * @defgroup lists_extract Extracting + * @defgroup lists_filling Filling * @defgroup lists_contains Searching * @defgroup lists_gather Gathering * @defgroup lists_elements Counting From fa0938fb071b5a69ceb2ff9d541649a725929d98 Mon Sep 17 00:00:00 2001 From: Jason Lowe Date: Mon, 4 Apr 2022 14:21:18 -0500 Subject: [PATCH 030/246] Fix missing RMM_STATIC_CUDART define when compiling JNI with static CUDA runtime (#10585) Fixes #10571. This fixes the JNI CMakeLists.txt so that RMM will automatically get the `RMM_STATIC_CUDART` define added to the build when `CUDA_STATIC_RUNTIME=ON`. Verified by building with Javva CI Dockerfile with static CUDA runtime and examining the build command-lines and flag definitions in java/target/cmake-build/CMakeFiles. Authors: - Jason Lowe (https://github.com/jlowe) Approvers: - Alessandro Bellina (https://github.com/abellina) URL: https://github.com/rapidsai/cudf/pull/10585 --- java/ci/build-in-docker.sh | 1 + java/src/main/native/CMakeLists.txt | 22 +++------------------- 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/java/ci/build-in-docker.sh b/java/ci/build-in-docker.sh index 75435319c91..d6a193fbeaf 100755 --- a/java/ci/build-in-docker.sh +++ b/java/ci/build-in-docker.sh @@ -56,6 +56,7 @@ mkdir -p "$WORKSPACE/cpp/build" cd "$WORKSPACE/cpp/build" cmake .. -G"${CMAKE_GENERATOR}" \ -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX \ + -DCUDA_STATIC_RUNTIME=$ENABLE_CUDA_STATIC_RUNTIME \ -DUSE_NVTX=$ENABLE_NVTX \ -DCUDF_USE_ARROW_STATIC=ON \ -DCUDF_ENABLE_ARROW_S3=OFF \ diff --git a/java/src/main/native/CMakeLists.txt b/java/src/main/native/CMakeLists.txt index f34b998d01e..5b6c6c00e6e 100755 --- a/java/src/main/native/CMakeLists.txt +++ b/java/src/main/native/CMakeLists.txt @@ -115,21 +115,7 @@ rapids_find_package(ZLIB REQUIRED) # ################################################################################################## # * RMM ------------------------------------------------------------------------------------------- -find_path( - RMM_INCLUDE "rmm" - HINTS "${CUDF_CPP_BUILD_DIR}/_deps/rmm-src/include" "$ENV{RMM_ROOT}/include" - "$ENV{RMM_HOME}/include" "$ENV{CONDA_PREFIX}/include/rmm" "$ENV{CONDA_PREFIX}/include" -) - -message(STATUS "RMM: RMM_INCLUDE set to ${RMM_INCLUDE}") - -find_path( - SPDLOG_INCLUDE "spdlog" - HINTS "${CUDF_CPP_BUILD_DIR}/_deps/spdlog-src/include" "$ENV{RMM_ROOT}/_deps/spdlog-src/include" - "$ENV{RMM_ROOT}/include" "$ENV{CONDA_PREFIX}/include" -) - -message(STATUS "SPDLOG: SPDLOG_INCLUDE set to ${SPDLOG_INCLUDE}") +include(${CUDF_SOURCE_DIR}/cmake/thirdparty/get_rmm.cmake) # ################################################################################################## # * ARROW ----------------------------------------------------------------------------------------- @@ -255,11 +241,9 @@ target_include_directories( "${NVCOMP_INCLUDE}" "${CMAKE_BINARY_DIR}/include" "${CMAKE_SOURCE_DIR}/include" - "${SPDLOG_INCLUDE}" "${CMAKE_SOURCE_DIR}/src" "${JNI_INCLUDE_DIRS}" "${CUDF_INCLUDE}" - "${RMM_INCLUDE}" "${ARROW_INCLUDE}" ) @@ -296,7 +280,7 @@ if(USE_GDS) PUBLIC "${LIBCUDACXX_INCLUDE}" "${CUDF_INCLUDE}" PRIVATE "${cuFile_INCLUDE_DIRS}" ) - target_link_libraries(cufilejni PRIVATE cudfjni "${cuFile_LIBRARIES}") + target_link_libraries(cufilejni PRIVATE cudfjni rmm::rmm "${cuFile_LIBRARIES}") endif() # ################################################################################################## @@ -323,7 +307,7 @@ if(CUDF_JNI_LIBCUDF_STATIC) endif() target_link_libraries( - cudfjni PRIVATE ${CUDF_LINK} ${NVCOMP_LIBRARY} ${ARROW_LIBRARY} CUDA::cuda_driver + cudfjni PRIVATE ${CUDF_LINK} ${NVCOMP_LIBRARY} ${ARROW_LIBRARY} rmm::rmm CUDA::cuda_driver ) # ################################################################################################## From ff1ff8003e3e5ebf9c3a61c330b6bb938cf876e1 Mon Sep 17 00:00:00 2001 From: David Wendt <45795991+davidwendt@users.noreply.github.com> Date: Mon, 4 Apr 2022 16:13:06 -0400 Subject: [PATCH 031/246] Add patch for thrust-cub 1.16 to fix sort compile times (#10577) Fixes `thrust.patch` to patch the CUB source for `sort` to minimize the inlining of the comparator functor. The build was updated in #10489 to thrust-1.16 which includes change to thrust sort using CUB's `DeviceMergeSort`. This means the previous patch does not apply to the new thrust/cub source. This dramatically increased the build for `sort.cu` and other related source files as can be seen in this Build Metrics Report from #10489: https://gpuci.gpuopenanalytics.com/job/rapidsai/job/gpuci/job/cudf/job/prb/job/cudf-cpu-cuda-build/CUDA=11.5/8633/Build_20Metrics_20Report/ This PR moves the `pragma unroll` changes into the appropriate CUB source files reducing the build time back to the previous levels (or close to it I hope). Authors: - David Wendt (https://github.com/davidwendt) Approvers: - Bradley Dice (https://github.com/bdice) - Nghia Truong (https://github.com/ttnghia) - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/cudf/pull/10577 --- cpp/cmake/thrust.patch | 102 +++++++++++++++++++++-------------------- 1 file changed, 53 insertions(+), 49 deletions(-) diff --git a/cpp/cmake/thrust.patch b/cpp/cmake/thrust.patch index 2f9201d8ab4..6f735b955cf 100644 --- a/cpp/cmake/thrust.patch +++ b/cpp/cmake/thrust.patch @@ -1,52 +1,39 @@ -diff --git a/thrust/system/cuda/detail/sort.h b/thrust/system/cuda/detail/sort.h -index 1ffeef0..5e80800 100644 ---- a/thrust/system/cuda/detail/sort.h -+++ b/thrust/system/cuda/detail/sort.h -@@ -108,7 +108,7 @@ namespace __merge_sort { - key_type key2 = keys_shared[keys2_beg]; - +diff --git a/cub/block/block_merge_sort.cuh b/cub/block/block_merge_sort.cuh +index 4769df36..d86d6342 100644 +--- a/cub/block/block_merge_sort.cuh ++++ b/cub/block/block_merge_sort.cuh +@@ -91,7 +91,7 @@ __device__ __forceinline__ void SerialMerge(KeyT *keys_shared, + KeyT key1 = keys_shared[keys1_beg]; + KeyT key2 = keys_shared[keys2_beg]; -#pragma unroll +#pragma unroll 1 - for (int ITEM = 0; ITEM < ITEMS_PER_THREAD; ++ITEM) - { - bool p = (keys2_beg < keys2_end) && -@@ -311,10 +311,10 @@ namespace __merge_sort { - void stable_odd_even_sort(key_type (&keys)[ITEMS_PER_THREAD], - item_type (&items)[ITEMS_PER_THREAD]) + for (int item = 0; item < ITEMS_PER_THREAD; ++item) + { + bool p = (keys2_beg < keys2_end) && +@@ -383,7 +383,7 @@ public: + // + KeyT max_key = oob_default; + +- #pragma unroll ++ #pragma unroll 1 + for (int item = 1; item < ITEMS_PER_THREAD; ++item) { --#pragma unroll -+#pragma unroll 1 - for (int i = 0; i < ITEMS_PER_THREAD; ++i) - { --#pragma unroll -+#pragma unroll 1 - for (int j = 1 & i; j < ITEMS_PER_THREAD - 1; j += 2) - { - if (compare_op(keys[j + 1], keys[j])) -@@ -350,7 +350,7 @@ namespace __merge_sort { - // each thread has sorted keys_loc - // merge sort keys_loc in shared memory - // --#pragma unroll -+#pragma unroll 1 - for (int coop = 2; coop <= BLOCK_THREADS; coop *= 2) - { - sync_threadblock(); -@@ -479,7 +479,7 @@ namespace __merge_sort { - // and fill the remainig keys with it - // - key_type max_key = keys_loc[0]; --#pragma unroll -+#pragma unroll 1 - for (int ITEM = 1; ITEM < ITEMS_PER_THREAD; ++ITEM) - { - if (ITEMS_PER_THREAD * tid + ITEM < num_remaining) -diff a/cub/device/dispatch/dispatch_radix_sort.cuh b/cub/device/dispatch/dispatch_radix_sort.cuh -index 41eb1d2..f2893b4 100644 + if (ITEMS_PER_THREAD * linear_tid + item < valid_items) +@@ -407,7 +407,7 @@ public: + // each thread has sorted keys + // merge sort keys in shared memory + // +- #pragma unroll ++ #pragma unroll 1 + for (int target_merged_threads_number = 2; + target_merged_threads_number <= NUM_THREADS; + target_merged_threads_number *= 2) +diff --git a/cub/device/dispatch/dispatch_radix_sort.cuh b/cub/device/dispatch/dispatch_radix_sort.cuh +index b188c75f..3f36656f 100644 --- a/cub/device/dispatch/dispatch_radix_sort.cuh +++ b/cub/device/dispatch/dispatch_radix_sort.cuh -@@ -723,7 +723,7 @@ struct DeviceRadixSortPolicy +@@ -736,7 +736,7 @@ struct DeviceRadixSortPolicy /// SM60 (GP100) @@ -55,11 +42,11 @@ index 41eb1d2..f2893b4 100644 { enum { PRIMARY_RADIX_BITS = (sizeof(KeyT) > 1) ? 7 : 5, // 6.9B 32b keys/s (Quadro P100) -diff a/cub/device/dispatch/dispatch_reduce.cuh b/cub/device/dispatch/dispatch_reduce.cuh -index f6aee45..dd64301 100644 +diff --git a/cub/device/dispatch/dispatch_reduce.cuh b/cub/device/dispatch/dispatch_reduce.cuh +index e0470ccb..6a0c2ed6 100644 --- a/cub/device/dispatch/dispatch_reduce.cuh +++ b/cub/device/dispatch/dispatch_reduce.cuh -@@ -284,7 +284,7 @@ struct DeviceReducePolicy +@@ -280,7 +280,7 @@ struct DeviceReducePolicy }; /// SM60 @@ -68,11 +55,11 @@ index f6aee45..dd64301 100644 { // ReducePolicy (P100: 591 GB/s @ 64M 4B items; 583 GB/s @ 256M 1B items) typedef AgentReducePolicy< -diff a/cub/device/dispatch/dispatch_scan.cuh b/cub/device/dispatch/dispatch_scan.cuh -index c0c6d59..937ee31 100644 +diff --git a/cub/device/dispatch/dispatch_scan.cuh b/cub/device/dispatch/dispatch_scan.cuh +index c2d04588..ac2d10e0 100644 --- a/cub/device/dispatch/dispatch_scan.cuh +++ b/cub/device/dispatch/dispatch_scan.cuh -@@ -178,7 +178,7 @@ struct DeviceScanPolicy +@@ -177,7 +177,7 @@ struct DeviceScanPolicy }; /// SM600 @@ -81,3 +68,20 @@ index c0c6d59..937ee31 100644 { typedef AgentScanPolicy< 128, 15, ///< Threads per block, items per thread +diff --git a/cub/thread/thread_sort.cuh b/cub/thread/thread_sort.cuh +index 5d486789..b42fb5f0 100644 +--- a/cub/thread/thread_sort.cuh ++++ b/cub/thread/thread_sort.cuh +@@ -83,10 +83,10 @@ StableOddEvenSort(KeyT (&keys)[ITEMS_PER_THREAD], + { + constexpr bool KEYS_ONLY = std::is_same::value; + +- #pragma unroll ++ #pragma unroll 1 + for (int i = 0; i < ITEMS_PER_THREAD; ++i) + { +- #pragma unroll ++ #pragma unroll 1 + for (int j = 1 & i; j < ITEMS_PER_THREAD - 1; j += 2) + { + if (compare_op(keys[j + 1], keys[j])) From 5d2e206ee98db48396c87d5f1278c50ba265e547 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Mon, 4 Apr 2022 14:49:51 -0700 Subject: [PATCH 032/246] Remove ColumnBase.__getitem__ (#10516) This PR removes the `ColumnBase.__getitem__` method, which is heavily overloaded and easy to abuse, and changes everywhere that called it to use the appropriate method. There turn out to be exactly two places in the code that actually require the current implementation of this method, Series and Index indexing, so this functionality has been moved into `SingleColumnFrame`. Removing `__getitem__` also means that we no longer need to explicitly fail on `__iter__` and `__array__` since there is no longer an implicit fallback. The one downside to this now is that it _is_ possible to create a numpy array from a column. However, it won't make a numpy array from the data, it will create an object dtype 0-D array _containing_ the column. This is how `np.array` and `np.asarray` behave for normal objects, so I think this behavior is fine for us too. ColumnBase is (for now) an internal object, so we don't need to provide super helpful error messages, and for developers it should be fairly obvious what is wrong if they try to do this conversion: ``` >>> import cudf >>> import numpy as np >>> s = cudf.Series([1]) >>> arr = np.array(s._column) >>> arr.ndim 0 >>> arr[0] Traceback (most recent call last): File "", line 1, in IndexError: too many indices for array: array is 0-dimensional, but 1 were indexed >>> arr array( [ 1 ] dtype: int64, dtype=object) ``` That being said, I can put back the `__array__` implementation if people feel strongly about it. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Ashwin Srinath (https://github.com/shwina) - Ram (Ramakrishna Prabhu) (https://github.com/rgsl888prabhu) URL: https://github.com/rapidsai/cudf/pull/10516 --- python/cudf/cudf/core/column/categorical.py | 22 +++++++++--- python/cudf/cudf/core/column/column.py | 28 ++------------- python/cudf/cudf/core/column/datetime.py | 8 +++-- python/cudf/cudf/core/column/numerical.py | 4 ++- .../cudf/cudf/core/column/numerical_base.py | 9 +++-- python/cudf/cudf/core/column/string.py | 8 +++-- python/cudf/cudf/core/column/struct.py | 16 ++++----- python/cudf/cudf/core/index.py | 35 ++++++++----------- python/cudf/cudf/core/indexed_frame.py | 16 +++++---- python/cudf/cudf/core/series.py | 2 +- python/cudf/cudf/core/single_column_frame.py | 28 +++++++++++++-- python/cudf/cudf/core/tools/datetimes.py | 12 ++++--- python/cudf/cudf/testing/testing.py | 8 +++-- python/cudf/cudf/tests/test_column.py | 20 ++++++----- python/cudf/cudf/tests/test_df_protocol.py | 5 ++- python/cudf/cudf/tests/test_series.py | 9 +---- python/cudf/cudf/tests/test_testing.py | 8 ++--- 17 files changed, 132 insertions(+), 106 deletions(-) diff --git a/python/cudf/cudf/core/column/categorical.py b/python/cudf/cudf/core/column/categorical.py index 9f00f9a203f..911391ef984 100644 --- a/python/cudf/cudf/core/column/categorical.py +++ b/python/cudf/cudf/core/column/categorical.py @@ -1066,8 +1066,18 @@ def find_and_replace( ) df = df.drop_duplicates(subset=["old"], keep="last", ignore_index=True) if df._data["old"].null_count == 1: - fill_value = df._data["new"][df._data["old"].isnull()][0] - if fill_value in self.categories: + fill_value = ( + df._data["new"] + .apply_boolean_mask(df._data["old"].isnull()) + .element_indexing(0) + ) + # TODO: This line of code does not work because we cannot use the + # `in` operator on self.categories (which is a column). mypy + # realizes that this is wrong because __iter__ is not implemented. + # However, it seems that this functionality has been broken for a + # long time so for now we're just having mypy ignore and we'll come + # back to this. + if fill_value in self.categories: # type: ignore replaced = self.fillna(fill_value) else: new_categories = self.categories.append( @@ -1081,11 +1091,13 @@ def find_and_replace( else: replaced = self if df._data["new"].null_count > 0: - drop_values = df._data["old"][df._data["new"].isnull()] + drop_values = df._data["old"].apply_boolean_mask( + df._data["new"].isnull() + ) cur_categories = replaced.categories - new_categories = cur_categories[ + new_categories = cur_categories.apply_boolean_mask( ~cudf.Series(cur_categories.isin(drop_values)) - ] + ) replaced = replaced._set_categories(new_categories) df = df.dropna(subset=["new"]) to_replace_col = df._data["old"] diff --git a/python/cudf/cudf/core/column/column.py b/python/cudf/cudf/core/column/column.py index bc59b67119e..b2e3e42531b 100644 --- a/python/cudf/cudf/core/column/column.py +++ b/python/cudf/cudf/core/column/column.py @@ -44,7 +44,6 @@ from cudf._typing import ColumnLike, Dtype, ScalarLike from cudf.api.types import ( _is_non_decimal_numeric_dtype, - _is_scalar_or_zero_d_array, infer_dtype, is_bool_dtype, is_categorical_dtype, @@ -78,7 +77,7 @@ pandas_dtypes_alias_to_cudf_alias, pandas_dtypes_to_np_dtypes, ) -from cudf.utils.utils import NotIterable, _array_ufunc, mask_dtype +from cudf.utils.utils import _array_ufunc, mask_dtype T = TypeVar("T", bound="ColumnBase") # TODO: This workaround allows type hints for `slice`, since `slice` is a @@ -86,7 +85,7 @@ Slice = TypeVar("Slice", bound=slice) -class ColumnBase(Column, Serializable, BinaryOperand, Reducible, NotIterable): +class ColumnBase(Column, Serializable, BinaryOperand, Reducible): _VALID_REDUCTIONS = { "any", "all", @@ -480,22 +479,6 @@ def slice(self, start: int, stop: int, stride: int = None) -> ColumnBase: ) return self.take(gather_map) - def __getitem__(self, arg) -> Union[ScalarLike, ColumnBase]: - if _is_scalar_or_zero_d_array(arg): - return self.element_indexing(int(arg)) - elif isinstance(arg, slice): - start, stop, stride = arg.indices(len(self)) - return self.slice(start, stop, stride) - else: - arg = as_column(arg) - if len(arg) == 0: - arg = as_column([], dtype="int32") - if is_integer_dtype(arg.dtype): - return self.take(arg) - if is_bool_dtype(arg.dtype): - return self.apply_boolean_mask(arg) - raise NotImplementedError(type(arg)) - def __setitem__(self, key: Any, value: Any): """ Set the value of ``self[key]`` to ``value``. @@ -1028,13 +1011,6 @@ def __arrow_array__(self, type=None): "consider using .to_arrow()" ) - def __array__(self, dtype=None): - raise TypeError( - "Implicit conversion to a host NumPy array via __array__ is not " - "allowed. To explicitly construct a host array, consider using " - ".to_numpy()" - ) - @property def __cuda_array_interface__(self): raise NotImplementedError( diff --git a/python/cudf/cudf/core/column/datetime.py b/python/cudf/cudf/core/column/datetime.py index 4ce5a70f0ec..685f6fb281c 100644 --- a/python/cudf/cudf/core/column/datetime.py +++ b/python/cudf/cudf/core/column/datetime.py @@ -473,7 +473,9 @@ def find_first_value( Returns offset of first value that matches """ value = pd.to_datetime(value) - value = column.as_column(value, dtype=self.dtype).as_numerical[0] + value = column.as_column( + value, dtype=self.dtype + ).as_numerical.element_indexing(0) return self.as_numerical.find_first_value(value, closest=closest) def find_last_value(self, value: ScalarLike, closest: bool = False) -> int: @@ -481,7 +483,9 @@ def find_last_value(self, value: ScalarLike, closest: bool = False) -> int: Returns offset of last value that matches """ value = pd.to_datetime(value) - value = column.as_column(value, dtype=self.dtype).as_numerical[0] + value = column.as_column( + value, dtype=self.dtype + ).as_numerical.element_indexing(0) return self.as_numerical.find_last_value(value, closest=closest) @property diff --git a/python/cudf/cudf/core/column/numerical.py b/python/cudf/cudf/core/column/numerical.py index a89c8dfed54..216faaa8250 100644 --- a/python/cudf/cudf/core/column/numerical.py +++ b/python/cudf/cudf/core/column/numerical.py @@ -453,7 +453,9 @@ def find_and_replace( df = df.drop_duplicates(subset=["old"], keep="last", ignore_index=True) if df._data["old"].null_count == 1: replaced = replaced.fillna( - df._data["new"][df._data["old"].isnull()][0] + df._data["new"] + .apply_boolean_mask(df._data["old"].isnull()) + .element_indexing(0) ) df = df.dropna(subset=["old"]) diff --git a/python/cudf/cudf/core/column/numerical_base.py b/python/cudf/cudf/core/column/numerical_base.py index 3ae60671b5a..659bb58d790 100644 --- a/python/cudf/cudf/core/column/numerical_base.py +++ b/python/cudf/cudf/core/column/numerical_base.py @@ -113,10 +113,11 @@ def quantile( else: result = self._numeric_quantile(q, interpolation, exact) if return_scalar: + scalar_result = result.element_indexing(0) return ( cudf.utils.dtypes._get_nan_for_dtype(self.dtype) - if result[0] is cudf.NA - else result[0] + if scalar_result is cudf.NA + else scalar_result ) return result @@ -160,7 +161,9 @@ def _numeric_quantile( sorted_indices = self.as_frame()._get_sorted_inds( ascending=True, na_position="first" ) - sorted_indices = sorted_indices[self.null_count :] + sorted_indices = sorted_indices.slice( + self.null_count, len(sorted_indices) + ) return libcudf.quantiles.quantile( self, q, interpolation, sorted_indices, exact diff --git a/python/cudf/cudf/core/column/string.py b/python/cudf/cudf/core/column/string.py index 88033fe700c..ef8e9c4dffc 100644 --- a/python/cudf/cudf/core/column/string.py +++ b/python/cudf/cudf/core/column/string.py @@ -5205,7 +5205,7 @@ def sum( result_col, sep=cudf.Scalar(""), na_rep=cudf.Scalar(None, "str"), - )[0] + ).element_indexing(0) else: return result_col @@ -5432,7 +5432,11 @@ def find_and_replace( ) df = df.drop_duplicates(subset=["old"], keep="last", ignore_index=True) if df._data["old"].null_count == 1: - res = self.fillna(df._data["new"][df._data["old"].isnull()][0]) + res = self.fillna( + df._data["new"] + .apply_boolean_mask(df._data["old"].isnull()) + .element_indexing(0) + ) df = df.dropna(subset=["old"]) else: res = self diff --git a/python/cudf/cudf/core/column/struct.py b/python/cudf/cudf/core/column/struct.py index f0d02a706e2..53e6e9972b1 100644 --- a/python/cudf/cudf/core/column/struct.py +++ b/python/cudf/cudf/core/column/struct.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-2022, NVIDIA CORPORATION. from __future__ import annotations import pandas as pd @@ -91,14 +91,12 @@ def to_pandas(self, index: pd.Index = None, **kwargs) -> "pd.Series": pd_series.index = index return pd_series - def __getitem__(self, args): - result = super().__getitem__(args) - if isinstance(result, dict): - return { - field: value - for field, value in zip(self.dtype.fields, result.values()) - } - return result + def element_indexing(self, index: int): + result = super().element_indexing(index) + return { + field: value + for field, value in zip(self.dtype.fields, result.values()) + } def __setitem__(self, key, value): if isinstance(value, dict): diff --git a/python/cudf/cudf/core/index.py b/python/cudf/cudf/core/index.py index a31fe4c3b99..aff13025e72 100644 --- a/python/cudf/cudf/core/index.py +++ b/python/cudf/cudf/core/index.py @@ -30,7 +30,6 @@ from cudf._lib.search import search_sorted from cudf.api.types import ( _is_non_decimal_numeric_dtype, - _is_scalar_or_zero_d_array, is_categorical_dtype, is_dtype_equal, is_interval_dtype, @@ -342,9 +341,8 @@ def __len__(self): @_cudf_nvtx_annotate def __getitem__(self, index): - len_self = len(self) if isinstance(index, slice): - sl_start, sl_stop, sl_step = index.indices(len_self) + sl_start, sl_stop, sl_step = index.indices(len(self)) lo = self._start + sl_start * self._step hi = self._start + sl_stop * self._step @@ -352,19 +350,13 @@ def __getitem__(self, index): return RangeIndex(start=lo, stop=hi, step=st, name=self._name) elif isinstance(index, Number): + len_self = len(self) if index < 0: - index = len_self + index + index += len_self if not (0 <= index < len_self): - raise IndexError("out-of-bound") - index = min(index, len_self) - index = self._start + index * self._step - return index - else: - if _is_scalar_or_zero_d_array(index): - index = np.min_scalar_type(index).type(index) - index = column.as_column(index) - - return as_index(self._values[index], name=self.name) + raise IndexError("Index out of bounds") + return self._start + index * self._step + return self._as_int64()[index] @_cudf_nvtx_annotate def equals(self, other): @@ -1183,11 +1175,7 @@ def __repr__(self): @_cudf_nvtx_annotate def __getitem__(self, index): - if type(self) == IntervalIndex: - raise NotImplementedError( - "Getting a scalar from an IntervalIndex is not yet supported" - ) - res = self._values[index] + res = self._get_elements_from_column(index) if not isinstance(index, int): res = as_index(res) res.name = self.name @@ -2457,8 +2445,8 @@ def interval_range( init=start.device_value, step=freq_step.device_value, ) - left_col = bin_edges[:-1] - right_col = bin_edges[1:] + left_col = bin_edges.slice(0, len(bin_edges) - 1) + right_col = bin_edges.slice(1, len(bin_edges)) elif freq and periods: if end: start = end - (freq * periods) @@ -2614,6 +2602,11 @@ def from_breaks(breaks, closed="right", name=None, copy=False, dtype=None): return IntervalIndex(interval_col, name=name) + def __getitem__(self, index): + raise NotImplementedError( + "Getting a scalar from an IntervalIndex is not yet supported" + ) + def is_interval(self): return True diff --git a/python/cudf/cudf/core/indexed_frame.py b/python/cudf/cudf/core/indexed_frame.py index 458fc16c511..3d025738974 100644 --- a/python/cudf/cudf/core/indexed_frame.py +++ b/python/cudf/cudf/core/indexed_frame.py @@ -1173,9 +1173,9 @@ def _n_largest_or_smallest(self, largest, n, columns, keep): # argsort the `by` column return self._gather( - self._get_columns_by_label(columns)._get_sorted_inds( - ascending=not largest - )[:n], + self._get_columns_by_label(columns) + ._get_sorted_inds(ascending=not largest) + .slice(*slice(None, n).indices(len(self))), keep_index=True, check_bounds=False, ) @@ -1186,9 +1186,11 @@ def _n_largest_or_smallest(self, largest, n, columns, keep): if n <= 0: # Empty slice. - indices = indices[0:0] + indices = indices.slice(0, 0) else: - indices = indices[: -n - 1 : -1] + indices = indices.slice( + *slice(None, -n - 1, -1).indices(len(self)) + ) return self._gather(indices, keep_index=True, check_bounds=False) else: raise ValueError('keep must be either "first", "last"') @@ -1808,7 +1810,9 @@ def _first_or_last( return self.copy() pd_offset = pd.tseries.frequencies.to_offset(offset) - to_search = op(pd.Timestamp(self._index._column[idx]), pd_offset) + to_search = op( + pd.Timestamp(self._index._column.element_indexing(idx)), pd_offset + ) if ( idx == 0 and not isinstance(pd_offset, pd.tseries.offsets.Tick) diff --git a/python/cudf/cudf/core/series.py b/python/cudf/cudf/core/series.py index 8748b9775be..d14942cd3ce 100644 --- a/python/cudf/cudf/core/series.py +++ b/python/cudf/cudf/core/series.py @@ -96,7 +96,7 @@ class _SeriesIlocIndexer(_FrameIndexer): def __getitem__(self, arg): if isinstance(arg, tuple): arg = list(arg) - data = self._frame._column[arg] + data = self._frame._get_elements_from_column(arg) if ( isinstance(data, (dict, list)) diff --git a/python/cudf/cudf/core/single_column_frame.py b/python/cudf/cudf/core/single_column_frame.py index 3e91aa634f4..a71284ddeed 100644 --- a/python/cudf/cudf/core/single_column_frame.py +++ b/python/cudf/cudf/core/single_column_frame.py @@ -10,8 +10,12 @@ import pandas as pd import cudf -from cudf._typing import Dtype -from cudf.api.types import _is_scalar_or_zero_d_array +from cudf._typing import Dtype, ScalarLike +from cudf.api.types import ( + _is_scalar_or_zero_d_array, + is_bool_dtype, + is_integer_dtype, +) from cudf.core.column import ColumnBase, as_column from cudf.core.frame import Frame from cudf.utils.utils import NotIterable, _cudf_nvtx_annotate @@ -359,3 +363,23 @@ def nunique(self, dropna: bool = True): if self._column.null_count == len(self): return 0 return self._column.distinct_count(dropna=dropna) + + def _get_elements_from_column(self, arg) -> Union[ScalarLike, ColumnBase]: + # A generic method for getting elements from a column that supports a + # wide range of different inputs. This method should only used where + # _absolutely_ necessary, since in almost all cases a more specific + # method can be used e.g. element_indexing or slice. + if _is_scalar_or_zero_d_array(arg): + return self._column.element_indexing(int(arg)) + elif isinstance(arg, slice): + start, stop, stride = arg.indices(len(self)) + return self._column.slice(start, stop, stride) + else: + arg = as_column(arg) + if len(arg) == 0: + arg = as_column([], dtype="int32") + if is_integer_dtype(arg.dtype): + return self._column.take(arg) + if is_bool_dtype(arg.dtype): + return self._column.apply_boolean_mask(arg) + raise NotImplementedError(f"Unknown indexer {type(arg)}") diff --git a/python/cudf/cudf/core/tools/datetimes.py b/python/cudf/cudf/core/tools/datetimes.py index f766ea0de74..3d1a659e201 100644 --- a/python/cudf/cudf/core/tools/datetimes.py +++ b/python/cudf/cudf/core/tools/datetimes.py @@ -262,7 +262,7 @@ def to_datetime( ) if is_scalar(arg): - return col[0] + return col.element_indexing(0) else: return as_index(col) except Exception as e: @@ -346,11 +346,13 @@ def _process_col(col, unit, dayfirst, infer_datetime_format, format): else: if infer_datetime_format and format is None: format = column.datetime.infer_format( - element=col[0], + element=col.element_indexing(0), dayfirst=dayfirst, ) elif format is None: - format = column.datetime.infer_format(element=col[0]) + format = column.datetime.infer_format( + element=col.element_indexing(0) + ) col = col.as_datetime_column( dtype=_unit_dtype_map[unit], format=format, @@ -909,9 +911,9 @@ def date_range( # As mentioned in [1], this is a post processing step to trim extra # elements when `periods` is an estimated value. Only offset # specified with non fixed frequencies requires trimming. - res = res[ + res = res.apply_boolean_mask( (res <= end) if _is_increment_sequence else (res <= start) - ] + ) else: # If `offset` is fixed frequency, we generate a range of # treating `start`, `stop` and `step` as ints: diff --git a/python/cudf/cudf/testing/testing.py b/python/cudf/cudf/testing/testing.py index 5f7616cc75e..702136d7c98 100644 --- a/python/cudf/cudf/testing/testing.py +++ b/python/cudf/cudf/testing/testing.py @@ -247,8 +247,12 @@ def assert_column_equal( if columns_equal and not check_exact and is_numeric_dtype(left): # non-null values must be the same columns_equal = cp.allclose( - left[left.isnull().unary_operator("not")].values, - right[right.isnull().unary_operator("not")].values, + left.apply_boolean_mask( + left.isnull().unary_operator("not") + ).values, + right.apply_boolean_mask( + right.isnull().unary_operator("not") + ).values, ) if columns_equal and ( left.dtype.kind == right.dtype.kind == "f" diff --git a/python/cudf/cudf/tests/test_column.py b/python/cudf/cudf/tests/test_column.py index 854e79af9f4..6d28808b791 100644 --- a/python/cudf/cudf/tests/test_column.py +++ b/python/cudf/cudf/tests/test_column.py @@ -110,8 +110,7 @@ def test_column_offset_and_size(pandas_input, offset, size): def column_slicing_test(col, offset, size, cast_to_float=False): - sl = slice(offset, offset + size) - col_slice = col[sl] + col_slice = col.slice(offset, offset + size) series = cudf.Series(col) sliced_series = cudf.Series(col_slice) @@ -128,11 +127,14 @@ def column_slicing_test(col, offset, size, cast_to_float=False): # However, we must compare these as frames, not raw arrays, because # numpy comparison of categorical values won't work. assert_eq( - pd_series[sl].reset_index(drop=True), + pd_series[offset : offset + size].reset_index(drop=True), sliced_series.reset_index(drop=True), ) else: - assert_eq(np.asarray(pd_series[sl]), sliced_series.to_numpy()) + assert_eq( + np.asarray(pd_series[offset : offset + size]), + sliced_series.to_numpy(), + ) @pytest.mark.parametrize("offset", [0, 1, 15]) @@ -355,25 +357,27 @@ def test_column_view_nulls_widths_even(): assert_eq(expect, got) -@pytest.mark.parametrize("slc", [slice(1, None), slice(None, 4), slice(2, 4)]) +@pytest.mark.parametrize("slc", [slice(1, 5), slice(0, 4), slice(2, 4)]) def test_column_view_numeric_slice(slc): data = np.array([1, 2, 3, 4, 5], dtype="int32") sr = cudf.Series(data) expect = cudf.Series(data[slc].view("int64")) - got = cudf.Series(sr._column[slc].view("int64")) + got = cudf.Series(sr._column.slice(slc.start, slc.stop).view("int64")) assert_eq(expect, got) @pytest.mark.parametrize( - "slc", [slice(3, None), slice(None, 4), slice(2, 5), slice(1, 3)] + "slc", [slice(3, 5), slice(0, 4), slice(2, 5), slice(1, 3)] ) def test_column_view_string_slice(slc): data = ["a", "bcde", "cd", "efg", "h"] - expect = cudf.Series(cudf.Series(data)._column[slc].view("int8")) + expect = cudf.Series( + cudf.Series(data)._column.slice(slc.start, slc.stop).view("int8") + ) got = cudf.Series(str_host_view(data[slc], "int8")) assert_eq(expect, got) diff --git a/python/cudf/cudf/tests/test_df_protocol.py b/python/cudf/cudf/tests/test_df_protocol.py index c67fc199710..21e18470b2f 100644 --- a/python/cudf/cudf/tests/test_df_protocol.py +++ b/python/cudf/cudf/tests/test_df_protocol.py @@ -33,7 +33,10 @@ def assert_buffer_equal(buffer_and_dtype: Tuple[_CuDFBuffer, Any], cudfcol): # currently only non-null values are compared, null positions are # unchecked. non_null_idxs = ~cudf.Series(cudfcol).isna() - assert_eq(col_from_buf[non_null_idxs], cudfcol[non_null_idxs]) + assert_eq( + col_from_buf.apply_boolean_mask(non_null_idxs), + cudfcol.apply_boolean_mask(non_null_idxs), + ) if dtype[0] != _DtypeKind.BOOL: array_from_dlpack = cp.fromDlpack(buf.__dlpack__()).get() diff --git a/python/cudf/cudf/tests/test_series.py b/python/cudf/cudf/tests/test_series.py index b5be0b208a0..6f0f77f0aa2 100644 --- a/python/cudf/cudf/tests/test_series.py +++ b/python/cudf/cudf/tests/test_series.py @@ -341,14 +341,7 @@ def test_series_column_iter_error(): ): gs.iteritems() - with pytest.raises( - TypeError, - match=re.escape( - f"{gs._column.__class__.__name__} object is not iterable. " - f"Consider using `.to_arrow()`, `.to_pandas()` or `.values_host` " - f"if you wish to iterate over the values." - ), - ): + with pytest.raises(TypeError): iter(gs._column) diff --git a/python/cudf/cudf/tests/test_testing.py b/python/cudf/cudf/tests/test_testing.py index efb3ce96838..e5c78b6ea9a 100644 --- a/python/cudf/cudf/tests/test_testing.py +++ b/python/cudf/cudf/tests/test_testing.py @@ -170,8 +170,8 @@ def test_assert_column_equal_dtype_edge_cases(other): assert_column_equal(base, other, check_dtype=False) # the exceptions are the empty and all null cases - assert_column_equal(base[:0], other[:0], check_dtype=False) - assert_column_equal(other[:0], base[:0], check_dtype=False) + assert_column_equal(base.slice(0, 0), other.slice(0, 0), check_dtype=False) + assert_column_equal(other.slice(0, 0), base.slice(0, 0), check_dtype=False) base = full(len(base), fill_value=cudf.NA, dtype=base.dtype) other = full(len(other), fill_value=cudf.NA, dtype=other.dtype) @@ -411,8 +411,8 @@ def test_assert_column_memory_basic(arrow_arrays): def test_assert_column_memory_slice(arrow_arrays): col = cudf.core.column.ColumnBase.from_arrow(arrow_arrays) - left = col[0:1] - right = col[1:2] + left = col.slice(0, 1) + right = col.slice(1, 2) with pytest.raises(AssertionError): assert_column_memory_eq(left, right) From 090f6b886ad0ebef62ffb0ea25adc42f5b059081 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Mon, 4 Apr 2022 17:08:56 -0700 Subject: [PATCH 033/246] Revert Thrust 1.16 to Thrust 1.15 (#10586) PR #10489 updated from Thrust 1.15 to Thrust 1.16. However, this appears to be causing conflicts with other repositories -- [cuSpatial](https://github.com/rapidsai/cuspatial/pull/511#issuecomment-1087738627) and cuGraph have reported issues where their builds are finding Thrust 1.16 from libcudf instead of Thrust 1.15 which is [currently pinned by rapids-cmake](https://github.com/rapidsai/rapids-cmake/blob/06a657281cdd83781e49afcdbb39abc491eeab17/rapids-cmake/cpm/versions.json#L26). This PR is intended to unblock local builds and CI builds for other RAPIDS packages until we are able to identify the root cause (which may be due to CMake include path orderingsrapids-cmake). Last time Thrust was updated, [rapids-cmake was updated](https://github.com/rapidsai/rapids-cmake/pull/138) one day before [libcudf was updated](https://github.com/rapidsai/cudf/pull/9912). That may explain why we didn't notice this problem with the 1.15 update. The plan I currently have in mind is: 1. Merge this PR to roll back libcudf to Thrust 1.15 (and revert the patch for Thrust 1.16 [10577](https://github.com/rapidsai/cudf/pull/10577)). This will hopefully unblock CI for cugraph and cuspatial. 2. Try to work out whatever issues with CMake / include paths may exist. 3. Prepare all rapids-cmake repos for Thrust 1.16 compatibility. I've [done this for RMM already](https://github.com/rapidsai/rmm/pull/1011), and I am working on [PR 4675](https://github.com/rapidsai/cuml/pull/4675) to cuML now. I am planning to make the same fixes for `#include`s in cuCollections, raft, cuSpatial, and cuGraph so they will be compatible with Thrust 1.16. 4. Try to upgrade libcudf to Thrust 1.16 again (and re-apply the updated patch). If (2) has been resolved, I hope we won't see any issues in other RAPIDS libraries 5. Upgrade rapids-cmake to Thrust 1.16. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Vyas Ramasubramani (https://github.com/vyasr) - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/cudf/pull/10586 --- cpp/cmake/thirdparty/get_thrust.cmake | 2 +- cpp/cmake/thrust.patch | 102 +++++++++++++------------- 2 files changed, 50 insertions(+), 54 deletions(-) diff --git a/cpp/cmake/thirdparty/get_thrust.cmake b/cpp/cmake/thirdparty/get_thrust.cmake index 295617c9996..927186d3f49 100644 --- a/cpp/cmake/thirdparty/get_thrust.cmake +++ b/cpp/cmake/thirdparty/get_thrust.cmake @@ -80,6 +80,6 @@ function(find_and_configure_thrust VERSION) endif() endfunction() -set(CUDF_MIN_VERSION_Thrust 1.16.0) +set(CUDF_MIN_VERSION_Thrust 1.15.0) find_and_configure_thrust(${CUDF_MIN_VERSION_Thrust}) diff --git a/cpp/cmake/thrust.patch b/cpp/cmake/thrust.patch index 6f735b955cf..2f9201d8ab4 100644 --- a/cpp/cmake/thrust.patch +++ b/cpp/cmake/thrust.patch @@ -1,39 +1,52 @@ -diff --git a/cub/block/block_merge_sort.cuh b/cub/block/block_merge_sort.cuh -index 4769df36..d86d6342 100644 ---- a/cub/block/block_merge_sort.cuh -+++ b/cub/block/block_merge_sort.cuh -@@ -91,7 +91,7 @@ __device__ __forceinline__ void SerialMerge(KeyT *keys_shared, - KeyT key1 = keys_shared[keys1_beg]; - KeyT key2 = keys_shared[keys2_beg]; +diff --git a/thrust/system/cuda/detail/sort.h b/thrust/system/cuda/detail/sort.h +index 1ffeef0..5e80800 100644 +--- a/thrust/system/cuda/detail/sort.h ++++ b/thrust/system/cuda/detail/sort.h +@@ -108,7 +108,7 @@ namespace __merge_sort { + key_type key2 = keys_shared[keys2_beg]; + -#pragma unroll +#pragma unroll 1 - for (int item = 0; item < ITEMS_PER_THREAD; ++item) - { - bool p = (keys2_beg < keys2_end) && -@@ -383,7 +383,7 @@ public: - // - KeyT max_key = oob_default; - -- #pragma unroll -+ #pragma unroll 1 - for (int item = 1; item < ITEMS_PER_THREAD; ++item) + for (int ITEM = 0; ITEM < ITEMS_PER_THREAD; ++ITEM) + { + bool p = (keys2_beg < keys2_end) && +@@ -311,10 +311,10 @@ namespace __merge_sort { + void stable_odd_even_sort(key_type (&keys)[ITEMS_PER_THREAD], + item_type (&items)[ITEMS_PER_THREAD]) { - if (ITEMS_PER_THREAD * linear_tid + item < valid_items) -@@ -407,7 +407,7 @@ public: - // each thread has sorted keys - // merge sort keys in shared memory - // -- #pragma unroll -+ #pragma unroll 1 - for (int target_merged_threads_number = 2; - target_merged_threads_number <= NUM_THREADS; - target_merged_threads_number *= 2) -diff --git a/cub/device/dispatch/dispatch_radix_sort.cuh b/cub/device/dispatch/dispatch_radix_sort.cuh -index b188c75f..3f36656f 100644 +-#pragma unroll ++#pragma unroll 1 + for (int i = 0; i < ITEMS_PER_THREAD; ++i) + { +-#pragma unroll ++#pragma unroll 1 + for (int j = 1 & i; j < ITEMS_PER_THREAD - 1; j += 2) + { + if (compare_op(keys[j + 1], keys[j])) +@@ -350,7 +350,7 @@ namespace __merge_sort { + // each thread has sorted keys_loc + // merge sort keys_loc in shared memory + // +-#pragma unroll ++#pragma unroll 1 + for (int coop = 2; coop <= BLOCK_THREADS; coop *= 2) + { + sync_threadblock(); +@@ -479,7 +479,7 @@ namespace __merge_sort { + // and fill the remainig keys with it + // + key_type max_key = keys_loc[0]; +-#pragma unroll ++#pragma unroll 1 + for (int ITEM = 1; ITEM < ITEMS_PER_THREAD; ++ITEM) + { + if (ITEMS_PER_THREAD * tid + ITEM < num_remaining) +diff a/cub/device/dispatch/dispatch_radix_sort.cuh b/cub/device/dispatch/dispatch_radix_sort.cuh +index 41eb1d2..f2893b4 100644 --- a/cub/device/dispatch/dispatch_radix_sort.cuh +++ b/cub/device/dispatch/dispatch_radix_sort.cuh -@@ -736,7 +736,7 @@ struct DeviceRadixSortPolicy +@@ -723,7 +723,7 @@ struct DeviceRadixSortPolicy /// SM60 (GP100) @@ -42,11 +55,11 @@ index b188c75f..3f36656f 100644 { enum { PRIMARY_RADIX_BITS = (sizeof(KeyT) > 1) ? 7 : 5, // 6.9B 32b keys/s (Quadro P100) -diff --git a/cub/device/dispatch/dispatch_reduce.cuh b/cub/device/dispatch/dispatch_reduce.cuh -index e0470ccb..6a0c2ed6 100644 +diff a/cub/device/dispatch/dispatch_reduce.cuh b/cub/device/dispatch/dispatch_reduce.cuh +index f6aee45..dd64301 100644 --- a/cub/device/dispatch/dispatch_reduce.cuh +++ b/cub/device/dispatch/dispatch_reduce.cuh -@@ -280,7 +280,7 @@ struct DeviceReducePolicy +@@ -284,7 +284,7 @@ struct DeviceReducePolicy }; /// SM60 @@ -55,11 +68,11 @@ index e0470ccb..6a0c2ed6 100644 { // ReducePolicy (P100: 591 GB/s @ 64M 4B items; 583 GB/s @ 256M 1B items) typedef AgentReducePolicy< -diff --git a/cub/device/dispatch/dispatch_scan.cuh b/cub/device/dispatch/dispatch_scan.cuh -index c2d04588..ac2d10e0 100644 +diff a/cub/device/dispatch/dispatch_scan.cuh b/cub/device/dispatch/dispatch_scan.cuh +index c0c6d59..937ee31 100644 --- a/cub/device/dispatch/dispatch_scan.cuh +++ b/cub/device/dispatch/dispatch_scan.cuh -@@ -177,7 +177,7 @@ struct DeviceScanPolicy +@@ -178,7 +178,7 @@ struct DeviceScanPolicy }; /// SM600 @@ -68,20 +81,3 @@ index c2d04588..ac2d10e0 100644 { typedef AgentScanPolicy< 128, 15, ///< Threads per block, items per thread -diff --git a/cub/thread/thread_sort.cuh b/cub/thread/thread_sort.cuh -index 5d486789..b42fb5f0 100644 ---- a/cub/thread/thread_sort.cuh -+++ b/cub/thread/thread_sort.cuh -@@ -83,10 +83,10 @@ StableOddEvenSort(KeyT (&keys)[ITEMS_PER_THREAD], - { - constexpr bool KEYS_ONLY = std::is_same::value; - -- #pragma unroll -+ #pragma unroll 1 - for (int i = 0; i < ITEMS_PER_THREAD; ++i) - { -- #pragma unroll -+ #pragma unroll 1 - for (int j = 1 & i; j < ITEMS_PER_THREAD - 1; j += 2) - { - if (compare_op(keys[j + 1], keys[j])) From 0aef0c1c3e2204acb84623f3044c8c9ae95d4614 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Mon, 4 Apr 2022 19:20:48 -0700 Subject: [PATCH 034/246] Refactor binary ops for timedelta and datetime columns (#10581) This PR simplifies the handling of binary operations for datetime and timedelta columns. It reduces the number of nearly identical helper functions and consolidates logic for datetime-timedelta interop into the DatetimeColumn since timedeltas don't need to know how to work with datetimes. These changes also significantly reduce the number of redundant checks for the type of the other operand. The raised errors are no longer as highly customized as they used to be, but the type of exception is still the same which is the level of pandas compatibility that we want to provide, and the changes let us take advantage of reflection which is a major advantage. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/cudf/pull/10581 --- python/cudf/cudf/core/column/datetime.py | 94 ++++---- python/cudf/cudf/core/column/timedelta.py | 259 ++++++++-------------- python/cudf/cudf/core/tools/datetimes.py | 12 +- python/cudf/cudf/testing/_utils.py | 4 +- python/cudf/cudf/tests/test_timedelta.py | 64 ++---- 5 files changed, 164 insertions(+), 269 deletions(-) diff --git a/python/cudf/cudf/core/column/datetime.py b/python/cudf/cudf/core/column/datetime.py index 685f6fb281c..fac8af652c1 100644 --- a/python/cudf/cudf/core/column/datetime.py +++ b/python/cudf/cudf/core/column/datetime.py @@ -21,10 +21,11 @@ DtypeObj, ScalarLike, ) -from cudf.api.types import is_scalar +from cudf.api.types import is_datetime64_dtype, is_scalar, is_timedelta64_dtype from cudf.core._compat import PANDAS_GE_120 from cudf.core.buffer import Buffer from cudf.core.column import ColumnBase, as_column, column, string +from cudf.core.column.timedelta import _unit_to_nanoseconds_conversion from cudf.utils.utils import _fillna_natwise if PANDAS_GE_120: @@ -33,16 +34,6 @@ _guess_datetime_format = pd.core.tools.datetimes._guess_datetime_format # nanoseconds per time_unit -_numpy_to_pandas_conversion = { - "ns": 1, - "us": 1000, - "ms": 1000000, - "s": 1000000000, - "m": 60000000000, - "h": 3600000000000, - "D": 86400000000000, -} - _dtype_to_format_conversion = { "datetime64[ns]": "%Y-%m-%d %H:%M:%S.%9f", "datetime64[us]": "%Y-%m-%d %H:%M:%S.%6f", @@ -378,7 +369,7 @@ def std( self.as_numerical.std( skipna=skipna, min_count=min_count, dtype=dtype, ddof=ddof ) - * _numpy_to_pandas_conversion[self.time_unit], + * _unit_to_nanoseconds_conversion[self.time_unit], ) def median(self, skipna: bool = None) -> pd.Timestamp: @@ -411,45 +402,49 @@ def _binaryop(self, other: ColumnBinaryOperand, op: str) -> ColumnBase: if isinstance(other, cudf.DateOffset): return other._datetime_binop(self, op, reflect=reflect) - # TODO: Figure out if I can reflect before we start these checks. That - # requires figuring out why _timedelta_add_result_dtype and - # _timedelta_sub_result_dtype are 1) not symmetric, and 2) different - # from each other. + # We check this on `other` before reflection since we already know the + # dtype of `self`. + other_is_timedelta = is_timedelta64_dtype(other.dtype) + other_is_datetime64 = not other_is_timedelta and is_datetime64_dtype( + other.dtype + ) + lhs, rhs = (other, self) if reflect else (self, other) + out_dtype = None if op in { "__eq__", - "__ne__", - "__lt__", - "__gt__", - "__le__", - "__ge__", "NULL_EQUALS", }: - out_dtype: Dtype = cudf.dtype(np.bool_) - elif op == "__add__" and pd.api.types.is_timedelta64_dtype( - other.dtype + out_dtype = cudf.dtype(np.bool_) + elif ( + op + in { + "__ne__", + "__lt__", + "__gt__", + "__le__", + "__ge__", + } + and other_is_datetime64 ): - out_dtype = cudf.core.column.timedelta._timedelta_add_result_dtype( - other, self - ) - elif op == "__sub__" and pd.api.types.is_timedelta64_dtype( - other.dtype - ): - out_dtype = cudf.core.column.timedelta._timedelta_sub_result_dtype( - other if reflect else self, self if reflect else other - ) - elif op == "__sub__" and pd.api.types.is_datetime64_dtype(other.dtype): - units = ["s", "ms", "us", "ns"] - lhs_time_unit = cudf.utils.dtypes.get_time_unit(self) - lhs_unit = units.index(lhs_time_unit) - rhs_time_unit = cudf.utils.dtypes.get_time_unit(other) - rhs_unit = units.index(rhs_time_unit) - out_dtype = np.dtype( - f"timedelta64[{units[max(lhs_unit, rhs_unit)]}]" - ) - else: + out_dtype = cudf.dtype(np.bool_) + elif op == "__add__" and other_is_timedelta: + # The only thing we can add to a datetime is a timedelta. This + # operation is symmetric, i.e. we allow `datetime + timedelta` or + # `timedelta + datetime`. Both result in DatetimeColumns. + out_dtype = _resolve_mixed_dtypes(lhs, rhs, "datetime64") + elif op == "__sub__": + # Subtracting a datetime from a datetime results in a timedelta. + if other_is_datetime64: + out_dtype = _resolve_mixed_dtypes(lhs, rhs, "timedelta64") + # We can subtract a timedelta from a datetime, but not vice versa. + # Not only is subtraction antisymmetric (as is normal), it is only + # well-defined if this operation was not invoked via reflection. + elif other_is_timedelta and not reflect: + out_dtype = _resolve_mixed_dtypes(lhs, rhs, "datetime64") + + if out_dtype is None: return NotImplemented - lhs, rhs = (other, self) if reflect else (self, other) return libcudf.binaryop.binaryop(lhs, rhs, op, out_dtype) def fillna( @@ -573,3 +568,14 @@ def infer_format(element: str, **kwargs) -> str: raise ValueError("Unable to infer the timestamp format from the data") return fmt + + +def _resolve_mixed_dtypes( + lhs: ColumnBinaryOperand, rhs: ColumnBinaryOperand, base_type: str +) -> Dtype: + units = ["s", "ms", "us", "ns"] + lhs_time_unit = cudf.utils.dtypes.get_time_unit(lhs) + lhs_unit = units.index(lhs_time_unit) + rhs_time_unit = cudf.utils.dtypes.get_time_unit(rhs) + rhs_unit = units.index(rhs_time_unit) + return cudf.dtype(f"{base_type}[{units[max(lhs_unit, rhs_unit)]}]") diff --git a/python/cudf/cudf/core/column/timedelta.py b/python/cudf/cudf/core/column/timedelta.py index 8e1b938033e..15815427aca 100644 --- a/python/cudf/cudf/core/column/timedelta.py +++ b/python/cudf/cudf/core/column/timedelta.py @@ -3,7 +3,7 @@ from __future__ import annotations import datetime as dt -from typing import Any, Sequence, Tuple, cast +from typing import Any, Sequence, cast import numpy as np import pandas as pd @@ -11,16 +11,10 @@ import cudf from cudf import _lib as libcudf -from cudf._typing import ( - ColumnBinaryOperand, - DatetimeLikeScalar, - Dtype, - DtypeObj, -) -from cudf.api.types import is_scalar +from cudf._typing import ColumnBinaryOperand, DatetimeLikeScalar, Dtype +from cudf.api.types import is_scalar, is_timedelta64_dtype from cudf.core.buffer import Buffer from cudf.core.column import ColumnBase, column, string -from cudf.core.column.datetime import _numpy_to_pandas_conversion from cudf.utils.dtypes import np_to_pa_dtype from cudf.utils.utils import _fillna_natwise @@ -31,8 +25,18 @@ "timedelta64[s]": "%D days %H:%M:%S", } +_unit_to_nanoseconds_conversion = { + "ns": 1, + "us": 1_000, + "ms": 1_000_000, + "s": 1_000_000_000, + "m": 60_000_000_000, + "h": 3_600_000_000_000, + "D": 86_400_000_000_000, +} + -class TimeDeltaColumn(column.ColumnBase): +class TimeDeltaColumn(ColumnBase): """ Parameters ---------- @@ -151,99 +155,55 @@ def to_pandas( return pd_series - def _binary_op_mul(self, other: ColumnBinaryOperand) -> DtypeObj: - if other.dtype.kind in ("f", "i", "u"): - out_dtype = self.dtype - else: - raise TypeError( - f"Multiplication of {self.dtype} with {other.dtype} " - f"cannot be performed." - ) - return out_dtype - - def _binary_op_mod(self, other: ColumnBinaryOperand) -> DtypeObj: - if pd.api.types.is_timedelta64_dtype(other.dtype): - out_dtype = determine_out_dtype(self.dtype, other.dtype) - elif other.dtype.kind in ("f", "i", "u"): - out_dtype = self.dtype - else: - raise TypeError( - f"Modulo of {self.dtype} with {other.dtype} " - f"cannot be performed." - ) - return out_dtype - - def _binary_op_lt_gt_le_ge_eq_ne( - self, other: ColumnBinaryOperand - ) -> DtypeObj: - if pd.api.types.is_timedelta64_dtype(other.dtype): - return np.bool_ - raise TypeError( - f"Invalid comparison between dtype={self.dtype}" - f" and {other.dtype}" - ) - - def _binary_op_div( - self, other: ColumnBinaryOperand, op: str - ) -> Tuple["column.ColumnBase", ColumnBinaryOperand, DtypeObj]: - this: ColumnBase = self - if pd.api.types.is_timedelta64_dtype(other.dtype): - common_dtype = determine_out_dtype(self.dtype, other.dtype) - this = self.astype(common_dtype).astype("float64") - if isinstance(other, cudf.Scalar): - if other.is_valid(): - other = other.value.astype(common_dtype).astype("float64") - else: - other = cudf.Scalar(None, "float64") - else: - other = other.astype(common_dtype).astype("float64") - - out_dtype = cudf.dtype( - "float64" if op == "__truediv__" else "int64" - ) - elif other.dtype.kind in ("f", "i", "u"): - out_dtype = self.dtype - else: - raise TypeError( - f"Division of {self.dtype} with {other.dtype} " - f"cannot be performed." - ) - - return this, other, out_dtype - - def _binaryop( - self, other: ColumnBinaryOperand, op: str - ) -> "column.ColumnBase": + def _binaryop(self, other: ColumnBinaryOperand, op: str) -> ColumnBase: reflect, op = self._check_reflected_op(op) other = self._wrap_binop_normalization(other) if other is NotImplemented: return NotImplemented this: ColumnBinaryOperand = self - if op in { - "__eq__", - "__ne__", - "__lt__", - "__gt__", - "__le__", - "__ge__", - "NULL_EQUALS", - }: - out_dtype = self._binary_op_lt_gt_le_ge_eq_ne(other) - elif op == "__mul__": - out_dtype = self._binary_op_mul(other) - elif op == "__mod__": - out_dtype = self._binary_op_mod(other) - elif op in {"__truediv__", "__floordiv__"}: - this, other, out_dtype = self._binary_op_div(other, op) - op = "__truediv__" - elif op == "__add__": - out_dtype = _timedelta_add_result_dtype(self, other) - elif op == "__sub__": - out_dtype = _timedelta_sub_result_dtype(self, other) - else: + out_dtype = None + + if is_timedelta64_dtype(other.dtype): + # TODO: pandas will allow these operators to work but return false + # when comparing to non-timedelta dtypes. We should do the same. + if op in { + "__eq__", + "__ne__", + "__lt__", + "__gt__", + "__le__", + "__ge__", + "NULL_EQUALS", + }: + out_dtype = np.bool_ + elif op == "__mod__": + out_dtype = determine_out_dtype(self.dtype, other.dtype) + elif op in {"__truediv__", "__floordiv__"}: + common_dtype = determine_out_dtype(self.dtype, other.dtype) + this = self.astype(common_dtype).astype("float64") + if isinstance(other, cudf.Scalar): + if other.is_valid(): + other = other.value.astype(common_dtype).astype( + "float64" + ) + else: + other = cudf.Scalar(None, "float64") + else: + other = other.astype(common_dtype).astype("float64") + out_dtype = np.float64 if op == "__truediv__" else np.int64 + elif op in {"__add__", "__sub__"}: + out_dtype = determine_out_dtype(self.dtype, other.dtype) + elif other.dtype.kind in {"f", "i", "u"}: + if op in {"__mul__", "__mod__", "__truediv__", "__floordiv__"}: + out_dtype = self.dtype + + if out_dtype is None: return NotImplemented + if op == "__floordiv__": + op = "__truediv__" + lhs, rhs = (other, this) if reflect else (this, other) return libcudf.binaryop.binaryop(lhs, rhs, op, out_dtype) @@ -262,12 +222,11 @@ def normalize_binop_value(self, other) -> ColumnBinaryOperand: if np.isnat(other): return cudf.Scalar(None, dtype=self.dtype) - if other_time_unit not in ("s", "ms", "ns", "us"): - other = other.astype("timedelta64[s]") + if other_time_unit not in {"s", "ms", "ns", "us"}: + common_dtype = "timedelta64[s]" else: common_dtype = determine_out_dtype(self.dtype, other.dtype) - other = other.astype(common_dtype) - return cudf.Scalar(other) + return cudf.Scalar(other.astype(common_dtype)) elif np.isscalar(other): return cudf.Scalar(other) return NotImplemented @@ -295,7 +254,7 @@ def fillna( if fill_value is not None: if cudf.utils.utils._isnat(fill_value): return _fillna_natwise(self) - col = self # type: column.ColumnBase + col: ColumnBase = self if is_scalar(fill_value): if isinstance(fill_value, np.timedelta64): dtype = determine_out_dtype(self.dtype, fill_value.dtype) @@ -366,7 +325,7 @@ def quantile( interpolation: str, exact: bool, return_scalar: bool, - ) -> "column.ColumnBase": + ) -> ColumnBase: result = self.as_numerical.quantile( q=q, interpolation=interpolation, @@ -440,61 +399,73 @@ def components(self, index=None) -> "cudf.DataFrame": data={ "days": self // cudf.Scalar( - np.timedelta64(_numpy_to_pandas_conversion["D"], "ns") + np.timedelta64(_unit_to_nanoseconds_conversion["D"], "ns") ), "hours": ( self % cudf.Scalar( - np.timedelta64(_numpy_to_pandas_conversion["D"], "ns") + np.timedelta64( + _unit_to_nanoseconds_conversion["D"], "ns" + ) ) ) // cudf.Scalar( - np.timedelta64(_numpy_to_pandas_conversion["h"], "ns") + np.timedelta64(_unit_to_nanoseconds_conversion["h"], "ns") ), "minutes": ( self % cudf.Scalar( - np.timedelta64(_numpy_to_pandas_conversion["h"], "ns") + np.timedelta64( + _unit_to_nanoseconds_conversion["h"], "ns" + ) ) ) // cudf.Scalar( - np.timedelta64(_numpy_to_pandas_conversion["m"], "ns") + np.timedelta64(_unit_to_nanoseconds_conversion["m"], "ns") ), "seconds": ( self % cudf.Scalar( - np.timedelta64(_numpy_to_pandas_conversion["m"], "ns") + np.timedelta64( + _unit_to_nanoseconds_conversion["m"], "ns" + ) ) ) // cudf.Scalar( - np.timedelta64(_numpy_to_pandas_conversion["s"], "ns") + np.timedelta64(_unit_to_nanoseconds_conversion["s"], "ns") ), "milliseconds": ( self % cudf.Scalar( - np.timedelta64(_numpy_to_pandas_conversion["s"], "ns") + np.timedelta64( + _unit_to_nanoseconds_conversion["s"], "ns" + ) ) ) // cudf.Scalar( - np.timedelta64(_numpy_to_pandas_conversion["ms"], "ns") + np.timedelta64(_unit_to_nanoseconds_conversion["ms"], "ns") ), "microseconds": ( self % cudf.Scalar( - np.timedelta64(_numpy_to_pandas_conversion["ms"], "ns") + np.timedelta64( + _unit_to_nanoseconds_conversion["ms"], "ns" + ) ) ) // cudf.Scalar( - np.timedelta64(_numpy_to_pandas_conversion["us"], "ns") + np.timedelta64(_unit_to_nanoseconds_conversion["us"], "ns") ), "nanoseconds": ( self % cudf.Scalar( - np.timedelta64(_numpy_to_pandas_conversion["us"], "ns") + np.timedelta64( + _unit_to_nanoseconds_conversion["us"], "ns" + ) ) ) // cudf.Scalar( - np.timedelta64(_numpy_to_pandas_conversion["ns"], "ns") + np.timedelta64(_unit_to_nanoseconds_conversion["ns"], "ns") ), }, index=index, @@ -510,7 +481,7 @@ def days(self) -> "cudf.core.column.NumericalColumn": NumericalColumn """ return self // cudf.Scalar( - np.timedelta64(_numpy_to_pandas_conversion["D"], "ns") + np.timedelta64(_unit_to_nanoseconds_conversion["D"], "ns") ) @property @@ -530,10 +501,10 @@ def seconds(self) -> "cudf.core.column.NumericalColumn": return ( self % cudf.Scalar( - np.timedelta64(_numpy_to_pandas_conversion["D"], "ns") + np.timedelta64(_unit_to_nanoseconds_conversion["D"], "ns") ) ) // cudf.Scalar( - np.timedelta64(_numpy_to_pandas_conversion["s"], "ns") + np.timedelta64(_unit_to_nanoseconds_conversion["s"], "ns") ) @property @@ -551,9 +522,9 @@ def microseconds(self) -> "cudf.core.column.NumericalColumn": # division operation to extract the number of microseconds. return ( - self % np.timedelta64(_numpy_to_pandas_conversion["s"], "ns") + self % np.timedelta64(_unit_to_nanoseconds_conversion["s"], "ns") ) // cudf.Scalar( - np.timedelta64(_numpy_to_pandas_conversion["us"], "ns") + np.timedelta64(_unit_to_nanoseconds_conversion["us"], "ns") ) @property @@ -574,10 +545,10 @@ def nanoseconds(self) -> "cudf.core.column.NumericalColumn": return ( self % cudf.Scalar( - np.timedelta64(_numpy_to_pandas_conversion["us"], "ns") + np.timedelta64(_unit_to_nanoseconds_conversion["us"], "ns") ) ) // cudf.Scalar( - np.timedelta64(_numpy_to_pandas_conversion["ns"], "ns") + np.timedelta64(_unit_to_nanoseconds_conversion["ns"], "ns") ) @@ -588,49 +559,3 @@ def determine_out_dtype(lhs_dtype: Dtype, rhs_dtype: Dtype) -> Dtype: return lhs_dtype else: raise TypeError(f"Cannot type-cast {lhs_dtype} and {rhs_dtype}") - - -def _timedelta_add_result_dtype( - lhs: ColumnBinaryOperand, rhs: ColumnBinaryOperand -) -> Dtype: - if pd.api.types.is_timedelta64_dtype(rhs.dtype): - out_dtype = determine_out_dtype(lhs.dtype, rhs.dtype) - elif pd.api.types.is_datetime64_dtype(rhs.dtype): - units = ["s", "ms", "us", "ns"] - lhs_time_unit = cudf.utils.dtypes.get_time_unit(lhs) - lhs_unit = units.index(lhs_time_unit) - rhs_time_unit = cudf.utils.dtypes.get_time_unit(rhs) - rhs_unit = units.index(rhs_time_unit) - out_dtype = cudf.dtype(f"datetime64[{units[max(lhs_unit, rhs_unit)]}]") - else: - raise TypeError( - f"Addition of {lhs.dtype} with {rhs.dtype} " - f"cannot be performed." - ) - - return out_dtype - - -def _timedelta_sub_result_dtype( - lhs: ColumnBinaryOperand, rhs: ColumnBinaryOperand -) -> Dtype: - if pd.api.types.is_timedelta64_dtype( - lhs.dtype - ) and pd.api.types.is_timedelta64_dtype(rhs.dtype): - out_dtype = determine_out_dtype(lhs.dtype, rhs.dtype) - elif pd.api.types.is_timedelta64_dtype( - rhs.dtype - ) and pd.api.types.is_datetime64_dtype(lhs.dtype): - units = ["s", "ms", "us", "ns"] - lhs_time_unit = cudf.utils.dtypes.get_time_unit(lhs) - lhs_unit = units.index(lhs_time_unit) - rhs_time_unit = cudf.utils.dtypes.get_time_unit(rhs) - rhs_unit = units.index(rhs_time_unit) - out_dtype = cudf.dtype(f"datetime64[{units[max(lhs_unit, rhs_unit)]}]") - else: - raise TypeError( - f"Subtraction of {lhs.dtype} with {rhs.dtype} " - f"cannot be performed." - ) - - return out_dtype diff --git a/python/cudf/cudf/core/tools/datetimes.py b/python/cudf/cudf/core/tools/datetimes.py index 3d1a659e201..3ce89bc27e8 100644 --- a/python/cudf/cudf/core/tools/datetimes.py +++ b/python/cudf/cudf/core/tools/datetimes.py @@ -214,9 +214,11 @@ def to_datetime( current_col = current_col.astype(dtype="float64") factor = cudf.Scalar( - column.datetime._numpy_to_pandas_conversion[u] + column.datetime._unit_to_nanoseconds_conversion[u] / ( - column.datetime._numpy_to_pandas_conversion["s"] + column.datetime._unit_to_nanoseconds_conversion[ + "s" + ] if np.datetime_data(col.dtype)[0] == "s" else 1 ) @@ -291,7 +293,7 @@ def _process_col(col, unit, dayfirst, infer_datetime_format, format): if col.dtype.kind in ("f"): if unit not in (None, "ns"): factor = cudf.Scalar( - column.datetime._numpy_to_pandas_conversion[unit] + column.datetime._unit_to_nanoseconds_conversion[unit] ) col = col * factor @@ -318,8 +320,8 @@ def _process_col(col, unit, dayfirst, infer_datetime_format, format): if col.dtype.kind in ("i"): if unit in ("D", "h", "m"): factor = cudf.Scalar( - column.datetime._numpy_to_pandas_conversion[unit] - / column.datetime._numpy_to_pandas_conversion["s"] + column.datetime._unit_to_nanoseconds_conversion[unit] + / column.datetime._unit_to_nanoseconds_conversion["s"] ) col = col * factor diff --git a/python/cudf/cudf/testing/_utils.py b/python/cudf/cudf/testing/_utils.py index 2ff311c1399..4dd9f434097 100644 --- a/python/cudf/cudf/testing/_utils.py +++ b/python/cudf/cudf/testing/_utils.py @@ -15,7 +15,7 @@ import cudf from cudf._lib.null_mask import bitmask_allocation_size_bytes -from cudf.core.column.datetime import _numpy_to_pandas_conversion +from cudf.core.column.timedelta import _unit_to_nanoseconds_conversion from cudf.utils import dtypes as dtypeutils supported_numpy_dtypes = [ @@ -300,7 +300,7 @@ def gen_rand(dtype, size, **kwargs): time_unit, _ = np.datetime_data(dtype) high = kwargs.get( "high", - 1000000000000000000 / _numpy_to_pandas_conversion[time_unit], + int(1e18) / _unit_to_nanoseconds_conversion[time_unit], ) return pd.to_datetime( np.random.randint(low=low, high=high, size=size), unit=time_unit diff --git a/python/cudf/cudf/tests/test_timedelta.py b/python/cudf/cudf/tests/test_timedelta.py index 71c30e0aaa5..8a118e0e1d6 100644 --- a/python/cudf/cudf/tests/test_timedelta.py +++ b/python/cudf/cudf/tests/test_timedelta.py @@ -346,10 +346,7 @@ def test_timedelta_ops_datetime_inputs( rfunc=operator.sub, lfunc_args_and_kwargs=([psr_timedelta, psr_datetime],), rfunc_args_and_kwargs=([gsr_timedelta, gsr_datetime],), - expected_error_message=re.escape( - f"Subtraction of {gsr_timedelta.dtype} with " - f"{gsr_datetime.dtype} cannot be performed." - ), + compare_error_message=False, ) @@ -1153,10 +1150,7 @@ def test_timedelta_invalid_ops(): rfunc=operator.add, lfunc_args_and_kwargs=([psr, 1],), rfunc_args_and_kwargs=([sr, 1],), - expected_error_message=re.escape( - f"Addition of {sr.dtype} with {np.dtype('int64')} " - f"cannot be performed." - ), + compare_error_message=False, ) assert_exceptions_equal( @@ -1164,10 +1158,7 @@ def test_timedelta_invalid_ops(): rfunc=operator.add, lfunc_args_and_kwargs=([psr, "a"],), rfunc_args_and_kwargs=([sr, "a"],), - expected_error_message=re.escape( - f"Addition of {sr.dtype} with {np.dtype('object')} " - f"cannot be performed." - ), + compare_error_message=False, ) dt_sr = cudf.Series([1, 2, 3], dtype="datetime64[ns]") @@ -1178,9 +1169,7 @@ def test_timedelta_invalid_ops(): rfunc=operator.mod, lfunc_args_and_kwargs=([psr, dt_psr],), rfunc_args_and_kwargs=([sr, dt_sr],), - expected_error_message=re.escape( - f"Modulo of {sr.dtype} with {dt_sr.dtype} " f"cannot be performed." - ), + compare_error_message=False, ) assert_exceptions_equal( @@ -1188,10 +1177,7 @@ def test_timedelta_invalid_ops(): rfunc=operator.mod, lfunc_args_and_kwargs=([psr, "a"],), rfunc_args_and_kwargs=([sr, "a"],), - expected_error_message=re.escape( - f"Modulo of {sr.dtype} with {np.dtype('object')} " - f"cannot be performed." - ), + compare_error_message=False, ) assert_exceptions_equal( @@ -1199,10 +1185,7 @@ def test_timedelta_invalid_ops(): rfunc=operator.gt, lfunc_args_and_kwargs=([psr, dt_psr],), rfunc_args_and_kwargs=([sr, dt_sr],), - expected_error_message=re.escape( - f"Invalid comparison between dtype={sr.dtype}" - f" and {dt_sr.dtype}" - ), + compare_error_message=False, ) assert_exceptions_equal( @@ -1210,10 +1193,7 @@ def test_timedelta_invalid_ops(): rfunc=operator.lt, lfunc_args_and_kwargs=([psr, dt_psr],), rfunc_args_and_kwargs=([sr, dt_sr],), - expected_error_message=re.escape( - f"Invalid comparison between dtype={sr.dtype}" - f" and {dt_sr.dtype}" - ), + compare_error_message=False, ) assert_exceptions_equal( @@ -1221,10 +1201,7 @@ def test_timedelta_invalid_ops(): rfunc=operator.ge, lfunc_args_and_kwargs=([psr, dt_psr],), rfunc_args_and_kwargs=([sr, dt_sr],), - expected_error_message=re.escape( - f"Invalid comparison between dtype={sr.dtype}" - f" and {dt_sr.dtype}" - ), + compare_error_message=False, ) assert_exceptions_equal( @@ -1232,10 +1209,7 @@ def test_timedelta_invalid_ops(): rfunc=operator.le, lfunc_args_and_kwargs=([psr, dt_psr],), rfunc_args_and_kwargs=([sr, dt_sr],), - expected_error_message=re.escape( - f"Invalid comparison between dtype={sr.dtype}" - f" and {dt_sr.dtype}" - ), + compare_error_message=False, ) assert_exceptions_equal( @@ -1243,10 +1217,7 @@ def test_timedelta_invalid_ops(): rfunc=operator.truediv, lfunc_args_and_kwargs=([psr, dt_psr],), rfunc_args_and_kwargs=([sr, dt_sr],), - expected_error_message=re.escape( - f"Division of {sr.dtype} with {dt_sr.dtype} " - f"cannot be performed." - ), + compare_error_message=False, ) assert_exceptions_equal( @@ -1254,10 +1225,7 @@ def test_timedelta_invalid_ops(): rfunc=operator.floordiv, lfunc_args_and_kwargs=([psr, dt_psr],), rfunc_args_and_kwargs=([sr, dt_sr],), - expected_error_message=re.escape( - f"Division of {sr.dtype} with {dt_sr.dtype} " - f"cannot be performed." - ), + compare_error_message=False, ) assert_exceptions_equal( @@ -1265,10 +1233,7 @@ def test_timedelta_invalid_ops(): rfunc=operator.mul, lfunc_args_and_kwargs=([psr, dt_psr],), rfunc_args_and_kwargs=([sr, dt_sr],), - expected_error_message=re.escape( - f"Multiplication of {sr.dtype} with {dt_sr.dtype} " - f"cannot be performed." - ), + compare_error_message=False, ) assert_exceptions_equal( @@ -1277,10 +1242,7 @@ def test_timedelta_invalid_ops(): lfunc_args_and_kwargs=([psr, psr],), rfunc_args_and_kwargs=([sr, sr],), check_exception_type=False, - expected_error_message=re.escape( - f"Multiplication of {sr.dtype} with {sr.dtype} " - f"cannot be performed." - ), + compare_error_message=False, ) assert_exceptions_equal( From e8d189c8d3369c0a19217ac7c91f0285ab2b05ca Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Tue, 5 Apr 2022 07:58:22 -0700 Subject: [PATCH 035/246] Rename CUDA_TRY macro to CUDF_CUDA_TRY, rename CHECK_CUDA macro to CUDF_CHECK_CUDA. (#10589) This PR renames the `CUDA_TRY` macro to `CUDF_CUDA_TRY` to avoid name conflicts with other libraries. Resolves #9660. Similarly, `CHECK_CUDA` has been renamed to `CUDF_CHECK_CUDA`. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Jake Hemstad (https://github.com/jrhemstad) - Jason Lowe (https://github.com/jlowe) - David Wendt (https://github.com/davidwendt) URL: https://github.com/rapidsai/cudf/pull/10589 --- cpp/benchmarks/column/concatenate.cpp | 6 +- cpp/benchmarks/join/generate_input_tables.cuh | 16 ++--- cpp/benchmarks/join/join_common.hpp | 2 +- .../synchronization/synchronization.cpp | 24 ++++---- .../type_dispatcher/type_dispatcher.cu | 4 +- cpp/docs/DEVELOPER_GUIDE.md | 4 +- cpp/include/cudf/detail/copy_if.cuh | 12 ++-- cpp/include/cudf/detail/copy_range.cuh | 4 +- cpp/include/cudf/detail/get_value.cuh | 12 ++-- cpp/include/cudf/detail/null_mask.cuh | 50 ++++++++-------- cpp/include/cudf/detail/utilities/cuda.cuh | 6 +- .../detail/utilities/vector_factories.hpp | 26 ++++---- .../io/text/data_chunk_source_factories.hpp | 10 ++-- cpp/include/cudf/strings/detail/utilities.cuh | 2 +- cpp/include/cudf/strings/string_view.cuh | 3 +- cpp/include/cudf/table/table_device_view.cuh | 2 +- cpp/include/cudf/utilities/error.hpp | 28 +++++++-- cpp/include/cudf_test/column_utilities.hpp | 5 +- cpp/src/binaryop/compiled/binary_ops.cuh | 2 +- cpp/src/bitmask/is_element_valid.cpp | 12 ++-- cpp/src/bitmask/null_mask.cu | 8 +-- cpp/src/column/column_device_view.cu | 10 ++-- cpp/src/copying/contiguous_split.cu | 24 ++++---- cpp/src/hash/concurrent_unordered_map.cuh | 20 +++---- .../hash/concurrent_unordered_multimap.cuh | 20 +++---- cpp/src/interop/dlpack.cpp | 24 ++++---- cpp/src/interop/from_arrow.cu | 24 ++++---- cpp/src/interop/to_arrow.cu | 42 ++++++------- cpp/src/io/avro/reader_impl.cu | 14 ++--- cpp/src/io/comp/debrotli.cu | 18 +++--- cpp/src/io/csv/reader_impl.cu | 50 ++++++++-------- cpp/src/io/csv/writer_impl.cu | 10 ++-- cpp/src/io/json/json_gpu.cu | 10 ++-- cpp/src/io/json/reader_impl.cu | 22 +++---- cpp/src/io/orc/reader_impl.cu | 8 +-- cpp/src/io/orc/writer_impl.cu | 22 +++---- cpp/src/io/parquet/reader_impl.cu | 60 +++++++++---------- cpp/src/io/parquet/writer_impl.cu | 34 +++++------ cpp/src/io/utilities/column_buffer.hpp | 2 +- cpp/src/io/utilities/hostdevice_vector.hpp | 6 +- cpp/src/io/utilities/parsing_utils.cu | 22 ++++++- cpp/src/jit/cache.cpp | 6 +- cpp/src/merge/merge.cu | 4 +- cpp/src/quantiles/quantiles_util.hpp | 2 +- cpp/src/reductions/minmax.cu | 4 +- cpp/src/reductions/scan/scan_exclusive.cu | 2 +- cpp/src/reductions/scan/scan_inclusive.cu | 2 +- cpp/src/rolling/rolling_detail.cuh | 2 +- cpp/src/scalar/scalar.cpp | 2 +- cpp/src/search/search.cu | 3 +- cpp/src/strings/combine/join.cu | 10 ++-- cpp/src/strings/convert/convert_durations.cu | 10 ++-- cpp/src/strings/copying/concatenate.cu | 2 +- cpp/src/strings/regex/regexec.cu | 4 +- cpp/src/strings/repeat_strings.cu | 10 ++-- cpp/src/strings/utilities.cu | 12 ++-- cpp/src/text/edit_distance.cu | 2 +- cpp/src/text/subword/load_hash_file.cu | 58 +++++++++--------- cpp/src/text/subword/wordpiece_tokenizer.cu | 6 +- cpp/src/transform/compute_column.cu | 6 +- cpp/src/transform/row_bit_count.cu | 4 +- cpp/src/unary/unary_ops.cuh | 2 +- cpp/tests/bitmask/bitmask_tests.cpp | 14 ++--- cpp/tests/copying/concatenate_tests.cu | 4 +- .../device_atomics/device_atomics_test.cu | 4 +- cpp/tests/error/error_handling_test.cu | 18 +++--- cpp/tests/io/parquet_test.cpp | 12 ++-- cpp/tests/join/join_tests.cpp | 2 +- cpp/tests/scalar/scalar_device_view_test.cu | 12 ++-- cpp/tests/sort/sort_test.cpp | 6 +- cpp/tests/sort/stable_sort_tests.cpp | 4 +- cpp/tests/strings/factories_test.cu | 2 +- cpp/tests/strings/integers_tests.cpp | 8 +-- cpp/tests/types/type_dispatcher_test.cu | 6 +- cpp/tests/utilities/column_utilities.cu | 16 ++--- java/src/main/native/src/TableJni.cpp | 4 +- java/src/main/native/src/map_lookup.cu | 4 +- java/src/main/native/src/row_conversion.cu | 8 +-- 78 files changed, 495 insertions(+), 462 deletions(-) diff --git a/cpp/benchmarks/column/concatenate.cpp b/cpp/benchmarks/column/concatenate.cpp index 21e5db8ca8f..67ea6129a74 100644 --- a/cpp/benchmarks/column/concatenate.cpp +++ b/cpp/benchmarks/column/concatenate.cpp @@ -45,7 +45,7 @@ static void BM_concatenate(benchmark::State& state) auto input_columns = input->view(); std::vector column_views(input_columns.begin(), input_columns.end()); - CHECK_CUDA(0); + CUDF_CHECK_CUDA(0); for (auto _ : state) { cuda_event_timer raii(state, true, rmm::cuda_stream_default); @@ -87,7 +87,7 @@ static void BM_concatenate_tables(benchmark::State& state) return table->view(); }); - CHECK_CUDA(0); + CUDF_CHECK_CUDA(0); for (auto _ : state) { cuda_event_timer raii(state, true, rmm::cuda_stream_default); @@ -146,7 +146,7 @@ static void BM_concatenate_strings(benchmark::State& state) return static_cast(col); }); - CHECK_CUDA(0); + CUDF_CHECK_CUDA(0); for (auto _ : state) { cuda_event_timer raii(state, true, rmm::cuda_stream_default); diff --git a/cpp/benchmarks/join/generate_input_tables.cuh b/cpp/benchmarks/join/generate_input_tables.cuh index e846317f472..5df77ac4319 100644 --- a/cpp/benchmarks/join/generate_input_tables.cuh +++ b/cpp/benchmarks/join/generate_input_tables.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -139,18 +139,18 @@ void generate_input_tables(key_type* const build_tbl, // Maximize exposed parallelism while minimizing storage for curand state int num_blocks_init_build_tbl{-1}; - CUDA_TRY(cudaOccupancyMaxActiveBlocksPerMultiprocessor( + CUDF_CUDA_TRY(cudaOccupancyMaxActiveBlocksPerMultiprocessor( &num_blocks_init_build_tbl, init_build_tbl, block_size, 0)); int num_blocks_init_probe_tbl{-1}; - CUDA_TRY(cudaOccupancyMaxActiveBlocksPerMultiprocessor( + CUDF_CUDA_TRY(cudaOccupancyMaxActiveBlocksPerMultiprocessor( &num_blocks_init_probe_tbl, init_probe_tbl, block_size, 0)); int dev_id{-1}; - CUDA_TRY(cudaGetDevice(&dev_id)); + CUDF_CUDA_TRY(cudaGetDevice(&dev_id)); int num_sms{-1}; - CUDA_TRY(cudaDeviceGetAttribute(&num_sms, cudaDevAttrMultiProcessorCount, dev_id)); + CUDF_CUDA_TRY(cudaDeviceGetAttribute(&num_sms, cudaDevAttrMultiProcessorCount, dev_id)); const int num_states = num_sms * std::max(num_blocks_init_build_tbl, num_blocks_init_probe_tbl) * block_size; @@ -158,12 +158,12 @@ void generate_input_tables(key_type* const build_tbl, init_curand<<<(num_states - 1) / block_size + 1, block_size>>>(devStates.data(), num_states); - CHECK_CUDA(0); + CUDF_CHECK_CUDA(0); init_build_tbl<<>>( build_tbl, build_tbl_size, multiplicity, devStates.data(), num_states); - CHECK_CUDA(0); + CUDF_CHECK_CUDA(0); auto const rand_max = std::numeric_limits::max(); @@ -177,5 +177,5 @@ void generate_input_tables(key_type* const build_tbl, devStates.data(), num_states); - CHECK_CUDA(0); + CUDF_CHECK_CUDA(0); } diff --git a/cpp/benchmarks/join/join_common.hpp b/cpp/benchmarks/join/join_common.hpp index 27339248968..6ff2543cf7d 100644 --- a/cpp/benchmarks/join/join_common.hpp +++ b/cpp/benchmarks/join/join_common.hpp @@ -116,7 +116,7 @@ static void BM_join(state_type& state, Join JoinFunc) auto build_payload_column = cudf::sequence(build_table_size, *init); auto probe_payload_column = cudf::sequence(probe_table_size, *init); - CHECK_CUDA(0); + CUDF_CHECK_CUDA(0); cudf::table_view build_table({build_key_column->view(), *build_payload_column}); cudf::table_view probe_table({probe_key_column->view(), *probe_payload_column}); diff --git a/cpp/benchmarks/synchronization/synchronization.cpp b/cpp/benchmarks/synchronization/synchronization.cpp index bd8a4d1de76..bbf90e6f68a 100644 --- a/cpp/benchmarks/synchronization/synchronization.cpp +++ b/cpp/benchmarks/synchronization/synchronization.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2020, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -29,32 +29,32 @@ cuda_event_timer::cuda_event_timer(benchmark::State& state, // flush all of L2$ if (flush_l2_cache) { int current_device = 0; - CUDA_TRY(cudaGetDevice(¤t_device)); + CUDF_CUDA_TRY(cudaGetDevice(¤t_device)); int l2_cache_bytes = 0; - CUDA_TRY(cudaDeviceGetAttribute(&l2_cache_bytes, cudaDevAttrL2CacheSize, current_device)); + CUDF_CUDA_TRY(cudaDeviceGetAttribute(&l2_cache_bytes, cudaDevAttrL2CacheSize, current_device)); if (l2_cache_bytes > 0) { const int memset_value = 0; rmm::device_buffer l2_cache_buffer(l2_cache_bytes, stream); - CUDA_TRY( + CUDF_CUDA_TRY( cudaMemsetAsync(l2_cache_buffer.data(), memset_value, l2_cache_bytes, stream.value())); } } - CUDA_TRY(cudaEventCreate(&start)); - CUDA_TRY(cudaEventCreate(&stop)); - CUDA_TRY(cudaEventRecord(start, stream.value())); + CUDF_CUDA_TRY(cudaEventCreate(&start)); + CUDF_CUDA_TRY(cudaEventCreate(&stop)); + CUDF_CUDA_TRY(cudaEventRecord(start, stream.value())); } cuda_event_timer::~cuda_event_timer() { - CUDA_TRY(cudaEventRecord(stop, stream.value())); - CUDA_TRY(cudaEventSynchronize(stop)); + CUDF_CUDA_TRY(cudaEventRecord(stop, stream.value())); + CUDF_CUDA_TRY(cudaEventSynchronize(stop)); float milliseconds = 0.0f; - CUDA_TRY(cudaEventElapsedTime(&milliseconds, start, stop)); + CUDF_CUDA_TRY(cudaEventElapsedTime(&milliseconds, start, stop)); p_state->SetIterationTime(milliseconds / (1000.0f)); - CUDA_TRY(cudaEventDestroy(start)); - CUDA_TRY(cudaEventDestroy(stop)); + CUDF_CUDA_TRY(cudaEventDestroy(start)); + CUDF_CUDA_TRY(cudaEventDestroy(stop)); } diff --git a/cpp/benchmarks/type_dispatcher/type_dispatcher.cu b/cpp/benchmarks/type_dispatcher/type_dispatcher.cu index 6ab6f9a2095..aba78dad3fe 100644 --- a/cpp/benchmarks/type_dispatcher/type_dispatcher.cu +++ b/cpp/benchmarks/type_dispatcher/type_dispatcher.cu @@ -196,13 +196,13 @@ void type_dispatcher_benchmark(::benchmark::State& state) rmm::device_uvector d_vec(n_cols, rmm::cuda_stream_default); if (dispatching_type == NO_DISPATCHING) { - CUDA_TRY(cudaMemcpy( + CUDF_CUDA_TRY(cudaMemcpy( d_vec.data(), h_vec_p.data(), sizeof(TypeParam*) * n_cols, cudaMemcpyHostToDevice)); } // Warm up launch_kernel(source_table, d_vec.data(), work_per_thread); - CUDA_TRY(cudaDeviceSynchronize()); + CUDF_CUDA_TRY(cudaDeviceSynchronize()); for (auto _ : state) { cuda_event_timer raii(state, true); // flush_l2_cache = true, stream = 0 diff --git a/cpp/docs/DEVELOPER_GUIDE.md b/cpp/docs/DEVELOPER_GUIDE.md index eeebe38d873..1599c81cbe5 100644 --- a/cpp/docs/DEVELOPER_GUIDE.md +++ b/cpp/docs/DEVELOPER_GUIDE.md @@ -373,7 +373,7 @@ namespace detail{ void external_function(..., rmm::cuda_stream_view stream){ // Implementation uses the stream with async APIs. rmm::device_buffer buff(...,stream); - CUDA_TRY(cudaMemcpyAsync(...,stream.value())); + CUDF_CUDA_TRY(cudaMemcpyAsync(...,stream.value())); kernel<<<..., stream>>>(...); thrust::algorithm(rmm::exec_policy(stream), ...); } @@ -777,7 +777,7 @@ CUDF_FAIL("This code path should not be reached."); ### CUDA Error Checking -Use the `CUDA_TRY` macro to check for the successful completion of CUDA runtime API functions. This +Use the `CUDF_CUDA_TRY` macro to check for the successful completion of CUDA runtime API functions. This macro throws a `cudf::cuda_error` exception if the CUDA API return value is not `cudaSuccess`. The thrown exception includes a description of the CUDA error code in its `what()` message. diff --git a/cpp/include/cudf/detail/copy_if.cuh b/cpp/include/cudf/detail/copy_if.cuh index 0087dd1b173..ecaa4a30cf0 100644 --- a/cpp/include/cudf/detail/copy_if.cuh +++ b/cpp/include/cudf/detail/copy_if.cuh @@ -254,10 +254,10 @@ struct scatter_gather_functor { if (output.nullable()) { // Have to initialize the output mask to all zeros because we may update // it with atomicOr(). - CUDA_TRY(cudaMemsetAsync(static_cast(output.null_mask()), - 0, - cudf::bitmask_allocation_size_bytes(output.size()), - stream.value())); + CUDF_CUDA_TRY(cudaMemsetAsync(static_cast(output.null_mask()), + 0, + cudf::bitmask_allocation_size_bytes(output.size()), + stream.value())); } auto output_device_view = cudf::mutable_column_device_view::create(output, stream); @@ -344,7 +344,7 @@ std::unique_ptr
copy_if( // initialize just the first element of block_offsets to 0 since the InclusiveSum below // starts at the second element. - CUDA_TRY(cudaMemsetAsync(block_offsets.begin(), 0, sizeof(cudf::size_type), stream.value())); + CUDF_CUDA_TRY(cudaMemsetAsync(block_offsets.begin(), 0, sizeof(cudf::size_type), stream.value())); // 2. Find the offset for each block's output using a scan of block counts if (grid.num_blocks > 1) { @@ -370,7 +370,7 @@ std::unique_ptr
copy_if( // As it is InclusiveSum, last value in block_offsets will be output_size // unless num_blocks == 1, in which case output_size is just block_counts[0] cudf::size_type output_size{0}; - CUDA_TRY(cudaMemcpyAsync( + CUDF_CUDA_TRY(cudaMemcpyAsync( &output_size, grid.num_blocks > 1 ? block_offsets.begin() + grid.num_blocks : block_counts.begin(), sizeof(cudf::size_type), diff --git a/cpp/include/cudf/detail/copy_range.cuh b/cpp/include/cudf/detail/copy_range.cuh index ac59b429a2c..6703db305a1 100644 --- a/cpp/include/cudf/detail/copy_range.cuh +++ b/cpp/include/cudf/detail/copy_range.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2020, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -185,7 +185,7 @@ void copy_range(SourceValueIterator source_value_begin, nullptr); } - CHECK_CUDA(stream.value()); + CUDF_CHECK_CUDA(stream.value()); } /** diff --git a/cpp/include/cudf/detail/get_value.cuh b/cpp/include/cudf/detail/get_value.cuh index 56c0289dc0a..49a406ab5f0 100644 --- a/cpp/include/cudf/detail/get_value.cuh +++ b/cpp/include/cudf/detail/get_value.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -49,11 +49,11 @@ T get_value(column_view const& col_view, size_type element_index, rmm::cuda_stre CUDF_EXPECTS(element_index >= 0 && element_index < col_view.size(), "invalid element_index value"); T result; - CUDA_TRY(cudaMemcpyAsync(&result, - col_view.data() + element_index, - sizeof(T), - cudaMemcpyDeviceToHost, - stream.value())); + CUDF_CUDA_TRY(cudaMemcpyAsync(&result, + col_view.data() + element_index, + sizeof(T), + cudaMemcpyDeviceToHost, + stream.value())); stream.synchronize(); return result; } diff --git a/cpp/include/cudf/detail/null_mask.cuh b/cpp/include/cudf/detail/null_mask.cuh index be010689847..7aec56fdc51 100644 --- a/cpp/include/cudf/detail/null_mask.cuh +++ b/cpp/include/cudf/detail/null_mask.cuh @@ -170,20 +170,20 @@ size_type inplace_bitmask_binop( rmm::device_uvector d_masks(masks.size(), stream, mr); rmm::device_uvector d_begin_bits(masks_begin_bits.size(), stream, mr); - CUDA_TRY(cudaMemcpyAsync( + CUDF_CUDA_TRY(cudaMemcpyAsync( d_masks.data(), masks.data(), masks.size_bytes(), cudaMemcpyHostToDevice, stream.value())); - CUDA_TRY(cudaMemcpyAsync(d_begin_bits.data(), - masks_begin_bits.data(), - masks_begin_bits.size_bytes(), - cudaMemcpyHostToDevice, - stream.value())); + CUDF_CUDA_TRY(cudaMemcpyAsync(d_begin_bits.data(), + masks_begin_bits.data(), + masks_begin_bits.size_bytes(), + cudaMemcpyHostToDevice, + stream.value())); auto constexpr block_size = 256; cudf::detail::grid_1d config(dest_mask.size(), block_size); offset_bitmask_binop <<>>( op, dest_mask, d_masks, d_begin_bits, mask_size_bits, d_counter.data()); - CHECK_CUDA(stream.value()); + CUDF_CHECK_CUDA(stream.value()); return d_counter.value(stream); } @@ -298,27 +298,25 @@ rmm::device_uvector segmented_count_bits(bitmask_type const* bitmask, // Allocate temporary memory. size_t temp_storage_bytes{0}; - CUDA_TRY(cub::DeviceSegmentedReduce::Sum(nullptr, - temp_storage_bytes, - num_set_bits_in_word, - d_bit_counts.begin(), - num_ranges, - first_word_indices, - last_word_indices, - stream.value())); + CUDF_CUDA_TRY(cub::DeviceSegmentedReduce::Sum(nullptr, + temp_storage_bytes, + num_set_bits_in_word, + d_bit_counts.begin(), + num_ranges, + first_word_indices, + last_word_indices, + stream.value())); rmm::device_buffer d_temp_storage(temp_storage_bytes, stream); // Perform segmented reduction. - CUDA_TRY(cub::DeviceSegmentedReduce::Sum(d_temp_storage.data(), - temp_storage_bytes, - num_set_bits_in_word, - d_bit_counts.begin(), - num_ranges, - first_word_indices, - last_word_indices, - stream.value())); - - CHECK_CUDA(stream.value()); + CUDF_CUDA_TRY(cub::DeviceSegmentedReduce::Sum(d_temp_storage.data(), + temp_storage_bytes, + num_set_bits_in_word, + d_bit_counts.begin(), + num_ranges, + first_word_indices, + last_word_indices, + stream.value())); // Adjust counts in segment boundaries (if segments are not word-aligned). constexpr size_type block_size{256}; @@ -350,7 +348,7 @@ rmm::device_uvector segmented_count_bits(bitmask_type const* bitmask, }); } - CHECK_CUDA(stream.value()); + CUDF_CHECK_CUDA(stream.value()); return d_bit_counts; } diff --git a/cpp/include/cudf/detail/utilities/cuda.cuh b/cpp/include/cudf/detail/utilities/cuda.cuh index a00bd64caa3..23d0ff26e0f 100644 --- a/cpp/include/cudf/detail/utilities/cuda.cuh +++ b/cpp/include/cudf/detail/utilities/cuda.cuh @@ -127,12 +127,12 @@ cudf::size_type elements_per_thread(Kernel kernel, // calculate theoretical occupancy int max_blocks = 0; - CUDA_TRY(cudaOccupancyMaxActiveBlocksPerMultiprocessor(&max_blocks, kernel, block_size, 0)); + CUDF_CUDA_TRY(cudaOccupancyMaxActiveBlocksPerMultiprocessor(&max_blocks, kernel, block_size, 0)); int device = 0; - CUDA_TRY(cudaGetDevice(&device)); + CUDF_CUDA_TRY(cudaGetDevice(&device)); int num_sms = 0; - CUDA_TRY(cudaDeviceGetAttribute(&num_sms, cudaDevAttrMultiProcessorCount, device)); + CUDF_CUDA_TRY(cudaDeviceGetAttribute(&num_sms, cudaDevAttrMultiProcessorCount, device)); int per_thread = total_size / (max_blocks * num_sms * block_size); return std::clamp(per_thread, 1, max_per_thread); } diff --git a/cpp/include/cudf/detail/utilities/vector_factories.hpp b/cpp/include/cudf/detail/utilities/vector_factories.hpp index e3f44ce0bee..63ac48f6060 100644 --- a/cpp/include/cudf/detail/utilities/vector_factories.hpp +++ b/cpp/include/cudf/detail/utilities/vector_factories.hpp @@ -53,7 +53,7 @@ rmm::device_uvector make_zeroed_device_uvector_async( rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()) { rmm::device_uvector ret(size, stream, mr); - CUDA_TRY(cudaMemsetAsync(ret.data(), 0, size * sizeof(T), stream.value())); + CUDF_CUDA_TRY(cudaMemsetAsync(ret.data(), 0, size * sizeof(T), stream.value())); return ret; } @@ -75,7 +75,7 @@ rmm::device_uvector make_zeroed_device_uvector_sync( rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()) { rmm::device_uvector ret(size, stream, mr); - CUDA_TRY(cudaMemsetAsync(ret.data(), 0, size * sizeof(T), stream.value())); + CUDF_CUDA_TRY(cudaMemsetAsync(ret.data(), 0, size * sizeof(T), stream.value())); stream.synchronize(); return ret; } @@ -99,11 +99,11 @@ rmm::device_uvector make_device_uvector_async( rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()) { rmm::device_uvector ret(source_data.size(), stream, mr); - CUDA_TRY(cudaMemcpyAsync(ret.data(), - source_data.data(), - source_data.size() * sizeof(T), - cudaMemcpyDefault, - stream.value())); + CUDF_CUDA_TRY(cudaMemcpyAsync(ret.data(), + source_data.data(), + source_data.size() * sizeof(T), + cudaMemcpyDefault, + stream.value())); return ret; } @@ -151,11 +151,11 @@ rmm::device_uvector make_device_uvector_async( rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()) { rmm::device_uvector ret(source_data.size(), stream, mr); - CUDA_TRY(cudaMemcpyAsync(ret.data(), - source_data.data(), - source_data.size() * sizeof(T), - cudaMemcpyDefault, - stream.value())); + CUDF_CUDA_TRY(cudaMemcpyAsync(ret.data(), + source_data.data(), + source_data.size() * sizeof(T), + cudaMemcpyDefault, + stream.value())); return ret; } @@ -286,7 +286,7 @@ template OutContainer make_vector_async(device_span v, rmm::cuda_stream_view stream) { OutContainer result(v.size()); - CUDA_TRY(cudaMemcpyAsync( + CUDF_CUDA_TRY(cudaMemcpyAsync( result.data(), v.data(), v.size() * sizeof(T), cudaMemcpyDeviceToHost, stream.value())); return result; } diff --git a/cpp/include/cudf/io/text/data_chunk_source_factories.hpp b/cpp/include/cudf/io/text/data_chunk_source_factories.hpp index ffe159b59dc..56db3fd6216 100644 --- a/cpp/include/cudf/io/text/data_chunk_source_factories.hpp +++ b/cpp/include/cudf/io/text/data_chunk_source_factories.hpp @@ -78,14 +78,14 @@ class istream_data_chunk_reader : public data_chunk_reader { { // create an event to track the completion of the last device-to-host copy. for (std::size_t i = 0; i < _tickets.size(); i++) { - CUDA_TRY(cudaEventCreate(&(_tickets[i].event))); + CUDF_CUDA_TRY(cudaEventCreate(&(_tickets[i].event))); } } ~istream_data_chunk_reader() { for (std::size_t i = 0; i < _tickets.size(); i++) { - CUDA_TRY(cudaEventDestroy(_tickets[i].event)); + CUDF_CUDA_TRY(cudaEventDestroy(_tickets[i].event)); } } @@ -101,7 +101,7 @@ class istream_data_chunk_reader : public data_chunk_reader { _next_ticket_idx = (_next_ticket_idx + 1) % _tickets.size(); // synchronize on the last host-to-device copy, so we don't clobber the host buffer. - CUDA_TRY(cudaEventSynchronize(h_ticket.event)); + CUDF_CUDA_TRY(cudaEventSynchronize(h_ticket.event)); // resize the host buffer as necessary to contain the requested number of bytes if (h_ticket.buffer.size() < read_size) { h_ticket.buffer.resize(read_size); } @@ -116,7 +116,7 @@ class istream_data_chunk_reader : public data_chunk_reader { auto chunk = rmm::device_uvector(read_size, stream); // copy the host-pinned data on to device - CUDA_TRY(cudaMemcpyAsync( // + CUDF_CUDA_TRY(cudaMemcpyAsync( // chunk.data(), h_ticket.buffer.data(), read_size, @@ -124,7 +124,7 @@ class istream_data_chunk_reader : public data_chunk_reader { stream.value())); // record the host-to-device copy. - CUDA_TRY(cudaEventRecord(h_ticket.event, stream.value())); + CUDF_CUDA_TRY(cudaEventRecord(h_ticket.event, stream.value())); // return the view over device memory so it can be processed. return std::make_unique(std::move(chunk)); diff --git a/cpp/include/cudf/strings/detail/utilities.cuh b/cpp/include/cudf/strings/detail/utilities.cuh index 4b036fb7f0e..b9ea2d9ecff 100644 --- a/cpp/include/cudf/strings/detail/utilities.cuh +++ b/cpp/include/cudf/strings/detail/utilities.cuh @@ -67,7 +67,7 @@ std::unique_ptr make_offsets_child_column( // we use inclusive-scan on a shifted output (d_offsets+1) and then set the first // offset values to zero manually. thrust::inclusive_scan(rmm::exec_policy(stream), begin, end, d_offsets + 1); - CUDA_TRY(cudaMemsetAsync(d_offsets, 0, sizeof(int32_t), stream.value())); + CUDF_CUDA_TRY(cudaMemsetAsync(d_offsets, 0, sizeof(int32_t), stream.value())); return offsets_column; } diff --git a/cpp/include/cudf/strings/string_view.cuh b/cpp/include/cudf/strings/string_view.cuh index 27ee5cf95cd..a486a5a765c 100644 --- a/cpp/include/cudf/strings/string_view.cuh +++ b/cpp/include/cudf/strings/string_view.cuh @@ -99,7 +99,8 @@ CUDF_HOST_DEVICE inline string_view string_view::max() #if defined(__CUDA_ARCH__) psentinel = &cudf::strings::detail::max_string_sentinel[0]; #else - CUDA_TRY(cudaGetSymbolAddress((void**)&psentinel, cudf::strings::detail::max_string_sentinel)); + CUDF_CUDA_TRY( + cudaGetSymbolAddress((void**)&psentinel, cudf::strings::detail::max_string_sentinel)); #endif return string_view(psentinel, 4); } diff --git a/cpp/include/cudf/table/table_device_view.cuh b/cpp/include/cudf/table/table_device_view.cuh index 3ed18099463..8d08a3fd0b0 100644 --- a/cpp/include/cudf/table/table_device_view.cuh +++ b/cpp/include/cudf/table/table_device_view.cuh @@ -145,7 +145,7 @@ auto contiguous_copy_column_device_views(HostTableView source_view, rmm::cuda_st auto d_columns = detail::child_columns_to_device_array( source_view.begin(), source_view.end(), h_ptr, d_ptr); - CUDA_TRY(cudaMemcpyAsync(d_ptr, h_ptr, views_size_bytes, cudaMemcpyDefault, stream.value())); + CUDF_CUDA_TRY(cudaMemcpyAsync(d_ptr, h_ptr, views_size_bytes, cudaMemcpyDefault, stream.value())); stream.synchronize(); return std::make_tuple(std::move(descendant_storage), d_columns); } diff --git a/cpp/include/cudf/utilities/error.hpp b/cpp/include/cudf/utilities/error.hpp index 2036723a6ed..8be1a7e3a32 100644 --- a/cpp/include/cudf/utilities/error.hpp +++ b/cpp/include/cudf/utilities/error.hpp @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2019-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. + */ + #pragma once #include @@ -99,7 +115,7 @@ inline void throw_cuda_error(cudaError_t error, const char* file, unsigned int l * cudaSuccess, invokes cudaGetLastError() to clear the error and throws an * exception detailing the CUDA error that occurred */ -#define CUDA_TRY(call) \ +#define CUDF_CUDA_TRY(call) \ do { \ cudaError_t const status = (call); \ if (cudaSuccess != status) { \ @@ -122,12 +138,12 @@ inline void throw_cuda_error(cudaError_t error, const char* file, unsigned int l * asynchronous kernel launch. */ #ifndef NDEBUG -#define CHECK_CUDA(stream) \ - do { \ - CUDA_TRY(cudaStreamSynchronize(stream)); \ - CUDA_TRY(cudaPeekAtLastError()); \ +#define CUDF_CHECK_CUDA(stream) \ + do { \ + CUDF_CUDA_TRY(cudaStreamSynchronize(stream)); \ + CUDF_CUDA_TRY(cudaPeekAtLastError()); \ } while (0); #else -#define CHECK_CUDA(stream) CUDA_TRY(cudaPeekAtLastError()); +#define CUDF_CHECK_CUDA(stream) CUDF_CUDA_TRY(cudaPeekAtLastError()); #endif /** @} */ diff --git a/cpp/include/cudf_test/column_utilities.hpp b/cpp/include/cudf_test/column_utilities.hpp index 4c2d4d429eb..b28ed4f70fa 100644 --- a/cpp/include/cudf_test/column_utilities.hpp +++ b/cpp/include/cudf_test/column_utilities.hpp @@ -183,7 +183,8 @@ template ()>* = nullptr std::pair, std::vector> to_host(column_view c) { thrust::host_vector host_data(c.size()); - CUDA_TRY(cudaMemcpy(host_data.data(), c.data(), c.size() * sizeof(T), cudaMemcpyDeviceToHost)); + CUDF_CUDA_TRY( + cudaMemcpy(host_data.data(), c.data(), c.size() * sizeof(T), cudaMemcpyDeviceToHost)); return {host_data, bitmask_to_host(c)}; } @@ -206,7 +207,7 @@ std::pair, std::vector> to_host(column_view auto host_rep_types = thrust::host_vector(c.size()); - CUDA_TRY(cudaMemcpy( + CUDF_CUDA_TRY(cudaMemcpy( host_rep_types.data(), c.begin(), c.size() * sizeof(Rep), cudaMemcpyDeviceToHost)); auto to_fp = [&](Rep val) { return T{scaled_integer{val, scale_type{c.type().scale()}}}; }; diff --git a/cpp/src/binaryop/compiled/binary_ops.cuh b/cpp/src/binaryop/compiled/binary_ops.cuh index 9b3e33f491e..ec41fbb8883 100644 --- a/cpp/src/binaryop/compiled/binary_ops.cuh +++ b/cpp/src/binaryop/compiled/binary_ops.cuh @@ -265,7 +265,7 @@ void for_each(rmm::cuda_stream_view stream, cudf::size_type size, Functor f) { int block_size; int min_grid_size; - CUDA_TRY( + CUDF_CUDA_TRY( cudaOccupancyMaxPotentialBlockSize(&min_grid_size, &block_size, for_each_kernel)); // 2 elements per thread. const int grid_size = util::div_rounding_up_safe(size, 2 * block_size); diff --git a/cpp/src/bitmask/is_element_valid.cpp b/cpp/src/bitmask/is_element_valid.cpp index 47870e01567..4a94ec9759c 100644 --- a/cpp/src/bitmask/is_element_valid.cpp +++ b/cpp/src/bitmask/is_element_valid.cpp @@ -1,6 +1,6 @@ /* - * 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. @@ -34,11 +34,11 @@ bool is_element_valid_sync(column_view const& col_view, bitmask_type word; // null_mask() returns device ptr to bitmask without offset size_type index = element_index + col_view.offset(); - CUDA_TRY(cudaMemcpyAsync(&word, - col_view.null_mask() + word_index(index), - sizeof(bitmask_type), - cudaMemcpyDeviceToHost, - stream.value())); + CUDF_CUDA_TRY(cudaMemcpyAsync(&word, + col_view.null_mask() + word_index(index), + sizeof(bitmask_type), + cudaMemcpyDeviceToHost, + stream.value())); stream.synchronize(); return static_cast(word & (bitmask_type{1} << intra_word_index(index))); } diff --git a/cpp/src/bitmask/null_mask.cu b/cpp/src/bitmask/null_mask.cu index d1107ad3cfd..756cf3421c9 100644 --- a/cpp/src/bitmask/null_mask.cu +++ b/cpp/src/bitmask/null_mask.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -90,7 +90,7 @@ rmm::device_buffer create_null_mask(size_type size, if (state != mask_state::UNINITIALIZED) { uint8_t fill_value = (state == mask_state::ALL_VALID) ? 0xff : 0x00; - CUDA_TRY(cudaMemsetAsync( + CUDF_CUDA_TRY(cudaMemsetAsync( static_cast(mask.data()), fill_value, mask_size, stream.value())); } @@ -146,7 +146,7 @@ void set_null_mask(bitmask_type* bitmask, cudf::detail::grid_1d config(number_of_mask_words, 256); set_null_mask_kernel<<>>( static_cast(bitmask), begin_bit, end_bit, valid, number_of_mask_words); - CHECK_CUDA(stream.value()); + CUDF_CHECK_CUDA(stream.value()); } } @@ -220,7 +220,7 @@ rmm::device_buffer copy_bitmask(bitmask_type const* mask, cudf::detail::grid_1d config(number_of_mask_words, 256); copy_offset_bitmask<<>>( static_cast(dest_mask.data()), mask, begin_bit, end_bit, number_of_mask_words); - CHECK_CUDA(stream.value()); + CUDF_CHECK_CUDA(stream.value()); } return dest_mask; } diff --git a/cpp/src/column/column_device_view.cu b/cpp/src/column/column_device_view.cu index dd1803f4b90..fc244521617 100644 --- a/cpp/src/column/column_device_view.cu +++ b/cpp/src/column/column_device_view.cu @@ -77,11 +77,11 @@ create_device_view_from_view(ColumnView const& source, rmm::cuda_stream_view str new ColumnDeviceView(source, staging_buffer.data(), descendant_storage->data()), deleter}; // copy the CPU memory with all the children into device memory - CUDA_TRY(cudaMemcpyAsync(descendant_storage->data(), - staging_buffer.data(), - descendant_storage->size(), - cudaMemcpyDefault, - stream.value())); + CUDF_CUDA_TRY(cudaMemcpyAsync(descendant_storage->data(), + staging_buffer.data(), + descendant_storage->size(), + cudaMemcpyDefault, + stream.value())); stream.synchronize(); diff --git a/cpp/src/copying/contiguous_split.cu b/cpp/src/copying/contiguous_split.cu index 46470e69611..514374d450d 100644 --- a/cpp/src/copying/contiguous_split.cu +++ b/cpp/src/copying/contiguous_split.cu @@ -1046,11 +1046,11 @@ std::vector contiguous_split(cudf::table_view const& input, setup_source_buf_info(input.begin(), input.end(), h_src_buf_info, h_src_buf_info); // HtoD indices and source buf info to device - CUDA_TRY(cudaMemcpyAsync(d_indices, - h_indices, - indices_size + src_buf_info_size, - cudaMemcpyHostToDevice, - stream.value())); + CUDF_CUDA_TRY(cudaMemcpyAsync(d_indices, + h_indices, + indices_size + src_buf_info_size, + cudaMemcpyHostToDevice, + stream.value())); // packed block of memory 2. partition buffer sizes and dst_buf_info structs std::size_t const buf_sizes_size = @@ -1180,11 +1180,11 @@ std::vector contiguous_split(cudf::table_view const& input, } // DtoH buf sizes and col info back to the host - CUDA_TRY(cudaMemcpyAsync(h_buf_sizes, - d_buf_sizes, - buf_sizes_size + dst_buf_info_size, - cudaMemcpyDeviceToHost, - stream.value())); + CUDF_CUDA_TRY(cudaMemcpyAsync(h_buf_sizes, + d_buf_sizes, + buf_sizes_size + dst_buf_info_size, + cudaMemcpyDeviceToHost, + stream.value())); stream.synchronize(); // allocate output partition buffers @@ -1224,14 +1224,14 @@ std::vector contiguous_split(cudf::table_view const& input, }); // HtoD src and dest buffers - CUDA_TRY(cudaMemcpyAsync( + CUDF_CUDA_TRY(cudaMemcpyAsync( d_src_bufs, h_src_bufs, src_bufs_size + dst_bufs_size, cudaMemcpyHostToDevice, stream.value())); // perform the copy. copy_data(num_bufs, num_src_bufs, d_src_bufs, d_dst_bufs, d_dst_buf_info, stream); // DtoH dst info (to retrieve null counts) - CUDA_TRY(cudaMemcpyAsync( + CUDF_CUDA_TRY(cudaMemcpyAsync( h_dst_buf_info, d_dst_buf_info, dst_buf_info_size, cudaMemcpyDeviceToHost, stream.value())); stream.synchronize(); diff --git a/cpp/src/hash/concurrent_unordered_map.cuh b/cpp/src/hash/concurrent_unordered_map.cuh index 0ae0baa9908..76f3fba4689 100644 --- a/cpp/src/hash/concurrent_unordered_map.cuh +++ b/cpp/src/hash/concurrent_unordered_map.cuh @@ -432,11 +432,11 @@ class concurrent_unordered_map { m_hashtbl_values = m_allocator.allocate(m_capacity, stream); } - CUDA_TRY(cudaMemcpyAsync(m_hashtbl_values, - other.m_hashtbl_values, - m_capacity * sizeof(value_type), - cudaMemcpyDefault, - stream.value())); + CUDF_CUDA_TRY(cudaMemcpyAsync(m_hashtbl_values, + other.m_hashtbl_values, + m_capacity * sizeof(value_type), + cudaMemcpyDefault, + stream.value())); } void clear_async(rmm::cuda_stream_view stream = rmm::cuda_stream_default) @@ -460,10 +460,10 @@ class concurrent_unordered_map { cudaError_t status = cudaPointerGetAttributes(&hashtbl_values_ptr_attributes, m_hashtbl_values); if (cudaSuccess == status && isPtrManaged(hashtbl_values_ptr_attributes)) { - CUDA_TRY(cudaMemPrefetchAsync( + CUDF_CUDA_TRY(cudaMemPrefetchAsync( m_hashtbl_values, m_capacity * sizeof(value_type), dev_id, stream.value())); } - CUDA_TRY(cudaMemPrefetchAsync(this, sizeof(*this), dev_id, stream.value())); + CUDF_CUDA_TRY(cudaMemPrefetchAsync(this, sizeof(*this), dev_id, stream.value())); } /** @@ -532,8 +532,8 @@ class concurrent_unordered_map { if (cudaSuccess == status && isPtrManaged(hashtbl_values_ptr_attributes)) { int dev_id = 0; - CUDA_TRY(cudaGetDevice(&dev_id)); - CUDA_TRY(cudaMemPrefetchAsync( + CUDF_CUDA_TRY(cudaGetDevice(&dev_id)); + CUDF_CUDA_TRY(cudaMemPrefetchAsync( m_hashtbl_values, m_capacity * sizeof(value_type), dev_id, stream.value())); } } @@ -543,6 +543,6 @@ class concurrent_unordered_map { m_hashtbl_values, m_capacity, m_unused_key, m_unused_element); } - CUDA_TRY(cudaGetLastError()); + CUDF_CHECK_CUDA(stream.value()); } }; diff --git a/cpp/src/hash/concurrent_unordered_multimap.cuh b/cpp/src/hash/concurrent_unordered_multimap.cuh index cdf5b6a8649..aa5b8db393f 100644 --- a/cpp/src/hash/concurrent_unordered_multimap.cuh +++ b/cpp/src/hash/concurrent_unordered_multimap.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2020, NVIDIA CORPORATION. + * Copyright (c) 2017-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. @@ -488,11 +488,11 @@ class concurrent_unordered_multimap { m_hashtbl_values = m_allocator.allocate(m_hashtbl_capacity, stream); } - CUDA_TRY(cudaMemcpyAsync(m_hashtbl_values, - other.m_hashtbl_values, - m_hashtbl_size * sizeof(value_type), - cudaMemcpyDefault, - stream.value())); + CUDF_CUDA_TRY(cudaMemcpyAsync(m_hashtbl_values, + other.m_hashtbl_values, + m_hashtbl_size * sizeof(value_type), + cudaMemcpyDefault, + stream.value())); } void clear_async(rmm::cuda_stream_view stream = rmm::cuda_stream_default) @@ -519,7 +519,7 @@ class concurrent_unordered_multimap { cudaError_t status = cudaPointerGetAttributes(&hashtbl_values_ptr_attributes, m_hashtbl_values); if (cudaSuccess == status && isPtrManaged(hashtbl_values_ptr_attributes)) { - CUDA_TRY(cudaMemPrefetchAsync( + CUDF_CUDA_TRY(cudaMemPrefetchAsync( m_hashtbl_values, m_hashtbl_size * sizeof(value_type), dev_id, stream.value())); } } @@ -575,8 +575,8 @@ class concurrent_unordered_multimap { if (cudaSuccess == status && isPtrManaged(hashtbl_values_ptr_attributes)) { int dev_id = 0; - CUDA_TRY(cudaGetDevice(&dev_id)); - CUDA_TRY(cudaMemPrefetchAsync( + CUDF_CUDA_TRY(cudaGetDevice(&dev_id)); + CUDF_CUDA_TRY(cudaMemPrefetchAsync( m_hashtbl_values, m_hashtbl_size * sizeof(value_type), dev_id, stream.value())); } } @@ -584,7 +584,7 @@ class concurrent_unordered_multimap { if (init) { init_hashtbl<<<((m_hashtbl_size - 1) / block_size) + 1, block_size, 0, stream.value()>>>( m_hashtbl_values, m_hashtbl_size, unused_key, unused_element); - CUDA_TRY(cudaGetLastError()); + CUDF_CHECK_CUDA(stream.value()); } } }; diff --git a/cpp/src/interop/dlpack.cpp b/cpp/src/interop/dlpack.cpp index 01ca32e6a2f..e5da4794ca3 100644 --- a/cpp/src/interop/dlpack.cpp +++ b/cpp/src/interop/dlpack.cpp @@ -144,7 +144,7 @@ std::unique_ptr
from_dlpack(DLManagedTensor const* managed_tensor, // Make sure the current device ID matches the Tensor's device ID if (tensor.device.device_type != kDLCPU) { int device_id = 0; - CUDA_TRY(cudaGetDevice(&device_id)); + CUDF_CUDA_TRY(cudaGetDevice(&device_id)); CUDF_EXPECTS(tensor.device.device_id == device_id, "DLTensor device ID must be current device"); } @@ -184,11 +184,11 @@ std::unique_ptr
from_dlpack(DLManagedTensor const* managed_tensor, for (auto& col : columns) { col = make_numeric_column(dtype, num_rows, mask_state::UNALLOCATED, stream, mr); - CUDA_TRY(cudaMemcpyAsync(col->mutable_view().head(), - reinterpret_cast(tensor_data), - bytes, - cudaMemcpyDefault, - stream.value())); + CUDF_CUDA_TRY(cudaMemcpyAsync(col->mutable_view().head(), + reinterpret_cast(tensor_data), + bytes, + cudaMemcpyDefault, + stream.value())); tensor_data += col_stride; } @@ -234,7 +234,7 @@ DLManagedTensor* to_dlpack(table_view const& input, tensor.strides[1] = num_rows; } - CUDA_TRY(cudaGetDevice(&tensor.device.device_id)); + CUDF_CUDA_TRY(cudaGetDevice(&tensor.device.device_id)); tensor.device.device_type = kDLCUDA; // If there is only one column, then a 1D tensor can just copy the pointer @@ -254,11 +254,11 @@ DLManagedTensor* to_dlpack(table_view const& input, auto tensor_data = reinterpret_cast(tensor.data); for (auto const& col : input) { - CUDA_TRY(cudaMemcpyAsync(reinterpret_cast(tensor_data), - get_column_data(col), - stride_bytes, - cudaMemcpyDefault, - stream.value())); + CUDF_CUDA_TRY(cudaMemcpyAsync(reinterpret_cast(tensor_data), + get_column_data(col), + stride_bytes, + cudaMemcpyDefault, + stream.value())); tensor_data += stride_bytes; } diff --git a/cpp/src/interop/from_arrow.cu b/cpp/src/interop/from_arrow.cu index 99b657fb9d5..6c5cd56d2a7 100644 --- a/cpp/src/interop/from_arrow.cu +++ b/cpp/src/interop/from_arrow.cu @@ -108,11 +108,11 @@ struct dispatch_to_cudf_column { stream, mr); auto mask_buffer = array.null_bitmap(); - CUDA_TRY(cudaMemcpyAsync(mask->data(), - reinterpret_cast(mask_buffer->address()), - array.null_bitmap()->size(), - cudaMemcpyDefault, - stream.value())); + CUDF_CUDA_TRY(cudaMemcpyAsync(mask->data(), + reinterpret_cast(mask_buffer->address()), + array.null_bitmap()->size(), + cudaMemcpyDefault, + stream.value())); return mask; } @@ -135,7 +135,7 @@ struct dispatch_to_cudf_column { auto const has_nulls = skip_mask ? false : array.null_bitmap_data() != nullptr; auto col = make_fixed_width_column(type, num_rows, mask_state::UNALLOCATED, stream, mr); auto mutable_column_view = col->mutable_view(); - CUDA_TRY(cudaMemcpyAsync( + CUDF_CUDA_TRY(cudaMemcpyAsync( mutable_column_view.data(), reinterpret_cast(data_buffer->address()) + array.offset() * sizeof(T), sizeof(T) * num_rows, @@ -191,7 +191,7 @@ std::unique_ptr dispatch_to_cudf_column::operator() auto col = make_fixed_width_column(type, num_rows, mask_state::UNALLOCATED, stream, mr); auto mutable_column_view = col->mutable_view(); - CUDA_TRY(cudaMemcpyAsync( + CUDF_CUDA_TRY(cudaMemcpyAsync( mutable_column_view.data(), reinterpret_cast(data_buffer->address()) + array.offset() * sizeof(DeviceType), sizeof(DeviceType) * num_rows, @@ -227,11 +227,11 @@ std::unique_ptr dispatch_to_cudf_column::operator()( { auto data_buffer = array.data()->buffers[1]; auto data = rmm::device_buffer(data_buffer->size(), stream, mr); - CUDA_TRY(cudaMemcpyAsync(data.data(), - reinterpret_cast(data_buffer->address()), - data_buffer->size(), - cudaMemcpyDefault, - stream.value())); + CUDF_CUDA_TRY(cudaMemcpyAsync(data.data(), + reinterpret_cast(data_buffer->address()), + data_buffer->size(), + cudaMemcpyDefault, + stream.value())); auto out_col = mask_to_bools(static_cast(data.data()), array.offset(), array.offset() + array.length(), diff --git a/cpp/src/interop/to_arrow.cu b/cpp/src/interop/to_arrow.cu index c7409978bb2..517a83c716e 100644 --- a/cpp/src/interop/to_arrow.cu +++ b/cpp/src/interop/to_arrow.cu @@ -53,11 +53,11 @@ std::shared_ptr fetch_data_buffer(column_view input_view, auto data_buffer = allocate_arrow_buffer(data_size_in_bytes, ar_mr); - CUDA_TRY(cudaMemcpyAsync(data_buffer->mutable_data(), - input_view.data(), - data_size_in_bytes, - cudaMemcpyDeviceToHost, - stream.value())); + CUDF_CUDA_TRY(cudaMemcpyAsync(data_buffer->mutable_data(), + input_view.data(), + data_size_in_bytes, + cudaMemcpyDeviceToHost, + stream.value())); return std::move(data_buffer); } @@ -73,7 +73,7 @@ std::shared_ptr fetch_mask_buffer(column_view input_view, if (input_view.has_nulls()) { auto mask_buffer = allocate_arrow_bitmap(static_cast(input_view.size()), ar_mr); - CUDA_TRY(cudaMemcpyAsync( + CUDF_CUDA_TRY(cudaMemcpyAsync( mask_buffer->mutable_data(), (input_view.offset() > 0) ? cudf::copy_bitmask(input_view).data() : input_view.null_mask(), mask_size_in_bytes, @@ -163,11 +163,11 @@ std::shared_ptr dispatch_to_arrow::operator()( auto const buf_size_in_bytes = buf.size() * sizeof(DeviceType); auto data_buffer = allocate_arrow_buffer(buf_size_in_bytes, ar_mr); - CUDA_TRY(cudaMemcpyAsync(data_buffer->mutable_data(), - buf.data(), - buf_size_in_bytes, - cudaMemcpyDeviceToHost, - stream.value())); + CUDF_CUDA_TRY(cudaMemcpyAsync(data_buffer->mutable_data(), + buf.data(), + buf_size_in_bytes, + cudaMemcpyDeviceToHost, + stream.value())); auto type = arrow::decimal(18, -input.type().scale()); auto mask = fetch_mask_buffer(input, ar_mr, stream); @@ -197,11 +197,11 @@ std::shared_ptr dispatch_to_arrow::operator() auto const buf_size_in_bytes = buf.size() * sizeof(DeviceType); auto data_buffer = allocate_arrow_buffer(buf_size_in_bytes, ar_mr); - CUDA_TRY(cudaMemcpyAsync(data_buffer->mutable_data(), - buf.data(), - buf_size_in_bytes, - cudaMemcpyDeviceToHost, - stream.value())); + CUDF_CUDA_TRY(cudaMemcpyAsync(data_buffer->mutable_data(), + buf.data(), + buf_size_in_bytes, + cudaMemcpyDeviceToHost, + stream.value())); auto type = arrow::decimal(18, -input.type().scale()); auto mask = fetch_mask_buffer(input, ar_mr, stream); @@ -222,11 +222,11 @@ std::shared_ptr dispatch_to_arrow::operator()(column_view in auto data_buffer = allocate_arrow_buffer(static_cast(bitmask.first->size()), ar_mr); - CUDA_TRY(cudaMemcpyAsync(data_buffer->mutable_data(), - bitmask.first->data(), - bitmask.first->size(), - cudaMemcpyDeviceToHost, - stream.value())); + CUDF_CUDA_TRY(cudaMemcpyAsync(data_buffer->mutable_data(), + bitmask.first->data(), + bitmask.first->size(), + cudaMemcpyDeviceToHost, + stream.value())); return to_arrow_array(id, static_cast(input.size()), std::move(data_buffer), diff --git a/cpp/src/io/avro/reader_impl.cu b/cpp/src/io/avro/reader_impl.cu index b5b76c2def8..5885b61b35b 100644 --- a/cpp/src/io/avro/reader_impl.cu +++ b/cpp/src/io/avro/reader_impl.cu @@ -192,9 +192,9 @@ rmm::device_buffer decompress_data(datasource& source, for (int loop_cnt = 0; loop_cnt < 2; loop_cnt++) { inflate_in.host_to_device(stream); - CUDA_TRY( + CUDF_CUDA_TRY( cudaMemsetAsync(inflate_out.device_ptr(), 0, inflate_out.memory_size(), stream.value())); - CUDA_TRY(gpuinflate( + CUDF_CUDA_TRY(gpuinflate( inflate_in.device_ptr(), inflate_out.device_ptr(), inflate_in.size(), 0, stream)); inflate_out.device_to_host(stream, true); @@ -424,11 +424,11 @@ std::vector decode_data(metadata& meta, // Copy valid bits that are shared between columns for (size_t i = 0; i < out_buffers.size(); i++) { if (valid_alias[i] != nullptr) { - CUDA_TRY(cudaMemcpyAsync(out_buffers[i].null_mask(), - valid_alias[i], - out_buffers[i].null_mask_size(), - cudaMemcpyHostToDevice, - stream.value())); + CUDF_CUDA_TRY(cudaMemcpyAsync(out_buffers[i].null_mask(), + valid_alias[i], + out_buffers[i].null_mask_size(), + cudaMemcpyHostToDevice, + stream.value())); } } schema_desc.device_to_host(stream, true); diff --git a/cpp/src/io/comp/debrotli.cu b/cpp/src/io/comp/debrotli.cu index b4a42a66133..631cf19b2aa 100644 --- a/cpp/src/io/comp/debrotli.cu +++ b/cpp/src/io/comp/debrotli.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020, 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. @@ -2048,7 +2048,7 @@ size_t __host__ get_gpu_debrotli_scratch_size(int max_num_inputs) int sm_count = 0; int dev = 0; uint32_t max_fb_size, min_fb_size, fb_size; - CUDA_TRY(cudaGetDevice(&dev)); + CUDF_CUDA_TRY(cudaGetDevice(&dev)); if (cudaSuccess == cudaDeviceGetAttribute(&sm_count, cudaDevAttrMultiProcessorCount, dev)) { // printf("%d SMs on device %d\n", sm_count, dev); max_num_inputs = @@ -2092,14 +2092,14 @@ cudaError_t __host__ gpu_debrotli(gpu_inflate_input_s* inputs, scratch_size = min(scratch_size, (size_t)0xffffffffu); fb_heap_size = (uint32_t)((scratch_size - sizeof(brotli_dictionary_s)) & ~0xf); - CUDA_TRY(cudaMemsetAsync(scratch_u8, 0, 2 * sizeof(uint32_t), stream.value())); + CUDF_CUDA_TRY(cudaMemsetAsync(scratch_u8, 0, 2 * sizeof(uint32_t), stream.value())); // NOTE: The 128KB dictionary copy can have a relatively large overhead since source isn't // page-locked - CUDA_TRY(cudaMemcpyAsync(scratch_u8 + fb_heap_size, - get_brotli_dictionary(), - sizeof(brotli_dictionary_s), - cudaMemcpyHostToDevice, - stream.value())); + CUDF_CUDA_TRY(cudaMemcpyAsync(scratch_u8 + fb_heap_size, + get_brotli_dictionary(), + sizeof(brotli_dictionary_s), + cudaMemcpyHostToDevice, + stream.value())); gpu_debrotli_kernel<<>>( inputs, outputs, scratch_u8, fb_heap_size, count32); #if DUMP_FB_HEAP @@ -2107,7 +2107,7 @@ cudaError_t __host__ gpu_debrotli(gpu_inflate_input_s* inputs, uint32_t cur = 0; printf("heap dump (%d bytes)\n", fb_heap_size); while (cur < fb_heap_size && !(cur & 3)) { - CUDA_TRY(cudaMemcpyAsync( + CUDF_CUDA_TRY(cudaMemcpyAsync( &dump[0], scratch_u8 + cur, 2 * sizeof(uint32_t), cudaMemcpyDeviceToHost, stream.value())); stream.synchronize(); printf("@%d: next = %d, size = %d\n", cur, dump[0], dump[1]); diff --git a/cpp/src/io/csv/reader_impl.cu b/cpp/src/io/csv/reader_impl.cu index ae9738164f3..cd070d28f38 100644 --- a/cpp/src/io/csv/reader_impl.cu +++ b/cpp/src/io/csv/reader_impl.cu @@ -260,11 +260,11 @@ std::pair, selected_rows_offsets> load_data_and_gather auto const previous_data_size = d_data.size(); d_data.resize(target_pos - buffer_pos, stream); - CUDA_TRY(cudaMemcpyAsync(d_data.begin() + previous_data_size, - data.begin() + buffer_pos + previous_data_size, - target_pos - buffer_pos - previous_data_size, - cudaMemcpyDefault, - stream.value())); + CUDF_CUDA_TRY(cudaMemcpyAsync(d_data.begin() + previous_data_size, + data.begin() + buffer_pos + previous_data_size, + target_pos - buffer_pos - previous_data_size, + cudaMemcpyDefault, + stream.value())); // Pass 1: Count the potential number of rows in each character block for each // possible parser state at the beginning of the block. @@ -280,11 +280,11 @@ std::pair, selected_rows_offsets> load_data_and_gather range_end, skip_rows, stream); - CUDA_TRY(cudaMemcpyAsync(row_ctx.host_ptr(), - row_ctx.device_ptr(), - num_blocks * sizeof(uint64_t), - cudaMemcpyDeviceToHost, - stream.value())); + CUDF_CUDA_TRY(cudaMemcpyAsync(row_ctx.host_ptr(), + row_ctx.device_ptr(), + num_blocks * sizeof(uint64_t), + cudaMemcpyDeviceToHost, + stream.value())); stream.synchronize(); // Sum up the rows in each character block, selecting the row count that @@ -300,11 +300,11 @@ std::pair, selected_rows_offsets> load_data_and_gather // At least one row in range in this batch all_row_offsets.resize(total_rows - skip_rows, stream); - CUDA_TRY(cudaMemcpyAsync(row_ctx.device_ptr(), - row_ctx.host_ptr(), - num_blocks * sizeof(uint64_t), - cudaMemcpyHostToDevice, - stream.value())); + CUDF_CUDA_TRY(cudaMemcpyAsync(row_ctx.device_ptr(), + row_ctx.host_ptr(), + num_blocks * sizeof(uint64_t), + cudaMemcpyHostToDevice, + stream.value())); // Pass 2: Output row offsets cudf::io::csv::gpu::gather_row_offsets(parse_opts.view(), @@ -321,11 +321,11 @@ std::pair, selected_rows_offsets> load_data_and_gather stream); // With byte range, we want to keep only one row out of the specified range if (range_end < data.size()) { - CUDA_TRY(cudaMemcpyAsync(row_ctx.host_ptr(), - row_ctx.device_ptr(), - num_blocks * sizeof(uint64_t), - cudaMemcpyDeviceToHost, - stream.value())); + CUDF_CUDA_TRY(cudaMemcpyAsync(row_ctx.host_ptr(), + row_ctx.device_ptr(), + num_blocks * sizeof(uint64_t), + cudaMemcpyDeviceToHost, + stream.value())); stream.synchronize(); size_t rows_out_of_range = 0; @@ -370,11 +370,11 @@ std::pair, selected_rows_offsets> load_data_and_gather // Remove header rows and extract header const size_t header_row_index = std::max(header_rows, 1) - 1; if (header_row_index + 1 < row_offsets.size()) { - CUDA_TRY(cudaMemcpyAsync(row_ctx.host_ptr(), - row_offsets.data() + header_row_index, - 2 * sizeof(uint64_t), - cudaMemcpyDeviceToHost, - stream.value())); + CUDF_CUDA_TRY(cudaMemcpyAsync(row_ctx.host_ptr(), + row_offsets.data() + header_row_index, + 2 * sizeof(uint64_t), + cudaMemcpyDeviceToHost, + stream.value())); stream.synchronize(); const auto header_start = buffer_pos + row_ctx[0]; diff --git a/cpp/src/io/csv/writer_impl.cu b/cpp/src/io/csv/writer_impl.cu index cb2197cf755..2aa93ae4d0f 100644 --- a/cpp/src/io/csv/writer_impl.cu +++ b/cpp/src/io/csv/writer_impl.cu @@ -378,11 +378,11 @@ void write_chunked(data_sink* out_sink, } else { // copy the bytes to host to write them out thrust::host_vector h_bytes(total_num_bytes); - CUDA_TRY(cudaMemcpyAsync(h_bytes.data(), - ptr_all_bytes, - total_num_bytes * sizeof(char), - cudaMemcpyDeviceToHost, - stream.value())); + CUDF_CUDA_TRY(cudaMemcpyAsync(h_bytes.data(), + ptr_all_bytes, + total_num_bytes * sizeof(char), + cudaMemcpyDeviceToHost, + stream.value())); stream.synchronize(); out_sink->host_write(h_bytes.data(), total_num_bytes); diff --git a/cpp/src/io/json/json_gpu.cu b/cpp/src/io/json/json_gpu.cu index d26831b9112..56a00191ae4 100644 --- a/cpp/src/io/json/json_gpu.cu +++ b/cpp/src/io/json/json_gpu.cu @@ -689,7 +689,7 @@ void convert_json_to_columns(parse_options_view const& opts, { int block_size; int min_grid_size; - CUDA_TRY(cudaOccupancyMaxPotentialBlockSize( + CUDF_CUDA_TRY(cudaOccupancyMaxPotentialBlockSize( &min_grid_size, &block_size, convert_data_to_columns_kernel)); const int grid_size = (row_offsets.size() + block_size - 1) / block_size; @@ -703,7 +703,7 @@ void convert_json_to_columns(parse_options_view const& opts, valid_fields, num_valid_fields); - CUDA_TRY(cudaGetLastError()); + CUDF_CHECK_CUDA(stream.value()); } /** @@ -721,7 +721,7 @@ std::vector detect_data_types( { int block_size; int min_grid_size; - CUDA_TRY( + CUDF_CUDA_TRY( cudaOccupancyMaxPotentialBlockSize(&min_grid_size, &block_size, detect_data_types_kernel)); auto d_column_infos = [&]() { @@ -763,7 +763,7 @@ void collect_keys_info(parse_options_view const& options, { int block_size; int min_grid_size; - CUDA_TRY( + CUDF_CUDA_TRY( cudaOccupancyMaxPotentialBlockSize(&min_grid_size, &block_size, collect_keys_info_kernel)); // Calculate actual block count to use based on records count @@ -772,7 +772,7 @@ void collect_keys_info(parse_options_view const& options, collect_keys_info_kernel<<>>( options, data, row_offsets, keys_cnt, keys_info); - CUDA_TRY(cudaGetLastError()); + CUDF_CHECK_CUDA(stream.value()); } } // namespace gpu diff --git a/cpp/src/io/json/reader_impl.cu b/cpp/src/io/json/reader_impl.cu index 5ca947f3ee5..20eeec267b1 100644 --- a/cpp/src/io/json/reader_impl.cu +++ b/cpp/src/io/json/reader_impl.cu @@ -274,7 +274,7 @@ rmm::device_uvector find_record_starts(json_reader_options const& read // Manually adding an extra row to account for the first row in the file if (reader_opts.get_byte_range_offset() == 0) { find_result_ptr++; - CUDA_TRY(cudaMemsetAsync(rec_starts.data(), 0ull, sizeof(uint64_t), stream.value())); + CUDF_CUDA_TRY(cudaMemsetAsync(rec_starts.data(), 0ull, sizeof(uint64_t), stream.value())); } std::vector chars_to_find{'\n'}; @@ -356,18 +356,18 @@ std::pair, col_map_ptr_type> get_column_names_and_map( uint64_t first_row_len = d_data.size(); if (rec_starts.size() > 1) { // Set first_row_len to the offset of the second row, if it exists - CUDA_TRY(cudaMemcpyAsync(&first_row_len, - rec_starts.data() + 1, - sizeof(uint64_t), - cudaMemcpyDeviceToHost, - stream.value())); + CUDF_CUDA_TRY(cudaMemcpyAsync(&first_row_len, + rec_starts.data() + 1, + sizeof(uint64_t), + cudaMemcpyDeviceToHost, + stream.value())); } std::vector first_row(first_row_len); - CUDA_TRY(cudaMemcpyAsync(first_row.data(), - d_data.data(), - first_row_len * sizeof(char), - cudaMemcpyDeviceToHost, - stream.value())); + CUDF_CUDA_TRY(cudaMemcpyAsync(first_row.data(), + d_data.data(), + first_row_len * sizeof(char), + cudaMemcpyDeviceToHost, + stream.value())); stream.synchronize(); // Determine the row format between: diff --git a/cpp/src/io/orc/reader_impl.cu b/cpp/src/io/orc/reader_impl.cu index 059df283c94..83c23774362 100644 --- a/cpp/src/io/orc/reader_impl.cu +++ b/cpp/src/io/orc/reader_impl.cu @@ -431,7 +431,7 @@ rmm::device_buffer reader::impl::decompress_stripe_data( device_span inflate_out_view(inflate_out.data(), num_compressed_blocks); switch (decompressor->GetKind()) { case orc::ZLIB: - CUDA_TRY( + CUDF_CUDA_TRY( gpuinflate(inflate_in.data(), inflate_out.data(), num_compressed_blocks, 0, stream)); break; case orc::SNAPPY: @@ -440,7 +440,7 @@ rmm::device_buffer reader::impl::decompress_stripe_data( num_compressed_blocks}; snappy_decompress(inflate_in_view, inflate_out_view, max_uncomp_block_size, stream); } else { - CUDA_TRY( + CUDF_CUDA_TRY( gpu_unsnap(inflate_in.data(), inflate_out.data(), num_compressed_blocks, stream)); } break; @@ -449,7 +449,7 @@ rmm::device_buffer reader::impl::decompress_stripe_data( decompress_check(inflate_out_view, any_block_failure.device_ptr(), stream); } if (num_uncompressed_blocks > 0) { - CUDA_TRY(gpu_copy_uncompressed_blocks( + CUDF_CUDA_TRY(gpu_copy_uncompressed_blocks( inflate_in.data() + num_compressed_blocks, num_uncompressed_blocks, stream)); } gpu::PostDecompressionReassemble(compinfo.device_ptr(), compinfo.size(), stream); @@ -1129,7 +1129,7 @@ table_with_metadata reader::impl::read(size_type skip_rows, _metadata.per_file_metadata[stripe_source_mapping.source_idx].source->host_read( offset, len); CUDF_EXPECTS(buffer->size() == len, "Unexpected discrepancy in bytes read."); - CUDA_TRY(cudaMemcpyAsync( + CUDF_CUDA_TRY(cudaMemcpyAsync( d_dst, buffer->data(), len, cudaMemcpyHostToDevice, stream.value())); stream.synchronize(); } diff --git a/cpp/src/io/orc/writer_impl.cu b/cpp/src/io/orc/writer_impl.cu index 30385d395f1..d0c1cea97a8 100644 --- a/cpp/src/io/orc/writer_impl.cu +++ b/cpp/src/io/orc/writer_impl.cu @@ -706,11 +706,11 @@ std::vector> calculate_aligned_rowgroup_bounds( auto aligned_rgs = hostdevice_2dvector( segmentation.num_rowgroups(), orc_table.num_columns(), stream); - CUDA_TRY(cudaMemcpyAsync(aligned_rgs.base_device_ptr(), - segmentation.rowgroups.base_device_ptr(), - aligned_rgs.count() * sizeof(rowgroup_rows), - cudaMemcpyDefault, - stream.value())); + CUDF_CUDA_TRY(cudaMemcpyAsync(aligned_rgs.base_device_ptr(), + segmentation.rowgroups.base_device_ptr(), + aligned_rgs.count() * sizeof(rowgroup_rows), + cudaMemcpyDefault, + stream.value())); auto const d_stripes = cudf::detail::make_device_uvector_async(segmentation.stripes, stream); // One thread per column, per stripe @@ -1330,7 +1330,7 @@ std::future writer::impl::write_data_stream(gpu::StripeStream const& strm_ if (out_sink_->is_device_write_preferred(length)) { return out_sink_->device_write_async(stream_in, length, stream); } else { - CUDA_TRY( + CUDF_CUDA_TRY( cudaMemcpyAsync(stream_out, stream_in, length, cudaMemcpyDeviceToHost, stream.value())); stream.synchronize(); @@ -1419,10 +1419,10 @@ void pushdown_lists_null_mask(orc_column_view const& col, rmm::cuda_stream_view stream) { // Set all bits - correct unless there's a mismatch between offsets and null mask - CUDA_TRY(cudaMemsetAsync(static_cast(out_mask.data()), - 255, - out_mask.size() * sizeof(bitmask_type), - stream.value())); + CUDF_CUDA_TRY(cudaMemsetAsync(static_cast(out_mask.data()), + 255, + out_mask.size() * sizeof(bitmask_type), + stream.value())); // Reset bits where a null list element has rows in the child column thrust::for_each_n( @@ -1946,7 +1946,7 @@ void writer::impl::write(table_view const& table) } else { return pinned_buffer{[](size_t size) { uint8_t* ptr = nullptr; - CUDA_TRY(cudaMallocHost(&ptr, size)); + CUDF_CUDA_TRY(cudaMallocHost(&ptr, size)); return ptr; }(max_stream_size), cudaFreeHost}; diff --git a/cpp/src/io/parquet/reader_impl.cu b/cpp/src/io/parquet/reader_impl.cu index 33151102aec..56eb34bbe2f 100644 --- a/cpp/src/io/parquet/reader_impl.cu +++ b/cpp/src/io/parquet/reader_impl.cu @@ -1226,24 +1226,24 @@ rmm::device_buffer reader::impl::decompress_page_data( argc++; }); - CUDA_TRY(cudaMemcpyAsync(inflate_in.device_ptr(start_pos), - inflate_in.host_ptr(start_pos), - sizeof(decltype(inflate_in)::value_type) * (argc - start_pos), - cudaMemcpyHostToDevice, - stream.value())); - CUDA_TRY(cudaMemcpyAsync(inflate_out.device_ptr(start_pos), - inflate_out.host_ptr(start_pos), - sizeof(decltype(inflate_out)::value_type) * (argc - start_pos), - cudaMemcpyHostToDevice, - stream.value())); + CUDF_CUDA_TRY(cudaMemcpyAsync(inflate_in.device_ptr(start_pos), + inflate_in.host_ptr(start_pos), + sizeof(decltype(inflate_in)::value_type) * (argc - start_pos), + cudaMemcpyHostToDevice, + stream.value())); + CUDF_CUDA_TRY(cudaMemcpyAsync(inflate_out.device_ptr(start_pos), + inflate_out.host_ptr(start_pos), + sizeof(decltype(inflate_out)::value_type) * (argc - start_pos), + cudaMemcpyHostToDevice, + stream.value())); switch (codec.compression_type) { case parquet::GZIP: - CUDA_TRY(gpuinflate(inflate_in.device_ptr(start_pos), - inflate_out.device_ptr(start_pos), - argc - start_pos, - 1, - stream)) + CUDF_CUDA_TRY(gpuinflate(inflate_in.device_ptr(start_pos), + inflate_out.device_ptr(start_pos), + argc - start_pos, + 1, + stream)) break; case parquet::SNAPPY: if (nvcomp_integration::is_stable_enabled()) { @@ -1252,27 +1252,27 @@ rmm::device_buffer reader::impl::decompress_page_data( codec.max_decompressed_size, stream); } else { - CUDA_TRY(gpu_unsnap(inflate_in.device_ptr(start_pos), - inflate_out.device_ptr(start_pos), - argc - start_pos, - stream)); + CUDF_CUDA_TRY(gpu_unsnap(inflate_in.device_ptr(start_pos), + inflate_out.device_ptr(start_pos), + argc - start_pos, + stream)); } break; case parquet::BROTLI: - CUDA_TRY(gpu_debrotli(inflate_in.device_ptr(start_pos), - inflate_out.device_ptr(start_pos), - debrotli_scratch.data(), - debrotli_scratch.size(), - argc - start_pos, - stream)); + CUDF_CUDA_TRY(gpu_debrotli(inflate_in.device_ptr(start_pos), + inflate_out.device_ptr(start_pos), + debrotli_scratch.data(), + debrotli_scratch.size(), + argc - start_pos, + stream)); break; default: CUDF_FAIL("Unexpected decompression dispatch"); break; } - CUDA_TRY(cudaMemcpyAsync(inflate_out.host_ptr(start_pos), - inflate_out.device_ptr(start_pos), - sizeof(decltype(inflate_out)::value_type) * (argc - start_pos), - cudaMemcpyDeviceToHost, - stream.value())); + CUDF_CUDA_TRY(cudaMemcpyAsync(inflate_out.host_ptr(start_pos), + inflate_out.device_ptr(start_pos), + sizeof(decltype(inflate_out)::value_type) * (argc - start_pos), + cudaMemcpyDeviceToHost, + stream.value())); } } diff --git a/cpp/src/io/parquet/writer_impl.cu b/cpp/src/io/parquet/writer_impl.cu index 872ca6f6656..70a594423c9 100644 --- a/cpp/src/io/parquet/writer_impl.cu +++ b/cpp/src/io/parquet/writer_impl.cu @@ -1123,7 +1123,7 @@ void writer::impl::encode_pages(hostdevice_2dvector& chunks if (nvcomp_integration::is_stable_enabled()) { snappy_compress(comp_in, comp_stat, max_page_uncomp_data_size, stream); } else { - CUDA_TRY(gpu_snap(comp_in.data(), comp_stat.data(), pages_in_batch, stream)); + CUDF_CUDA_TRY(gpu_snap(comp_in.data(), comp_stat.data(), pages_in_batch, stream)); } break; default: break; @@ -1136,11 +1136,11 @@ void writer::impl::encode_pages(hostdevice_2dvector& chunks GatherPages(d_chunks_in_batch.flat_view(), pages, stream); auto h_chunks_in_batch = chunks.host_view().subspan(first_rowgroup, rowgroups_in_batch); - CUDA_TRY(cudaMemcpyAsync(h_chunks_in_batch.data(), - d_chunks_in_batch.data(), - d_chunks_in_batch.flat_view().size_bytes(), - cudaMemcpyDeviceToHost, - stream.value())); + CUDF_CUDA_TRY(cudaMemcpyAsync(h_chunks_in_batch.data(), + d_chunks_in_batch.data(), + d_chunks_in_batch.flat_view().size_bytes(), + cudaMemcpyDeviceToHost, + stream.value())); stream.synchronize(); } @@ -1579,28 +1579,28 @@ void writer::impl::write(table_view const& table, std::vector co // we still need to do a (much smaller) memcpy for the statistics. if (ck.ck_stat_size != 0) { column_chunk_meta.statistics_blob.resize(ck.ck_stat_size); - CUDA_TRY(cudaMemcpyAsync(column_chunk_meta.statistics_blob.data(), - dev_bfr, - ck.ck_stat_size, - cudaMemcpyDeviceToHost, - stream.value())); + CUDF_CUDA_TRY(cudaMemcpyAsync(column_chunk_meta.statistics_blob.data(), + dev_bfr, + ck.ck_stat_size, + cudaMemcpyDeviceToHost, + stream.value())); stream.synchronize(); } } else { if (!host_bfr) { host_bfr = pinned_buffer{[](size_t size) { uint8_t* ptr = nullptr; - CUDA_TRY(cudaMallocHost(&ptr, size)); + CUDF_CUDA_TRY(cudaMallocHost(&ptr, size)); return ptr; }(max_chunk_bfr_size), cudaFreeHost}; } // copy the full data - CUDA_TRY(cudaMemcpyAsync(host_bfr.get(), - dev_bfr, - ck.ck_stat_size + ck.compressed_size, - cudaMemcpyDeviceToHost, - stream.value())); + CUDF_CUDA_TRY(cudaMemcpyAsync(host_bfr.get(), + dev_bfr, + ck.ck_stat_size + ck.compressed_size, + cudaMemcpyDeviceToHost, + stream.value())); stream.synchronize(); out_sink_[p]->host_write(host_bfr.get() + ck.ck_stat_size, ck.compressed_size); if (ck.ck_stat_size != 0) { diff --git a/cpp/src/io/utilities/column_buffer.hpp b/cpp/src/io/utilities/column_buffer.hpp index 34d8307b024..fd510466477 100644 --- a/cpp/src/io/utilities/column_buffer.hpp +++ b/cpp/src/io/utilities/column_buffer.hpp @@ -55,7 +55,7 @@ inline rmm::device_buffer create_data(data_type type, std::size_t data_size = size_of(type) * size; rmm::device_buffer data(data_size, stream, mr); - CUDA_TRY(cudaMemsetAsync(data.data(), 0, data_size, stream.value())); + CUDF_CUDA_TRY(cudaMemsetAsync(data.data(), 0, data_size, stream.value())); return data; } diff --git a/cpp/src/io/utilities/hostdevice_vector.hpp b/cpp/src/io/utilities/hostdevice_vector.hpp index 367bbfcbdfa..5c73cf31428 100644 --- a/cpp/src/io/utilities/hostdevice_vector.hpp +++ b/cpp/src/io/utilities/hostdevice_vector.hpp @@ -54,7 +54,7 @@ class hostdevice_vector { : num_elements(initial_size), max_elements(max_size) { if (max_elements != 0) { - CUDA_TRY(cudaMallocHost(&h_data, sizeof(T) * max_elements)); + CUDF_CUDA_TRY(cudaMallocHost(&h_data, sizeof(T) * max_elements)); d_data.resize(sizeof(T) * max_elements, stream); } } @@ -101,14 +101,14 @@ class hostdevice_vector { void host_to_device(rmm::cuda_stream_view stream, bool synchronize = false) { - CUDA_TRY(cudaMemcpyAsync( + CUDF_CUDA_TRY(cudaMemcpyAsync( d_data.data(), h_data, memory_size(), cudaMemcpyHostToDevice, stream.value())); if (synchronize) { stream.synchronize(); } } void device_to_host(rmm::cuda_stream_view stream, bool synchronize = false) { - CUDA_TRY(cudaMemcpyAsync( + CUDF_CUDA_TRY(cudaMemcpyAsync( h_data, d_data.data(), memory_size(), cudaMemcpyDeviceToHost, stream.value())); if (synchronize) { stream.synchronize(); } } diff --git a/cpp/src/io/utilities/parsing_utils.cu b/cpp/src/io/utilities/parsing_utils.cu index 2db87736848..a03789464cc 100644 --- a/cpp/src/io/utilities/parsing_utils.cu +++ b/cpp/src/io/utilities/parsing_utils.cu @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2019-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 #include #include @@ -106,7 +122,7 @@ cudf::size_type find_all_from_set(device_span data, { int block_size = 0; // suggested thread count to use int min_grid_size = 0; // minimum block count required - CUDA_TRY( + CUDF_CUDA_TRY( cudaOccupancyMaxPotentialBlockSize(&min_grid_size, &block_size, count_and_set_positions)); const int grid_size = divCeil(data.size(), (size_t)block_size); @@ -131,7 +147,7 @@ cudf::size_type find_all_from_set(host_span data, int block_size = 0; // suggested thread count to use int min_grid_size = 0; // minimum block count required - CUDA_TRY( + CUDF_CUDA_TRY( cudaOccupancyMaxPotentialBlockSize(&min_grid_size, &block_size, count_and_set_positions)); const size_t chunk_count = divCeil(data.size(), max_chunk_bytes); @@ -143,7 +159,7 @@ cudf::size_type find_all_from_set(host_span data, const int grid_size = divCeil(chunk_bits, block_size); // Copy chunk to device - CUDA_TRY( + CUDF_CUDA_TRY( cudaMemcpyAsync(d_chunk.data(), h_chunk, chunk_bytes, cudaMemcpyDefault, stream.value())); for (char key : keys) { diff --git a/cpp/src/jit/cache.cpp b/cpp/src/jit/cache.cpp index 159681eaffc..8228ff6da1f 100644 --- a/cpp/src/jit/cache.cpp +++ b/cpp/src/jit/cache.cpp @@ -77,9 +77,9 @@ std::filesystem::path get_cache_dir() int device; int cc_major; int cc_minor; - CUDA_TRY(cudaGetDevice(&device)); - CUDA_TRY(cudaDeviceGetAttribute(&cc_major, cudaDevAttrComputeCapabilityMajor, device)); - CUDA_TRY(cudaDeviceGetAttribute(&cc_minor, cudaDevAttrComputeCapabilityMinor, device)); + CUDF_CUDA_TRY(cudaGetDevice(&device)); + CUDF_CUDA_TRY(cudaDeviceGetAttribute(&cc_major, cudaDevAttrComputeCapabilityMajor, device)); + CUDF_CUDA_TRY(cudaDeviceGetAttribute(&cc_minor, cudaDevAttrComputeCapabilityMinor, device)); int cc = cc_major * 10 + cc_minor; kernel_cache_path /= std::to_string(cc); diff --git a/cpp/src/merge/merge.cu b/cpp/src/merge/merge.cu index 043c04b409e..01a94457b69 100644 --- a/cpp/src/merge/merge.cu +++ b/cpp/src/merge/merge.cu @@ -139,7 +139,7 @@ void materialize_bitmask(column_view const& left_col, } } - CHECK_CUDA(stream.value()); + CUDF_CHECK_CUDA(stream.value()); } struct side_index_generator { @@ -212,7 +212,7 @@ index_vector generate_merged_indices(table_view const& left_table, ineq_op); } - CHECK_CUDA(stream.value()); + CUDF_CHECK_CUDA(stream.value()); return merged_indices; } diff --git a/cpp/src/quantiles/quantiles_util.hpp b/cpp/src/quantiles/quantiles_util.hpp index 171b81152ff..280a42d9e20 100644 --- a/cpp/src/quantiles/quantiles_util.hpp +++ b/cpp/src/quantiles/quantiles_util.hpp @@ -29,7 +29,7 @@ CUDF_HOST_DEVICE inline Result get_array_value(T const* devarr, size_type locati #if defined(__CUDA_ARCH__) result = devarr[location]; #else - CUDA_TRY(cudaMemcpy(&result, devarr + location, sizeof(T), cudaMemcpyDeviceToHost)); + CUDF_CUDA_TRY(cudaMemcpy(&result, devarr + location, sizeof(T), cudaMemcpyDeviceToHost)); #endif return static_cast(result); } diff --git a/cpp/src/reductions/minmax.cu b/cpp/src/reductions/minmax.cu index 61f728447e8..454a8c9d694 100644 --- a/cpp/src/reductions/minmax.cu +++ b/cpp/src/reductions/minmax.cu @@ -216,7 +216,7 @@ struct minmax_functor { // copy the minmax_pair to the host; does not copy the strings using OutputType = minmax_pair; OutputType host_result; - CUDA_TRY(cudaMemcpyAsync( + CUDF_CUDA_TRY(cudaMemcpyAsync( &host_result, dev_result.data(), sizeof(OutputType), cudaMemcpyDeviceToHost, stream.value())); // strings are copied to create the scalars here return {std::make_unique(host_result.min_val, true, stream, mr), @@ -235,7 +235,7 @@ struct minmax_functor { // copy the minmax_pair to the host to call get_element using OutputType = minmax_pair; OutputType host_result; - CUDA_TRY(cudaMemcpyAsync( + CUDF_CUDA_TRY(cudaMemcpyAsync( &host_result, dev_result.data(), sizeof(OutputType), cudaMemcpyDeviceToHost, stream.value())); // get the keys for those indexes auto const keys = dictionary_column_view(col).keys(); diff --git a/cpp/src/reductions/scan/scan_exclusive.cu b/cpp/src/reductions/scan/scan_exclusive.cu index 3b8cc17c4aa..885d7e904b4 100644 --- a/cpp/src/reductions/scan/scan_exclusive.cu +++ b/cpp/src/reductions/scan/scan_exclusive.cu @@ -67,7 +67,7 @@ struct scan_dispatcher { thrust::exclusive_scan( rmm::exec_policy(stream), begin, begin + input.size(), output.data(), identity, Op{}); - CHECK_CUDA(stream.value()); + CUDF_CHECK_CUDA(stream.value()); return output_column; } diff --git a/cpp/src/reductions/scan/scan_inclusive.cu b/cpp/src/reductions/scan/scan_inclusive.cu index 9d07f340ebf..5ffdf1f5c56 100644 --- a/cpp/src/reductions/scan/scan_inclusive.cu +++ b/cpp/src/reductions/scan/scan_inclusive.cu @@ -120,7 +120,7 @@ struct scan_functor { thrust::inclusive_scan( rmm::exec_policy(stream), begin, begin + input_view.size(), result.data(), Op{}); - CHECK_CUDA(stream.value()); + CUDF_CHECK_CUDA(stream.value()); return output_column; } }; diff --git a/cpp/src/rolling/rolling_detail.cuh b/cpp/src/rolling/rolling_detail.cuh index d704b18774f..ca07d60f426 100644 --- a/cpp/src/rolling/rolling_detail.cuh +++ b/cpp/src/rolling/rolling_detail.cuh @@ -1281,7 +1281,7 @@ std::unique_ptr rolling_window_udf(column_view const& input, output->set_null_count(output->size() - device_valid_count.value(stream)); // check the stream for debugging - CHECK_CUDA(stream.value()); + CUDF_CHECK_CUDA(stream.value()); return output; } diff --git a/cpp/src/scalar/scalar.cpp b/cpp/src/scalar/scalar.cpp index 76ec171052a..19bb60ef1a8 100644 --- a/cpp/src/scalar/scalar.cpp +++ b/cpp/src/scalar/scalar.cpp @@ -114,7 +114,7 @@ std::string string_scalar::to_string(rmm::cuda_stream_view stream) const { std::string result; result.resize(_data.size()); - CUDA_TRY(cudaMemcpyAsync( + CUDF_CUDA_TRY(cudaMemcpyAsync( &result[0], _data.data(), _data.size(), cudaMemcpyDeviceToHost, stream.value())); stream.synchronize(); return result; diff --git a/cpp/src/search/search.cu b/cpp/src/search/search.cu index 477666d93ae..29eddf703df 100644 --- a/cpp/src/search/search.cu +++ b/cpp/src/search/search.cu @@ -97,7 +97,8 @@ std::unique_ptr search_ordered(table_view const& t, // Handle empty inputs if (t.num_rows() == 0) { - CUDA_TRY(cudaMemsetAsync(result_out, 0, values.num_rows() * sizeof(size_type), stream.value())); + CUDF_CUDA_TRY( + cudaMemsetAsync(result_out, 0, values.num_rows() * sizeof(size_type), stream.value())); return result; } diff --git a/cpp/src/strings/combine/join.cu b/cpp/src/strings/combine/join.cu index adfd24f1ca2..6a90a605ca3 100644 --- a/cpp/src/strings/combine/join.cu +++ b/cpp/src/strings/combine/join.cu @@ -87,11 +87,11 @@ std::unique_ptr join_strings(strings_column_view const& strings, auto offsets_view = offsets_column->mutable_view(); // set the first entry to 0 and the last entry to bytes int32_t new_offsets[] = {0, static_cast(bytes)}; - CUDA_TRY(cudaMemcpyAsync(offsets_view.data(), - new_offsets, - sizeof(new_offsets), - cudaMemcpyHostToDevice, - stream.value())); + CUDF_CUDA_TRY(cudaMemcpyAsync(offsets_view.data(), + new_offsets, + sizeof(new_offsets), + cudaMemcpyHostToDevice, + stream.value())); // build null mask // only one entry so it is either all valid or all null diff --git a/cpp/src/strings/convert/convert_durations.cu b/cpp/src/strings/convert/convert_durations.cu index ac3c4df6aeb..1a423ef8eec 100644 --- a/cpp/src/strings/convert/convert_durations.cu +++ b/cpp/src/strings/convert/convert_durations.cu @@ -153,11 +153,11 @@ struct format_compiler { // create program in device memory d_items.resize(items.size(), stream); - CUDA_TRY(cudaMemcpyAsync(d_items.data(), - items.data(), - items.size() * sizeof(items[0]), - cudaMemcpyHostToDevice, - stream.value())); + CUDF_CUDA_TRY(cudaMemcpyAsync(d_items.data(), + items.data(), + items.size() * sizeof(items[0]), + cudaMemcpyHostToDevice, + stream.value())); } format_item const* compiled_format_items() { return d_items.data(); } diff --git a/cpp/src/strings/copying/concatenate.cu b/cpp/src/strings/copying/concatenate.cu index 9fa033e9f9a..fedb8d38a08 100644 --- a/cpp/src/strings/copying/concatenate.cu +++ b/cpp/src/strings/copying/concatenate.cu @@ -297,7 +297,7 @@ std::unique_ptr concatenate(host_span columns, cudf::detail::get_value(offsets_child, column_size + column_offset, stream) - bytes_offset; - CUDA_TRY( + CUDF_CUDA_TRY( cudaMemcpyAsync(d_new_chars, d_chars, bytes, cudaMemcpyDeviceToDevice, stream.value())); // get ready for the next column diff --git a/cpp/src/strings/regex/regexec.cu b/cpp/src/strings/regex/regexec.cu index b286812226b..3bcf55cf069 100644 --- a/cpp/src/strings/regex/regexec.cu +++ b/cpp/src/strings/regex/regexec.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2019-2022, NVIDIA CORPORATION. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -163,7 +163,7 @@ std::unique_ptr> reprog_devic } // copy flat prog to device memory - CUDA_TRY(cudaMemcpyAsync( + CUDF_CUDA_TRY(cudaMemcpyAsync( d_buffer->data(), h_buffer.data(), memsize, cudaMemcpyHostToDevice, stream.value())); // auto deleter = [d_buffer, d_relists](reprog_device* t) { diff --git a/cpp/src/strings/repeat_strings.cu b/cpp/src/strings/repeat_strings.cu index c0673a5e2b5..d496b46bc36 100644 --- a/cpp/src/strings/repeat_strings.cu +++ b/cpp/src/strings/repeat_strings.cu @@ -81,10 +81,10 @@ auto generate_empty_output(strings_column_view const& input, auto offsets_column = make_numeric_column( data_type{type_to_id()}, strings_count + 1, mask_state::UNALLOCATED, stream, mr); - CUDA_TRY(cudaMemsetAsync(offsets_column->mutable_view().template data(), - 0, - offsets_column->size() * sizeof(offset_type), - stream.value())); + CUDF_CUDA_TRY(cudaMemsetAsync(offsets_column->mutable_view().template data(), + 0, + offsets_column->size() * sizeof(offset_type), + stream.value())); return make_strings_column(strings_count, std::move(offsets_column), @@ -264,7 +264,7 @@ auto make_strings_children(Func fn, } else { // Compute the offsets values from the provided output string sizes. auto const string_sizes = output_strings_sizes.value(); - CUDA_TRY(cudaMemsetAsync(d_offsets, 0, sizeof(offset_type), stream.value())); + CUDF_CUDA_TRY(cudaMemsetAsync(d_offsets, 0, sizeof(offset_type), stream.value())); thrust::inclusive_scan(rmm::exec_policy(stream), string_sizes.template begin(), string_sizes.template end(), diff --git a/cpp/src/strings/utilities.cu b/cpp/src/strings/utilities.cu index 825f09c66e6..d7cc72fdfff 100644 --- a/cpp/src/strings/utilities.cu +++ b/cpp/src/strings/utilities.cu @@ -130,9 +130,9 @@ const character_flags_table_type* get_character_flags_table() { return d_character_codepoint_flags.find_or_initialize([&](void) { character_flags_table_type* table = nullptr; - CUDA_TRY(cudaMemcpyToSymbol( + CUDF_CUDA_TRY(cudaMemcpyToSymbol( character_codepoint_flags, g_character_codepoint_flags, sizeof(g_character_codepoint_flags))); - CUDA_TRY(cudaGetSymbolAddress((void**)&table, character_codepoint_flags)); + CUDF_CUDA_TRY(cudaGetSymbolAddress((void**)&table, character_codepoint_flags)); return table; }); } @@ -144,9 +144,9 @@ const character_cases_table_type* get_character_cases_table() { return d_character_cases_table.find_or_initialize([&](void) { character_cases_table_type* table = nullptr; - CUDA_TRY(cudaMemcpyToSymbol( + CUDF_CUDA_TRY(cudaMemcpyToSymbol( character_cases_table, g_character_cases_table, sizeof(g_character_cases_table))); - CUDA_TRY(cudaGetSymbolAddress((void**)&table, character_cases_table)); + CUDF_CUDA_TRY(cudaGetSymbolAddress((void**)&table, character_cases_table)); return table; }); } @@ -158,9 +158,9 @@ const special_case_mapping* get_special_case_mapping_table() { return d_special_case_mappings.find_or_initialize([&](void) { special_case_mapping* table = nullptr; - CUDA_TRY(cudaMemcpyToSymbol( + CUDF_CUDA_TRY(cudaMemcpyToSymbol( character_special_case_mappings, g_special_case_mappings, sizeof(g_special_case_mappings))); - CUDA_TRY(cudaGetSymbolAddress((void**)&table, character_special_case_mappings)); + CUDF_CUDA_TRY(cudaGetSymbolAddress((void**)&table, character_special_case_mappings)); return table; }); } diff --git a/cpp/src/text/edit_distance.cu b/cpp/src/text/edit_distance.cu index 6ec364cc048..b69d735f612 100644 --- a/cpp/src/text/edit_distance.cu +++ b/cpp/src/text/edit_distance.cu @@ -231,7 +231,7 @@ std::unique_ptr edit_distance_matrix(cudf::strings_column_view con cudf::size_type n_upper = (strings_count * (strings_count - 1)) / 2; rmm::device_uvector offsets(n_upper, stream); auto d_offsets = offsets.data(); - CUDA_TRY(cudaMemsetAsync(d_offsets, 0, n_upper * sizeof(cudf::size_type), stream.value())); + CUDF_CUDA_TRY(cudaMemsetAsync(d_offsets, 0, n_upper * sizeof(cudf::size_type), stream.value())); thrust::for_each_n( rmm::exec_policy(stream), thrust::make_counting_iterator(0), diff --git a/cpp/src/text/subword/load_hash_file.cu b/cpp/src/text/subword/load_hash_file.cu index 9ab769f9edd..00094f2de71 100644 --- a/cpp/src/text/subword/load_hash_file.cu +++ b/cpp/src/text/subword/load_hash_file.cu @@ -52,12 +52,12 @@ rmm::device_uvector get_codepoint_metadata(rmm::cuda_st table + cp_section1_end, table + codepoint_metadata_size, codepoint_metadata_default_value); - CUDA_TRY(cudaMemcpyAsync(table, - codepoint_metadata, - cp_section1_end * sizeof(codepoint_metadata[0]), // 1st section - cudaMemcpyHostToDevice, - stream.value())); - CUDA_TRY(cudaMemcpyAsync( + CUDF_CUDA_TRY(cudaMemcpyAsync(table, + codepoint_metadata, + cp_section1_end * sizeof(codepoint_metadata[0]), // 1st section + cudaMemcpyHostToDevice, + stream.value())); + CUDF_CUDA_TRY(cudaMemcpyAsync( table + cp_section2_begin, cp_metadata_917505_917999, (cp_section2_end - cp_section2_begin + 1) * sizeof(codepoint_metadata[0]), // 2nd section @@ -80,24 +80,24 @@ rmm::device_uvector get_aux_codepoint_data(rmm::cuda_st table + aux_section1_end, table + aux_codepoint_data_size, aux_codepoint_default_value); - CUDA_TRY(cudaMemcpyAsync(table, - aux_codepoint_data, - aux_section1_end * sizeof(aux_codepoint_data[0]), // 1st section - cudaMemcpyHostToDevice, - stream.value())); - CUDA_TRY(cudaMemcpyAsync( + CUDF_CUDA_TRY(cudaMemcpyAsync(table, + aux_codepoint_data, + aux_section1_end * sizeof(aux_codepoint_data[0]), // 1st section + cudaMemcpyHostToDevice, + stream.value())); + CUDF_CUDA_TRY(cudaMemcpyAsync( table + aux_section2_begin, aux_cp_data_44032_55203, (aux_section2_end - aux_section2_begin + 1) * sizeof(aux_codepoint_data[0]), // 2nd section cudaMemcpyHostToDevice, stream.value())); - CUDA_TRY(cudaMemcpyAsync( + CUDF_CUDA_TRY(cudaMemcpyAsync( table + aux_section3_begin, aux_cp_data_70475_71099, (aux_section3_end - aux_section3_begin + 1) * sizeof(aux_codepoint_data[0]), // 3rd section cudaMemcpyHostToDevice, stream.value())); - CUDA_TRY(cudaMemcpyAsync( + CUDF_CUDA_TRY(cudaMemcpyAsync( table + aux_section4_begin, aux_cp_data_119134_119232, (aux_section4_end - aux_section4_begin + 1) * sizeof(aux_codepoint_data[0]), // 4th section @@ -236,33 +236,33 @@ std::unique_ptr load_vocabulary_file( cudf::mask_state::UNALLOCATED, stream, mr); - CUDA_TRY(cudaMemcpyAsync(result.table->mutable_view().data(), - table.data(), - table.size() * sizeof(uint64_t), - cudaMemcpyHostToDevice, - stream.value())); + CUDF_CUDA_TRY(cudaMemcpyAsync(result.table->mutable_view().data(), + table.data(), + table.size() * sizeof(uint64_t), + cudaMemcpyHostToDevice, + stream.value())); result.bin_coefficients = cudf::make_numeric_column(cudf::data_type{cudf::type_id::UINT64}, bin_coefficients.size(), cudf::mask_state::UNALLOCATED, stream, mr); - CUDA_TRY(cudaMemcpyAsync(result.bin_coefficients->mutable_view().data(), - bin_coefficients.data(), - bin_coefficients.size() * sizeof(uint64_t), - cudaMemcpyHostToDevice, - stream.value())); + CUDF_CUDA_TRY(cudaMemcpyAsync(result.bin_coefficients->mutable_view().data(), + bin_coefficients.data(), + bin_coefficients.size() * sizeof(uint64_t), + cudaMemcpyHostToDevice, + stream.value())); result.bin_offsets = cudf::make_numeric_column(cudf::data_type{cudf::type_id::UINT16}, bin_offsets.size(), cudf::mask_state::UNALLOCATED, stream, mr); - CUDA_TRY(cudaMemcpyAsync(result.bin_offsets->mutable_view().data(), - bin_offsets.data(), - bin_offsets.size() * sizeof(uint16_t), - cudaMemcpyHostToDevice, - stream.value())); + CUDF_CUDA_TRY(cudaMemcpyAsync(result.bin_offsets->mutable_view().data(), + bin_offsets.data(), + bin_offsets.size() * sizeof(uint16_t), + cudaMemcpyHostToDevice, + stream.value())); auto cp_metadata = detail::get_codepoint_metadata(stream); auto const cp_metadata_size = static_cast(cp_metadata.size()); diff --git a/cpp/src/text/subword/wordpiece_tokenizer.cu b/cpp/src/text/subword/wordpiece_tokenizer.cu index 82bb50c6aaa..7d8df583039 100644 --- a/cpp/src/text/subword/wordpiece_tokenizer.cu +++ b/cpp/src/text/subword/wordpiece_tokenizer.cu @@ -457,7 +457,7 @@ void wordpiece_tokenizer::tokenize(uvector_pair& cps_and_offsets, rmm::cuda_stre num_code_points, device_token_ids.data(), device_tokens_per_word.data()); - CHECK_CUDA(stream.value()); + CUDF_CHECK_CUDA(stream.value()); cudf::detail::grid_1d const grid_mark{static_cast(num_strings + 1), THREADS_PER_BLOCK}; @@ -469,7 +469,7 @@ void wordpiece_tokenizer::tokenize(uvector_pair& cps_and_offsets, rmm::cuda_stre device_start_word_indices, device_end_word_indices, num_strings); - CHECK_CUDA(stream.value()); + CUDF_CHECK_CUDA(stream.value()); // check for special tokens and adjust indices thrust::for_each_n( @@ -512,7 +512,7 @@ void wordpiece_tokenizer::tokenize(uvector_pair& cps_and_offsets, rmm::cuda_stre num_words, device_token_ids.data(), device_tokens_per_word.data()); - CHECK_CUDA(stream.value()); + CUDF_CHECK_CUDA(stream.value()); // Repurpose the input array for the token ids. In the worst case, each code point ends up being a // token so this will always have enough memory to store the contiguous tokens. diff --git a/cpp/src/transform/compute_column.cu b/cpp/src/transform/compute_column.cu index bc3678380be..74433af9f05 100644 --- a/cpp/src/transform/compute_column.cu +++ b/cpp/src/transform/compute_column.cu @@ -102,9 +102,9 @@ std::unique_ptr compute_column(table_view const& table, // Configure kernel parameters auto const& device_expression_data = parser.device_expression_data; int device_id; - CUDA_TRY(cudaGetDevice(&device_id)); + CUDF_CUDA_TRY(cudaGetDevice(&device_id)); int shmem_limit_per_block; - CUDA_TRY( + CUDF_CUDA_TRY( cudaDeviceGetAttribute(&shmem_limit_per_block, cudaDevAttrMaxSharedMemoryPerBlock, device_id)); auto constexpr MAX_BLOCK_SIZE = 128; auto const block_size = @@ -125,7 +125,7 @@ std::unique_ptr compute_column(table_view const& table, <<>>( *table_device, device_expression_data, *mutable_output_device); } - CHECK_CUDA(stream.value()); + CUDF_CHECK_CUDA(stream.value()); return output_column; } diff --git a/cpp/src/transform/row_bit_count.cu b/cpp/src/transform/row_bit_count.cu index 0f06be0149e..744cec90fd9 100644 --- a/cpp/src/transform/row_bit_count.cu +++ b/cpp/src/transform/row_bit_count.cu @@ -505,9 +505,9 @@ std::unique_ptr row_bit_count(table_view const& t, // of memory of size (# input rows * sizeof(row_span) * max_branch_depth). auto const shmem_per_thread = sizeof(row_span) * h_info.max_branch_depth; int device_id; - CUDA_TRY(cudaGetDevice(&device_id)); + CUDF_CUDA_TRY(cudaGetDevice(&device_id)); int shmem_limit_per_block; - CUDA_TRY( + CUDF_CUDA_TRY( cudaDeviceGetAttribute(&shmem_limit_per_block, cudaDevAttrMaxSharedMemoryPerBlock, device_id)); constexpr int max_block_size = 256; auto const block_size = diff --git a/cpp/src/unary/unary_ops.cuh b/cpp/src/unary/unary_ops.cuh index 19d78b010ec..08b68cc0591 100644 --- a/cpp/src/unary/unary_ops.cuh +++ b/cpp/src/unary/unary_ops.cuh @@ -70,7 +70,7 @@ struct launcher { thrust::transform( rmm::exec_policy(stream), input.begin(), input.end(), output_view.begin(), F{}); - CHECK_CUDA(stream.value()); + CUDF_CHECK_CUDA(stream.value()); return output; } diff --git a/cpp/tests/bitmask/bitmask_tests.cpp b/cpp/tests/bitmask/bitmask_tests.cpp index 3a479f0860b..6c2c0716331 100644 --- a/cpp/tests/bitmask/bitmask_tests.cpp +++ b/cpp/tests/bitmask/bitmask_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -88,10 +88,10 @@ rmm::device_uvector make_mask(cudf::size_type size, bool fil return cudf::detail::make_zeroed_device_uvector_sync(size); } else { auto ret = rmm::device_uvector(size, rmm::cuda_stream_default); - CUDA_TRY(cudaMemsetAsync(ret.data(), - ~cudf::bitmask_type{0}, - size * sizeof(cudf::bitmask_type), - rmm::cuda_stream_default.value())); + CUDF_CUDA_TRY(cudaMemsetAsync(ret.data(), + ~cudf::bitmask_type{0}, + size * sizeof(cudf::bitmask_type), + rmm::cuda_stream_default.value())); return ret; } } @@ -530,10 +530,10 @@ void cleanEndWord(rmm::device_buffer& mask, int begin_bit, int end_bit) auto number_of_bits = end_bit - begin_bit; if (number_of_bits % 32 != 0) { cudf::bitmask_type end_mask = 0; - CUDA_TRY(cudaMemcpy( + CUDF_CUDA_TRY(cudaMemcpy( &end_mask, ptr + number_of_mask_words - 1, sizeof(end_mask), cudaMemcpyDeviceToHost)); end_mask = end_mask & ((1 << (number_of_bits % 32)) - 1); - CUDA_TRY(cudaMemcpy( + CUDF_CUDA_TRY(cudaMemcpy( ptr + number_of_mask_words - 1, &end_mask, sizeof(end_mask), cudaMemcpyHostToDevice)); } } diff --git a/cpp/tests/copying/concatenate_tests.cu b/cpp/tests/copying/concatenate_tests.cu index 93e4e588e0e..4d76008fd13 100644 --- a/cpp/tests/copying/concatenate_tests.cu +++ b/cpp/tests/copying/concatenate_tests.cu @@ -62,9 +62,9 @@ struct TypedColumnTest : public cudf::test::BaseFixture { std::iota(h_data.begin(), h_data.end(), char{0}); std::vector h_mask(mask.size()); std::iota(h_mask.begin(), h_mask.end(), char{0}); - CUDA_TRY(cudaMemcpyAsync( + CUDF_CUDA_TRY(cudaMemcpyAsync( typed_data, h_data.data(), data.size(), cudaMemcpyHostToDevice, stream.value())); - CUDA_TRY(cudaMemcpyAsync( + CUDF_CUDA_TRY(cudaMemcpyAsync( typed_mask, h_mask.data(), mask.size(), cudaMemcpyHostToDevice, stream.value())); stream.synchronize(); } diff --git a/cpp/tests/device_atomics/device_atomics_test.cu b/cpp/tests/device_atomics/device_atomics_test.cu index 581268f26f4..1067366d010 100644 --- a/cpp/tests/device_atomics/device_atomics_test.cu +++ b/cpp/tests/device_atomics/device_atomics_test.cu @@ -155,7 +155,7 @@ struct AtomicsTest : public cudf::test::BaseFixture { auto host_result = cudf::detail::make_host_vector_sync(dev_result); - CHECK_CUDA(rmm::cuda_stream_default.value()); + CUDF_CHECK_CUDA(rmm::cuda_stream_default.value()); if (!is_timestamp_sum()) { EXPECT_EQ(host_result[0], exact[0]) << "atomicAdd test failed"; @@ -302,7 +302,7 @@ struct AtomicsBitwiseOpTest : public cudf::test::BaseFixture { auto host_result = cudf::detail::make_host_vector_sync(dev_result); - CHECK_CUDA(rmm::cuda_stream_default.value()); + CUDF_CHECK_CUDA(rmm::cuda_stream_default.value()); // print_exact(exact, "exact"); // print_exact(host_result.data(), "result"); diff --git a/cpp/tests/error/error_handling_test.cu b/cpp/tests/error/error_handling_test.cu index da9509e94a6..4327a8b694b 100644 --- a/cpp/tests/error/error_handling_test.cu +++ b/cpp/tests/error/error_handling_test.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020, 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. @@ -36,28 +36,28 @@ TEST(ExpectsTest, TryCatch) TEST(CudaTryTest, Error) { - CUDA_EXPECT_THROW_MESSAGE(CUDA_TRY(cudaErrorLaunchFailure), + CUDA_EXPECT_THROW_MESSAGE(CUDF_CUDA_TRY(cudaErrorLaunchFailure), "cudaErrorLaunchFailure unspecified launch failure"); } -TEST(CudaTryTest, Success) { EXPECT_NO_THROW(CUDA_TRY(cudaSuccess)); } +TEST(CudaTryTest, Success) { EXPECT_NO_THROW(CUDF_CUDA_TRY(cudaSuccess)); } TEST(CudaTryTest, TryCatch) { - CUDA_EXPECT_THROW_MESSAGE(CUDA_TRY(cudaErrorMemoryAllocation), + CUDA_EXPECT_THROW_MESSAGE(CUDF_CUDA_TRY(cudaErrorMemoryAllocation), "cudaErrorMemoryAllocation out of memory"); } -TEST(StreamCheck, success) { EXPECT_NO_THROW(CHECK_CUDA(0)); } +TEST(StreamCheck, success) { EXPECT_NO_THROW(CUDF_CHECK_CUDA(0)); } namespace { // Some silly kernel that will cause an error void __global__ test_kernel(int* data) { data[threadIdx.x] = threadIdx.x; } } // namespace -// In a release build and without explicit synchronization, CHECK_CUDA may +// In a release build and without explicit synchronization, CUDF_CHECK_CUDA may // or may not fail on erroneous asynchronous CUDA calls. Invoke // cudaStreamSynchronize to guarantee failure on error. In a non-release build, -// CHECK_CUDA deterministically fails on erroneous asynchronous CUDA +// CUDF_CHECK_CUDA deterministically fails on erroneous asynchronous CUDA // calls. TEST(StreamCheck, FailedKernel) { @@ -67,7 +67,7 @@ TEST(StreamCheck, FailedKernel) #ifdef NDEBUG stream.synchronize(); #endif - EXPECT_THROW(CHECK_CUDA(stream.value()), cudf::cuda_error); + EXPECT_THROW(CUDF_CHECK_CUDA(stream.value()), cudf::cuda_error); } TEST(StreamCheck, CatchFailedKernel) @@ -78,7 +78,7 @@ TEST(StreamCheck, CatchFailedKernel) #ifndef NDEBUG stream.synchronize(); #endif - CUDA_EXPECT_THROW_MESSAGE(CHECK_CUDA(stream.value()), + CUDA_EXPECT_THROW_MESSAGE(CUDF_CHECK_CUDA(stream.value()), "cudaErrorInvalidConfiguration " "invalid configuration argument"); } diff --git a/cpp/tests/io/parquet_test.cpp b/cpp/tests/io/parquet_test.cpp index 1f4a8a7e508..cd0aab3caeb 100644 --- a/cpp/tests/io/parquet_test.cpp +++ b/cpp/tests/io/parquet_test.cpp @@ -1101,11 +1101,11 @@ class custom_test_data_sink : public cudf::io::data_sink { { return std::async(std::launch::deferred, [=] { char* ptr = nullptr; - CUDA_TRY(cudaMallocHost(&ptr, size)); - CUDA_TRY(cudaMemcpyAsync(ptr, gpu_data, size, cudaMemcpyDeviceToHost, stream.value())); + CUDF_CUDA_TRY(cudaMallocHost(&ptr, size)); + CUDF_CUDA_TRY(cudaMemcpyAsync(ptr, gpu_data, size, cudaMemcpyDeviceToHost, stream.value())); stream.synchronize(); outfile_.write(ptr, size); - CUDA_TRY(cudaFreeHost(ptr)); + CUDF_CUDA_TRY(cudaFreeHost(ptr)); }); } @@ -2166,11 +2166,11 @@ class custom_test_memmap_sink : public cudf::io::data_sink { { return std::async(std::launch::deferred, [=] { char* ptr = nullptr; - CUDA_TRY(cudaMallocHost(&ptr, size)); - CUDA_TRY(cudaMemcpyAsync(ptr, gpu_data, size, cudaMemcpyDeviceToHost, stream.value())); + CUDF_CUDA_TRY(cudaMallocHost(&ptr, size)); + CUDF_CUDA_TRY(cudaMemcpyAsync(ptr, gpu_data, size, cudaMemcpyDeviceToHost, stream.value())); stream.synchronize(); mm_writer->host_write(ptr, size); - CUDA_TRY(cudaFreeHost(ptr)); + CUDF_CUDA_TRY(cudaFreeHost(ptr)); }); } diff --git a/cpp/tests/join/join_tests.cpp b/cpp/tests/join/join_tests.cpp index 57041e448a2..f560ce7f20c 100644 --- a/cpp/tests/join/join_tests.cpp +++ b/cpp/tests/join/join_tests.cpp @@ -1423,7 +1423,7 @@ TEST_F(JoinTest, HashJoinLargeOutputSize) // self-join a table of zeroes to generate an output row count that would overflow int32_t std::size_t col_size = 65567; rmm::device_buffer zeroes(col_size * sizeof(int32_t), rmm::cuda_stream_default); - CUDA_TRY(cudaMemsetAsync(zeroes.data(), 0, zeroes.size(), rmm::cuda_stream_default.value())); + CUDF_CUDA_TRY(cudaMemsetAsync(zeroes.data(), 0, zeroes.size(), rmm::cuda_stream_default.value())); cudf::column_view col_zeros(cudf::data_type{cudf::type_id::INT32}, col_size, zeroes.data()); cudf::table_view tview{{col_zeros}}; cudf::hash_join hash_join(tview, cudf::null_equality::UNEQUAL); diff --git a/cpp/tests/scalar/scalar_device_view_test.cu b/cpp/tests/scalar/scalar_device_view_test.cu index ee4c878726f..30c843a91c4 100644 --- a/cpp/tests/scalar/scalar_device_view_test.cu +++ b/cpp/tests/scalar/scalar_device_view_test.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -60,13 +60,13 @@ TYPED_TEST(TypedScalarDeviceViewTest, Value) rmm::device_scalar result{rmm::cuda_stream_default}; test_set_value<<<1, 1>>>(scalar_device_view, scalar_device_view1); - CHECK_CUDA(0); + CUDF_CHECK_CUDA(0); EXPECT_EQ(s1.value(), value); EXPECT_TRUE(s1.is_valid()); test_value<<<1, 1>>>(scalar_device_view, scalar_device_view1, result.data()); - CHECK_CUDA(0); + CUDF_CHECK_CUDA(0); EXPECT_TRUE(result.value(rmm::cuda_stream_default)); } @@ -85,7 +85,7 @@ TYPED_TEST(TypedScalarDeviceViewTest, ConstructNull) rmm::device_scalar result{rmm::cuda_stream_default}; test_null<<<1, 1>>>(scalar_device_view, result.data()); - CHECK_CUDA(0); + CUDF_CHECK_CUDA(0); EXPECT_FALSE(result.value(rmm::cuda_stream_default)); } @@ -105,7 +105,7 @@ TYPED_TEST(TypedScalarDeviceViewTest, SetNull) EXPECT_TRUE(s.is_valid()); test_setnull<<<1, 1>>>(scalar_device_view); - CHECK_CUDA(0); + CUDF_CHECK_CUDA(0); EXPECT_FALSE(s.is_valid()); } @@ -131,7 +131,7 @@ TEST_F(StringScalarDeviceViewTest, Value) auto value_v = cudf::detail::make_device_uvector_sync(value); test_string_value<<<1, 1>>>(scalar_device_view, value_v.data(), value.size(), result.data()); - CHECK_CUDA(0); + CUDF_CHECK_CUDA(0); EXPECT_TRUE(result.value(rmm::cuda_stream_default)); } diff --git a/cpp/tests/sort/sort_test.cpp b/cpp/tests/sort/sort_test.cpp index a6e1a25ec17..b9ea7a0b078 100644 --- a/cpp/tests/sort/sort_test.cpp +++ b/cpp/tests/sort/sort_test.cpp @@ -86,7 +86,7 @@ TYPED_TEST(Sort, WithNullMax) // the rest of the values are equivalent and yields random sorted order. auto to_host = [](column_view const& col) { thrust::host_vector h_data(col.size()); - CUDA_TRY(cudaMemcpy( + CUDF_CUDA_TRY(cudaMemcpy( h_data.data(), col.data(), h_data.size() * sizeof(int32_t), cudaMemcpyDefault)); return h_data; }; @@ -124,7 +124,7 @@ TYPED_TEST(Sort, WithNullMin) // the rest of the values are equivalent and yields random sorted order. auto to_host = [](column_view const& col) { thrust::host_vector h_data(col.size()); - CUDA_TRY(cudaMemcpy( + CUDF_CUDA_TRY(cudaMemcpy( h_data.data(), col.data(), h_data.size() * sizeof(int32_t), cudaMemcpyDefault)); return h_data; }; @@ -160,7 +160,7 @@ TYPED_TEST(Sort, WithMixedNullOrder) // the rest of the values are equivalent and yields random sorted order. auto to_host = [](column_view const& col) { thrust::host_vector h_data(col.size()); - CUDA_TRY(cudaMemcpy( + CUDF_CUDA_TRY(cudaMemcpy( h_data.data(), col.data(), h_data.size() * sizeof(int32_t), cudaMemcpyDefault)); return h_data; }; diff --git a/cpp/tests/sort/stable_sort_tests.cpp b/cpp/tests/sort/stable_sort_tests.cpp index b6b7495136e..ee43c9e7b4b 100644 --- a/cpp/tests/sort/stable_sort_tests.cpp +++ b/cpp/tests/sort/stable_sort_tests.cpp @@ -94,7 +94,7 @@ TYPED_TEST(StableSort, WithNullMax) // the rest of the values are equivalent and yields random sorted order. auto to_host = [](column_view const& col) { thrust::host_vector h_data(col.size()); - CUDA_TRY(cudaMemcpy( + CUDF_CUDA_TRY(cudaMemcpy( h_data.data(), col.data(), h_data.size() * sizeof(int32_t), cudaMemcpyDefault)); return h_data; }; @@ -130,7 +130,7 @@ TYPED_TEST(StableSort, WithNullMin) // the rest of the values are equivalent and yields random sorted order. auto to_host = [](column_view const& col) { thrust::host_vector h_data(col.size()); - CUDA_TRY(cudaMemcpy( + CUDF_CUDA_TRY(cudaMemcpy( h_data.data(), col.data(), h_data.size() * sizeof(int32_t), cudaMemcpyDefault)); return h_data; }; diff --git a/cpp/tests/strings/factories_test.cu b/cpp/tests/strings/factories_test.cu index 0ba4b268c70..6861737bfb5 100644 --- a/cpp/tests/strings/factories_test.cu +++ b/cpp/tests/strings/factories_test.cu @@ -78,7 +78,7 @@ TEST_F(StringsFactoriesTest, CreateColumnFromPair) h_offsets[idx + 1] = offset; } auto d_strings = cudf::detail::make_device_uvector_sync(strings); - CUDA_TRY(cudaMemcpy(d_buffer.data(), h_buffer.data(), memsize, cudaMemcpyHostToDevice)); + CUDF_CUDA_TRY(cudaMemcpy(d_buffer.data(), h_buffer.data(), memsize, cudaMemcpyHostToDevice)); auto column = cudf::make_strings_column(d_strings); EXPECT_EQ(column->type(), cudf::data_type{cudf::type_id::STRING}); EXPECT_EQ(column->null_count(), nulls); diff --git a/cpp/tests/strings/integers_tests.cpp b/cpp/tests/strings/integers_tests.cpp index 7f8a31ef9bb..5802a1ddc0a 100644 --- a/cpp/tests/strings/integers_tests.cpp +++ b/cpp/tests/strings/integers_tests.cpp @@ -302,10 +302,10 @@ TYPED_TEST(StringsIntegerConvertTest, FromToInteger) auto integers = cudf::make_numeric_column(cudf::data_type{cudf::type_to_id()}, (cudf::size_type)d_integers.size()); auto integers_view = integers->mutable_view(); - CUDA_TRY(cudaMemcpy(integers_view.data(), - d_integers.data(), - d_integers.size() * sizeof(TypeParam), - cudaMemcpyDeviceToDevice)); + CUDF_CUDA_TRY(cudaMemcpy(integers_view.data(), + d_integers.data(), + d_integers.size() * sizeof(TypeParam), + cudaMemcpyDeviceToDevice)); integers_view.set_null_count(0); // convert to strings diff --git a/cpp/tests/types/type_dispatcher_test.cu b/cpp/tests/types/type_dispatcher_test.cu index dca80b597c0..d8b2a736bde 100644 --- a/cpp/tests/types/type_dispatcher_test.cu +++ b/cpp/tests/types/type_dispatcher_test.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -71,7 +71,7 @@ TYPED_TEST(TypedDispatcherTest, DeviceDispatch) { auto result = cudf::detail::make_zeroed_device_uvector_sync(1); dispatch_test_kernel<<<1, 1>>>(cudf::type_to_id(), result.data()); - CUDA_TRY(cudaDeviceSynchronize()); + CUDF_CUDA_TRY(cudaDeviceSynchronize()); EXPECT_EQ(true, result.front_element(rmm::cuda_stream_default)); } @@ -132,7 +132,7 @@ TYPED_TEST(TypedDoubleDispatcherTest, DeviceDoubleDispatch) auto result = cudf::detail::make_zeroed_device_uvector_sync(1); double_dispatch_test_kernel<<<1, 1>>>( cudf::type_to_id(), cudf::type_to_id(), result.data()); - CUDA_TRY(cudaDeviceSynchronize()); + CUDF_CUDA_TRY(cudaDeviceSynchronize()); EXPECT_EQ(true, result.front_element(rmm::cuda_stream_default)); } diff --git a/cpp/tests/utilities/column_utilities.cu b/cpp/tests/utilities/column_utilities.cu index 68626c2d4d3..015178f8c7c 100644 --- a/cpp/tests/utilities/column_utilities.cu +++ b/cpp/tests/utilities/column_utilities.cu @@ -824,16 +824,16 @@ std::vector bitmask_to_host(cudf::column_view const& c) auto num_bitmasks = num_bitmask_words(c.size()); std::vector host_bitmask(num_bitmasks); if (c.offset() == 0) { - CUDA_TRY(cudaMemcpy(host_bitmask.data(), - c.null_mask(), - num_bitmasks * sizeof(bitmask_type), - cudaMemcpyDeviceToHost)); + CUDF_CUDA_TRY(cudaMemcpy(host_bitmask.data(), + c.null_mask(), + num_bitmasks * sizeof(bitmask_type), + cudaMemcpyDeviceToHost)); } else { auto mask = copy_bitmask(c.null_mask(), c.offset(), c.offset() + c.size()); - CUDA_TRY(cudaMemcpy(host_bitmask.data(), - mask.data(), - num_bitmasks * sizeof(bitmask_type), - cudaMemcpyDeviceToHost)); + CUDF_CUDA_TRY(cudaMemcpy(host_bitmask.data(), + mask.data(), + num_bitmasks * sizeof(bitmask_type), + cudaMemcpyDeviceToHost)); } return host_bitmask; diff --git a/java/src/main/native/src/TableJni.cpp b/java/src/main/native/src/TableJni.cpp index 78ac8a18107..cebe476dd87 100644 --- a/java/src/main/native/src/TableJni.cpp +++ b/java/src/main/native/src/TableJni.cpp @@ -137,8 +137,8 @@ class jni_writer_data_sink final : public cudf::io::data_sink { left_to_copy < buffer_amount_available ? left_to_copy : buffer_amount_available; char *copy_to = current_buffer_data + current_buffer_written; - CUDA_TRY(cudaMemcpyAsync(copy_to, copy_from, amount_to_copy, cudaMemcpyDeviceToHost, - stream.value())); + CUDF_CUDA_TRY(cudaMemcpyAsync(copy_to, copy_from, amount_to_copy, cudaMemcpyDeviceToHost, + stream.value())); copy_from = copy_from + amount_to_copy; current_buffer_written += amount_to_copy; diff --git a/java/src/main/native/src/map_lookup.cu b/java/src/main/native/src/map_lookup.cu index 683651799e7..13d1a5a94a9 100644 --- a/java/src/main/native/src/map_lookup.cu +++ b/java/src/main/native/src/map_lookup.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -123,7 +123,7 @@ get_gather_map_for_map_values(column_view const &input, string_scalar &lookup_ke gpu_find_first<<>>( *input_device_view, *output_view, lookup_key_device_view); - CHECK_CUDA(stream.value()); + CUDF_CHECK_CUDA(stream.value()); return gather_map; } diff --git a/java/src/main/native/src/row_conversion.cu b/java/src/main/native/src/row_conversion.cu index 4d78f416134..96ee95c476d 100644 --- a/java/src/main/native/src/row_conversion.cu +++ b/java/src/main/native/src/row_conversion.cu @@ -1766,9 +1766,9 @@ std::vector> convert_to_rows( std::optional> variable_width_offsets, rmm::cuda_stream_view stream, rmm::mr::device_memory_resource *mr) { int device_id; - CUDA_TRY(cudaGetDevice(&device_id)); + CUDF_CUDA_TRY(cudaGetDevice(&device_id)); int total_shmem_in_bytes; - CUDA_TRY( + CUDF_CUDA_TRY( cudaDeviceGetAttribute(&total_shmem_in_bytes, cudaDevAttrMaxSharedMemoryPerBlock, device_id)); #ifndef __CUDA_ARCH__ // __host__ code. @@ -2097,9 +2097,9 @@ std::unique_ptr
convert_from_rows(lists_column_view const &input, auto const num_rows = input.parent().size(); int device_id; - CUDA_TRY(cudaGetDevice(&device_id)); + CUDF_CUDA_TRY(cudaGetDevice(&device_id)); int total_shmem_in_bytes; - CUDA_TRY( + CUDF_CUDA_TRY( cudaDeviceGetAttribute(&total_shmem_in_bytes, cudaDevAttrMaxSharedMemoryPerBlock, device_id)); #ifndef __CUDA_ARCH__ // __host__ code. From 9ee7617bada19b7d6b6aef442e26de2492ca4911 Mon Sep 17 00:00:00 2001 From: Vukasin Milovanovic Date: Tue, 5 Apr 2022 08:32:30 -0700 Subject: [PATCH 036/246] Add support for struct columns to the random table generator (#10566) Closes #7619 This PR adds support to generate struct columns of any nesting depth/number of leaf columns. Leaf column types can be manually specified, number of leaf columns will match the number of types. Cannot specify struct columns as leaf type, as the type of the struct column will recursively include the leaf struct which has the same hierarchy, and so on until OOM. Non-leaf columns in the generated hierarchy have approximately the same number of children. Authors: - Vukasin Milovanovic (https://github.com/vuule) Approvers: - Mark Harris (https://github.com/harrism) - Nghia Truong (https://github.com/ttnghia) URL: https://github.com/rapidsai/cudf/pull/10566 --- cpp/benchmarks/common/generate_input.cu | 118 +++++++++++++++++-- cpp/benchmarks/common/generate_input.hpp | 39 +++++- cpp/benchmarks/io/orc/orc_reader.cpp | 1 + cpp/benchmarks/io/orc/orc_writer.cpp | 1 + cpp/benchmarks/io/parquet/parquet_reader.cpp | 1 + cpp/benchmarks/io/parquet/parquet_writer.cpp | 1 + 6 files changed, 151 insertions(+), 10 deletions(-) diff --git a/cpp/benchmarks/common/generate_input.cu b/cpp/benchmarks/common/generate_input.cu index 3af64b0945a..b6a37453a13 100644 --- a/cpp/benchmarks/common/generate_input.cu +++ b/cpp/benchmarks/common/generate_input.cu @@ -87,6 +87,15 @@ T get_distribution_mean(distribution_params const& dist) } } +/** + * @brief Computes the average element size in a column, given the data profile. + * + * Random distribution parameters like average string length and maximum list nesting level affect + * the element size of non-fixed-width columns. For lists and structs, `avg_element_size` is called + * recursively to determine the size of nested columns. + */ +size_t avg_element_size(data_profile const& profile, cudf::data_type dtype); + // Utilities to determine the mean size of an element, given the data profile template ())> size_t non_fixed_width_size(data_profile const& profile) @@ -112,10 +121,22 @@ size_t non_fixed_width_size(data_profile const& profile) { auto const dist_params = profile.get_distribution_params(); auto const single_level_mean = get_distribution_mean(dist_params.length_params); - auto const element_size = cudf::size_of(cudf::data_type{dist_params.element_type}); + auto const element_size = avg_element_size(profile, cudf::data_type{dist_params.element_type}); return element_size * pow(single_level_mean, dist_params.max_depth); } +template <> +size_t non_fixed_width_size(data_profile const& profile) +{ + auto const dist_params = profile.get_distribution_params(); + return std::accumulate(dist_params.leaf_types.cbegin(), + dist_params.leaf_types.cend(), + 0ul, + [&](auto& sum, auto type_id) { + return sum + avg_element_size(profile, cudf::data_type{type_id}); + }); +} + struct non_fixed_width_size_fn { template size_t operator()(data_profile const& profile) @@ -527,14 +548,6 @@ std::unique_ptr create_random_column(data_prof CUDF_FAIL("not implemented yet"); } -template <> -std::unique_ptr create_random_column(data_profile const& profile, - thrust::minstd_rand& engine, - cudf::size_type num_rows) -{ - CUDF_FAIL("not implemented yet"); -} - /** * @brief Functor to dispatch create_random_column calls. */ @@ -549,6 +562,93 @@ struct create_rand_col_fn { } }; +/** + * @brief Calculates the number of direct parents needed to generate a struct column hierarchy with + * lowest maximum number of children in any nested column. + * + * Used to generate an "evenly distributed" struct column hierarchy with the given number of leaf + * columns and nesting levels. The column tree is considered evenly distributed if all columns have + * nearly the same number of child columns (difference not larger than one). + */ +int num_direct_parents(int num_lvls, int num_leaf_columns) +{ + // Estimated average number of children in the hierarchy; + auto const num_children_avg = std::pow(num_leaf_columns, 1. / num_lvls); + // Minimum number of children columns for any column in the hierarchy + int const num_children_min = std::floor(num_children_avg); + // Maximum number of children columns for any column in the hierarchy + int const num_children_max = num_children_min + 1; + + // Minimum number of columns needed so that their number of children does not exceed the maximum + int const min_for_current_nesting = std::ceil((double)num_leaf_columns / num_children_max); + // Minimum number of columns needed so that columns at the higher levels have at least the minimum + // number of children + int const min_for_upper_nesting = std::pow(num_children_min, num_lvls - 1); + // Both conditions need to be satisfied + return std::max(min_for_current_nesting, min_for_upper_nesting); +} + +template <> +std::unique_ptr create_random_column(data_profile const& profile, + thrust::minstd_rand& engine, + cudf::size_type num_rows) +{ + auto const dist_params = profile.get_distribution_params(); + + // Generate leaf columns + std::vector> children; + children.reserve(dist_params.leaf_types.size()); + std::transform(dist_params.leaf_types.cbegin(), + dist_params.leaf_types.cend(), + std::back_inserter(children), + [&](auto& type_id) { + return cudf::type_dispatcher( + cudf::data_type(type_id), create_rand_col_fn{}, profile, engine, num_rows); + }); + + auto valid_dist = + random_value_fn(distribution_params{1. - profile.get_null_frequency().value_or(0)}); + + // Generate the column bottom-up + for (int lvl = dist_params.max_depth; lvl > 0; --lvl) { + // Generating the next level + std::vector> parents; + parents.resize(num_direct_parents(lvl, children.size())); + + auto current_child = children.begin(); + for (auto current_parent = parents.begin(); current_parent != parents.end(); ++current_parent) { + auto [null_mask, null_count] = [&]() { + if (profile.get_null_frequency().has_value()) { + auto valids = valid_dist(engine, num_rows); + return cudf::detail::valid_if(valids.begin(), valids.end(), thrust::identity{}); + } + return std::pair{}; + }(); + + // Adopt remaining children as evenly as possible + auto const num_to_adopt = cudf::util::div_rounding_up_unsafe( + std::distance(current_child, children.end()), std::distance(current_parent, parents.end())); + CUDF_EXPECTS(num_to_adopt > 0, "No children columns left to adopt"); + + std::vector> children_to_adopt; + children_to_adopt.insert(children_to_adopt.end(), + std::make_move_iterator(current_child), + std::make_move_iterator(current_child + num_to_adopt)); + current_child += children_to_adopt.size(); + + *current_parent = cudf::make_structs_column( + num_rows, std::move(children_to_adopt), null_count, std::move(null_mask)); + } + + if (lvl == 1) { + CUDF_EXPECTS(parents.size() == 1, "There should be one top-level column"); + return std::move(parents.front()); + } + children = std::move(parents); + } + CUDF_FAIL("Reached unreachable code in struct column creation"); +} + template struct clamp_down : public thrust::unary_function { T max; diff --git a/cpp/benchmarks/common/generate_input.hpp b/cpp/benchmarks/common/generate_input.hpp index c955f60f97e..8a4e3783da5 100644 --- a/cpp/benchmarks/common/generate_input.hpp +++ b/cpp/benchmarks/common/generate_input.hpp @@ -171,6 +171,15 @@ struct distribution_params +struct distribution_params>> { + std::vector leaf_types; + cudf::size_type max_depth; +}; + // Present for compilation only. To be implemented once reader/writers support the fixed width type. template struct distribution_params()>> { @@ -214,6 +223,8 @@ class data_profile { distribution_params string_dist_desc{{distribution_id::NORMAL, 0, 32}}; distribution_params list_dist_desc{ cudf::type_id::INT32, {distribution_id::GEOMETRIC, 0, 100}, 2}; + distribution_params struct_dist_desc{ + {cudf::type_id::INT32, cudf::type_id::FLOAT32, cudf::type_id::STRING}, 2}; std::map> decimal_params; double bool_probability = 0.5; @@ -281,6 +292,12 @@ class data_profile { return list_dist_desc; } + template >* = nullptr> + distribution_params get_distribution_params() const + { + return struct_dist_desc; + } + template ()>* = nullptr> distribution_params get_distribution_params() const { @@ -357,8 +374,28 @@ class data_profile { void set_cardinality(cudf::size_type c) { cardinality = c; } void set_avg_run_length(cudf::size_type avg_rl) { avg_run_length = avg_rl; } - void set_list_depth(cudf::size_type max_depth) { list_dist_desc.max_depth = max_depth; } + void set_list_depth(cudf::size_type max_depth) + { + CUDF_EXPECTS(max_depth > 0, "List depth must be positive"); + list_dist_desc.max_depth = max_depth; + } + void set_list_type(cudf::type_id type) { list_dist_desc.element_type = type; } + + void set_struct_depth(cudf::size_type max_depth) + { + CUDF_EXPECTS(max_depth > 0, "Struct depth must be positive"); + struct_dist_desc.max_depth = max_depth; + } + + void set_struct_types(std::vector const& types) + { + CUDF_EXPECTS( + std::none_of( + types.cbegin(), types.cend(), [](auto& type) { return type == cudf::type_id::STRUCT; }), + "Cannot include STRUCT as its own subtype"); + struct_dist_desc.leaf_types = types; + } }; /** diff --git a/cpp/benchmarks/io/orc/orc_reader.cpp b/cpp/benchmarks/io/orc/orc_reader.cpp index 29d4860a0e5..0fc2238a272 100644 --- a/cpp/benchmarks/io/orc/orc_reader.cpp +++ b/cpp/benchmarks/io/orc/orc_reader.cpp @@ -166,6 +166,7 @@ RD_BENCHMARK_DEFINE_ALL_SOURCES(ORC_RD_BM_INPUTS_DEFINE, decimal, type_group_id: RD_BENCHMARK_DEFINE_ALL_SOURCES(ORC_RD_BM_INPUTS_DEFINE, timestamps, type_group_id::TIMESTAMP); RD_BENCHMARK_DEFINE_ALL_SOURCES(ORC_RD_BM_INPUTS_DEFINE, string, cudf::type_id::STRING); RD_BENCHMARK_DEFINE_ALL_SOURCES(ORC_RD_BM_INPUTS_DEFINE, list, cudf::type_id::LIST); +RD_BENCHMARK_DEFINE_ALL_SOURCES(ORC_RD_BM_INPUTS_DEFINE, struct, cudf::type_id::STRUCT); BENCHMARK_DEFINE_F(OrcRead, column_selection) (::benchmark::State& state) { BM_orc_read_varying_options(state); } diff --git a/cpp/benchmarks/io/orc/orc_writer.cpp b/cpp/benchmarks/io/orc/orc_writer.cpp index e24ca7f749d..525c13af5c0 100644 --- a/cpp/benchmarks/io/orc/orc_writer.cpp +++ b/cpp/benchmarks/io/orc/orc_writer.cpp @@ -116,6 +116,7 @@ WR_BENCHMARK_DEFINE_ALL_SINKS(ORC_WR_BM_INOUTS_DEFINE, decimal, type_group_id::F WR_BENCHMARK_DEFINE_ALL_SINKS(ORC_WR_BM_INOUTS_DEFINE, timestamps, type_group_id::TIMESTAMP); WR_BENCHMARK_DEFINE_ALL_SINKS(ORC_WR_BM_INOUTS_DEFINE, string, cudf::type_id::STRING); WR_BENCHMARK_DEFINE_ALL_SINKS(ORC_WR_BM_INOUTS_DEFINE, list, cudf::type_id::LIST); +WR_BENCHMARK_DEFINE_ALL_SINKS(ORC_WR_BM_INOUTS_DEFINE, struct, cudf::type_id::STRUCT); BENCHMARK_DEFINE_F(OrcWrite, writer_options) (::benchmark::State& state) { BM_orc_write_varying_options(state); } diff --git a/cpp/benchmarks/io/parquet/parquet_reader.cpp b/cpp/benchmarks/io/parquet/parquet_reader.cpp index 74613e50158..8a97fd35c31 100644 --- a/cpp/benchmarks/io/parquet/parquet_reader.cpp +++ b/cpp/benchmarks/io/parquet/parquet_reader.cpp @@ -166,6 +166,7 @@ RD_BENCHMARK_DEFINE_ALL_SOURCES(PARQ_RD_BM_INPUTS_DEFINE, decimal, type_group_id RD_BENCHMARK_DEFINE_ALL_SOURCES(PARQ_RD_BM_INPUTS_DEFINE, timestamps, type_group_id::TIMESTAMP); RD_BENCHMARK_DEFINE_ALL_SOURCES(PARQ_RD_BM_INPUTS_DEFINE, string, cudf::type_id::STRING); RD_BENCHMARK_DEFINE_ALL_SOURCES(PARQ_RD_BM_INPUTS_DEFINE, list, cudf::type_id::LIST); +RD_BENCHMARK_DEFINE_ALL_SOURCES(PARQ_RD_BM_INPUTS_DEFINE, struct, cudf::type_id::STRUCT); BENCHMARK_DEFINE_F(ParquetRead, column_selection) (::benchmark::State& state) { BM_parq_read_varying_options(state); } diff --git a/cpp/benchmarks/io/parquet/parquet_writer.cpp b/cpp/benchmarks/io/parquet/parquet_writer.cpp index d203f0d27c8..d25fae42d0e 100644 --- a/cpp/benchmarks/io/parquet/parquet_writer.cpp +++ b/cpp/benchmarks/io/parquet/parquet_writer.cpp @@ -111,6 +111,7 @@ WR_BENCHMARK_DEFINE_ALL_SINKS(PARQ_WR_BM_INOUTS_DEFINE, decimal, type_group_id:: WR_BENCHMARK_DEFINE_ALL_SINKS(PARQ_WR_BM_INOUTS_DEFINE, timestamps, type_group_id::TIMESTAMP); WR_BENCHMARK_DEFINE_ALL_SINKS(PARQ_WR_BM_INOUTS_DEFINE, string, cudf::type_id::STRING); WR_BENCHMARK_DEFINE_ALL_SINKS(PARQ_WR_BM_INOUTS_DEFINE, list, cudf::type_id::LIST); +WR_BENCHMARK_DEFINE_ALL_SINKS(PARQ_WR_BM_INOUTS_DEFINE, struct, cudf::type_id::STRUCT); BENCHMARK_DEFINE_F(ParquetWrite, writer_options) (::benchmark::State& state) { BM_parq_write_varying_options(state); } From faff5de5952d562abdb5b5b050a1b63198a1c417 Mon Sep 17 00:00:00 2001 From: Jim Brennan Date: Tue, 5 Apr 2022 12:00:37 -0500 Subject: [PATCH 037/246] Fix has_atomic_support check in can_use_hash_groupby() (#10588) Closes #10583. Change the has_atomic_support check in can_use_hash_groupby() to check the target type for the aggregation instead of the source type. See discussion in #10583. I have verified that this fixes the performance regression in our customer queries, and all unit tests still pass. Authors: - Jim Brennan (https://github.com/jbrennan333) Approvers: - Jake Hemstad (https://github.com/jrhemstad) - Yunsong Wang (https://github.com/PointKernel) - Nghia Truong (https://github.com/ttnghia) URL: https://github.com/rapidsai/cudf/pull/10588 --- cpp/src/groupby/hash/groupby.cu | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cpp/src/groupby/hash/groupby.cu b/cpp/src/groupby/hash/groupby.cu index 49ed0b7fc1d..44df981f5bf 100644 --- a/cpp/src/groupby/hash/groupby.cu +++ b/cpp/src/groupby/hash/groupby.cu @@ -645,10 +645,14 @@ bool can_use_hash_groupby(table_view const& keys, host_spankind); + std::all_of(r.aggregations.begin(), r.aggregations.end(), [v_type](auto const& a) { + return cudf::has_atomic_support(cudf::detail::target_type(v_type, a->kind)) and + is_hash_aggregation(a->kind); }); }); } From f359ec7f9beacf7b8a34a7e30cca3c35eb82f889 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Tue, 5 Apr 2022 13:57:44 -0400 Subject: [PATCH 038/246] Support nvComp 2.3 if local, otherwise use nvcomp 2.2 (#10513) This will allow us to utilize new features in nvComp 2.3 when it already has been installed locally, otherwise we fallback to building 2.2 from source. Loccal tests with CUDA 11.5 and 11.6 show no regressions Authors: - Robert Maynard (https://github.com/robertmaynard) - Nghia Truong (https://github.com/ttnghia) - Paul Taylor (https://github.com/trxcllnt) Approvers: - Vyas Ramasubramani (https://github.com/vyasr) - Jason Lowe (https://github.com/jlowe) URL: https://github.com/rapidsai/cudf/pull/10513 --- cpp/cmake/thirdparty/get_nvcomp.cmake | 20 +-- .../ai/rapids/cudf/nvcomp/LZ4Compressor.java | 126 ----------------- .../rapids/cudf/nvcomp/LZ4Decompressor.java | 118 ---------------- .../java/ai/rapids/cudf/nvcomp/NvcompJni.java | 96 +------------ java/src/main/native/src/NvcompJni.cpp | 127 +----------------- .../ai/rapids/cudf/nvcomp/NvcompTest.java | 98 +------------- 6 files changed, 13 insertions(+), 572 deletions(-) delete mode 100644 java/src/main/java/ai/rapids/cudf/nvcomp/LZ4Compressor.java delete mode 100644 java/src/main/java/ai/rapids/cudf/nvcomp/LZ4Decompressor.java diff --git a/cpp/cmake/thirdparty/get_nvcomp.cmake b/cpp/cmake/thirdparty/get_nvcomp.cmake index c1765408d62..0356725548b 100644 --- a/cpp/cmake/thirdparty/get_nvcomp.cmake +++ b/cpp/cmake/thirdparty/get_nvcomp.cmake @@ -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. You may obtain a copy of the License at @@ -13,14 +13,15 @@ # ============================================================================= # This function finds nvcomp and sets any additional necessary environment variables. -function(find_and_configure_nvcomp VERSION) - - # Find or install nvcomp +function(find_and_configure_nvcomp VERSION_MIN VERSION_MAX) + # Search for latest version of nvComp + rapids_find_package(nvcomp ${VERSION_MAX} QUIET) + # If latest isn't found, fall back to building oldest support from source rapids_cpm_find( - nvcomp ${VERSION} + nvcomp ${VERSION_MIN} GLOBAL_TARGETS nvcomp::nvcomp CPM_ARGS GITHUB_REPOSITORY NVIDIA/nvcomp - GIT_TAG c435afaf4ba8a8d12f379d688effcb185886cec1 + GIT_TAG v${VERSION_MIN} OPTIONS "BUILD_STATIC ON" "BUILD_TESTS OFF" "BUILD_BENCHMARKS OFF" "BUILD_EXAMPLES OFF" ) @@ -32,9 +33,8 @@ function(find_and_configure_nvcomp VERSION) if(TARGET nvcomp AND PER_THREAD_DEFAULT_STREAM) target_compile_definitions(nvcomp PRIVATE CUDA_API_PER_THREAD_DEFAULT_STREAM) endif() - endfunction() -set(CUDF_MIN_VERSION_nvCOMP 2.1.0) - -find_and_configure_nvcomp(${CUDF_MIN_VERSION_nvCOMP}) +set(CUDF_MIN_VERSION_nvCOMP 2.2.0) +set(CUDF_MAX_VERSION_nvCOMP 2.3.0) +find_and_configure_nvcomp(${CUDF_MIN_VERSION_nvCOMP} ${CUDF_MAX_VERSION_nvCOMP}) diff --git a/java/src/main/java/ai/rapids/cudf/nvcomp/LZ4Compressor.java b/java/src/main/java/ai/rapids/cudf/nvcomp/LZ4Compressor.java deleted file mode 100644 index 67a770f1346..00000000000 --- a/java/src/main/java/ai/rapids/cudf/nvcomp/LZ4Compressor.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (c) 2020-2021, 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. - */ - -package ai.rapids.cudf.nvcomp; - -import ai.rapids.cudf.Cuda; -import ai.rapids.cudf.BaseDeviceMemoryBuffer; -import ai.rapids.cudf.DeviceMemoryBuffer; -import ai.rapids.cudf.HostMemoryBuffer; - -/** Single-buffer compressor implementing LZ4 */ -public class LZ4Compressor { - - /** LZ4 compression settings corresponding to a chunk size */ - public static final class Configuration { - private final long metadataBytes; - private final long tempBytes; - private final long maxCompressedBytes; - - Configuration(long metadataBytes, long tempBytes, long maxCompressedBytes) { - this.metadataBytes = metadataBytes; - this.tempBytes = tempBytes; - this.maxCompressedBytes = maxCompressedBytes; - } - - /** Get the size of the metadata information in bytes */ - public long getMetadataBytes() { - return metadataBytes; - } - - /** Get the size of the temporary storage in bytes needed to compress */ - public long getTempBytes() { - return tempBytes; - } - - /** Get the maximum compressed output size in bytes */ - public long getMaxCompressedBytes() { - return maxCompressedBytes; - } - } - - /** - * Get the compression configuration necessary for a particular chunk size. - * @param chunkSize size of an LZ4 chunk in bytes - * @param uncompressedSize total size of the uncompressed data - * @return compression configuration for the specified chunk size - */ - public static Configuration configure(long chunkSize, long uncompressedSize) { - long[] configs = NvcompJni.lz4CompressConfigure(chunkSize, uncompressedSize); - assert configs.length == 3; - return new Configuration(configs[0], configs[1], configs[2]); - } - - /** - * Synchronously compress a buffer with LZ4. - * @param input buffer to compress - * @param inputType type of data within the buffer - * @param chunkSize compression chunk size to use - * @param tempBuffer temporary storage space - * @param output buffer that will contain the compressed result - * @param stream CUDA stream to use - * @return size of the resulting compressed data stored to the output buffer - */ - public static long compress(BaseDeviceMemoryBuffer input, CompressionType inputType, - long chunkSize, BaseDeviceMemoryBuffer tempBuffer, - BaseDeviceMemoryBuffer output, Cuda.Stream stream) { - if (chunkSize <= 0) { - throw new IllegalArgumentException("Illegal chunk size: " + chunkSize); - } - try (DeviceMemoryBuffer devOutputSizeBuffer = DeviceMemoryBuffer.allocate(Long.BYTES); - HostMemoryBuffer hostOutputSizeBuffer = HostMemoryBuffer.allocate(Long.BYTES)) { - compressAsync(devOutputSizeBuffer, input, inputType, chunkSize, tempBuffer, output, stream); - hostOutputSizeBuffer.copyFromDeviceBuffer(devOutputSizeBuffer, stream); - return hostOutputSizeBuffer.getLong(0); - } - } - - /** - * Asynchronously compress a buffer with LZ4. The compressed size output buffer must be pinned - * memory for this operation to be truly asynchronous. Note that the caller must synchronize - * on the specified CUDA stream in order to safely examine the compressed output size! - * @param compressedSizeOutputBuffer device memory where the compressed output size will be stored - * @param input buffer to compress - * @param inputType type of data within the buffer - * @param chunkSize compression chunk size to use - * @param tempBuffer temporary storage space - * @param output buffer that will contain the compressed result - * @param stream CUDA stream to use - */ - public static void compressAsync(DeviceMemoryBuffer compressedSizeOutputBuffer, - BaseDeviceMemoryBuffer input, CompressionType inputType, - long chunkSize, BaseDeviceMemoryBuffer tempBuffer, - BaseDeviceMemoryBuffer output, Cuda.Stream stream) { - if (chunkSize <= 0) { - throw new IllegalArgumentException("Illegal chunk size: " + chunkSize); - } - if (compressedSizeOutputBuffer.getLength() < 8) { - throw new IllegalArgumentException("compressed output size buffer must be able to hold " + - "at least 8 bytes, size is only " + compressedSizeOutputBuffer.getLength()); - } - NvcompJni.lz4CompressAsync( - compressedSizeOutputBuffer.getAddress(), - input.getAddress(), - input.getLength(), - inputType.nativeId, - chunkSize, - tempBuffer.getAddress(), - tempBuffer.getLength(), - output.getAddress(), - output.getLength(), - stream.getStream()); - } -} diff --git a/java/src/main/java/ai/rapids/cudf/nvcomp/LZ4Decompressor.java b/java/src/main/java/ai/rapids/cudf/nvcomp/LZ4Decompressor.java deleted file mode 100644 index 46b3127581b..00000000000 --- a/java/src/main/java/ai/rapids/cudf/nvcomp/LZ4Decompressor.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) 2021, 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. - */ - -package ai.rapids.cudf.nvcomp; - -import ai.rapids.cudf.BaseDeviceMemoryBuffer; -import ai.rapids.cudf.Cuda; - -/** Single-buffer decompression using LZ4 */ -public class LZ4Decompressor { - - /** - * LZ4 decompression settings corresponding to an LZ4 compressed input. - * NOTE: Each instance must be closed to avoid a native memory leak. - */ - public static final class Configuration implements AutoCloseable { - private final long metadataPtr; - private final long metadataSize; - private final long tempBytes; - private final long uncompressedBytes; - - Configuration(long metadataPtr, long metadataSize, long tempBytes, - long uncompressedBytes) { - this.metadataPtr = metadataPtr; - this.metadataSize = metadataSize; - this.tempBytes = tempBytes; - this.uncompressedBytes = uncompressedBytes; - } - - /** Get the host address of the metadata */ - public long getMetadataPtr() { - return metadataPtr; - } - - /** Get the size of the metadata in bytes */ - public long getMetadataSize() { - return metadataSize; - } - - /** Get the size of the temporary buffer in bytes needed to decompress */ - public long getTempBytes() { - return tempBytes; - } - - /** Get the size of the uncompressed data in bytes */ - public long getUncompressedBytes() { - return uncompressedBytes; - } - - @Override - public void close() { - NvcompJni.lz4DestroyMetadata(metadataPtr); - } - } - - /** - * Determine if a buffer is data compressed with LZ4. - * @param buffer data to examine - * @param stream CUDA stream to use - * @return true if the data is LZ4 compressed - */ - public static boolean isLZ4Data(BaseDeviceMemoryBuffer buffer, Cuda.Stream stream) { - return NvcompJni.isLZ4Data(buffer.getAddress(), buffer.getLength(), stream.getStream()); - } - - /** - * Get the decompression configuration from compressed data. - * NOTE: The resulting configuration object must be closed to avoid a native memory leak. - * @param compressed data that has been compressed by the LZ4 compressor - * @param stream CUDA stream to use - * @return decompression configuration for the specified input - */ - public static Configuration configure(BaseDeviceMemoryBuffer compressed, Cuda.Stream stream) { - long[] configs = NvcompJni.lz4DecompressConfigure(compressed.getAddress(), - compressed.getLength(), stream.getStream()); - assert configs.length == 4; - return new Configuration(configs[0], configs[1], configs[2], configs[3]); - } - - /** - * Asynchronously decompress data compressed with the LZ4 compressor. - * @param compressed buffer containing LZ4-compressed data - * @param config decompression configuration - * @param temp temporary storage buffer - * @param outputBuffer buffer that will be written with the uncompressed output - * @param stream CUDA stream to use - */ - public static void decompressAsync( - BaseDeviceMemoryBuffer compressed, - Configuration config, - BaseDeviceMemoryBuffer temp, - BaseDeviceMemoryBuffer outputBuffer, - Cuda.Stream stream) { - NvcompJni.lz4DecompressAsync( - compressed.getAddress(), - compressed.getLength(), - config.getMetadataPtr(), - config.getMetadataSize(), - temp.getAddress(), - temp.getLength(), - outputBuffer.getAddress(), - outputBuffer.getLength(), - stream.getStream()); - } -} diff --git a/java/src/main/java/ai/rapids/cudf/nvcomp/NvcompJni.java b/java/src/main/java/ai/rapids/cudf/nvcomp/NvcompJni.java index 58f8390d0eb..57094008c08 100644 --- a/java/src/main/java/ai/rapids/cudf/nvcomp/NvcompJni.java +++ b/java/src/main/java/ai/rapids/cudf/nvcomp/NvcompJni.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -24,100 +24,6 @@ class NvcompJni { NativeDepsLoader.loadNativeDeps(); } - /** - * Determine if data is compressed with the nvcomp LZ4 compressor. - * @param inPtr device address of the compressed data - * @param inSize size of the compressed data in bytes - * @param stream CUDA stream to use - * @return true if the data is compressed with the nvcomp LZ4 compressor - */ - static native boolean isLZ4Data(long inPtr, long inSize, long stream); - - /** - * Determine if the metadata corresponds to data compressed with the nvcomp LZ4 compressor. - * @param metadataPtr address of the metadata object - * @return true if the metadata describes data compressed with the nvcomp LZ4 compressor. - */ - static native boolean isLZ4Metadata(long metadataPtr); - - /** - * Return the LZ4 compression configuration necessary for a particular chunk size. - * @param chunkSize maximum size of an uncompressed chunk in bytes - * @param uncompressedSize total size of the uncompressed data - * @return array of three longs containing metadata size, temp storage size, - * and output buffer size - */ - static native long[] lz4CompressConfigure(long chunkSize, long uncompressedSize); - - /** - * Perform LZ4 compression asynchronously using the specified CUDA stream. - * @param compressedSizeOutputPtr host address of a 64-bit integer to update - * with the resulting compressed size of the - * data. For the operation to be truly - * asynchronous this should point to pinned - * host memory. - * @param inPtr device address of the uncompressed data - * @param inSize size of the uncompressed data in bytes - * @param inputType type of uncompressed data - * @param chunkSize size of an LZ4 chunk in bytes - * @param tempPtr device address of the temporary compression storage buffer - * @param tempSize size of the temporary storage buffer in bytes - * @param outPtr device address of the output buffer - * @param outSize size of the output buffer in bytes - * @param stream CUDA stream to use - */ - static native void lz4CompressAsync( - long compressedSizeOutputPtr, - long inPtr, - long inSize, - int inputType, - long chunkSize, - long tempPtr, - long tempSize, - long outPtr, - long outSize, - long stream); - - /** - * Return the decompression configuration for a compressed input. - * NOTE: The resulting configuration object must be closed to destroy the corresponding - * host-side metadata created by this method to avoid a native memory leak. - * @param inPtr device address of the compressed data - * @param inSize size of the compressed data - * @return array of four longs containing metadata address, metadata size, temp storage size, - * and output buffer size - */ - static native long[] lz4DecompressConfigure(long inPtr, long inSize, long stream); - - /** - * Perform LZ4 decompression asynchronously using the specified CUDA stream. - * @param inPtr device address of the uncompressed data - * @param inSize size of the uncompressed data in bytes - * @param metadataPtr host address of the metadata - * @param metadataSize size of the metadata in bytes - * @param tempPtr device address of the temporary compression storage buffer - * @param tempSize size of the temporary storage buffer in bytes - * @param outPtr device address of the output buffer - * @param outSize size of the output buffer in bytes - * @param stream CUDA stream to use - */ - static native void lz4DecompressAsync( - long inPtr, - long inSize, - long metadataPtr, - long metadataSize, - long tempPtr, - long tempSize, - long outPtr, - long outSize, - long stream); - - /** - * Destroy host-side metadata created by {@link NvcompJni#lz4DecompressConfigure(long, long, long)} - * @param metadataPtr host address of metadata - */ - static native void lz4DestroyMetadata(long metadataPtr); - /** * Get the temporary workspace size required to perform compression of entire LZ4 batch. * @param batchSize number of chunks in the batch diff --git a/java/src/main/native/src/NvcompJni.cpp b/java/src/main/native/src/NvcompJni.cpp index 533654baee1..e616b7f66be 100644 --- a/java/src/main/native/src/NvcompJni.cpp +++ b/java/src/main/native/src/NvcompJni.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -56,131 +56,6 @@ void check_nvcomp_status(JNIEnv *env, nvcompStatus_t status) { extern "C" { -JNIEXPORT jboolean JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_isLZ4Data(JNIEnv *env, jclass, - jlong j_in_ptr, - jlong j_in_size, - jlong j_stream) { - try { - cudf::jni::auto_set_device(env); - auto in_ptr = reinterpret_cast(j_in_ptr); - auto in_size = static_cast(j_in_size); - auto stream = reinterpret_cast(j_stream); - return nvcompLZ4IsData(in_ptr, in_size, stream); - } - CATCH_STD(env, 0) -} - -JNIEXPORT jboolean JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_isLZ4Metadata(JNIEnv *env, jclass, - jlong metadata_ptr) { - try { - cudf::jni::auto_set_device(env); - return nvcompLZ4IsMetadata(reinterpret_cast(metadata_ptr)); - } - CATCH_STD(env, 0) -} - -JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_lz4CompressConfigure( - JNIEnv *env, jclass, jlong j_chunk_size, jlong j_uncompressed_size) { - try { - cudf::jni::auto_set_device(env); - nvcompLZ4FormatOpts opts{}; - opts.chunk_size = static_cast(j_chunk_size); - auto uncompressed_size = static_cast(j_uncompressed_size); - std::size_t metadata_bytes = 0; - std::size_t temp_bytes = 0; - std::size_t out_bytes = 0; - auto status = nvcompLZ4CompressConfigure(&opts, NVCOMP_TYPE_CHAR, uncompressed_size, - &metadata_bytes, &temp_bytes, &out_bytes); - check_nvcomp_status(env, status); - cudf::jni::native_jlongArray result(env, 3); - result[0] = static_cast(metadata_bytes); - result[1] = static_cast(temp_bytes); - result[2] = static_cast(out_bytes); - return result.get_jArray(); - } - CATCH_STD(env, 0); -} - -JNIEXPORT void JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_lz4CompressAsync( - JNIEnv *env, jclass, jlong j_compressed_size_ptr, jlong j_in_ptr, jlong j_in_size, - jint j_input_type, jlong j_chunk_size, jlong j_temp_ptr, jlong j_temp_size, jlong j_out_ptr, - jlong j_out_size, jlong j_stream) { - try { - cudf::jni::auto_set_device(env); - auto in_ptr = reinterpret_cast(j_in_ptr); - auto in_size = static_cast(j_in_size); - auto comp_type = static_cast(j_input_type); - nvcompLZ4FormatOpts opts{}; - opts.chunk_size = static_cast(j_chunk_size); - auto temp_ptr = reinterpret_cast(j_temp_ptr); - auto temp_size = static_cast(j_temp_size); - auto out_ptr = reinterpret_cast(j_out_ptr); - auto compressed_size_ptr = reinterpret_cast(j_compressed_size_ptr); - auto stream = reinterpret_cast(j_stream); - auto status = nvcompLZ4CompressAsync(&opts, comp_type, in_ptr, in_size, temp_ptr, temp_size, - out_ptr, compressed_size_ptr, stream); - check_nvcomp_status(env, status); - } - CATCH_STD(env, ); -} - -JNIEXPORT jlongArray JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_lz4DecompressConfigure( - JNIEnv *env, jclass, jlong j_input_ptr, jlong j_input_size, jlong j_stream) { - try { - cudf::jni::auto_set_device(env); - auto compressed_ptr = reinterpret_cast(j_input_ptr); - auto compressed_bytes = static_cast(j_input_size); - void *metadata_ptr = nullptr; - std::size_t metadata_bytes = 0; - std::size_t temp_bytes = 0; - std::size_t uncompressed_bytes = 0; - auto stream = reinterpret_cast(j_stream); - auto status = - nvcompLZ4DecompressConfigure(compressed_ptr, compressed_bytes, &metadata_ptr, - &metadata_bytes, &temp_bytes, &uncompressed_bytes, stream); - check_nvcomp_status(env, status); - cudf::jni::native_jlongArray result(env, 4); - result[0] = reinterpret_cast(metadata_ptr); - result[1] = static_cast(metadata_bytes); - result[2] = static_cast(temp_bytes); - result[3] = static_cast(uncompressed_bytes); - return result.get_jArray(); - } - CATCH_STD(env, 0); -} - -JNIEXPORT void JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_lz4DecompressAsync( - JNIEnv *env, jclass, jlong j_in_ptr, jlong j_in_size, jlong j_metadata_ptr, - jlong j_metadata_size, jlong j_temp_ptr, jlong j_temp_size, jlong j_out_ptr, jlong j_out_size, - jlong j_stream) { - try { - cudf::jni::auto_set_device(env); - auto compressed_ptr = reinterpret_cast(j_in_ptr); - auto compressed_bytes = static_cast(j_in_size); - auto metadata_ptr = reinterpret_cast(j_metadata_ptr); - auto metadata_bytes = static_cast(j_metadata_size); - auto temp_ptr = reinterpret_cast(j_temp_ptr); - auto temp_bytes = static_cast(j_temp_size); - auto uncompressed_ptr = reinterpret_cast(j_out_ptr); - auto uncompressed_bytes = static_cast(j_out_size); - auto stream = reinterpret_cast(j_stream); - auto status = nvcompLZ4DecompressAsync(compressed_ptr, compressed_bytes, metadata_ptr, - metadata_bytes, temp_ptr, temp_bytes, uncompressed_ptr, - uncompressed_bytes, stream); - check_nvcomp_status(env, status); - } - CATCH_STD(env, ); -} - -JNIEXPORT void JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_lz4DestroyMetadata(JNIEnv *env, jclass, - jlong metadata_ptr) { - try { - cudf::jni::auto_set_device(env); - nvcompLZ4DestroyMetadata(reinterpret_cast(metadata_ptr)); - } - CATCH_STD(env, ); -} - JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_nvcomp_NvcompJni_batchedLZ4CompressGetTempSize( JNIEnv *env, jclass, jlong j_batch_size, jlong j_max_chunk_size) { try { diff --git a/java/src/test/java/ai/rapids/cudf/nvcomp/NvcompTest.java b/java/src/test/java/ai/rapids/cudf/nvcomp/NvcompTest.java index c36d241500a..ec14a1cfee6 100644 --- a/java/src/test/java/ai/rapids/cudf/nvcomp/NvcompTest.java +++ b/java/src/test/java/ai/rapids/cudf/nvcomp/NvcompTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -28,16 +28,6 @@ public class NvcompTest { private static final Logger log = LoggerFactory.getLogger(ColumnVector.class); - @Test - void testLZ4RoundTripViaLZ4DecompressorSync() { - lz4RoundTrip(false); - } - - @Test - void testLZ4RoundTripViaLZ4DecompressorAsync() { - lz4RoundTrip(true); - } - @Test void testBatchedLZ4RoundTripAsync() { final Cuda.Stream stream = Cuda.DEFAULT_STREAM; @@ -134,90 +124,4 @@ private DeviceMemoryBuffer initBatchBuffer(long[] data, int bufferId) { throw new RuntimeException(t); } } - - private void lz4RoundTrip(boolean useAsync) { - final Cuda.Stream stream = Cuda.DEFAULT_STREAM; - final long chunkSize = 64 * 1024; - final int numElements = 10 * 1024 * 1024 + 1; - long[] data = new long[numElements]; - for (int i = 0; i < numElements; ++i) { - data[i] = i; - } - - DeviceMemoryBuffer tempBuffer = null; - DeviceMemoryBuffer compressedBuffer = null; - DeviceMemoryBuffer uncompressedBuffer = null; - try (ColumnVector v = ColumnVector.fromLongs(data)) { - BaseDeviceMemoryBuffer inputBuffer = v.getDeviceBufferFor(BufferType.DATA); - final long uncompressedSize = inputBuffer.getLength(); - log.debug("Uncompressed size is {}", uncompressedSize); - - LZ4Compressor.Configuration compressConf = - LZ4Compressor.configure(chunkSize, uncompressedSize); - Assertions.assertTrue(compressConf.getMetadataBytes() > 0); - log.debug("Using {} temporary space for lz4 compression", compressConf.getTempBytes()); - tempBuffer = DeviceMemoryBuffer.allocate(compressConf.getTempBytes()); - log.debug("lz4 compressed size estimate is {}", compressConf.getMaxCompressedBytes()); - - compressedBuffer = DeviceMemoryBuffer.allocate(compressConf.getMaxCompressedBytes()); - - long startTime = System.nanoTime(); - long compressedSize; - if (useAsync) { - try (DeviceMemoryBuffer devCompressedSizeBuffer = DeviceMemoryBuffer.allocate(8); - HostMemoryBuffer hostCompressedSizeBuffer = HostMemoryBuffer.allocate(8)) { - LZ4Compressor.compressAsync(devCompressedSizeBuffer, inputBuffer, CompressionType.CHAR, - chunkSize, tempBuffer, compressedBuffer, stream); - hostCompressedSizeBuffer.copyFromDeviceBufferAsync(devCompressedSizeBuffer, stream); - stream.sync(); - compressedSize = hostCompressedSizeBuffer.getLong(0); - } - } else { - compressedSize = LZ4Compressor.compress(inputBuffer, CompressionType.CHAR, chunkSize, - tempBuffer, compressedBuffer, stream); - } - double duration = (System.nanoTime() - startTime) / 1000.0; - log.info("Compressed with lz4 to {} in {} us", compressedSize, duration); - - tempBuffer.close(); - tempBuffer = null; - - try (LZ4Decompressor.Configuration decompressConf = - LZ4Decompressor.configure(compressedBuffer, stream)) { - final long tempSize = decompressConf.getTempBytes(); - - log.debug("Using {} temporary space for lz4 compression", tempSize); - tempBuffer = DeviceMemoryBuffer.allocate(tempSize); - - final long outSize = decompressConf.getUncompressedBytes(); - Assertions.assertEquals(inputBuffer.getLength(), outSize); - - uncompressedBuffer = DeviceMemoryBuffer.allocate(outSize); - - LZ4Decompressor.decompressAsync(compressedBuffer, decompressConf, tempBuffer, - uncompressedBuffer, stream); - - try (ColumnVector v2 = new ColumnVector( - DType.INT64, - numElements, - Optional.empty(), - uncompressedBuffer, - null, - null); - HostColumnVector hv2 = v2.copyToHost()) { - uncompressedBuffer = null; - for (int i = 0; i < numElements; ++i) { - long val = hv2.getLong(i); - if (val != i) { - Assertions.fail("Expected " + i + " at " + i + " found " + val); - } - } - } - } - } finally { - closeBuffer(tempBuffer); - closeBuffer(compressedBuffer); - closeBuffer(uncompressedBuffer); - } - } } From 5f4f232e325343c2e4e7f0c79cd034f091b9817f Mon Sep 17 00:00:00 2001 From: Paul Taylor Date: Tue, 5 Apr 2022 15:15:01 -0700 Subject: [PATCH 039/246] Enable building static libs (#10545) This PR tracks private dependencies in the build and install export sets when building static libs. This is necessary for consumers to statically link `libcudf.a` via CMake. Authors: - Paul Taylor (https://github.com/trxcllnt) Approvers: - Mark Harris (https://github.com/harrism) - Robert Maynard (https://github.com/robertmaynard) URL: https://github.com/rapidsai/cudf/pull/10545 --- cpp/CMakeLists.txt | 15 +++++++++++++++ cpp/cmake/thirdparty/get_cucollections.cmake | 7 +++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 9936db5b2fa..d9422edaa8f 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -156,6 +156,21 @@ include(cmake/Modules/JitifyPreprocessKernels.cmake) # find cuFile include(cmake/Modules/FindcuFile.cmake) +# Workaround until https://github.com/rapidsai/rapids-cmake/issues/176 is resolved +if(NOT BUILD_SHARED_LIBS) + include("${rapids-cmake-dir}/export/find_package_file.cmake") + list(APPEND METADATA_KINDS BUILD INSTALL) + foreach(METADATA_KIND IN LISTS METADATA_KINDS) + rapids_export_find_package_file( + ${METADATA_KIND} "${CUDF_SOURCE_DIR}/cmake/Modules/FindcuFile.cmake" cudf-exports + ) + rapids_export_package(${METADATA_KIND} cuco cudf-exports) + rapids_export_package(${METADATA_KIND} ZLIB cudf-exports) + rapids_export_package(${METADATA_KIND} cuFile cudf-exports) + rapids_export_package(${METADATA_KIND} nvcomp cudf-exports) + endforeach() +endif() + # ################################################################################################## # * library targets ------------------------------------------------------------------------------- diff --git a/cpp/cmake/thirdparty/get_cucollections.cmake b/cpp/cmake/thirdparty/get_cucollections.cmake index 5a20f78b798..1639655d1e9 100644 --- a/cpp/cmake/thirdparty/get_cucollections.cmake +++ b/cpp/cmake/thirdparty/get_cucollections.cmake @@ -18,10 +18,13 @@ function(find_and_configure_cucollections) # Find or install cuCollections rapids_cpm_find( # cuCollections doesn't have a version yet - cuco 0.0 + cuco 0.0.1 GLOBAL_TARGETS cuco::cuco + BUILD_EXPORT_SET cudf-exports + INSTALL_EXPORT_SET cudf-exports CPM_ARGS GITHUB_REPOSITORY NVIDIA/cuCollections - GIT_TAG 6ec8b6dcdeceea07ab4456d32461a05c18864411 + GIT_TAG fb58a38701f1c24ecfe07d8f1f208bbe80930da5 + EXCLUDE_FROM_ALL ${BUILD_SHARED_LIBS} OPTIONS "BUILD_TESTS OFF" "BUILD_BENCHMARKS OFF" "BUILD_EXAMPLES OFF" ) From 956c7b5f56ddb6c3ed3119572db77fa38ae13f42 Mon Sep 17 00:00:00 2001 From: David Wendt <45795991+davidwendt@users.noreply.github.com> Date: Tue, 5 Apr 2022 23:41:02 -0400 Subject: [PATCH 040/246] Fix strings strip() to accept only str Scalar for to_strip parameter (#10597) Closes #10591 Ensures `to_strip` parameter is a `str` type when converting it to `cudf.Scalar`. It will now through a `TypeError` as follows ``` libstrings.strip(self._column, cudf.Scalar(to_strip, "str")) File "/conda/envs/rapids/lib/python3.8/site-packages/cudf-22.6.0a0+96.g0aef0c1c3e.dirty-py3.8-linux-x86_64.egg/cudf/core/scalar.py", line 78, in __init__ self._host_value, self._host_dtype = self._preprocess_host_value( File "/conda/envs/rapids/lib/python3.8/site-packages/cudf-22.6.0a0+96.g0aef0c1c3e.dirty-py3.8-linux-x86_64.egg/cudf/core/scalar.py", line 128, in _preprocess_host_value raise TypeError("Lists may not be cast to a different dtype") TypeError: Lists may not be cast to a different dtype ``` This will also prevent the _sticky_ CUDA error. Also, added the `str` parameter to other `cudf.Scalar` calls where only strings are supported as well. Authors: - David Wendt (https://github.com/davidwendt) Approvers: - Ashwin Srinath (https://github.com/shwina) - GALI PREM SAGAR (https://github.com/galipremsagar) URL: https://github.com/rapidsai/cudf/pull/10597 --- python/cudf/cudf/core/column/string.py | 22 +++++++++-------- python/cudf/cudf/tests/test_string.py | 33 ++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 10 deletions(-) diff --git a/python/cudf/cudf/core/column/string.py b/python/cudf/cudf/core/column/string.py index ef8e9c4dffc..d5d45c341d5 100644 --- a/python/cudf/cudf/core/column/string.py +++ b/python/cudf/cudf/core/column/string.py @@ -2006,7 +2006,9 @@ def filter_alphanum( repl = "" return self._return_or_inplace( - libstrings.filter_alphanum(self._column, cudf.Scalar(repl), keep), + libstrings.filter_alphanum( + self._column, cudf.Scalar(repl, "str"), keep + ), ) def slice_from( @@ -2141,7 +2143,7 @@ def slice_replace( return self._return_or_inplace( libstrings.slice_replace( - self._column, start, stop, cudf.Scalar(repl) + self._column, start, stop, cudf.Scalar(repl, "str") ), ) @@ -2192,7 +2194,7 @@ def insert(self, start: int = 0, repl: str = None) -> SeriesOrIndex: repl = "" return self._return_or_inplace( - libstrings.insert(self._column, start, cudf.Scalar(repl)), + libstrings.insert(self._column, start, cudf.Scalar(repl, "str")), ) def get(self, i: int = 0) -> SeriesOrIndex: @@ -2643,7 +2645,7 @@ def rsplit( ) else: result_table = libstrings.rsplit_record( - self._column, cudf.Scalar(pat), n + self._column, cudf.Scalar(pat, "str"), n ) return self._return_or_inplace(result_table, expand=expand) @@ -2726,7 +2728,7 @@ def partition(self, sep: str = " ", expand: bool = True) -> SeriesOrIndex: return self._return_or_inplace( cudf.core.frame.Frame( - *libstrings.partition(self._column, cudf.Scalar(sep)) + *libstrings.partition(self._column, cudf.Scalar(sep, "str")) ), expand=expand, ) @@ -2793,7 +2795,7 @@ def rpartition(self, sep: str = " ", expand: bool = True) -> SeriesOrIndex: return self._return_or_inplace( cudf.core.frame.Frame( - *libstrings.rpartition(self._column, cudf.Scalar(sep)) + *libstrings.rpartition(self._column, cudf.Scalar(sep, "str")) ), expand=expand, ) @@ -3194,7 +3196,7 @@ def strip(self, to_strip: str = None) -> SeriesOrIndex: to_strip = "" return self._return_or_inplace( - libstrings.strip(self._column, cudf.Scalar(to_strip)) + libstrings.strip(self._column, cudf.Scalar(to_strip, "str")) ) def lstrip(self, to_strip: str = None) -> SeriesOrIndex: @@ -3241,7 +3243,7 @@ def lstrip(self, to_strip: str = None) -> SeriesOrIndex: to_strip = "" return self._return_or_inplace( - libstrings.lstrip(self._column, cudf.Scalar(to_strip)) + libstrings.lstrip(self._column, cudf.Scalar(to_strip, "str")) ) def rstrip(self, to_strip: str = None) -> SeriesOrIndex: @@ -3296,7 +3298,7 @@ def rstrip(self, to_strip: str = None) -> SeriesOrIndex: to_strip = "" return self._return_or_inplace( - libstrings.rstrip(self._column, cudf.Scalar(to_strip)) + libstrings.rstrip(self._column, cudf.Scalar(to_strip, "str")) ) def wrap(self, width: int, **kwargs) -> SeriesOrIndex: @@ -4245,7 +4247,7 @@ def filter_characters( table = str.maketrans(table) return self._return_or_inplace( libstrings.filter_characters( - self._column, table, keep, cudf.Scalar(repl) + self._column, table, keep, cudf.Scalar(repl, "str") ), ) diff --git a/python/cudf/cudf/tests/test_string.py b/python/cudf/cudf/tests/test_string.py index 493098cd494..d600fdeee27 100644 --- a/python/cudf/cudf/tests/test_string.py +++ b/python/cudf/cudf/tests/test_string.py @@ -1299,6 +1299,12 @@ def test_string_slice_replace(string, number, diff, repr): ) +def test_string_slice_replace_fail(): + gs = cudf.Series(["abc", "xyz", ""]) + with pytest.raises(TypeError): + gs.str.slice_replace(0, 1, ["_"]) + + def test_string_insert(): gs = cudf.Series(["hello world", "holy accéntéd", "batman", None, ""]) @@ -1312,6 +1318,9 @@ def test_string_insert(): ps.str.slice(stop=5) + "---" + ps.str.slice(start=5), ) + with pytest.raises(TypeError): + gs.str.insert(0, ["+"]) + _string_char_types_data = [ ["abc", "xyz", "a", "ab", "123", "097"], @@ -1404,6 +1413,9 @@ def test_string_filter_alphanum(): expected.append(rs) assert_eq(gs.str.filter_alphanum("*", keep=False), cudf.Series(expected)) + with pytest.raises(TypeError): + gs.str.filter_alphanum(["a"]) + @pytest.mark.parametrize( "case_op", ["title", "capitalize", "lower", "upper", "swapcase"] @@ -1504,6 +1516,14 @@ def test_strings_partition(data): assert_eq(pi.str.partition("-"), gi.str.partition("-")) +def test_string_partition_fail(): + gs = cudf.Series(["abc", "aa", "cba"]) + with pytest.raises(TypeError): + gs.str.partition(["a"]) + with pytest.raises(TypeError): + gs.str.rpartition(["a"]) + + @pytest.mark.parametrize( "data", [ @@ -1640,6 +1660,16 @@ def test_strings_strip_tests(data, to_strip): ) +def test_string_strip_fail(): + gs = cudf.Series(["a", "aa", ""]) + with pytest.raises(TypeError): + gs.str.strip(["a"]) + with pytest.raises(TypeError): + gs.str.lstrip(["a"]) + with pytest.raises(TypeError): + gs.str.rstrip(["a"]) + + @pytest.mark.parametrize( "data", [ @@ -2364,6 +2394,9 @@ def test_string_str_filter_characters(): ) assert_eq(expected, gs.str.filter_characters(filter, True, " ")) + with pytest.raises(TypeError): + gs.str.filter_characters(filter, True, ["a"]) + def test_string_str_code_points(): From 261879f87fb81c8fea272f9f824eb26da46c51fe Mon Sep 17 00:00:00 2001 From: Ashwin Srinath <3190405+shwina@users.noreply.github.com> Date: Wed, 6 Apr 2022 13:54:21 -0400 Subject: [PATCH 041/246] Add default= kwarg to .list.get() accessor method (#10547) Closes #10540. As mentioned in the issue, this is a breaking change, although we could introduce this change in a non-breaking way by using a sentinel value for the kwarg if desired. Authors: - Ashwin Srinath (https://github.com/shwina) Approvers: - Ram (Ramakrishna Prabhu) (https://github.com/rgsl888prabhu) - Bradley Dice (https://github.com/bdice) - GALI PREM SAGAR (https://github.com/galipremsagar) URL: https://github.com/rapidsai/cudf/pull/10547 --- python/cudf/cudf/core/column/lists.py | 49 ++++++++++++++----- python/cudf/cudf/tests/test_list.py | 30 ++++++++++-- .../dask_cudf/tests/test_accessor.py | 2 +- 3 files changed, 65 insertions(+), 16 deletions(-) diff --git a/python/cudf/cudf/core/column/lists.py b/python/cudf/cudf/core/column/lists.py index 60d13150b39..3f8c8997803 100644 --- a/python/cudf/cudf/core/column/lists.py +++ b/python/cudf/cudf/core/column/lists.py @@ -2,7 +2,7 @@ import pickle from functools import cached_property -from typing import List, Sequence +from typing import List, Optional, Sequence import numpy as np import pyarrow as pa @@ -337,16 +337,20 @@ def __init__(self, parent: ParentType): ) super().__init__(parent=parent) - def get(self, index: int) -> ParentType: + def get( + self, index: int, default: Optional[ScalarLike] = None + ) -> ParentType: """ - Extract element at the given index from each component + Extract element at the given index from each list. - Extract element from lists, tuples, or strings in - each element in the Series/Index. + If the index is out of bounds for any list, + return or, if provided, ``default``. + Thus, this method never raises an ``IndexError``. Parameters ---------- index : int + default : scalar, optional Returns ------- @@ -360,14 +364,37 @@ def get(self, index: int) -> ParentType: 1 5 2 6 dtype: int64 + + >>> s = cudf.Series([[1, 2], [3, 4, 5], [4, 5, 6]]) + >>> s.list.get(2) + 0 + 1 5 + 2 6 + dtype: int64 + + >>> s = cudf.Series([[1, 2], [3, 4, 5], [4, 5, 6]]) + >>> s.list.get(2, default=0) + 0 0 + 1 5 + 2 6 + dtype: int64 """ - min_col_list_len = self.len().min() - if -min_col_list_len <= index < min_col_list_len: - return self._return_or_inplace( - extract_element(self._column, index) + out = extract_element(self._column, index) + + if not (default is None or default is cudf.NA): + # determine rows for which `index` is out-of-bounds + lengths = count_elements(self._column) + out_of_bounds_mask = (np.negative(index) > lengths) | ( + index >= lengths ) - else: - raise IndexError("list index out of range") + + # replace the value in those rows (should be NA) with `default` + if out_of_bounds_mask.any(): + out = out._scatter_by_column( + out_of_bounds_mask, cudf.Scalar(default) + ) + + return self._return_or_inplace(out) def contains(self, search_key: ScalarLike) -> ParentType: """ diff --git a/python/cudf/cudf/tests/test_list.py b/python/cudf/cudf/tests/test_list.py index 6a665a2b43c..dc624ebe2b5 100644 --- a/python/cudf/cudf/tests/test_list.py +++ b/python/cudf/cudf/tests/test_list.py @@ -292,10 +292,32 @@ def test_get_nested_lists(): assert_eq(expect, got) -def test_get_nulls(): - with pytest.raises(IndexError, match="list index out of range"): - sr = cudf.Series([[], [], []]) - sr.list.get(100) +def test_get_default(): + sr = cudf.Series([[1, 2], [3, 4, 5], [6, 7, 8, 9]]) + + assert_eq(cudf.Series([cudf.NA, 5, 8]), sr.list.get(2)) + assert_eq(cudf.Series([cudf.NA, 5, 8]), sr.list.get(2, default=cudf.NA)) + assert_eq(cudf.Series([0, 5, 8]), sr.list.get(2, default=0)) + assert_eq(cudf.Series([0, 3, 7]), sr.list.get(-3, default=0)) + assert_eq(cudf.Series([2, 5, 9]), sr.list.get(-1)) + + string_sr = cudf.Series( + [["apple", "banana"], ["carrot", "daffodil", "elephant"]] + ) + assert_eq( + cudf.Series(["default", "elephant"]), + string_sr.list.get(2, default="default"), + ) + + sr_with_null = cudf.Series([[0, cudf.NA], [1]]) + assert_eq(cudf.Series([cudf.NA, 0]), sr_with_null.list.get(1, default=0)) + + sr_nested = cudf.Series([[[1, 2], [3, 4], [5, 6]], [[5, 6], [7, 8]]]) + assert_eq(cudf.Series([[3, 4], [7, 8]]), sr_nested.list.get(1)) + assert_eq(cudf.Series([[5, 6], cudf.NA]), sr_nested.list.get(2)) + assert_eq( + cudf.Series([[5, 6], [0, 0]]), sr_nested.list.get(2, default=[0, 0]) + ) @pytest.mark.parametrize( diff --git a/python/dask_cudf/dask_cudf/tests/test_accessor.py b/python/dask_cudf/dask_cudf/tests/test_accessor.py index 84c0e0e9b39..95cf0c8d56d 100644 --- a/python/dask_cudf/dask_cudf/tests/test_accessor.py +++ b/python/dask_cudf/dask_cudf/tests/test_accessor.py @@ -384,7 +384,7 @@ def test_contains(data, search_key): "data, index, expectation", [ (data_test_1(), 1, does_not_raise()), - (data_test_2(), 2, pytest.raises(IndexError)), + (data_test_2(), 2, does_not_raise()), ], ) def test_get(data, index, expectation): From fb03c8bc91e6a9de0605ff727da45e183f0fd5b5 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Wed, 6 Apr 2022 14:51:52 -0700 Subject: [PATCH 042/246] Move binop methods from Frame to IndexedFrame and standardize the docstring (#10576) This PR moves all the binary operation methods such as `Frame.add` into `IndexedFrame`. This removes these methods from `Index` objects to match pandas, where Index objects do not have these methods. I have also consolidated the docstrings for these methods using a single template and our `docutils`. Note that this is technically a breaking change that I am implementing without a deprecation cycle; however, I feel comfortable doing so because these methods were introduced incidentally in #9357 and #9542 into 21.12, so just a couple of releases ago, and since they are not pandas APIs I doubt that they have made significant penetration into user workflows. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - GALI PREM SAGAR (https://github.com/galipremsagar) URL: https://github.com/rapidsai/cudf/pull/10576 --- python/cudf/cudf/core/dataframe.py | 2 +- python/cudf/cudf/core/frame.py | 1617 ------------------------ python/cudf/cudf/core/indexed_frame.py | 890 +++++++++++++ python/cudf/cudf/core/series.py | 3 +- 4 files changed, 892 insertions(+), 1620 deletions(-) diff --git a/python/cudf/cudf/core/dataframe.py b/python/cudf/cudf/core/dataframe.py index 08a30729e7c..1b85769b84d 100644 --- a/python/cudf/cudf/core/dataframe.py +++ b/python/cudf/cudf/core/dataframe.py @@ -6126,7 +6126,7 @@ def make_binop_func(op, postprocess=None): # def postprocess(left, right, output) # where left and right are the inputs to the binop and output is the result # of calling the wrapped Frame binop. - wrapped_func = getattr(Frame, op) + wrapped_func = getattr(IndexedFrame, op) @functools.wraps(wrapped_func) def wrapper(self, other, axis="columns", level=None, fill_value=None): diff --git a/python/cudf/cudf/core/frame.py b/python/cudf/cudf/core/frame.py index 75c6e4d0964..1382ebfd8ee 100644 --- a/python/cudf/cudf/core/frame.py +++ b/python/cudf/cudf/core/frame.py @@ -3649,1623 +3649,6 @@ def __invert__(self): self._index, ) - @_cudf_nvtx_annotate - def add(self, other, axis, level=None, fill_value=None): - """ - Get Addition of dataframe or series and other, element-wise (binary - operator `add`). - - Equivalent to ``frame + other``, but with support to substitute a - ``fill_value`` for missing data in one of the inputs. - - Parameters - ---------- - - other : scalar, sequence, Series, or DataFrame - Any single or multiple element data structure, or list-like object. - axis : int or string - Only ``0`` is supported for series, ``1`` or ``columns`` supported - for dataframe - fill_value : float or None, default None - Fill existing missing (NaN) values, and any new element needed - for successful DataFrame alignment, with this value before - computation. If data in both corresponding DataFrame locations - is missing the result will be missing. - - Returns - ------- - DataFrame or Series - Result of the arithmetic operation. - - Examples - -------- - - **DataFrame** - - >>> df = cudf.DataFrame({'angles': [0, 3, 4], - ... 'degrees': [360, 180, 360]}, - ... index=['circle', 'triangle', 'rectangle']) - >>> df + 1 - angles degrees - circle 1 361 - triangle 4 181 - rectangle 5 361 - >>> df.add(1) - angles degrees - circle 1 361 - triangle 4 181 - rectangle 5 361 - - **Series** - - >>> a = cudf.Series([1, 1, 1, None], index=['a', 'b', 'c', 'd']) - >>> b = cudf.Series([1, None, 1, None], index=['a', 'b', 'd', 'e']) - >>> a.add(b) - a 2 - b - c - d - e - dtype: int64 - >>> a.add(b, fill_value=0) - a 2 - b 1 - c 1 - d 1 - e - dtype: int64 - """ - if level is not None: - raise NotImplementedError("level parameter is not supported yet.") - - return self._binaryop(other, "__add__", fill_value) - - @_cudf_nvtx_annotate - def radd(self, other, axis, level=None, fill_value=None): - """ - Get Addition of dataframe or series and other, element-wise (binary - operator `radd`). - - Equivalent to ``other + frame``, but with support to substitute a - fill_value for missing data in one of the inputs. With reverse - version, `add`. - - Parameters - ---------- - - other : scalar, sequence, Series, or DataFrame - Any single or multiple element data structure, or list-like object. - axis : int or string - Only ``0`` is supported for series, ``1`` or ``columns`` supported - for dataframe - fill_value : float or None, default None - Fill existing missing (NaN) values, and any new element needed - for successful DataFrame alignment, with this value before - computation. If data in both corresponding DataFrame locations - is missing the result will be missing. - - Returns - ------- - DataFrame or Series - Result of the arithmetic operation. - - Examples - -------- - - **DataFrame** - - >>> import cudf - >>> df = cudf.DataFrame({'angles': [0, 3, 4], - ... 'degrees': [360, 180, 360]}, - ... index=['circle', 'triangle', 'rectangle']) - >>> df + 1 - angles degrees - circle 1 361 - triangle 4 181 - rectangle 5 361 - >>> df.radd(1) - angles degrees - circle 1 361 - triangle 4 181 - rectangle 5 361 - - **Series** - - >>> a = cudf.Series([1, 2, 3, None], index=['a', 'b', 'c', 'd']) - >>> a - a 1 - b 2 - c 3 - d - dtype: int64 - >>> b = cudf.Series([1, None, 1, None], index=['a', 'b', 'd', 'e']) - >>> b - a 1 - b - d 1 - e - dtype: int64 - >>> a.add(b, fill_value=0) - a 2 - b 2 - c 3 - d 1 - e - dtype: int64 - - """ - - if level is not None: - raise NotImplementedError("level parameter is not supported yet.") - - return self._binaryop(other, "__radd__", fill_value) - - @_cudf_nvtx_annotate - def subtract(self, other, axis, level=None, fill_value=None): - """ - Get Subtraction of dataframe or series and other, element-wise (binary - operator `sub`). - - Equivalent to ``frame - other``, but with support to substitute a - fill_value for missing data in one of the inputs. With reverse - version, `rsub`. - - Parameters - ---------- - - other : scalar, sequence, Series, or DataFrame - Any single or multiple element data structure, or list-like object. - axis : int or string - Only ``0`` is supported for series, ``1`` or ``columns`` supported - for dataframe - fill_value : float or None, default None - Fill existing missing (NaN) values, and any new element needed - for successful DataFrame alignment, with this value before - computation. If data in both corresponding DataFrame locations - is missing the result will be missing. - - Returns - ------- - DataFrame or Series - Result of the arithmetic operation. - - Examples - -------- - - **DataFrame** - - >>> import cudf - >>> df = cudf.DataFrame({'angles': [0, 3, 4], - ... 'degrees': [360, 180, 360]}, - ... index=['circle', 'triangle', 'rectangle']) - >>> df.sub(1) - angles degrees - circle -1 359 - triangle 2 179 - rectangle 3 359 - >>> df.sub([1, 2]) - angles degrees - circle -1 358 - triangle 2 178 - rectangle 3 358 - - **Series** - - >>> a = cudf.Series([10, 20, None, 30, None], index=['a', 'b', 'c', 'd', 'e']) - >>> a - a 10 - b 20 - c - d 30 - e - dtype: int64 - >>> b = cudf.Series([1, None, 2, 30], index=['a', 'c', 'b', 'd']) - >>> b - a 1 - c - b 2 - d 30 - dtype: int64 - >>> a.subtract(b, fill_value=2) - a 9 - b 18 - c - d 0 - e - dtype: int64 - - """ # noqa: E501 - - if level is not None: - raise NotImplementedError("level parameter is not supported yet.") - - return self._binaryop(other, "__sub__", fill_value) - - sub = subtract - - @_cudf_nvtx_annotate - def rsub(self, other, axis, level=None, fill_value=None): - """ - Get Subtraction of dataframe or series and other, element-wise (binary - operator `rsub`). - - Equivalent to ``other - frame``, but with support to substitute a - fill_value for missing data in one of the inputs. With reverse - version, `sub`. - - Parameters - ---------- - - other : scalar, sequence, Series, or DataFrame - Any single or multiple element data structure, or list-like object. - axis : int or string - Only ``0`` is supported for series, ``1`` or ``columns`` supported - for dataframe - fill_value : float or None, default None - Fill existing missing (NaN) values, and any new element needed - for successful DataFrame alignment, with this value before - computation. If data in both corresponding DataFrame locations - is missing the result will be missing. - - Returns - ------- - DataFrame or Series - Result of the arithmetic operation. - - Examples - -------- - - **DataFrame** - - >>> import cudf - >>> df = cudf.DataFrame({'angles': [0, 3, 4], - ... 'degrees': [360, 180, 360]}, - ... index=['circle', 'triangle', 'rectangle']) - >>> df - angles degrees - circle 0 360 - triangle 3 180 - rectangle 4 360 - >>> df.rsub(1) - angles degrees - circle 1 -359 - triangle -2 -179 - rectangle -3 -359 - >>> df.rsub([1, 2]) - angles degrees - circle 1 -358 - triangle -2 -178 - rectangle -3 -358 - - **Series** - - >>> import cudf - >>> a = cudf.Series([1, 2, 3, None], index=['a', 'b', 'c', 'd']) - >>> a - a 1 - b 2 - c 3 - d - dtype: int64 - >>> b = cudf.Series([1, None, 2, None], index=['a', 'b', 'd', 'e']) - >>> b - a 1 - b - d 2 - e - dtype: int64 - >>> a.rsub(b, fill_value=10) - a 0 - b 8 - c 7 - d -8 - e - dtype: int64 - """ - if level is not None: - raise NotImplementedError("level parameter is not supported yet.") - - return self._binaryop(other, "__rsub__", fill_value) - - @_cudf_nvtx_annotate - def multiply(self, other, axis, level=None, fill_value=None): - """ - Get Multiplication of dataframe or series and other, element-wise - (binary operator `mul`). - - Equivalent to ``frame * other``, but with support to substitute a - fill_value for missing data in one of the inputs. With reverse - version, `rmul`. - - Parameters - ---------- - - other : scalar, sequence, Series, or DataFrame - Any single or multiple element data structure, or list-like object. - axis : int or string - Only ``0`` is supported for series, ``1`` or ``columns`` supported - for dataframe - fill_value : float or None, default None - Fill existing missing (NaN) values, and any new element needed - for successful DataFrame alignment, with this value before - computation. If data in both corresponding DataFrame locations - is missing the result will be missing. - - Returns - ------- - DataFrame or Series - Result of the arithmetic operation. - - Examples - -------- - - **DataFrame** - - >>> import cudf - >>> df = cudf.DataFrame({'angles': [0, 3, 4], - ... 'degrees': [360, 180, 360]}, - ... index=['circle', 'triangle', 'rectangle']) - >>> other = cudf.DataFrame({'angles': [0, 3, 4]}, - ... index=['circle', 'triangle', 'rectangle']) - >>> df * other - angles degrees - circle 0 - triangle 9 - rectangle 16 - >>> df.mul(other, fill_value=0) - angles degrees - circle 0 0 - triangle 9 0 - rectangle 16 0 - - **Series** - - >>> import cudf - >>> a = cudf.Series([1, 2, 3, None], index=['a', 'b', 'c', 'd']) - >>> a - a 1 - b 2 - c 3 - d - dtype: int64 - >>> b = cudf.Series([1, None, 2, None], index=['a', 'b', 'd', 'e']) - >>> b - a 1 - b - d 2 - e - dtype: int64 - >>> a.multiply(b, fill_value=0) - a 1 - b 0 - c 0 - d 0 - e - dtype: int64 - - """ - - if level is not None: - raise NotImplementedError("level parameter is not supported yet.") - - return self._binaryop(other, "__mul__", fill_value) - - mul = multiply - - @_cudf_nvtx_annotate - def rmul(self, other, axis, level=None, fill_value=None): - """ - Get Multiplication of dataframe or series and other, element-wise - (binary operator `rmul`). - - Equivalent to ``other * frame``, but with support to substitute a - fill_value for missing data in one of the inputs. With reverse - version, `mul`. - - Parameters - ---------- - - other : scalar, sequence, Series, or DataFrame - Any single or multiple element data structure, or list-like object. - axis : int or string - Only ``0`` is supported for series, ``1`` or ``columns`` supported - for dataframe - fill_value : float or None, default None - Fill existing missing (NaN) values, and any new element needed - for successful DataFrame alignment, with this value before - computation. If data in both corresponding DataFrame locations - is missing the result will be missing. - - Returns - ------- - DataFrame or Series - Result of the arithmetic operation. - - Examples - -------- - - **DataFrame** - - >>> import cudf - >>> df = cudf.DataFrame({'angles': [0, 3, 4], - ... 'degrees': [360, 180, 360]}, - ... index=['circle', 'triangle', 'rectangle']) - >>> other = cudf.DataFrame({'angles': [0, 3, 4]}, - ... index=['circle', 'triangle', 'rectangle']) - >>> other * df - angles degrees - circle 0 - triangle 9 - rectangle 16 - >>> df.rmul(other, fill_value=0) - angles degrees - circle 0 0 - triangle 9 0 - rectangle 16 0 - - **Series** - - >>> import cudf - >>> a = cudf.Series([10, 20, None, 30, 40], index=['a', 'b', 'c', 'd', 'e']) - >>> a - a 10 - b 20 - c - d 30 - e 40 - dtype: int64 - >>> b = cudf.Series([None, 1, 20, 5, 4], index=['a', 'b', 'd', 'e', 'f']) - >>> b - a - b 1 - d 20 - e 5 - f 4 - dtype: int64 - >>> a.rmul(b, fill_value=2) - a 20 - b 20 - c - d 600 - e 200 - f 8 - dtype: int64 - """ # noqa E501 - - if level is not None: - raise NotImplementedError("level parameter is not supported yet.") - - return self._binaryop(other, "__rmul__", fill_value) - - @_cudf_nvtx_annotate - def mod(self, other, axis, level=None, fill_value=None): - """ - Get Modulo division of dataframe or series and other, element-wise - (binary operator `mod`). - - Equivalent to ``frame % other``, but with support to substitute a - fill_value for missing data in one of the inputs. With reverse - version, `rmod`. - - Parameters - ---------- - - other : scalar, sequence, Series, or DataFrame - Any single or multiple element data structure, or list-like object. - axis : int or string - Only ``0`` is supported for series, ``1`` or ``columns`` supported - for dataframe - fill_value : float or None, default None - Fill existing missing (NaN) values, and any new element needed - for successful DataFrame alignment, with this value before - computation. If data in both corresponding DataFrame locations - is missing the result will be missing. - - Returns - ------- - DataFrame or Series - Result of the arithmetic operation. - - Examples - -------- - - **DataFrame** - - >>> import cudf - >>> df = cudf.DataFrame({'angles': [0, 3, 4], - ... 'degrees': [360, 180, 360]}, - ... index=['circle', 'triangle', 'rectangle']) - >>> df % 100 - angles degrees - circle 0 60 - triangle 3 80 - rectangle 4 60 - >>> df.mod(100) - angles degrees - circle 0 60 - triangle 3 80 - rectangle 4 60 - - **Series** - - >>> import cudf - >>> series = cudf.Series([10, 20, 30]) - >>> series - 0 10 - 1 20 - 2 30 - dtype: int64 - >>> series.mod(4) - 0 2 - 1 0 - 2 2 - dtype: int64 - - - """ - if level is not None: - raise NotImplementedError("level parameter is not supported yet.") - - return self._binaryop(other, "__mod__", fill_value) - - @_cudf_nvtx_annotate - def rmod(self, other, axis, level=None, fill_value=None): - """ - Get Modulo division of dataframe or series and other, element-wise - (binary operator `rmod`). - - Equivalent to ``other % frame``, but with support to substitute a - fill_value for missing data in one of the inputs. With reverse - version, `mod`. - - Parameters - ---------- - - other : scalar, sequence, Series, or DataFrame - Any single or multiple element data structure, or list-like object. - axis : int or string - Only ``0`` is supported for series, ``1`` or ``columns`` supported - for dataframe - fill_value : float or None, default None - Fill existing missing (NaN) values, and any new element needed - for successful DataFrame alignment, with this value before - computation. If data in both corresponding DataFrame locations - is missing the result will be missing. - - Returns - ------- - DataFrame or Series - Result of the arithmetic operation. - - Examples - -------- - - **DataFrame** - - >>> import cudf - >>> df = cudf.DataFrame({'angles': [1, 3, 4], - ... 'degrees': [360, 180, 360]}, - ... index=['circle', 'triangle', 'rectangle']) - >>> 100 % df - angles degrees - circle 0 100 - triangle 1 100 - rectangle 0 100 - >>> df.rmod(100) - angles degrees - circle 0 100 - triangle 1 100 - rectangle 0 100 - - **Series** - - >>> import cudf - >>> a = cudf.Series([10, 20, None, 30, 40], index=['a', 'b', 'c', 'd', 'e']) - >>> a - a 10 - b 20 - c - d 30 - e 40 - dtype: int64 - >>> b = cudf.Series([None, 1, 20, 5, 4], index=['a', 'b', 'd', 'e', 'f']) - >>> b - a - b 1 - d 20 - e 5 - f 4 - dtype: int64 - >>> a.rmod(b, fill_value=10) - a 0 - b 1 - c - d 20 - e 5 - f 4 - dtype: int64 - """ # noqa E501 - - if level is not None: - raise NotImplementedError("level parameter is not supported yet.") - - return self._binaryop(other, "__rmod__", fill_value) - - @_cudf_nvtx_annotate - def pow(self, other, axis, level=None, fill_value=None): - """ - Get Exponential power of dataframe series and other, element-wise - (binary operator `pow`). - - Equivalent to ``frame ** other``, but with support to substitute a - fill_value for missing data in one of the inputs. With reverse - version, `rpow`. - - Parameters - ---------- - - other : scalar, sequence, Series, or DataFrame - Any single or multiple element data structure, or list-like object. - axis : int or string - Only ``0`` is supported for series, ``1`` or ``columns`` supported - for dataframe - fill_value : float or None, default None - Fill existing missing (NaN) values, and any new element needed - for successful DataFrame alignment, with this value before - computation. If data in both corresponding DataFrame locations - is missing the result will be missing. - - Returns - ------- - DataFrame or Series - Result of the arithmetic operation. - - Examples - -------- - - **DataFrame** - - >>> import cudf - >>> df = cudf.DataFrame({'angles': [1, 3, 4], - ... 'degrees': [360, 180, 360]}, - ... index=['circle', 'triangle', 'rectangle']) - >>> df ** 2 - angles degrees - circle 0 129600 - triangle 9 32400 - rectangle 16 129600 - >>> df.pow(2) - angles degrees - circle 0 129600 - triangle 9 32400 - rectangle 16 129600 - - **Series** - - >>> import cudf - >>> a = cudf.Series([1, 2, 3, None], index=['a', 'b', 'c', 'd']) - >>> a - a 1 - b 2 - c 3 - d - dtype: int64 - >>> b = cudf.Series([10, None, 12, None], index=['a', 'b', 'd', 'e']) - >>> b - a 10 - b - d 12 - e - dtype: int64 - >>> a.pow(b, fill_value=0) - a 1 - b 1 - c 1 - d 0 - e - dtype: int64 - """ - - if level is not None: - raise NotImplementedError("level parameter is not supported yet.") - - return self._binaryop(other, "__pow__", fill_value) - - @_cudf_nvtx_annotate - def rpow(self, other, axis, level=None, fill_value=None): - """ - Get Exponential power of dataframe or series and other, element-wise - (binary operator `pow`). - - Equivalent to ``other ** frame``, but with support to substitute a - fill_value for missing data in one of the inputs. With reverse - version, `pow`. - - Parameters - ---------- - - other : scalar, sequence, Series, or DataFrame - Any single or multiple element data structure, or list-like object. - axis : int or string - Only ``0`` is supported for series, ``1`` or ``columns`` supported - for dataframe - fill_value : float or None, default None - Fill existing missing (NaN) values, and any new element needed - for successful DataFrame alignment, with this value before - computation. If data in both corresponding DataFrame locations - is missing the result will be missing. - - Returns - ------- - DataFrame or Series - Result of the arithmetic operation. - - Examples - -------- - - **DataFrame** - - >>> import cudf - >>> df = cudf.DataFrame({'angles': [1, 3, 4], - ... 'degrees': [360, 180, 360]}, - ... index=['circle', 'triangle', 'rectangle']) - >>> 1 ** df - angles degrees - circle 1 1 - triangle 1 1 - rectangle 1 1 - >>> df.rpow(1) - angles degrees - circle 1 1 - triangle 1 1 - rectangle 1 1 - - **Series** - - >>> import cudf - >>> a = cudf.Series([1, 2, 3, None], index=['a', 'b', 'c', 'd']) - >>> a - a 1 - b 2 - c 3 - d - dtype: int64 - >>> b = cudf.Series([10, None, 12, None], index=['a', 'b', 'd', 'e']) - >>> b - a 10 - b - d 12 - e - dtype: int64 - >>> a.rpow(b, fill_value=0) - a 10 - b 0 - c 0 - d 1 - e - dtype: int64 - """ - - if level is not None: - raise NotImplementedError("level parameter is not supported yet.") - - return self._binaryop(other, "__rpow__", fill_value) - - @_cudf_nvtx_annotate - def floordiv(self, other, axis, level=None, fill_value=None): - """ - Get Integer division of dataframe or series and other, element-wise - (binary operator `floordiv`). - - Equivalent to ``frame // other``, but with support to substitute a - fill_value for missing data in one of the inputs. With reverse - version, `rfloordiv`. - - Parameters - ---------- - - other : scalar, sequence, Series, or DataFrame - Any single or multiple element data structure, or list-like object. - axis : int or string - Only ``0`` is supported for series, ``1`` or ``columns`` supported - for dataframe - fill_value : float or None, default None - Fill existing missing (NaN) values, and any new element needed - for successful DataFrame alignment, with this value before - computation. If data in both corresponding DataFrame locations - is missing the result will be missing. - - Returns - ------- - DataFrame or Series - Result of the arithmetic operation. - - Examples - -------- - - **DataFrame** - - >>> import cudf - >>> df = cudf.DataFrame({'angles': [1, 3, 4], - ... 'degrees': [360, 180, 360]}, - ... index=['circle', 'triangle', 'rectangle']) - >>> df.floordiv(2) - angles degrees - circle 0 180 - triangle 1 90 - rectangle 2 180 - >>> df // 2 - angles degrees - circle 0 180 - triangle 1 90 - rectangle 2 180 - - **Series** - - >>> import cudf - >>> a = cudf.Series([1, 1, 1, None], index=['a', 'b', 'c', 'd']) - >>> a - a 1 - b 1 - c 1 - d - dtype: int64 - >>> b = cudf.Series([1, None, 1, None], index=['a', 'b', 'd', 'e']) - >>> b - a 1 - b - d 1 - e - dtype: int64 - >>> a.floordiv(b) - a 1 - b - c - d - e - dtype: int64 - """ - - if level is not None: - raise NotImplementedError("level parameter is not supported yet.") - - return self._binaryop(other, "__floordiv__", fill_value) - - @_cudf_nvtx_annotate - def rfloordiv(self, other, axis, level=None, fill_value=None): - """ - Get Integer division of dataframe or series and other, element-wise - (binary operator `rfloordiv`). - - Equivalent to ``other // dataframe``, but with support to substitute - a fill_value for missing data in one of the inputs. With reverse - version, `floordiv`. - - Parameters - ---------- - - other : scalar, sequence, Series, or DataFrame - Any single or multiple element data structure, or list-like object. - axis : int or string - Only ``0`` is supported for series, ``1`` or ``columns`` supported - for dataframe - fill_value : float or None, default None - Fill existing missing (NaN) values, and any new element needed - for successful DataFrame alignment, with this value before - computation. If data in both corresponding DataFrame locations - is missing the result will be missing. - - Returns - ------- - DataFrame or Series - Result of the arithmetic operation. - - Examples - -------- - - **DataFrame** - - >>> import cudf - >>> df = cudf.DataFrame({'col1': [10, 11, 23], - ... 'col2': [101, 122, 321]}) - >>> df - col1 col2 - 0 10 101 - 1 11 122 - 2 23 321 - >>> df.rfloordiv(df) - col1 col2 - 0 1 1 - 1 1 1 - 2 1 1 - >>> df.rfloordiv(200) - col1 col2 - 0 20 1 - 1 18 1 - 2 8 0 - >>> df.rfloordiv(100) - col1 col2 - 0 10 0 - 1 9 0 - 2 4 0 - - **Series** - - >>> import cudf - >>> s = cudf.Series([1, 2, 10, 17]) - >>> s - 0 1 - 1 2 - 2 10 - 3 17 - dtype: int64 - >>> s.rfloordiv(100) - 0 100 - 1 50 - 2 10 - 3 5 - dtype: int64 - >>> s = cudf.Series([10, 20, None]) - >>> s - 0 10 - 1 20 - 2 - dtype: int64 - >>> s.rfloordiv(200) - 0 20 - 1 10 - 2 - dtype: int64 - >>> s.rfloordiv(200, fill_value=2) - 0 20 - 1 10 - 2 100 - dtype: int64 - """ - - if level is not None: - raise NotImplementedError("level parameter is not supported yet.") - - return self._binaryop(other, "__rfloordiv__", fill_value) - - @_cudf_nvtx_annotate - def truediv(self, other, axis, level=None, fill_value=None): - """ - Get Floating division of dataframe or series and other, element-wise - (binary operator `truediv`). - - Equivalent to ``frame / other``, but with support to substitute a - fill_value for missing data in one of the inputs. With reverse - version, `rtruediv`. - - Parameters - ---------- - - other : scalar, sequence, Series, or DataFrame - Any single or multiple element data structure, or list-like object. - axis : int or string - Only ``0`` is supported for series, ``1`` or ``columns`` supported - for dataframe - fill_value : float or None, default None - Fill existing missing (NaN) values, and any new element needed - for successful DataFrame alignment, with this value before - computation. If data in both corresponding DataFrame locations - is missing the result will be missing. - - Returns - ------- - DataFrame or Series - Result of the arithmetic operation. - - Examples - -------- - - **DataFrame** - - >>> import cudf - >>> df = cudf.DataFrame({'angles': [0, 3, 4], - ... 'degrees': [360, 180, 360]}, - ... index=['circle', 'triangle', 'rectangle']) - >>> df.truediv(10) - angles degrees - circle 0.0 36.0 - triangle 0.3 18.0 - rectangle 0.4 36.0 - >>> df.div(10) - angles degrees - circle 0.0 36.0 - triangle 0.3 18.0 - rectangle 0.4 36.0 - >>> df / 10 - angles degrees - circle 0.0 36.0 - triangle 0.3 18.0 - rectangle 0.4 36.0 - - **Series** - - >>> import cudf - >>> a = cudf.Series([1, 10, 20, None], index=['a', 'b', 'c', 'd']) - >>> a - a 1 - b 10 - c 20 - d - dtype: int64 - >>> b = cudf.Series([1, None, 2, None], index=['a', 'b', 'd', 'e']) - >>> b - a 1 - b - d 2 - e - dtype: int64 - >>> a.truediv(b, fill_value=0) - a 1.0 - b Inf - c Inf - d 0.0 - e - dtype: float64 - """ - - if level is not None: - raise NotImplementedError("level parameter is not supported yet.") - - return self._binaryop(other, "__truediv__", fill_value) - - # Alias for truediv - div = truediv - divide = truediv - - @_cudf_nvtx_annotate - def rtruediv(self, other, axis, level=None, fill_value=None): - """ - Get Floating division of dataframe or series and other, element-wise - (binary operator `rtruediv`). - - Equivalent to ``other / frame``, but with support to substitute a - fill_value for missing data in one of the inputs. With reverse - version, `truediv`. - - Parameters - ---------- - - other : scalar, sequence, Series, or DataFrame - Any single or multiple element data structure, or list-like object. - axis : int or string - Only ``0`` is supported for series, ``1`` or ``columns`` supported - for dataframe - fill_value : float or None, default None - Fill existing missing (NaN) values, and any new element needed - for successful DataFrame alignment, with this value before - computation. If data in both corresponding DataFrame locations - is missing the result will be missing. - - Returns - ------- - DataFrame or Series - Result of the arithmetic operation. - - Examples - -------- - - **DataFrame** - - >>> import cudf - >>> df = cudf.DataFrame({'angles': [0, 3, 4], - ... 'degrees': [360, 180, 360]}, - ... index=['circle', 'triangle', 'rectangle']) - >>> df - angles degrees - circle 0 360 - triangle 3 180 - rectangle 4 360 - >>> df.rtruediv(10) - angles degrees - circle inf 0.027778 - triangle 3.333333 0.055556 - rectangle 2.500000 0.027778 - >>> df.rdiv(10) - angles degrees - circle inf 0.027778 - triangle 3.333333 0.055556 - rectangle 2.500000 0.027778 - >>> 10 / df - angles degrees - circle inf 0.027778 - triangle 3.333333 0.055556 - rectangle 2.500000 0.027778 - - **Series** - - >>> import cudf - >>> a = cudf.Series([10, 20, None, 30], index=['a', 'b', 'c', 'd']) - >>> a - a 10 - b 20 - c - d 30 - dtype: int64 - >>> b = cudf.Series([1, None, 2, 3], index=['a', 'b', 'd', 'e']) - >>> b - a 1 - b - d 2 - e 3 - dtype: int64 - >>> a.rtruediv(b, fill_value=0) - a 0.1 - b 0.0 - c - d 0.066666667 - e Inf - dtype: float64 - """ - - if level is not None: - raise NotImplementedError("level parameter is not supported yet.") - - return self._binaryop(other, "__rtruediv__", fill_value) - - # Alias for rtruediv - rdiv = rtruediv - - @_cudf_nvtx_annotate - def eq(self, other, axis="columns", level=None, fill_value=None): - """Equal to, element-wise (binary operator eq). - - Parameters - ---------- - other : Series or scalar value - fill_value : None or value - Value to fill nulls with before computation. If data in both - corresponding Series locations is null the result will be null - - Returns - ------- - Frame - The result of the operation. - - Examples - -------- - **DataFrame** - - >>> left = cudf.DataFrame({ - ... 'a': [1, 2, 3], - ... 'b': [4, 5, 6], - ... 'c': [7, 8, 9]} - ... ) - >>> right = cudf.DataFrame({ - ... 'a': [1, 2, 3], - ... 'b': [4, 5, 6], - ... 'd': [10, 12, 12]} - ... ) - >>> left.eq(right) - a b c d - 0 True True - 1 True True - 2 True True - >>> left.eq(right, fill_value=7) - a b c d - 0 True True True False - 1 True True False False - 2 True True False False - - **Series** - - >>> a = cudf.Series([1, 2, 3, None, 10, 20], - ... index=['a', 'c', 'd', 'e', 'f', 'g']) - >>> a - a 1 - c 2 - d 3 - e - f 10 - g 20 - dtype: int64 - >>> b = cudf.Series([-10, 23, -1, None, None], - ... index=['a', 'b', 'c', 'd', 'e']) - >>> b - a -10 - b 23 - c -1 - d - e - dtype: int64 - >>> a.eq(b, fill_value=2) - a False - b False - c False - d False - e - f False - g False - dtype: bool - """ - return self._binaryop( - other=other, op="__eq__", fill_value=fill_value, can_reindex=True - ) - - @_cudf_nvtx_annotate - def ne(self, other, axis="columns", level=None, fill_value=None): - """Not equal to, element-wise (binary operator ne). - - Parameters - ---------- - other : Series or scalar value - fill_value : None or value - Value to fill nulls with before computation. If data in both - corresponding Series locations is null the result will be null - - Returns - ------- - Frame - The result of the operation. - - Examples - -------- - **DataFrame** - - >>> left = cudf.DataFrame({ - ... 'a': [1, 2, 3], - ... 'b': [4, 5, 6], - ... 'c': [7, 8, 9]} - ... ) - >>> right = cudf.DataFrame({ - ... 'a': [1, 2, 3], - ... 'b': [4, 5, 6], - ... 'd': [10, 12, 12]} - ... ) - >>> left.ne(right) - a b c d - 0 False False - 1 False False - 2 False False - >>> left.ne(right, fill_value=7) - a b c d - 0 False False False True - 1 False False True True - 2 False False True True - - **Series** - - >>> a = cudf.Series([1, 2, 3, None, 10, 20], - ... index=['a', 'c', 'd', 'e', 'f', 'g']) - >>> a - a 1 - c 2 - d 3 - e - f 10 - g 20 - dtype: int64 - >>> b = cudf.Series([-10, 23, -1, None, None], - ... index=['a', 'b', 'c', 'd', 'e']) - >>> b - a -10 - b 23 - c -1 - d - e - dtype: int64 - >>> a.ne(b, fill_value=2) - a True - b True - c True - d True - e - f True - g True - dtype: bool - """ # noqa: E501 - return self._binaryop( - other=other, op="__ne__", fill_value=fill_value, can_reindex=True - ) - - @_cudf_nvtx_annotate - def lt(self, other, axis="columns", level=None, fill_value=None): - """Less than, element-wise (binary operator lt). - - Parameters - ---------- - other : Series or scalar value - fill_value : None or value - Value to fill nulls with before computation. If data in both - corresponding Series locations is null the result will be null - - Returns - ------- - Frame - The result of the operation. - - Examples - -------- - **DataFrame** - - >>> left = cudf.DataFrame({ - ... 'a': [1, 2, 3], - ... 'b': [4, 5, 6], - ... 'c': [7, 8, 9]} - ... ) - >>> right = cudf.DataFrame({ - ... 'a': [1, 2, 3], - ... 'b': [4, 5, 6], - ... 'd': [10, 12, 12]} - ... ) - >>> left.lt(right) - a b c d - 0 False False - 1 False False - 2 False False - >>> left.lt(right, fill_value=7) - a b c d - 0 False False False True - 1 False False False True - 2 False False False True - - **Series** - - >>> a = cudf.Series([1, 2, 3, None, 10, 20], - ... index=['a', 'c', 'd', 'e', 'f', 'g']) - >>> a - a 1 - c 2 - d 3 - e - f 10 - g 20 - dtype: int64 - >>> b = cudf.Series([-10, 23, -1, None, None], - ... index=['a', 'b', 'c', 'd', 'e']) - >>> b - a -10 - b 23 - c -1 - d - e - dtype: int64 - >>> a.lt(b, fill_value=-10) - a False - b True - c False - d False - e - f False - g False - dtype: bool - """ # noqa: E501 - return self._binaryop( - other=other, op="__lt__", fill_value=fill_value, can_reindex=True - ) - - @_cudf_nvtx_annotate - def le(self, other, axis="columns", level=None, fill_value=None): - """Less than or equal, element-wise (binary operator le). - - Parameters - ---------- - other : Series or scalar value - fill_value : None or value - Value to fill nulls with before computation. If data in both - corresponding Series locations is null the result will be null - - Returns - ------- - Frame - The result of the operation. - - Examples - -------- - **DataFrame** - - >>> left = cudf.DataFrame({ - ... 'a': [1, 2, 3], - ... 'b': [4, 5, 6], - ... 'c': [7, 8, 9]} - ... ) - >>> right = cudf.DataFrame({ - ... 'a': [1, 2, 3], - ... 'b': [4, 5, 6], - ... 'd': [10, 12, 12]} - ... ) - >>> left.le(right) - a b c d - 0 True True - 1 True True - 2 True True - >>> left.le(right, fill_value=7) - a b c d - 0 True True True True - 1 True True False True - 2 True True False True - - **Series** - - >>> a = cudf.Series([1, 2, 3, None, 10, 20], - ... index=['a', 'c', 'd', 'e', 'f', 'g']) - >>> a - a 1 - c 2 - d 3 - e - f 10 - g 20 - dtype: int64 - >>> b = cudf.Series([-10, 23, -1, None, None], - ... index=['a', 'b', 'c', 'd', 'e']) - >>> b - a -10 - b 23 - c -1 - d - e - dtype: int64 - >>> a.le(b, fill_value=-10) - a False - b True - c False - d False - e - f False - g False - dtype: bool - """ # noqa: E501 - return self._binaryop( - other=other, op="__le__", fill_value=fill_value, can_reindex=True - ) - - @_cudf_nvtx_annotate - def gt(self, other, axis="columns", level=None, fill_value=None): - """Greater than, element-wise (binary operator gt). - - Parameters - ---------- - other : Series or scalar value - fill_value : None or value - Value to fill nulls with before computation. If data in both - corresponding Series locations is null the result will be null - - Returns - ------- - Frame - The result of the operation. - - Examples - -------- - **DataFrame** - - >>> left = cudf.DataFrame({ - ... 'a': [1, 2, 3], - ... 'b': [4, 5, 6], - ... 'c': [7, 8, 9]} - ... ) - >>> right = cudf.DataFrame({ - ... 'a': [1, 2, 3], - ... 'b': [4, 5, 6], - ... 'd': [10, 12, 12]} - ... ) - >>> left.gt(right) - a b c d - 0 False False - 1 False False - 2 False False - >>> left.gt(right, fill_value=7) - a b c d - 0 False False False False - 1 False False True False - 2 False False True False - - **Series** - - >>> a = cudf.Series([1, 2, 3, None, 10, 20], - ... index=['a', 'c', 'd', 'e', 'f', 'g']) - >>> a - a 1 - c 2 - d 3 - e - f 10 - g 20 - dtype: int64 - >>> b = cudf.Series([-10, 23, -1, None, None], - ... index=['a', 'b', 'c', 'd', 'e']) - >>> b - a -10 - b 23 - c -1 - d - e - dtype: int64 - >>> a.gt(b) - a True - b False - c True - d False - e False - f False - g False - dtype: bool - """ # noqa: E501 - return self._binaryop( - other=other, op="__gt__", fill_value=fill_value, can_reindex=True - ) - - @_cudf_nvtx_annotate - def ge(self, other, axis="columns", level=None, fill_value=None): - """Greater than or equal, element-wise (binary operator ge). - - Parameters - ---------- - other : Series or scalar value - fill_value : None or value - Value to fill nulls with before computation. If data in both - corresponding Series locations is null the result will be null - - Returns - ------- - Frame - The result of the operation. - - Examples - -------- - **DataFrame** - - >>> left = cudf.DataFrame({ - ... 'a': [1, 2, 3], - ... 'b': [4, 5, 6], - ... 'c': [7, 8, 9]} - ... ) - >>> right = cudf.DataFrame({ - ... 'a': [1, 2, 3], - ... 'b': [4, 5, 6], - ... 'd': [10, 12, 12]} - ... ) - >>> left.ge(right) - a b c d - 0 True True - 1 True True - 2 True True - >>> left.ge(right, fill_value=7) - a b c d - 0 True True True False - 1 True True True False - 2 True True True False - - **Series** - - >>> a = cudf.Series([1, 2, 3, None, 10, 20], - ... index=['a', 'c', 'd', 'e', 'f', 'g']) - >>> a - a 1 - c 2 - d 3 - e - f 10 - g 20 - dtype: int64 - >>> b = cudf.Series([-10, 23, -1, None, None], - ... index=['a', 'b', 'c', 'd', 'e']) - >>> b - a -10 - b 23 - c -1 - d - e - dtype: int64 - >>> a.ge(b) - a True - b False - c True - d False - e False - f False - g False - dtype: bool - """ # noqa: E501 - return self._binaryop( - other=other, op="__ge__", fill_value=fill_value, can_reindex=True - ) - def nunique(self, dropna: bool = True): """ Returns a per column mapping with counts of unique values for diff --git a/python/cudf/cudf/core/indexed_frame.py b/python/cudf/cudf/core/indexed_frame.py index 3d025738974..10736948b57 100644 --- a/python/cudf/cudf/core/indexed_frame.py +++ b/python/cudf/cudf/core/indexed_frame.py @@ -5,6 +5,7 @@ import numbers import operator +import textwrap import warnings from collections import Counter, abc from functools import cached_property @@ -44,6 +45,7 @@ from cudf.core.index import Index, RangeIndex, _index_from_columns from cudf.core.multiindex import MultiIndex from cudf.core.udf.utils import _compile_or_get, _supported_cols_from_frame +from cudf.utils import docutils from cudf.utils.utils import _cudf_nvtx_annotate doc_reset_index_template = """ @@ -72,6 +74,55 @@ """ +doc_binop_template = textwrap.dedent( + """ + Get {operation} of DataFrame or Series and other, element-wise (binary + operator `{op_name}`). + + Equivalent to ``frame + other``, but with support to substitute a + ``fill_value`` for missing data in one of the inputs. + + Parameters + ---------- + other : scalar, sequence, Series, or DataFrame + Any single or multiple element data structure, or list-like object. + axis : int or string + Only ``0`` is supported for series, ``1`` or ``columns`` supported + for dataframe + level : int or name + Broadcast across a level, matching Index values on the + passed MultiIndex level. Not yet supported. + fill_value : float or None, default None + Fill existing missing (NaN) values, and any new element needed + for successful DataFrame alignment, with this value before + computation. If data in both corresponding DataFrame locations + is missing the result will be missing. + + Returns + ------- + DataFrame or Series + Result of the arithmetic operation. + + Examples + -------- + + **DataFrame** + + >>> df = cudf.DataFrame( + ... {{'angles': [0, 3, 4], 'degrees': [360, 180, 360]}}, + ... index=['circle', 'triangle', 'rectangle'] + ... ) + {df_op_example} + + **Series** + + >>> a = cudf.Series([1, 1, 1, None], index=['a', 'b', 'c', 'd']) + >>> b = cudf.Series([1, None, 1, None], index=['a', 'b', 'd', 'e']) + {ser_op_example} + """ +) + + def _get_host_unique(array): if isinstance(array, (cudf.Series, cudf.Index, ColumnBase)): return array.unique.to_pandas() @@ -2653,6 +2704,845 @@ def _explode(self, explode_column: Any, ignore_index: bool): res.index.names = self._index.names return res + @_cudf_nvtx_annotate + @docutils.doc_apply( + doc_binop_template.format( + operation="Addition", + op_name="add", + equivalent_op="frame + other", + df_op_example=textwrap.dedent( + """ + >>> df.add(1) + angles degrees + circle 1 361 + triangle 4 181 + rectangle 5 361 + """, + ), + ser_op_example=textwrap.dedent( + """ + >>> a.add(b) + a 2 + b + c + d + e + dtype: int64 + >>> a.add(b, fill_value=0) + a 2 + b 1 + c 1 + d 1 + e + dtype: int64 + """ + ), + ) + ) + def add(self, other, axis, level=None, fill_value=None): # noqa: D102 + if level is not None: + raise NotImplementedError("level parameter is not supported yet.") + + return self._binaryop(other, "__add__", fill_value) + + @_cudf_nvtx_annotate + @docutils.doc_apply( + doc_binop_template.format( + operation="Addition", + op_name="radd", + equivalent_op="other + frame", + df_op_example=textwrap.dedent( + """ + >>> df.radd(1) + angles degrees + circle 1 361 + triangle 4 181 + rectangle 5 361 + """ + ), + ser_op_example=textwrap.dedent( + """ + >>> a.radd(b) + a 2 + b + c + d + e + dtype: int64 + >>> a.radd(b, fill_value=0) + a 2 + b 1 + c 1 + d 1 + e + dtype: int64 + """ + ), + ) + ) + def radd(self, other, axis, level=None, fill_value=None): # noqa: D102 + if level is not None: + raise NotImplementedError("level parameter is not supported yet.") + + return self._binaryop(other, "__radd__", fill_value) + + @_cudf_nvtx_annotate + @docutils.doc_apply( + doc_binop_template.format( + operation="Subtraction", + op_name="sub", + equivalent_op="frame - other", + df_op_example=textwrap.dedent( + """ + >>> df.sub(1) + angles degrees + circle -1 359 + triangle 2 179 + rectangle 3 359 + """ + ), + ser_op_example=textwrap.dedent( + """ + >>> a.sub(b) + a 0 + b + c + d + e + dtype: int64 + >>> a.sub(b, fill_value=0) + a 2 + b 1 + c 1 + d -1 + e + dtype: int64 + """ + ), + ) + ) + def subtract(self, other, axis, level=None, fill_value=None): # noqa: D102 + if level is not None: + raise NotImplementedError("level parameter is not supported yet.") + + return self._binaryop(other, "__sub__", fill_value) + + sub = subtract + + @_cudf_nvtx_annotate + @docutils.doc_apply( + doc_binop_template.format( + operation="Subtraction", + op_name="rsub", + equivalent_op="other - frame", + df_op_example=textwrap.dedent( + """ + >>> df.rsub(1) + angles degrees + circle 1 -359 + triangle -2 -179 + rectangle -3 -359 + """ + ), + ser_op_example=textwrap.dedent( + """ + >>> a.rsub(b) + a 0 + b + c + d + e + dtype: int64 + >>> a.rsub(b, fill_value=0) + a 0 + b -1 + c -1 + d 1 + e + dtype: int64 + """ + ), + ) + ) + def rsub(self, other, axis, level=None, fill_value=None): # noqa: D102 + if level is not None: + raise NotImplementedError("level parameter is not supported yet.") + + return self._binaryop(other, "__rsub__", fill_value) + + @_cudf_nvtx_annotate + @docutils.doc_apply( + doc_binop_template.format( + operation="Multiplication", + op_name="mul", + equivalent_op="frame * other", + df_op_example=textwrap.dedent( + """ + >>> df.multiply(1) + angles degrees + circle 0 360 + triangle 3 180 + rectangle 4 360 + """ + ), + ser_op_example=textwrap.dedent( + """ + >>> a.multiply(b) + a 1 + b + c + d + e + dtype: int64 + >>> a.multiply(b, fill_value=0) + a 1 + b 0 + c 0 + d 0 + e + dtype: int64 + """ + ), + ) + ) + def multiply(self, other, axis, level=None, fill_value=None): # noqa: D102 + if level is not None: + raise NotImplementedError("level parameter is not supported yet.") + + return self._binaryop(other, "__mul__", fill_value) + + mul = multiply + + @_cudf_nvtx_annotate + @docutils.doc_apply( + doc_binop_template.format( + operation="Multiplication", + op_name="rmul", + equivalent_op="other * frame", + df_op_example=textwrap.dedent( + """ + >>> df.rmul(1) + angles degrees + circle 0 360 + triangle 3 180 + rectangle 4 360 + """ + ), + ser_op_example=textwrap.dedent( + """ + >>> a.rmul(b) + a 1 + b + c + d + e + dtype: int64 + >>> a.rmul(b, fill_value=0) + a 1 + b 0 + c 0 + d 0 + e + dtype: int64 + """ + ), + ) + ) + def rmul(self, other, axis, level=None, fill_value=None): # noqa: D102 + if level is not None: + raise NotImplementedError("level parameter is not supported yet.") + + return self._binaryop(other, "__rmul__", fill_value) + + @_cudf_nvtx_annotate + @docutils.doc_apply( + doc_binop_template.format( + operation="Modulo", + op_name="mod", + equivalent_op="frame % other", + df_op_example=textwrap.dedent( + """ + >>> df.mod(1) + angles degrees + circle 0 0 + triangle 0 0 + rectangle 0 0 + """ + ), + ser_op_example=textwrap.dedent( + """ + >>> a.mod(b) + a 0 + b + c + d + e + dtype: int64 + >>> a.mod(b, fill_value=0) + a 0 + b 4294967295 + c 4294967295 + d 0 + e + dtype: int64 + """ + ), + ) + ) + def mod(self, other, axis, level=None, fill_value=None): # noqa: D102 + if level is not None: + raise NotImplementedError("level parameter is not supported yet.") + + return self._binaryop(other, "__mod__", fill_value) + + @_cudf_nvtx_annotate + @docutils.doc_apply( + doc_binop_template.format( + operation="Modulo", + op_name="rmod", + equivalent_op="other % frame", + df_op_example=textwrap.dedent( + """ + >>> df.rmod(1) + angles degrees + circle 4294967295 1 + triangle 1 1 + rectangle 1 1 + """ + ), + ser_op_example=textwrap.dedent( + """ + >>> a.rmod(b) + a 0 + b + c + d + e + dtype: int64 + >>> a.rmod(b, fill_value=0) + a 0 + b 0 + c 0 + d 4294967295 + e + dtype: int64 + """ + ), + ) + ) + def rmod(self, other, axis, level=None, fill_value=None): # noqa: D102 + if level is not None: + raise NotImplementedError("level parameter is not supported yet.") + + return self._binaryop(other, "__rmod__", fill_value) + + @_cudf_nvtx_annotate + @docutils.doc_apply( + doc_binop_template.format( + operation="Exponential", + op_name="pow", + equivalent_op="frame ** other", + df_op_example=textwrap.dedent( + """ + >>> df.pow(1) + angles degrees + circle 0 360 + triangle 2 180 + rectangle 4 360 + """ + ), + ser_op_example=textwrap.dedent( + """ + >>> a.pow(b) + a 1 + b + c + d + e + dtype: int64 + >>> a.pow(b, fill_value=0) + a 1 + b 1 + c 1 + d 0 + e + dtype: int64 + """ + ), + ) + ) + def pow(self, other, axis, level=None, fill_value=None): # noqa: D102 + if level is not None: + raise NotImplementedError("level parameter is not supported yet.") + + return self._binaryop(other, "__pow__", fill_value) + + @_cudf_nvtx_annotate + @docutils.doc_apply( + doc_binop_template.format( + operation="Exponential", + op_name="rpow", + equivalent_op="other ** frame", + df_op_example=textwrap.dedent( + """ + >>> df.rpow(1) + angles degrees + circle 1 1 + triangle 1 1 + rectangle 1 1 + """ + ), + ser_op_example=textwrap.dedent( + """ + >>> a.rpow(b) + a 1 + b + c + d + e + dtype: int64 + >>> a.rpow(b, fill_value=0) + a 1 + b 0 + c 0 + d 1 + e + dtype: int64 + """ + ), + ) + ) + def rpow(self, other, axis, level=None, fill_value=None): # noqa: D102 + if level is not None: + raise NotImplementedError("level parameter is not supported yet.") + + return self._binaryop(other, "__rpow__", fill_value) + + @_cudf_nvtx_annotate + @docutils.doc_apply( + doc_binop_template.format( + operation="Integer division", + op_name="floordiv", + equivalent_op="frame // other", + df_op_example=textwrap.dedent( + """ + >>> df.floordiv(1) + angles degrees + circle 0 360 + triangle 3 180 + rectangle 4 360 + """ + ), + ser_op_example=textwrap.dedent( + """ + >>> a.floordiv(b) + a 1 + b + c + d + e + dtype: int64 + >>> a.floordiv(b, fill_value=0) + a 1 + b 9223372036854775807 + c 9223372036854775807 + d 0 + e + dtype: int64 + """ + ), + ) + ) + def floordiv(self, other, axis, level=None, fill_value=None): # noqa: D102 + if level is not None: + raise NotImplementedError("level parameter is not supported yet.") + + return self._binaryop(other, "__floordiv__", fill_value) + + @_cudf_nvtx_annotate + @docutils.doc_apply( + doc_binop_template.format( + operation="Integer division", + op_name="rfloordiv", + equivalent_op="other // frame", + df_op_example=textwrap.dedent( + """ + >>> df.rfloordiv(1) + angles degrees + circle 9223372036854775807 0 + triangle 0 0 + rectangle 0 0 + """ + ), + ser_op_example=textwrap.dedent( + """ + >>> a.rfloordiv(b) + a 1 + b + c + d + e + dtype: int64 + >>> a.rfloordiv(b, fill_value=0) + a 1 + b 0 + c 0 + d 9223372036854775807 + e + dtype: int64 + """ + ), + ) + ) + def rfloordiv( + self, other, axis, level=None, fill_value=None + ): # noqa: D102 + if level is not None: + raise NotImplementedError("level parameter is not supported yet.") + + return self._binaryop(other, "__rfloordiv__", fill_value) + + @_cudf_nvtx_annotate + @docutils.doc_apply( + doc_binop_template.format( + operation="Floating division", + op_name="truediv", + equivalent_op="frame / other", + df_op_example=textwrap.dedent( + """ + >>> df.truediv(1) + angles degrees + circle 0.0 360.0 + triangle 3.0 180.0 + rectangle 4.0 360.0 + """ + ), + ser_op_example=textwrap.dedent( + """ + >>> a.truediv(b) + a 1.0 + b + c + d + e + dtype: float64 + >>> a.truediv(b, fill_value=0) + a 1.0 + b Inf + c Inf + d 0.0 + e + dtype: float64 + """ + ), + ) + ) + def truediv(self, other, axis, level=None, fill_value=None): # noqa: D102 + if level is not None: + raise NotImplementedError("level parameter is not supported yet.") + + return self._binaryop(other, "__truediv__", fill_value) + + # Alias for truediv + div = truediv + divide = truediv + + @_cudf_nvtx_annotate + @docutils.doc_apply( + doc_binop_template.format( + operation="Floating division", + op_name="rtruediv", + equivalent_op="other / frame", + df_op_example=textwrap.dedent( + """ + >>> df.rtruediv(1) + angles degrees + circle inf 0.002778 + triangle 0.333333 0.005556 + rectangle 0.250000 0.002778 + """ + ), + ser_op_example=textwrap.dedent( + """ + >>> a.rtruediv(b) + a 1.0 + b + c + d + e + dtype: float64 + >>> a.rtruediv(b, fill_value=0) + a 1.0 + b 0.0 + c 0.0 + d Inf + e + dtype: float64 + """ + ), + ) + ) + def rtruediv(self, other, axis, level=None, fill_value=None): # noqa: D102 + if level is not None: + raise NotImplementedError("level parameter is not supported yet.") + + return self._binaryop(other, "__rtruediv__", fill_value) + + # Alias for rtruediv + rdiv = rtruediv + + @_cudf_nvtx_annotate + @docutils.doc_apply( + doc_binop_template.format( + operation="Equal to", + op_name="eq", + equivalent_op="frame == other", + df_op_example=textwrap.dedent( + """ + >>> df.eq(1) + angles degrees + circle False False + triangle False False + rectangle False False + """ + ), + ser_op_example=textwrap.dedent( + """ + >>> a.eq(b) + a True + b + c + d + e + dtype: bool + >>> a.eq(b, fill_value=0) + a True + b False + c False + d False + e + dtype: bool + """ + ), + ) + ) + def eq( + self, other, axis="columns", level=None, fill_value=None + ): # noqa: D102 + return self._binaryop( + other=other, op="__eq__", fill_value=fill_value, can_reindex=True + ) + + @_cudf_nvtx_annotate + @docutils.doc_apply( + doc_binop_template.format( + operation="Not equal to", + op_name="ne", + equivalent_op="frame != other", + df_op_example=textwrap.dedent( + """ + >>> df.ne(1) + angles degrees + circle True True + triangle True True + rectangle True True + """ + ), + ser_op_example=textwrap.dedent( + """ + >>> a.ne(b) + a False + b + c + d + e + dtype: bool + >>> a.ne(b, fill_value=0) + a False + b True + c True + d True + e + dtype: bool + """ + ), + ) + ) + def ne( + self, other, axis="columns", level=None, fill_value=None + ): # noqa: D102 + return self._binaryop( + other=other, op="__ne__", fill_value=fill_value, can_reindex=True + ) + + @_cudf_nvtx_annotate + @docutils.doc_apply( + doc_binop_template.format( + operation="Less than", + op_name="lt", + equivalent_op="frame < other", + df_op_example=textwrap.dedent( + """ + >>> df.lt(1) + angles degrees + circle True False + triangle False False + rectangle False False + """ + ), + ser_op_example=textwrap.dedent( + """ + >>> a.lt(b) + a False + b + c + d + e + dtype: bool + >>> a.lt(b, fill_value=0) + a False + b False + c False + d True + e + dtype: bool + """ + ), + ) + ) + def lt( + self, other, axis="columns", level=None, fill_value=None + ): # noqa: D102 + return self._binaryop( + other=other, op="__lt__", fill_value=fill_value, can_reindex=True + ) + + @_cudf_nvtx_annotate + @docutils.doc_apply( + doc_binop_template.format( + operation="Less than or equal to", + op_name="le", + equivalent_op="frame <= other", + df_op_example=textwrap.dedent( + """ + >>> df.le(1) + angles degrees + circle True False + triangle False False + rectangle False False + """ + ), + ser_op_example=textwrap.dedent( + """ + >>> a.le(b) + a True + b + c + d + e + dtype: bool + >>> a.le(b, fill_value=0) + a True + b False + c False + d True + e + dtype: bool + """ + ), + ) + ) + def le( + self, other, axis="columns", level=None, fill_value=None + ): # noqa: D102 + return self._binaryop( + other=other, op="__le__", fill_value=fill_value, can_reindex=True + ) + + @_cudf_nvtx_annotate + @docutils.doc_apply( + doc_binop_template.format( + operation="Greater than", + op_name="gt", + equivalent_op="frame > other", + df_op_example=textwrap.dedent( + """ + >>> df.gt(1) + angles degrees + circle False True + triangle True True + rectangle True True + """ + ), + ser_op_example=textwrap.dedent( + """ + >>> a.gt(b) + a False + b + c + d + e + dtype: bool + >>> a.gt(b, fill_value=0) + a False + b True + c True + d False + e + dtype: bool + """ + ), + ) + ) + def gt( + self, other, axis="columns", level=None, fill_value=None + ): # noqa: D102 + return self._binaryop( + other=other, op="__gt__", fill_value=fill_value, can_reindex=True + ) + + @_cudf_nvtx_annotate + @docutils.doc_apply( + doc_binop_template.format( + operation="Greater than or equal to", + op_name="ge", + equivalent_op="frame >= other", + df_op_example=textwrap.dedent( + """ + >>> df.ge(1) + angles degrees + circle False True + triangle True True + rectangle True True + """ + ), + ser_op_example=textwrap.dedent( + """ + >>> a.ge(b) + a True + b + c + d + e + dtype: bool + >>> a.ge(b, fill_value=0) + a True + b True + c True + d False + e + dtype: bool + """ + ), + ) + ) + def ge( + self, other, axis="columns", level=None, fill_value=None + ): # noqa: D102 + return self._binaryop( + other=other, op="__ge__", fill_value=fill_value, can_reindex=True + ) + def _check_duplicate_level_names(specified, level_names): """Raise if any of `specified` has duplicates in `level_names`.""" diff --git a/python/cudf/cudf/core/series.py b/python/cudf/cudf/core/series.py index d14942cd3ce..965810a19e6 100644 --- a/python/cudf/cudf/core/series.py +++ b/python/cudf/cudf/core/series.py @@ -53,7 +53,6 @@ from cudf.core.column.string import StringMethods from cudf.core.column.struct import StructMethods from cudf.core.column_accessor import ColumnAccessor -from cudf.core.frame import Frame from cudf.core.groupby.groupby import SeriesGroupBy from cudf.core.index import BaseIndex, RangeIndex, as_index from cudf.core.indexed_frame import ( @@ -3284,7 +3283,7 @@ def make_binop_func(op): # appropriate API for Series as required for pandas compatibility. The # main effect is reordering and error-checking parameters in # Series-specific ways. - wrapped_func = getattr(Frame, op) + wrapped_func = getattr(IndexedFrame, op) @functools.wraps(wrapped_func) def wrapper(self, other, level=None, fill_value=None, axis=0): From 018924f0b740d1094910abb66cf5a833d9c0d040 Mon Sep 17 00:00:00 2001 From: Vukasin Milovanovic Date: Thu, 7 Apr 2022 12:17:10 -0700 Subject: [PATCH 043/246] Verify compression type in Parquet reader (#10610) Closes #10602 This PR adds a compression type check for each chunk in the input file. Reader throws in an unsupported compression is used. Authors: - Vukasin Milovanovic (https://github.com/vuule) Approvers: - https://github.com/brandon-b-miller - Yunsong Wang (https://github.com/PointKernel) - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/cudf/pull/10610 --- cpp/src/io/parquet/reader_impl.cu | 13 +++++++++++++ .../cudf/tests/data/parquet/spark_zstd.parquet | Bin 0 -> 459 bytes python/cudf/cudf/tests/test_parquet.py | 7 +++++++ 3 files changed, 20 insertions(+) create mode 100644 python/cudf/cudf/tests/data/parquet/spark_zstd.parquet diff --git a/cpp/src/io/parquet/reader_impl.cu b/cpp/src/io/parquet/reader_impl.cu index 56eb34bbe2f..46b3206f731 100644 --- a/cpp/src/io/parquet/reader_impl.cu +++ b/cpp/src/io/parquet/reader_impl.cu @@ -1179,6 +1179,19 @@ rmm::device_buffer reader::impl::decompress_page_data( codec_stats{parquet::SNAPPY, 0, 0}, codec_stats{parquet::BROTLI, 0, 0}}; + auto is_codec_supported = [&codecs](int8_t codec) { + if (codec == parquet::UNCOMPRESSED) return true; + return std::find_if(codecs.begin(), codecs.end(), [codec](auto& cstats) { + return codec == cstats.compression_type; + }) != codecs.end(); + }; + CUDF_EXPECTS(std::all_of(chunks.begin(), + chunks.end(), + [&is_codec_supported](auto const& chunk) { + return is_codec_supported(chunk.codec); + }), + "Unsupported compression type"); + for (auto& codec : codecs) { for_each_codec_page(codec.compression_type, [&](size_t page) { auto page_uncomp_size = pages[page].uncompressed_page_size; diff --git a/python/cudf/cudf/tests/data/parquet/spark_zstd.parquet b/python/cudf/cudf/tests/data/parquet/spark_zstd.parquet new file mode 100644 index 0000000000000000000000000000000000000000..99b584aa557dc0837d70ac2f7d21a3898af7f279 GIT binary patch literal 459 zcmZWm%SyvQ6uqe$vgk(W3=_yA4760KV-rnZxN#%mse=bgp{cS(5(cs&H~AG0 zE7rwUaI4Otx{==^(x+4;1HeBFR^m@g0lhLS77t5gUlU@I4irw2EY-$cz3Ma@PR8Qk zO!=w~;^^N*HcJ!*oy~Qw(#e||=^P`>QQR$L{yx>RBeOi6_j6g3@lYpGCOh{FImXet zg~aZrhT~ihbV|f{o+Q{ys2^jJ>6-l0l%2(L`LG0WvvWKdrS2}G>nYDyo?GqBhe_o6 t81(Cne$a}s-D<|I0MYloX1%Aq^Qi4NqacnOx)~kWjzd45(l)xZ#$WzKX&3+i literal 0 HcmV?d00001 diff --git a/python/cudf/cudf/tests/test_parquet.py b/python/cudf/cudf/tests/test_parquet.py index 58ba77d0b0e..727200293f7 100644 --- a/python/cudf/cudf/tests/test_parquet.py +++ b/python/cudf/cudf/tests/test_parquet.py @@ -2420,3 +2420,10 @@ def test_parquet_reader_decimal_columns(): expected = pd.read_parquet(buffer, columns=["col3", "col2", "col1"]) assert_eq(actual, expected) + + +def test_parquet_reader_unsupported_compression(datadir): + fname = datadir / "spark_zstd.parquet" + + with pytest.raises(RuntimeError): + cudf.read_parquet(fname) From 26c1810fe23ed1ce6938fd6b39b4009f24e7e5aa Mon Sep 17 00:00:00 2001 From: Jason Lowe Date: Thu, 7 Apr 2022 17:37:13 -0500 Subject: [PATCH 044/246] Allow libcudfjni to be built as a static library (#10619) This adds the ability for the JNI native libraries to be built as static libraries rather than shared libraries by specifying `-DBUILD_SHARED_LIBS=OFF` when configuring with cmake. This can be useful for external projects that are leveraging the JNI libraries and would like to use an archive that they can link into their shared library. Authors: - Jason Lowe (https://github.com/jlowe) Approvers: - MithunR (https://github.com/mythrocks) URL: https://github.com/rapidsai/cudf/pull/10619 --- java/pom.xml | 3 ++- java/src/main/native/CMakeLists.txt | 28 +++++++++++++++++++++------- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/java/pom.xml b/java/pom.xml index d2104269c2c..9d94df8474a 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -1,6 +1,6 @@ |<-------------monza--------------> - * @endcode - */ -template -std::unique_ptr make_rank_aggregation(); - -/** - * @brief Factory to create a DENSE_RANK aggregation - * - * `DENSE_RANK` returns a non-nullable column of size_type "dense ranks": the preceding unique - * value's rank plus one. As a result, ranks are not unique but there are no gaps in the ranking - * sequence (unlike RANK aggregations). - * - * This aggregation only works with "scan" algorithms. The input column into the group or - * ungrouped scan is an orderby column that orders the rows that the aggregate function ranks. - * If rows are ordered by more than one column, the orderby input column should be a struct - * column containing the ordering columns. - * - * Note: - * 1. This method requires that the rows are presorted by the group keys and order_by columns. - * 2. `DENSE_RANK` aggregations will return a fully valid column regardless of null_handling - * policy specified in the scan. - * 3. `DENSE_RANK` aggregations are not compatible with exclusive scans. - * - * @code{.pseudo} - * Example: Consider a motor-racing statistics dataset, containing the following columns: - * 1. venue: (STRING) Location of the race event - * 2. driver: (STRING) Name of the car driver (abbreviated to 3 characters) - * 3. time: (INT32) Time taken to complete the circuit - * - * For the following presorted data: + * Produces the following rank column for each methods: + * first: { 1, 2, 3, 4, 5, 1, 2, 3, 4, 5} + * average: { 1, 2, 3.5, 3.5, 5, 1, 2.5, 2.5, 4, 5} + * min: { 1, 2, 3, 3, 5, 1, 2, 2, 4, 5} + * max: { 1, 2, 4, 4, 5, 1, 3, 3, 4, 5} + * dense: { 1, 2, 3, 3, 4, 1, 2, 2, 3, 4} + * This corresponds to the following grouping and `driver` rows: + * { "HAM", "LEC", "BOT", "NOR", "RIC", "RIC", "NOR", "BOT", "LEC", "PER" } + * <----------silverstone----------->|<-------------monza--------------> + * + * min rank for each percentage types: + * NONE: { 1, 2, 3, 3, 5, 1, 2, 2, 4, 5 } + * ZERO_NORMALIZED : { 0.16, 0.33, 0.50, 0.50, 0.83, 0.16, 0.33, 0.33, 0.66, 0.83 } + * ONE_NORMALIZED: { 0.00, 0.25, 0.50, 0.50, 1.00, 0.00, 0.25, 0.25, 0.75, 1.00 } + * where count corresponds to the number of rows in the group. @see cudf::rank_percentage * - * [ // venue, driver, time - * { "silverstone", "HAM" ("hamilton"), 15823}, - * { "silverstone", "LEC" ("leclerc"), 15827}, - * { "silverstone", "BOT" ("bottas"), 15834}, // <-- Tied for 3rd place. - * { "silverstone", "NOR" ("norris"), 15834}, // <-- Tied for 3rd place. - * { "silverstone", "RIC" ("ricciardo"), 15905}, - * { "monza", "RIC" ("ricciardo"), 12154}, - * { "monza", "NOR" ("norris"), 12156}, // <-- Tied for 2nd place. - * { "monza", "BOT" ("bottas"), 12156}, // <-- Tied for 2nd place. - * { "monza", "LEC" ("leclerc"), 12201}, - * { "monza", "PER" ("perez"), 12203} - * ] - * - * A grouped dense rank aggregation scan with: - * groupby column : venue - * input orderby column: time - * Produces the following dense rank column: - * { 1, 2, 3, 3, 4, 1, 2, 2, 3, 4} - * (This corresponds to the following grouping and `driver` rows:) - * { "HAM", "LEC", "BOT", "NOR", "RIC", "RIC", "NOR", "BOT", "LEC", "PER" } - * <----------silverstone----------->|<-------------monza--------------> * @endcode - */ -template -std::unique_ptr make_dense_rank_aggregation(); - -/** - * @brief Factory to create a PERCENT_RANK aggregation * - * `PERCENT_RANK` returns a non-nullable column of double precision "fractional" ranks. - * For row index `i`, the percent rank of row `i` is defined as: - * percent_rank = (rank - 1) / (group_row_count - 1) - * where, - * 1. rank is the `RANK` of the row within the group - * 2. group_row_count is the number of rows in the group - * - * This aggregation only works with "scan" algorithms. The input to the grouped or - * ungrouped scan is an orderby column that orders the rows that the aggregate function ranks. - * If rows are ordered by more than one column, the orderby input column should be a struct - * column containing the ordering columns. - * - * Note: - * 1. This method requires that the rows are presorted by the group keys and order_by columns. - * 2. `PERCENT_RANK` aggregations will return a fully valid column regardless of null_handling - * policy specified in the scan. - * 3. `PERCENT_RANK` aggregations are not compatible with exclusive scans. - * - * @code{.pseudo} - * Example: Consider a motor-racing statistics dataset, containing the following columns: - * 1. venue: (STRING) Location of the race event - * 2. driver: (STRING) Name of the car driver (abbreviated to 3 characters) - * 3. time: (INT32) Time taken to complete the circuit - * - * For the following presorted data: - * - * [ // venue, driver, time - * { "silverstone", "HAM" ("hamilton"), 15823}, - * { "silverstone", "LEC" ("leclerc"), 15827}, - * { "silverstone", "BOT" ("bottas"), 15834}, // <-- Tied for 3rd place. - * { "silverstone", "NOR" ("norris"), 15834}, // <-- Tied for 3rd place. - * { "silverstone", "RIC" ("ricciardo"), 15905}, - * { "monza", "RIC" ("ricciardo"), 12154}, - * { "monza", "NOR" ("norris"), 12156}, // <-- Tied for 2nd place. - * { "monza", "BOT" ("bottas"), 12156}, // <-- Tied for 2nd place. - * { "monza", "LEC" ("leclerc"), 12201}, - * { "monza", "PER" ("perez"), 12203} - * ] - * - * A grouped percent rank aggregation scan with: - * groupby column : venue - * input orderby column: time - * Produces the following percent rank column: - * { 0.00, 0.25, 0.50, 0.50, 1.00, 0.00, 0.25, 0.25, 0.75, 1.00 } - * - * (This corresponds to the following grouping and `driver` rows:) - * { "HAM", "LEC", "BOT", "NOR", "RIC", "RIC", "NOR", "BOT", "LEC", "PER" } - * <----------silverstone----------->|<-------------monza--------------> - * @endcode + * @param method The ranking method used for tie breaking (same values). + * @param column_order The desired sort order for ranking + * @param null_handling flag to include nulls during ranking. If nulls are not included, + * the corresponding rank will be null. + * @param null_precedence The desired order of null compared to other elements for column + * @param percentage enum to denote the type of conversion of ranks to percentage in range (0,1] */ template -std::unique_ptr make_percent_rank_aggregation(); +std::unique_ptr make_rank_aggregation(rank_method method, + order column_order = order::ASCENDING, + null_policy null_handling = null_policy::EXCLUDE, + null_order null_precedence = null_order::AFTER, + rank_percentage percentage = rank_percentage::NONE); /** * @brief Factory to create a COLLECT_LIST aggregation diff --git a/cpp/include/cudf/detail/aggregation/aggregation.hpp b/cpp/include/cudf/detail/aggregation/aggregation.hpp index 886151fb9d6..8ca49dd7d5f 100644 --- a/cpp/include/cudf/detail/aggregation/aggregation.hpp +++ b/cpp/include/cudf/detail/aggregation/aggregation.hpp @@ -75,10 +75,6 @@ class simple_aggregations_collector { // Declares the interface for the simple class row_number_aggregation const& agg); virtual std::vector> visit(data_type col_type, class rank_aggregation const& agg); - virtual std::vector> visit(data_type col_type, - class dense_rank_aggregation const& agg); - virtual std::vector> visit( - data_type col_type, class percent_rank_aggregation const& agg); virtual std::vector> visit( data_type col_type, class collect_list_aggregation const& agg); virtual std::vector> visit(data_type col_type, @@ -127,8 +123,6 @@ class aggregation_finalizer { // Declares the interface for the finalizer virtual void visit(class nth_element_aggregation const& agg); virtual void visit(class row_number_aggregation const& agg); virtual void visit(class rank_aggregation const& agg); - virtual void visit(class dense_rank_aggregation const& agg); - virtual void visit(class percent_rank_aggregation const& agg); virtual void visit(class collect_list_aggregation const& agg); virtual void visit(class collect_set_aggregation const& agg); virtual void visit(class lead_lag_aggregation const& agg); @@ -642,32 +636,42 @@ class rank_aggregation final : public rolling_aggregation, public groupby_scan_aggregation, public scan_aggregation { public: - rank_aggregation() : aggregation{RANK} {} - - [[nodiscard]] std::unique_ptr clone() const override + rank_aggregation(rank_method method, + order column_order, + null_policy null_handling, + null_order null_precedence, + rank_percentage percentage) + : aggregation{RANK}, + _method{method}, + _column_order{column_order}, + _null_handling{null_handling}, + _null_precedence{null_precedence}, + _percentage(percentage) { - return std::make_unique(*this); } - std::vector> get_simple_aggregations( - data_type col_type, simple_aggregations_collector& collector) const override + rank_method const _method; ///< rank method + order const _column_order; ///< order of the column to rank + null_policy const _null_handling; ///< include or exclude nulls in ranks + null_order const _null_precedence; ///< order of nulls in ranks + rank_percentage const _percentage; ///< whether to return percentage ranks + + [[nodiscard]] bool is_equal(aggregation const& _other) const override { - return collector.visit(col_type, *this); + if (!this->aggregation::is_equal(_other)) { return false; } + auto const& other = dynamic_cast(_other); + return _method == other._method and _null_handling == other._null_handling and + _column_order == other._column_order and _null_precedence == other._null_precedence and + _percentage == other._percentage; } - void finalize(aggregation_finalizer& finalizer) const override { finalizer.visit(*this); } -}; -/** - * @brief Derived class for specifying a dense rank aggregation - */ -class dense_rank_aggregation final : public rolling_aggregation, - public groupby_scan_aggregation, - public scan_aggregation { - public: - dense_rank_aggregation() : aggregation{DENSE_RANK} {} + [[nodiscard]] size_t do_hash() const override + { + return this->aggregation::do_hash() ^ hash_impl(); + } [[nodiscard]] std::unique_ptr clone() const override { - return std::make_unique(*this); + return std::make_unique(*this); } std::vector> get_simple_aggregations( data_type col_type, simple_aggregations_collector& collector) const override @@ -675,24 +679,16 @@ class dense_rank_aggregation final : public rolling_aggregation, return collector.visit(col_type, *this); } void finalize(aggregation_finalizer& finalizer) const override { finalizer.visit(*this); } -}; - -class percent_rank_aggregation final : public rolling_aggregation, - public groupby_scan_aggregation, - public scan_aggregation { - public: - percent_rank_aggregation() : aggregation{PERCENT_RANK} {} - [[nodiscard]] std::unique_ptr clone() const override - { - return std::make_unique(*this); - } - std::vector> get_simple_aggregations( - data_type col_type, simple_aggregations_collector& collector) const override + private: + [[nodiscard]] size_t hash_impl() const { - return collector.visit(col_type, *this); + return std::hash{}(static_cast(_method)) ^ + std::hash{}(static_cast(_column_order)) ^ + std::hash{}(static_cast(_null_handling)) ^ + std::hash{}(static_cast(_null_precedence)) ^ + std::hash{}(static_cast(_percentage)); } - void finalize(aggregation_finalizer& finalizer) const override { finalizer.visit(*this); } }; /** @@ -1278,19 +1274,7 @@ struct target_type_impl { // Always use size_type accumulator for RANK template struct target_type_impl { - using type = size_type; -}; - -// Always use size_type accumulator for DENSE_RANK -template -struct target_type_impl { - using type = size_type; -}; - -// Always use double for PERCENT_RANK -template -struct target_type_impl { - using type = double; + using type = size_type; // double for percentage=true. }; // Always use list for COLLECT_LIST @@ -1453,10 +1437,6 @@ CUDF_HOST_DEVICE inline decltype(auto) aggregation_dispatcher(aggregation::Kind return f.template operator()(std::forward(args)...); case aggregation::RANK: return f.template operator()(std::forward(args)...); - case aggregation::DENSE_RANK: - return f.template operator()(std::forward(args)...); - case aggregation::PERCENT_RANK: - return f.template operator()(std::forward(args)...); case aggregation::COLLECT_LIST: return f.template operator()(std::forward(args)...); case aggregation::COLLECT_SET: diff --git a/cpp/include/cudf/detail/scan.hpp b/cpp/include/cudf/detail/scan.hpp index fc829617c2d..13dddd3b0c8 100644 --- a/cpp/include/cudf/detail/scan.hpp +++ b/cpp/include/cudf/detail/scan.hpp @@ -103,16 +103,17 @@ std::unique_ptr inclusive_dense_rank_scan(column_view const& order_by, rmm::mr::device_memory_resource* mr); /** - * @brief Generate row percent ranks for a column. + * @brief Generate row ONE_NORMALIZED percent ranks for a column. + * Also, knowns as ANSI SQL PERCENT RANK. + * Calculated by (rank - 1) / (count - 1). * * @param order_by Input column to generate ranks for. * @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 rank values. */ -std::unique_ptr inclusive_percent_rank_scan(column_view const& order_by, - rmm::cuda_stream_view stream, - rmm::mr::device_memory_resource* mr); +std::unique_ptr inclusive_one_normalized_percent_rank_scan( + column_view const& order_by, rmm::cuda_stream_view stream, rmm::mr::device_memory_resource* mr); } // namespace detail } // namespace cudf diff --git a/cpp/include/cudf/sorting.hpp b/cpp/include/cudf/sorting.hpp index ff334b9ee85..b7e915650dc 100644 --- a/cpp/include/cudf/sorting.hpp +++ b/cpp/include/cudf/sorting.hpp @@ -16,6 +16,7 @@ #pragma once +#include #include #include @@ -23,19 +24,6 @@ namespace cudf { -/** - * @brief Tie-breaker method to use for ranking the column. - * - * @ingroup column_sort - */ -enum class rank_method { - FIRST, ///< stable sort order ranking (no ties) - AVERAGE, ///< mean of first in the group - MIN, ///< min of first in the group - MAX, ///< max of first in the group - DENSE ///< rank always increases by 1 between groups -}; - /** * @addtogroup column_sort * @{ @@ -198,7 +186,7 @@ std::unique_ptr
stable_sort_by_key( * included, corresponding rank will be null. * @param null_precedence The desired order of null compared to other elements * for column - * @param percentage flag to convert ranks to percentage in range (0,1} + * @param percentage flag to convert ranks to percentage in range (0,1] * @param mr Device memory resource used to allocate the returned column's device memory * @return std::unique_ptr A column of containing the rank of the each * element of the column of `input`. The output column type will be `size_type` diff --git a/cpp/src/aggregation/aggregation.cpp b/cpp/src/aggregation/aggregation.cpp index 8fedf641c8f..27732b25401 100644 --- a/cpp/src/aggregation/aggregation.cpp +++ b/cpp/src/aggregation/aggregation.cpp @@ -154,18 +154,6 @@ std::vector> simple_aggregations_collector::visit( return visit(col_type, static_cast(agg)); } -std::vector> simple_aggregations_collector::visit( - data_type col_type, dense_rank_aggregation const& agg) -{ - return visit(col_type, static_cast(agg)); -} - -std::vector> simple_aggregations_collector::visit( - data_type col_type, percent_rank_aggregation const& agg) -{ - return visit(col_type, static_cast(agg)); -} - std::vector> simple_aggregations_collector::visit( data_type col_type, collect_list_aggregation const& agg) { @@ -334,16 +322,6 @@ void aggregation_finalizer::visit(rank_aggregation const& agg) visit(static_cast(agg)); } -void aggregation_finalizer::visit(dense_rank_aggregation const& agg) -{ - visit(static_cast(agg)); -} - -void aggregation_finalizer::visit(percent_rank_aggregation const& agg) -{ - visit(static_cast(agg)); -} - void aggregation_finalizer::visit(collect_list_aggregation const& agg) { visit(static_cast(agg)); @@ -644,36 +622,33 @@ template std::unique_ptr make_row_number_aggregation -std::unique_ptr make_rank_aggregation() -{ - return std::make_unique(); -} -template std::unique_ptr make_rank_aggregation(); -template std::unique_ptr -make_rank_aggregation(); -template std::unique_ptr make_rank_aggregation(); - -/// Factory to create a DENSE_RANK aggregation -template -std::unique_ptr make_dense_rank_aggregation() -{ - return std::make_unique(); -} -template std::unique_ptr make_dense_rank_aggregation(); -template std::unique_ptr -make_dense_rank_aggregation(); -template std::unique_ptr make_dense_rank_aggregation(); - -/// Factory to create a PERCENT_RANK aggregation -template -std::unique_ptr make_percent_rank_aggregation() -{ - return std::make_unique(); -} -template std::unique_ptr make_percent_rank_aggregation(); -template std::unique_ptr -make_percent_rank_aggregation(); -template std::unique_ptr make_percent_rank_aggregation(); +std::unique_ptr make_rank_aggregation(rank_method method, + order column_order, + null_policy null_handling, + null_order null_precedence, + rank_percentage percentage) +{ + return std::make_unique( + method, column_order, null_handling, null_precedence, percentage); +} +template std::unique_ptr make_rank_aggregation( + rank_method method, + order column_order, + null_policy null_handling, + null_order null_precedence, + rank_percentage percentage); +template std::unique_ptr make_rank_aggregation( + rank_method method, + order column_order, + null_policy null_handling, + null_order null_precedence, + rank_percentage percentage); +template std::unique_ptr make_rank_aggregation( + rank_method method, + order column_order, + null_policy null_handling, + null_order null_precedence, + rank_percentage percentage); /// Factory to create a COLLECT_LIST aggregation template diff --git a/cpp/src/groupby/groupby.cu b/cpp/src/groupby/groupby.cu index 79882239b38..a002b0bb744 100644 --- a/cpp/src/groupby/groupby.cu +++ b/cpp/src/groupby/groupby.cu @@ -101,9 +101,12 @@ namespace { * Adds special handling for COLLECT_LIST/COLLECT_SET, because: * 1. `make_empty_column()` does not support construction of nested columns. * 2. Empty lists need empty child columns, to persist type information. + * Adds special handling for RANK, because it needs to return double type column when rank_method is + * AVERAGE or percentage is true. */ struct empty_column_constructor { column_view values; + aggregation const& agg; template std::unique_ptr operator()() const @@ -116,6 +119,14 @@ struct empty_column_constructor { 0, make_empty_column(type_to_id()), empty_like(values), 0, {}); } + if constexpr (k == aggregation::Kind::RANK) { + auto const& rank_agg = dynamic_cast(agg); + if (rank_agg._method == cudf::rank_method::AVERAGE or + rank_agg._percentage != rank_percentage::NONE) + return make_empty_column(type_to_id()); + return make_empty_column(target_type(values.type(), k)); + } + // If `values` is LIST typed, and the aggregation results match the type, // construct empty results based on `values`. // Most generally, this applies if input type matches output type. @@ -148,7 +159,7 @@ auto empty_results(host_span requests) std::back_inserter(results), [&request](auto const& agg) { return cudf::detail::dispatch_type_and_aggregation( - request.values.type(), agg->kind, empty_column_constructor{request.values}); + request.values.type(), agg->kind, empty_column_constructor{request.values, *agg}); }); return aggregation_result{std::move(results)}; diff --git a/cpp/src/groupby/sort/functors.hpp b/cpp/src/groupby/sort/functors.hpp index fa3d19bdcfd..748e34a583d 100644 --- a/cpp/src/groupby/sort/functors.hpp +++ b/cpp/src/groupby/sort/functors.hpp @@ -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. @@ -87,7 +87,6 @@ struct store_result_functor { */ column_view get_sorted_values() { - if (is_presorted()) { return values; } return sorted_values ? sorted_values->view() : (sorted_values = helper.sorted_values(values, stream))->view(); }; diff --git a/cpp/src/groupby/sort/group_rank_scan.cu b/cpp/src/groupby/sort/group_rank_scan.cu index 77d68edaa3a..0b25ab9a33d 100644 --- a/cpp/src/groupby/sort/group_rank_scan.cu +++ b/cpp/src/groupby/sort/group_rank_scan.cu @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -27,6 +28,7 @@ #include #include +#include #include #include #include @@ -35,23 +37,59 @@ namespace cudf { namespace groupby { namespace detail { namespace { + +/** + * @brief Functor to compare two rows of a table in given permutation order + * This is useful to identify unique elements in a sorted order table, when the permutation order is + * the sorted order of the table. + * + */ +template +struct permuted_comparator { + /** + * @brief comparator object which compares two rows of the table in given permutation order + * + * @param device_table Device table to compare + * @param permutation The permutation order, integer type column. + * @param has_nulls whether the table has nulls + */ + permuted_comparator(table_device_view device_table, Iterator const permutation, bool has_nulls) + : comparator(nullate::DYNAMIC{has_nulls}, device_table, device_table, null_equality::EQUAL), + permutation(permutation) + { + } + __device__ bool operator()(size_type index1, size_type index2) const + { + return comparator(permutation[index1], permutation[index2]); + }; + + private: + row_equality_comparator comparator; + Iterator const permutation; +}; + /** * @brief generate grouped row ranks or dense ranks using a row comparison then scan the results * + * @tparam forward true if the rank scan computation should use forward iterator traversal (default) + * else reverse iterator traversal * @tparam value_resolver flag value resolver function with boolean first and row number arguments * @tparam scan_operator scan function ran on the flag values - * @param order_by input column to generate ranks for + * @param grouped_values input column to generate ranks for + * @param value_order column of type INT32 that contains the order of the values in the + * grouped_values column * @param group_labels ID of group that the corresponding value belongs to * @param group_offsets group index offsets with group ID indices * @param resolver flag value resolver * @param scan_op scan operation ran on the flag results - * @param has_nulls true if nulls are included in the `order_by` column + * @param has_nulls true if nulls are included in the `grouped_values` column * @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 std::unique_ptr rank values */ -template -std::unique_ptr rank_generator(column_view const& order_by, +template +std::unique_ptr rank_generator(column_view const& grouped_values, + column_view const& value_order, device_span group_labels, device_span group_offsets, value_resolver resolver, @@ -61,10 +99,11 @@ std::unique_ptr rank_generator(column_view const& order_by, rmm::mr::device_memory_resource* mr) { auto const flattened = cudf::structs::detail::flatten_nested_columns( - table_view{{order_by}}, {}, {}, structs::detail::column_nullability::MATCH_INCOMING); + table_view{{grouped_values}}, {}, {}, structs::detail::column_nullability::MATCH_INCOMING); auto const d_flat_order = table_device_view::create(flattened, stream); - row_equality_comparator comparator( - nullate::DYNAMIC{has_nulls}, *d_flat_order, *d_flat_order, null_equality::EQUAL); + auto sorted_index_order = value_order.begin(); + auto comparator = permuted_comparator(*d_flat_order, sorted_index_order, has_nulls); + auto ranks = make_fixed_width_column(data_type{type_to_id()}, flattened.flattened_columns().num_rows(), mask_state::UNALLOCATED, @@ -72,100 +111,218 @@ std::unique_ptr rank_generator(column_view const& order_by, mr); auto mutable_ranks = ranks->mutable_view(); - thrust::tabulate( - rmm::exec_policy(stream), - mutable_ranks.begin(), - mutable_ranks.end(), - [comparator, resolver, labels = group_labels.data(), offsets = group_offsets.data()] __device__( - size_type row_index) { - auto group_start = offsets[labels[row_index]]; + auto unique_identifier = [labels = group_labels.begin(), + offsets = group_offsets.begin(), + comparator, + resolver] __device__(size_type row_index) { + auto const group_start = offsets[labels[row_index]]; + if constexpr (forward) { + // First value of equal values is 1. return resolver(row_index == group_start || !comparator(row_index, row_index - 1), row_index - group_start); - }); + } else { + auto const group_end = offsets[labels[row_index] + 1]; + // Last value of equal values is 1. + return resolver(row_index + 1 == group_end || !comparator(row_index, row_index + 1), + row_index - group_start); + } + }; + thrust::tabulate(rmm::exec_policy(stream), + mutable_ranks.begin(), + mutable_ranks.end(), + unique_identifier); + auto [group_labels_begin, mutable_rank_begin] = [&]() { + if constexpr (forward) { + return thrust::pair{group_labels.begin(), mutable_ranks.begin()}; + } else { + return thrust::pair{thrust::reverse_iterator(group_labels.end()), + thrust::reverse_iterator(mutable_ranks.end())}; + } + }(); thrust::inclusive_scan_by_key(rmm::exec_policy(stream), - group_labels.begin(), - group_labels.end(), - mutable_ranks.begin(), - mutable_ranks.begin(), + group_labels_begin, + group_labels_begin + group_labels.size(), + mutable_rank_begin, + mutable_rank_begin, thrust::equal_to{}, scan_op); - return ranks; } } // namespace -std::unique_ptr rank_scan(column_view const& order_by, - device_span group_labels, - device_span group_offsets, - rmm::cuda_stream_view stream, - rmm::mr::device_memory_resource* mr) +std::unique_ptr min_rank_scan(column_view const& grouped_values, + column_view const& value_order, + device_span group_labels, + device_span group_offsets, + rmm::cuda_stream_view stream, + rmm::mr::device_memory_resource* mr) { - return rank_generator( - order_by, + return rank_generator( + grouped_values, + value_order, group_labels, group_offsets, [] __device__(bool unequal, auto row_index_in_group) { return unequal ? row_index_in_group + 1 : 0; }, DeviceMax{}, - has_nested_nulls(table_view{{order_by}}), + has_nested_nulls(table_view{{grouped_values}}), stream, mr); } -std::unique_ptr dense_rank_scan(column_view const& order_by, - device_span group_labels, - device_span group_offsets, - rmm::cuda_stream_view stream, - rmm::mr::device_memory_resource* mr) +std::unique_ptr max_rank_scan(column_view const& grouped_values, + column_view const& value_order, + device_span group_labels, + device_span group_offsets, + rmm::cuda_stream_view stream, + rmm::mr::device_memory_resource* mr) { - return rank_generator( - order_by, + return rank_generator( + grouped_values, + value_order, group_labels, group_offsets, - [] __device__(bool const unequal, size_type const) { return unequal ? 1 : 0; }, - DeviceSum{}, - has_nested_nulls(table_view{{order_by}}), + [] __device__(bool unequal, auto row_index_in_group) { + return unequal ? row_index_in_group + 1 : std::numeric_limits::max(); + }, + DeviceMin{}, + has_nested_nulls(table_view{{grouped_values}}), stream, mr); } -std::unique_ptr percent_rank_scan(column_view const& order_by, +std::unique_ptr first_rank_scan(column_view const& grouped_values, + column_view const&, + device_span group_labels, + device_span group_offsets, + rmm::cuda_stream_view stream, + rmm::mr::device_memory_resource* mr) +{ + auto ranks = make_fixed_width_column( + data_type{type_to_id()}, group_labels.size(), mask_state::UNALLOCATED, stream, mr); + auto mutable_ranks = ranks->mutable_view(); + thrust::tabulate(rmm::exec_policy(stream), + mutable_ranks.begin(), + mutable_ranks.end(), + [labels = group_labels.begin(), + offsets = group_offsets.begin()] __device__(size_type row_index) { + auto group_start = offsets[labels[row_index]]; + return row_index - group_start + 1; + }); + return ranks; +} + +std::unique_ptr average_rank_scan(column_view const& grouped_values, + column_view const& value_order, device_span group_labels, device_span group_offsets, rmm::cuda_stream_view stream, rmm::mr::device_memory_resource* mr) { - auto const rank_column = rank_scan( - order_by, group_labels, group_offsets, stream, rmm::mr::get_current_device_resource()); - auto const rank_view = rank_column->view(); - auto const group_size_iter = cudf::detail::make_counting_transform_iterator( - 0, - [labels = group_labels.begin(), - offsets = group_offsets.begin()] __device__(size_type row_index) { - auto const group_label = labels[row_index]; - auto const group_start = offsets[group_label]; - auto const group_end = offsets[group_label + 1]; - return group_end - group_start; - }); - - // Result type for PERCENT_RANK is independent of input type. - using result_type = cudf::detail::target_type_t; - - auto percent_rank_result = cudf::make_fixed_width_column( - data_type{type_to_id()}, rank_view.size(), mask_state::UNALLOCATED, stream, mr); - + auto max_rank = max_rank_scan(grouped_values, + value_order, + group_labels, + group_offsets, + stream, + rmm::mr::get_current_device_resource()); + auto min_rank = min_rank_scan(grouped_values, + value_order, + group_labels, + group_offsets, + stream, + rmm::mr::get_current_device_resource()); + auto ranks = make_fixed_width_column( + data_type{type_to_id()}, group_labels.size(), mask_state::UNALLOCATED, stream, mr); + auto mutable_ranks = ranks->mutable_view(); thrust::transform(rmm::exec_policy(stream), - rank_view.begin(), - rank_view.end(), - group_size_iter, - percent_rank_result->mutable_view().begin(), - [] __device__(auto const rank, auto const group_size) { - return group_size == 1 ? 0.0 : ((rank - 1.0) / (group_size - 1)); + max_rank->view().begin(), + max_rank->view().end(), + min_rank->view().begin(), + mutable_ranks.begin(), + [] __device__(auto max_rank, auto min_rank) -> double { + return min_rank + (max_rank - min_rank) / 2.0; }); + return ranks; +} - return percent_rank_result; +std::unique_ptr dense_rank_scan(column_view const& grouped_values, + column_view const& value_order, + device_span group_labels, + device_span group_offsets, + rmm::cuda_stream_view stream, + rmm::mr::device_memory_resource* mr) +{ + return rank_generator( + grouped_values, + value_order, + group_labels, + group_offsets, + [] __device__(bool const unequal, size_type const) { return unequal ? 1 : 0; }, + DeviceSum{}, + has_nested_nulls(table_view{{grouped_values}}), + stream, + mr); +} + +std::unique_ptr group_rank_to_percentage(rank_method const method, + rank_percentage const percentage, + column_view const& rank, + column_view const& count, + device_span group_labels, + device_span group_offsets, + rmm::cuda_stream_view stream, + rmm::mr::device_memory_resource* mr) +{ + CUDF_EXPECTS(percentage != rank_percentage::NONE, "Percentage cannot be NONE"); + auto ranks = make_fixed_width_column( + data_type{type_to_id()}, group_labels.size(), mask_state::UNALLOCATED, stream, mr); + ranks->set_null_mask(copy_bitmask(rank, stream, mr)); + auto mutable_ranks = ranks->mutable_view(); + + auto one_normalized = [] __device__(auto const rank, auto const group_size) { + return group_size == 1 ? 0.0 : ((rank - 1.0) / (group_size - 1)); + }; + if (method == rank_method::DENSE) { + thrust::tabulate(rmm::exec_policy(stream), + mutable_ranks.begin(), + mutable_ranks.end(), + [percentage, + one_normalized, + is_double = rank.type().id() == type_id::FLOAT64, + dcount = count.begin(), + labels = group_labels.begin(), + offsets = group_offsets.begin(), + d_rank = rank.begin(), + s_rank = rank.begin()] __device__(size_type row_index) -> double { + double const r = is_double ? d_rank[row_index] : s_rank[row_index]; + auto const count = dcount[labels[row_index]]; + size_type const last_rank_index = offsets[labels[row_index]] + count - 1; + auto const last_rank = s_rank[last_rank_index]; + return percentage == rank_percentage::ZERO_NORMALIZED + ? r / last_rank + : one_normalized(r, last_rank); + }); + } else { + thrust::tabulate(rmm::exec_policy(stream), + mutable_ranks.begin(), + mutable_ranks.end(), + [percentage, + one_normalized, + is_double = rank.type().id() == type_id::FLOAT64, + dcount = count.begin(), + labels = group_labels.begin(), + d_rank = rank.begin(), + s_rank = rank.begin()] __device__(size_type row_index) -> double { + double const r = is_double ? d_rank[row_index] : s_rank[row_index]; + auto const count = dcount[labels[row_index]]; + return percentage == rank_percentage::ZERO_NORMALIZED + ? r / count + : one_normalized(r, count); + }); + } + return ranks; } } // namespace detail diff --git a/cpp/src/groupby/sort/group_scan.hpp b/cpp/src/groupby/sort/group_scan.hpp index 76a7f3f73c7..dc0eb691748 100644 --- a/cpp/src/groupby/sort/group_scan.hpp +++ b/cpp/src/groupby/sort/group_scan.hpp @@ -85,52 +85,115 @@ std::unique_ptr count_scan(device_span group_labels, rmm::mr::device_memory_resource* mr); /** - * @brief Internal API to calculate groupwise rank value + * @brief Internal API to calculate groupwise min rank value * - * @param order_by column or struct column that rows within a group are sorted by + * @param grouped_values column or struct column that rows within a group are sorted by + * @param value_order column of type INT32 that contains the order of the values in the + * grouped_values column * @param group_labels ID of group that the corresponding value belongs to * @param group_offsets group index offsets with group ID indices * @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 Column of type size_type of rank values */ -std::unique_ptr rank_scan(column_view const& order_by, - device_span group_labels, - device_span group_offsets, - rmm::cuda_stream_view stream, - rmm::mr::device_memory_resource* mr); +std::unique_ptr min_rank_scan(column_view const& grouped_values, + column_view const& value_order, + device_span group_labels, + device_span group_offsets, + rmm::cuda_stream_view stream, + rmm::mr::device_memory_resource* mr); + +/** + * @brief Internal API to calculate groupwise max rank value + * + * @details @copydetails min_rank_scan(column_view const& grouped_values, + * column_view const& value_order, + * device_span group_labels, + * device_span group_offsets, + * rmm::cuda_stream_view stream, + * rmm::mr::device_memory_resource* mr) + */ +std::unique_ptr max_rank_scan(column_view const& grouped_values, + column_view const& value_order, + device_span group_labels, + device_span group_offsets, + rmm::cuda_stream_view stream, + rmm::mr::device_memory_resource* mr); + +/** + * @brief Internal API to calculate groupwise first rank value + * + * @details @copydetails min_rank_scan(column_view const& grouped_values, + * column_view const& value_order, + * device_span group_labels, + * device_span group_offsets, + * rmm::cuda_stream_view stream, + * rmm::mr::device_memory_resource* mr) + */ +std::unique_ptr first_rank_scan(column_view const& grouped_values, + column_view const& value_order, + device_span group_labels, + device_span group_offsets, + rmm::cuda_stream_view stream, + rmm::mr::device_memory_resource* mr); + +/** + * @brief Internal API to calculate groupwise average rank value + * + * @details @copydetails min_rank_scan(column_view const& grouped_values, + * column_view const& value_order, + * device_span group_labels, + * device_span group_offsets, + * rmm::cuda_stream_view stream, + * rmm::mr::device_memory_resource* mr) + */ +std::unique_ptr average_rank_scan(column_view const& grouped_values, + column_view const& value_order, + device_span group_labels, + device_span group_offsets, + rmm::cuda_stream_view stream, + rmm::mr::device_memory_resource* mr); /** * @brief Internal API to calculate groupwise dense rank value * - * @param order_by column or struct column that rows within a group are sorted by + * @param grouped_values column or struct column that rows within a group are sorted by * @param group_labels ID of group that the corresponding value belongs to * @param group_offsets group index offsets with group ID indices * @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 Column of type size_type of dense rank values */ -std::unique_ptr dense_rank_scan(column_view const& order_by, +std::unique_ptr dense_rank_scan(column_view const& grouped_values, + column_view const& value_order, device_span group_labels, device_span group_offsets, rmm::cuda_stream_view stream, rmm::mr::device_memory_resource* mr); /** - * @brief Internal API to calculate groupwise percent rank value + * @brief Convert groupwise rank to groupwise percentage rank * - * @param order_by column or struct column by which the rows within a group are sorted - * @param group_labels ID of group to which the row belongs + * @param method rank method + * @param percentage enum to denote the type of conversion ranks to percentage in range (0,1] + * @param rank Groupwise rank column + * @param count Groupwise count column + * @param group_labels ID of group that the corresponding value belongs to * @param group_offsets group index offsets with group ID indices * @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 Column of type `double` of percent rank values + * @return Column of type double of rank values + */ -std::unique_ptr percent_rank_scan(column_view const& order_by, - device_span group_labels, - device_span group_offsets, - rmm::cuda_stream_view stream, - rmm::mr::device_memory_resource* mr); +std::unique_ptr group_rank_to_percentage(rank_method const method, + rank_percentage const percentage, + column_view const& rank, + column_view const& count, + device_span group_labels, + device_span group_offsets, + rmm::cuda_stream_view stream, + rmm::mr::device_memory_resource* mr); + } // namespace detail } // namespace groupby } // namespace cudf diff --git a/cpp/src/groupby/sort/scan.cpp b/cpp/src/groupby/sort/scan.cpp index 20edc1b3f50..5d345273782 100644 --- a/cpp/src/groupby/sort/scan.cpp +++ b/cpp/src/groupby/sort/scan.cpp @@ -16,14 +16,20 @@ #include #include +#include #include #include #include #include #include +#include +#include +#include +#include #include #include +#include #include #include #include @@ -115,51 +121,70 @@ template <> void scan_result_functor::operator()(aggregation const& agg) { if (cache.has_result(values, agg)) return; - CUDF_EXPECTS(helper.is_presorted(), - "Rank aggregate in groupby scan requires the keys to be presorted"); - auto const order_by = get_grouped_values(); - CUDF_EXPECTS(!cudf::structs::detail::is_or_has_nested_lists(order_by), - "Unsupported list type in grouped rank scan."); - - cache.add_result( - values, - agg, - detail::rank_scan( - order_by, helper.group_labels(stream), helper.group_offsets(stream), stream, mr)); -} - -template <> -void scan_result_functor::operator()(aggregation const& agg) -{ - if (cache.has_result(values, agg)) return; - CUDF_EXPECTS(helper.is_presorted(), - "Dense rank aggregate in groupby scan requires the keys to be presorted"); - auto const order_by = get_grouped_values(); - CUDF_EXPECTS(!cudf::structs::detail::is_or_has_nested_lists(order_by), - "Unsupported list type in grouped dense_rank scan."); - cache.add_result( - values, - agg, - detail::dense_rank_scan( - order_by, helper.group_labels(stream), helper.group_offsets(stream), stream, mr)); -} - -template <> -void scan_result_functor::operator()(aggregation const& agg) -{ - if (cache.has_result(values, agg)) return; - CUDF_EXPECTS(helper.is_presorted(), - "Percent rank aggregate in groupby scan requires the keys to be presorted"); - auto const order_by = get_grouped_values(); - CUDF_EXPECTS(!cudf::structs::detail::is_or_has_nested_lists(order_by), - "Unsupported list type in grouped percent_rank scan."); - - cache.add_result( - values, - agg, - detail::percent_rank_scan( - order_by, helper.group_labels(stream), helper.group_offsets(stream), stream, mr)); + CUDF_EXPECTS(!cudf::structs::detail::is_or_has_nested_lists(values), + "Unsupported list type in grouped rank scan."); + auto const& rank_agg = dynamic_cast(agg); + auto const& group_labels = helper.group_labels(stream); + auto const group_labels_view = column_view(cudf::device_span(group_labels)); + auto const gather_map = [&]() { + if (is_presorted()) { // assumes both keys and values are sorted, Spark does this. + return cudf::detail::sequence( + group_labels.size(), *cudf::make_fixed_width_scalar(size_type{0}, stream), stream); + } else { + auto sort_order = (rank_agg._method == rank_method::FIRST ? cudf::detail::stable_sorted_order + : cudf::detail::sorted_order); + return sort_order(table_view({group_labels_view, get_grouped_values()}), + {order::ASCENDING, rank_agg._column_order}, + {null_order::AFTER, rank_agg._null_precedence}, + stream, + rmm::mr::get_current_device_resource()); + } + }(); + + auto rank_scan = [&]() { + switch (rank_agg._method) { + case rank_method::FIRST: return detail::first_rank_scan; + case rank_method::AVERAGE: return detail::average_rank_scan; + case rank_method::DENSE: return detail::dense_rank_scan; + case rank_method::MIN: return detail::min_rank_scan; + case rank_method::MAX: return detail::max_rank_scan; + default: CUDF_FAIL("Unsupported rank method in groupby scan"); + } + }(); + auto result = rank_scan(get_grouped_values(), + *gather_map, + helper.group_labels(stream), + helper.group_offsets(stream), + stream, + rmm::mr::get_current_device_resource()); + if (rank_agg._percentage != rank_percentage::NONE) { + auto count = get_grouped_values().nullable() and rank_agg._null_handling == null_policy::EXCLUDE + ? detail::group_count_valid(get_grouped_values(), + helper.group_labels(stream), + helper.num_groups(stream), + stream, + rmm::mr::get_current_device_resource()) + : detail::group_count_all(helper.group_offsets(stream), + helper.num_groups(stream), + stream, + rmm::mr::get_current_device_resource()); + result = detail::group_rank_to_percentage(rank_agg._method, + rank_agg._percentage, + *result, + *count, + helper.group_labels(stream), + helper.group_offsets(stream), + stream, + mr); + } + result = std::move(cudf::detail::scatter( + table_view{{*result}}, *gather_map, table_view{{*result}}, false, stream, mr) + ->release()[0]); + if (rank_agg._null_handling == null_policy::EXCLUDE) { + result->set_null_mask(cudf::detail::copy_bitmask(get_grouped_values(), stream, mr)); + } + cache.add_result(values, agg, std::move(result)); } } // namespace detail diff --git a/cpp/src/reductions/scan/rank_scan.cu b/cpp/src/reductions/scan/rank_scan.cu index 521f8e2d06f..0ababbf0a3d 100644 --- a/cpp/src/reductions/scan/rank_scan.cu +++ b/cpp/src/reductions/scan/rank_scan.cu @@ -102,16 +102,15 @@ std::unique_ptr inclusive_rank_scan(column_view const& order_by, mr); } -std::unique_ptr inclusive_percent_rank_scan(column_view const& order_by, - rmm::cuda_stream_view stream, - rmm::mr::device_memory_resource* mr) +std::unique_ptr inclusive_one_normalized_percent_rank_scan( + column_view const& order_by, rmm::cuda_stream_view stream, rmm::mr::device_memory_resource* mr) { auto const rank_column = inclusive_rank_scan(order_by, stream, rmm::mr::get_current_device_resource()); auto const rank_view = rank_column->view(); - // Result type for PERCENT_RANK is independent of input type. - using result_type = cudf::detail::target_type_t; + // Result type for min 0-index percent rank is independent of input type. + using result_type = double; auto percent_rank_result = cudf::make_fixed_width_column( data_type{type_to_id()}, rank_view.size(), mask_state::UNALLOCATED, stream, mr); diff --git a/cpp/src/reductions/scan/scan.cpp b/cpp/src/reductions/scan/scan.cpp index 52aaad5ddcf..b678b9441a5 100644 --- a/cpp/src/reductions/scan/scan.cpp +++ b/cpp/src/reductions/scan/scan.cpp @@ -35,17 +35,17 @@ std::unique_ptr scan(column_view const& input, if (agg->kind == aggregation::RANK) { CUDF_EXPECTS(inclusive == scan_type::INCLUSIVE, "Rank aggregation operator requires an inclusive scan"); - return inclusive_rank_scan(input, rmm::cuda_stream_default, mr); - } - if (agg->kind == aggregation::DENSE_RANK) { - CUDF_EXPECTS(inclusive == scan_type::INCLUSIVE, - "Dense rank aggregation operator requires an inclusive scan"); - return inclusive_dense_rank_scan(input, rmm::cuda_stream_default, mr); - } - if (agg->kind == aggregation::PERCENT_RANK) { - CUDF_EXPECTS(inclusive == scan_type::INCLUSIVE, - "Percent rank aggregation operator requires an inclusive scan"); - return inclusive_percent_rank_scan(input, rmm::cuda_stream_default, mr); + auto const& rank_agg = dynamic_cast(*agg); + if (rank_agg._method == rank_method::MIN) { + if (rank_agg._percentage == rank_percentage::NONE) { + return inclusive_rank_scan(input, rmm::cuda_stream_default, mr); + } else if (rank_agg._percentage == rank_percentage::ONE_NORMALIZED) { + return inclusive_one_normalized_percent_rank_scan(input, rmm::cuda_stream_default, mr); + } + } else if (rank_agg._method == rank_method::DENSE) { + return inclusive_dense_rank_scan(input, rmm::cuda_stream_default, mr); + } + CUDF_FAIL("Unsupported rank aggregation method for inclusive scan"); } return inclusive == scan_type::EXCLUSIVE diff --git a/cpp/tests/groupby/rank_scan_tests.cpp b/cpp/tests/groupby/rank_scan_tests.cpp index 81369beb2ec..d4e8b4cbf0f 100644 --- a/cpp/tests/groupby/rank_scan_tests.cpp +++ b/cpp/tests/groupby/rank_scan_tests.cpp @@ -29,11 +29,9 @@ namespace test { using namespace iterators; template -using input = fixed_width_column_wrapper; -using rank_result_col = fixed_width_column_wrapper; -using percent_result_t = - cudf::detail::target_type_t; -using percent_result_col = fixed_width_column_wrapper; +using input = fixed_width_column_wrapper; +using rank_result_col = fixed_width_column_wrapper; +using percent_result_col = fixed_width_column_wrapper; using null_iter_t = decltype(nulls_at({})); auto constexpr X = int32_t{0}; // Placeholder for NULL rows. @@ -45,27 +43,31 @@ inline void test_rank_scans(column_view const& keys, column_view const& expected_rank, column_view const& expected_percent_rank) { - test_single_scan(keys, - order, - keys, - expected_dense, - make_dense_rank_aggregation(), - null_policy::INCLUDE, - sorted::YES); - test_single_scan(keys, - order, - keys, - expected_rank, - make_rank_aggregation(), - null_policy::INCLUDE, - sorted::YES); - test_single_scan(keys, - order, - keys, - expected_percent_rank, - make_percent_rank_aggregation(), - null_policy::INCLUDE, - sorted::YES); + test_single_scan( + keys, + order, + keys, + expected_dense, + make_rank_aggregation(rank_method::DENSE, {}, null_policy::INCLUDE), + null_policy::INCLUDE, + sorted::YES); + test_single_scan( + keys, + order, + keys, + expected_rank, + make_rank_aggregation(rank_method::MIN, {}, null_policy::INCLUDE), + null_policy::INCLUDE, + sorted::YES); + test_single_scan( + keys, + order, + keys, + expected_percent_rank, + make_rank_aggregation( + rank_method::MIN, {}, null_policy::INCLUDE, {}, rank_percentage::ONE_NORMALIZED), + null_policy::INCLUDE, + sorted::YES); } struct groupby_rank_scan_test : public BaseFixture { @@ -148,7 +150,7 @@ TYPED_TEST(typed_groupby_rank_scan_test, basic) { using T = TypeParam; - auto const keys = input{0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1}; + auto const keys = /* */ input{0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1}; auto const make_order_by = [&] { return input{5, 5, 5, 4, 4, 4, 3, 3, 2, 2, 1, 1}; }; auto const order_by = make_order_by(); auto const order_by_struct = [&] { @@ -244,9 +246,12 @@ TYPED_TEST(typed_groupby_rank_scan_test, mixedStructs) std::vector requests; requests.emplace_back(groupby::scan_request()); requests[0].values = *struct_col; - requests[0].aggregations.push_back(make_dense_rank_aggregation()); - requests[0].aggregations.push_back(make_rank_aggregation()); - requests[0].aggregations.push_back(make_percent_rank_aggregation()); + requests[0].aggregations.push_back( + make_rank_aggregation(rank_method::DENSE, {}, null_policy::INCLUDE)); + requests[0].aggregations.push_back( + make_rank_aggregation(rank_method::MIN, {}, null_policy::INCLUDE)); + requests[0].aggregations.push_back(make_rank_aggregation( + rank_method::MIN, {}, null_policy::INCLUDE, {}, rank_percentage::ONE_NORMALIZED)); groupby::groupby gb_obj(table_view({keys}), null_policy::INCLUDE, sorted::YES); auto [result_keys, agg_results] = gb_obj.scan(requests); @@ -288,13 +293,19 @@ TYPED_TEST(typed_groupby_rank_scan_test, nestedStructs) requests.emplace_back(groupby::scan_request()); requests.emplace_back(groupby::scan_request()); requests[0].values = *nested_structs; - requests[0].aggregations.push_back(make_dense_rank_aggregation()); - requests[0].aggregations.push_back(make_rank_aggregation()); - requests[0].aggregations.push_back(make_percent_rank_aggregation()); + requests[0].aggregations.push_back( + make_rank_aggregation(rank_method::DENSE)); + requests[0].aggregations.push_back( + make_rank_aggregation(rank_method::MIN)); + requests[0].aggregations.push_back(make_rank_aggregation( + rank_method::MIN, {}, null_policy::INCLUDE, {}, rank_percentage::ONE_NORMALIZED)); requests[1].values = *flat_struct; - requests[1].aggregations.push_back(make_dense_rank_aggregation()); - requests[1].aggregations.push_back(make_rank_aggregation()); - requests[1].aggregations.push_back(make_percent_rank_aggregation()); + requests[1].aggregations.push_back( + make_rank_aggregation(rank_method::DENSE)); + requests[1].aggregations.push_back( + make_rank_aggregation(rank_method::MIN)); + requests[1].aggregations.push_back(make_rank_aggregation( + rank_method::MIN, {}, null_policy::INCLUDE, {}, rank_percentage::ONE_NORMALIZED)); groupby::groupby gb_obj(table_view({keys}), null_policy::INCLUDE, sorted::YES); auto [result_keys, agg_results] = gb_obj.scan(requests); @@ -339,13 +350,19 @@ TYPED_TEST(typed_groupby_rank_scan_test, structsWithNullPushdown) requests.emplace_back(groupby::scan_request()); requests.emplace_back(groupby::scan_request()); requests[0].values = *possibly_null_structs; - requests[0].aggregations.push_back(make_dense_rank_aggregation()); - requests[0].aggregations.push_back(make_rank_aggregation()); - requests[0].aggregations.push_back(make_percent_rank_aggregation()); + requests[0].aggregations.push_back( + make_rank_aggregation(rank_method::DENSE, {}, null_policy::INCLUDE)); + requests[0].aggregations.push_back( + make_rank_aggregation(rank_method::MIN, {}, null_policy::INCLUDE)); + requests[0].aggregations.push_back(make_rank_aggregation( + rank_method::MIN, {}, null_policy::INCLUDE, {}, rank_percentage::ONE_NORMALIZED)); requests[1].values = *definitely_null_structs; - requests[1].aggregations.push_back(make_dense_rank_aggregation()); - requests[1].aggregations.push_back(make_rank_aggregation()); - requests[1].aggregations.push_back(make_percent_rank_aggregation()); + requests[1].aggregations.push_back( + make_rank_aggregation(rank_method::DENSE, {}, null_policy::INCLUDE)); + requests[1].aggregations.push_back( + make_rank_aggregation(rank_method::MIN, {}, null_policy::INCLUDE)); + requests[1].aggregations.push_back(make_rank_aggregation( + rank_method::MIN, {}, null_policy::INCLUDE, {}, rank_percentage::ONE_NORMALIZED)); groupby::groupby gb_obj(table_view({keys}), null_policy::INCLUDE, sorted::YES); auto [result_keys, agg_results] = gb_obj.scan(requests); @@ -405,11 +422,11 @@ TYPED_TEST(list_groupby_rank_scan_test, lists) requests.emplace_back(groupby::aggregation_request()); requests.emplace_back(groupby::aggregation_request()); requests[0].values = list_col; - requests[0].aggregations.push_back(make_dense_rank_aggregation()); - requests[0].aggregations.push_back(make_rank_aggregation()); + requests[0].aggregations.push_back(make_rank_aggregation(rank_method::DENSE)); + requests[0].aggregations.push_back(make_rank_aggregation(rank_method::MIN)); requests[1].values = struct_col; - requests[1].aggregations.push_back(make_dense_rank_aggregation()); - requests[1].aggregations.push_back(make_rank_aggregation()); + requests[1].aggregations.push_back(make_rank_aggregation(rank_method::DENSE)); + requests[1].aggregations.push_back(make_rank_aggregation(rank_method::MIN)); groupby::groupby gb_obj(table_view({keys}), null_policy::INCLUDE, sorted::YES); auto result = gb_obj.scan(requests); @@ -484,7 +501,7 @@ TEST(groupby_rank_scan_test, strings) keys, order_by_structs_with_nulls, expected_dense, expected_rank, expected_percent); } -TEST_F(groupby_rank_scan_test_failures, test_exception_triggers) +TEST_F(groupby_rank_scan_test_failures, DISABLED_test_exception_triggers) { using T = uint32_t; @@ -496,57 +513,60 @@ TEST_F(groupby_rank_scan_test_failures, test_exception_triggers) col, keys, col, - make_dense_rank_aggregation(), + make_rank_aggregation(rank_method::DENSE), null_policy::INCLUDE, sorted::NO), - "Dense rank aggregate in groupby scan requires the keys to be presorted"); + "Rank aggregate in groupby scan requires the keys to be presorted"); - CUDF_EXPECT_THROW_MESSAGE(test_single_scan(keys, - col, - keys, - col, - make_rank_aggregation(), - null_policy::INCLUDE, - sorted::NO), - "Rank aggregate in groupby scan requires the keys to be presorted"); + CUDF_EXPECT_THROW_MESSAGE( + test_single_scan(keys, + col, + keys, + col, + make_rank_aggregation(rank_method::MIN), + null_policy::INCLUDE, + sorted::NO), + "Rank aggregate in groupby scan requires the keys to be presorted"); + + CUDF_EXPECT_THROW_MESSAGE( + test_single_scan(keys, + col, + keys, + col, + make_rank_aggregation(rank_method::DENSE), + null_policy::EXCLUDE, + sorted::YES), + "Rank aggregate in groupby scan requires the keys to be presorted"); CUDF_EXPECT_THROW_MESSAGE( test_single_scan(keys, col, keys, col, - make_dense_rank_aggregation(), + make_rank_aggregation(rank_method::MIN), null_policy::EXCLUDE, sorted::YES), - "Dense rank aggregate in groupby scan requires the keys to be presorted"); + "Rank aggregate in groupby scan requires the keys to be presorted"); - CUDF_EXPECT_THROW_MESSAGE(test_single_scan(keys, - col, - keys, - col, - make_rank_aggregation(), - null_policy::EXCLUDE, - sorted::YES), - "Rank aggregate in groupby scan requires the keys to be presorted"); + CUDF_EXPECT_THROW_MESSAGE( + test_single_scan(keys, + col, + keys, + col, + make_rank_aggregation(rank_method::DENSE), + null_policy::EXCLUDE, + sorted::NO), + "Rank aggregate in groupby scan requires the keys to be presorted"); CUDF_EXPECT_THROW_MESSAGE( test_single_scan(keys, col, keys, col, - make_dense_rank_aggregation(), + make_rank_aggregation(rank_method::MIN), null_policy::EXCLUDE, sorted::NO), - "Dense rank aggregate in groupby scan requires the keys to be presorted"); - - CUDF_EXPECT_THROW_MESSAGE(test_single_scan(keys, - col, - keys, - col, - make_rank_aggregation(), - null_policy::EXCLUDE, - sorted::NO), - "Rank aggregate in groupby scan requires the keys to be presorted"); + "Rank aggregate in groupby scan requires the keys to be presorted"); } } // namespace test diff --git a/cpp/tests/reductions/list_rank_test.cpp b/cpp/tests/reductions/list_rank_test.cpp index d263677f23b..b3a8e7e0c28 100644 --- a/cpp/tests/reductions/list_rank_test.cpp +++ b/cpp/tests/reductions/list_rank_test.cpp @@ -42,10 +42,11 @@ TEST_F(ListRankScanTest, BasicList) auto const expected_dense_vals = cudf::test::fixed_width_column_wrapper{1, 1, 2, 3, 4, 5, 6, 7, 7, 8, 9, 9}; - this->test_ungrouped_rank_scan(col, - expected_dense_vals, - cudf::make_dense_rank_aggregation(), - cudf::null_policy::INCLUDE); + this->test_ungrouped_rank_scan( + col, + expected_dense_vals, + cudf::make_rank_aggregation(cudf::rank_method::DENSE), + cudf::null_policy::INCLUDE); } TEST_F(ListRankScanTest, DeepList) @@ -73,20 +74,22 @@ TEST_F(ListRankScanTest, DeepList) { // Non-sliced auto const expected_dense_vals = cudf::test::fixed_width_column_wrapper{ 1, 1, 2, 3, 4, 5, 5, 5, 6, 6, 7, 7, 8, 9, 10, 11}; - this->test_ungrouped_rank_scan(col, - expected_dense_vals, - cudf::make_dense_rank_aggregation(), - cudf::null_policy::INCLUDE); + this->test_ungrouped_rank_scan( + col, + expected_dense_vals, + cudf::make_rank_aggregation(cudf::rank_method::DENSE), + cudf::null_policy::INCLUDE); } { // sliced auto sliced_col = cudf::slice(col, {3, 12})[0]; auto const expected_dense_vals = cudf::test::fixed_width_column_wrapper{1, 2, 3, 3, 3, 4, 4, 5, 5}; - this->test_ungrouped_rank_scan(sliced_col, - expected_dense_vals, - cudf::make_dense_rank_aggregation(), - cudf::null_policy::INCLUDE); + this->test_ungrouped_rank_scan( + sliced_col, + expected_dense_vals, + cudf::make_rank_aggregation(cudf::rank_method::DENSE), + cudf::null_policy::INCLUDE); } } @@ -138,10 +141,11 @@ TEST_F(ListRankScanTest, ListOfStruct) auto expect = cudf::test::fixed_width_column_wrapper{ 1, 1, 2, 2, 3, 4, 4, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10}; - this->test_ungrouped_rank_scan(list_column, - expect, - cudf::make_dense_rank_aggregation(), - cudf::null_policy::INCLUDE); + this->test_ungrouped_rank_scan( + list_column, + expect, + cudf::make_rank_aggregation(cudf::rank_method::DENSE), + cudf::null_policy::INCLUDE); } { // Sliced @@ -149,10 +153,11 @@ TEST_F(ListRankScanTest, ListOfStruct) auto expect = cudf::test::fixed_width_column_wrapper{1, 2, 3, 3, 3, 4, 5, 6, 7, 7, 8, 8}; - this->test_ungrouped_rank_scan(sliced_col, - expect, - cudf::make_dense_rank_aggregation(), - cudf::null_policy::INCLUDE); + this->test_ungrouped_rank_scan( + sliced_col, + expect, + cudf::make_rank_aggregation(cudf::rank_method::DENSE), + cudf::null_policy::INCLUDE); } } @@ -192,10 +197,11 @@ TEST_F(ListRankScanTest, ListOfEmptyStruct) auto expect = cudf::test::fixed_width_column_wrapper{1, 1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6}; - this->test_ungrouped_rank_scan(*list_column, - expect, - cudf::make_dense_rank_aggregation(), - cudf::null_policy::INCLUDE); + this->test_ungrouped_rank_scan( + *list_column, + expect, + cudf::make_rank_aggregation(cudf::rank_method::DENSE), + cudf::null_policy::INCLUDE); } TEST_F(ListRankScanTest, EmptyDeepList) @@ -221,8 +227,9 @@ TEST_F(ListRankScanTest, EmptyDeepList) auto expect = cudf::test::fixed_width_column_wrapper{1, 1, 2, 2}; - this->test_ungrouped_rank_scan(*list_column, - expect, - cudf::make_dense_rank_aggregation(), - cudf::null_policy::INCLUDE); + this->test_ungrouped_rank_scan( + *list_column, + expect, + cudf::make_rank_aggregation(cudf::rank_method::DENSE), + cudf::null_policy::INCLUDE); } diff --git a/cpp/tests/reductions/rank_tests.cpp b/cpp/tests/reductions/rank_tests.cpp index fb2cd17fe30..3bf2899ce2f 100644 --- a/cpp/tests/reductions/rank_tests.cpp +++ b/cpp/tests/reductions/rank_tests.cpp @@ -36,15 +36,14 @@ namespace cudf::test { using namespace iterators; template -using input = fixed_width_column_wrapper; -using rank_result_col = fixed_width_column_wrapper; -using percent_result_t = - cudf::detail::target_type_t; -using percent_result_col = fixed_width_column_wrapper; +using input = fixed_width_column_wrapper; +using rank_result_col = fixed_width_column_wrapper; +using percent_result_col = fixed_width_column_wrapper; -auto const rank = cudf::make_rank_aggregation(); -auto const dense_rank = cudf::make_dense_rank_aggregation(); -auto const percent_rank = cudf::make_percent_rank_aggregation(); +auto const rank = cudf::make_rank_aggregation(cudf::rank_method::MIN); +auto const dense_rank = cudf::make_rank_aggregation(cudf::rank_method::DENSE); +auto const percent_rank = cudf::make_rank_aggregation( + cudf::rank_method::MIN, {}, null_policy::INCLUDE, {}, rank_percentage::ONE_NORMALIZED); auto constexpr INCLUSIVE_SCAN = cudf::scan_type::INCLUSIVE; auto constexpr INCLUDE_NULLS = cudf::null_policy::INCLUDE; @@ -56,6 +55,8 @@ struct TypedRankScanTest : BaseScanTest { std::unique_ptr const& agg) { auto col_out = cudf::scan(input, agg, INCLUSIVE_SCAN, INCLUDE_NULLS); + std::cout << "expect type: " << static_cast(expect_vals.type().id()) << std::endl; + std::cout << "out type: " << static_cast(col_out->type().id()) << std::endl; CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expect_vals, col_out->view()); } }; @@ -318,11 +319,11 @@ TEST(RankScanTest, ExclusiveScan) auto const vals = input{3, 4, 5}; CUDF_EXPECT_THROW_MESSAGE(cudf::scan(vals, dense_rank, scan_type::EXCLUSIVE, INCLUDE_NULLS), - "Dense rank aggregation operator requires an inclusive scan"); + "Rank aggregation operator requires an inclusive scan"); CUDF_EXPECT_THROW_MESSAGE(cudf::scan(vals, rank, scan_type::EXCLUSIVE, INCLUDE_NULLS), "Rank aggregation operator requires an inclusive scan"); CUDF_EXPECT_THROW_MESSAGE(cudf::scan(vals, percent_rank, scan_type::EXCLUSIVE, INCLUDE_NULLS), - "Percent rank aggregation operator requires an inclusive scan"); + "Rank aggregation operator requires an inclusive scan"); } } // namespace cudf::test diff --git a/cpp/tests/reductions/scan_tests.cpp b/cpp/tests/reductions/scan_tests.cpp index d533a91f4d0..68b4d85db2a 100644 --- a/cpp/tests/reductions/scan_tests.cpp +++ b/cpp/tests/reductions/scan_tests.cpp @@ -84,6 +84,7 @@ struct ScanTest : public BaseScanTest { case aggregation::PRODUCT: return std::is_invocable_v; case aggregation::MIN: return std::is_invocable_v; case aggregation::MAX: return std::is_invocable_v; + case aggregation::RANK: return std::is_invocable_v; // comparable default: return false; } return false; diff --git a/java/src/main/native/src/AggregationJni.cpp b/java/src/main/native/src/AggregationJni.cpp index f8c448566c8..6ac73282615 100644 --- a/java/src/main/native/src/AggregationJni.cpp +++ b/java/src/main/native/src/AggregationJni.cpp @@ -82,11 +82,14 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Aggregation_createNoParamAgg(JNIEnv case 27: // MERGE_M2 return cudf::make_merge_m2_aggregation(); case 28: // RANK - return cudf::make_rank_aggregation(); + return cudf::make_rank_aggregation(cudf::rank_method::MIN, {}, + cudf::null_policy::INCLUDE); case 29: // DENSE_RANK - return cudf::make_dense_rank_aggregation(); - case 30: // PERCENT_RANK - return cudf::make_percent_rank_aggregation(); + return cudf::make_rank_aggregation(cudf::rank_method::DENSE, {}, + cudf::null_policy::INCLUDE); + case 30: // ANSI SQL PERCENT_RANK + return cudf::make_rank_aggregation(cudf::rank_method::MIN, {}, cudf::null_policy::INCLUDE, + {}, cudf::rank_percentage::ONE_NORMALIZED); default: throw std::logic_error("Unsupported No Parameter Aggregation Operation"); } }(); diff --git a/python/cudf/cudf/_lib/aggregation.pyx b/python/cudf/cudf/_lib/aggregation.pyx index 4dc91268d57..84dd9c3a576 100644 --- a/python/cudf/cudf/_lib/aggregation.pyx +++ b/python/cudf/cudf/_lib/aggregation.pyx @@ -30,7 +30,10 @@ from cudf._lib.types import Interpolation cimport cudf._lib.cpp.aggregation as libcudf_aggregation cimport cudf._lib.cpp.types as libcudf_types -from cudf._lib.cpp.aggregation cimport underlying_type_t_correlation_type +from cudf._lib.cpp.aggregation cimport ( + underlying_type_t_correlation_type, + underlying_type_t_rank_method, +) import cudf @@ -54,6 +57,7 @@ class AggregationKind(Enum): ARGMIN = libcudf_aggregation.aggregation.Kind.ARGMIN NUNIQUE = libcudf_aggregation.aggregation.Kind.NUNIQUE NTH = libcudf_aggregation.aggregation.Kind.NTH_ELEMENT + RANK = libcudf_aggregation.aggregation.Kind.RANK COLLECT = libcudf_aggregation.aggregation.Kind.COLLECT UNIQUE = libcudf_aggregation.aggregation.Kind.COLLECT_SET PTX = libcudf_aggregation.aggregation.Kind.PTX @@ -77,6 +81,14 @@ class CorrelationType(IntEnum): ) +class RankMethod(IntEnum): + FIRST = libcudf_aggregation.rank_method.FIRST + AVERAGE = libcudf_aggregation.rank_method.AVERAGE + MIN = libcudf_aggregation.rank_method.MIN + MAX = libcudf_aggregation.rank_method.MAX + DENSE = libcudf_aggregation.rank_method.DENSE + + cdef class RollingAggregation: """A Cython wrapper for rolling window aggregations. @@ -564,6 +576,33 @@ cdef class GroupbyScanAggregation: cummin = min cummax = max + @classmethod + def rank(cls, method, ascending, na_option, pct): + cdef GroupbyScanAggregation agg = cls() + cdef libcudf_aggregation.rank_method c_method = ( + ( + ( + RankMethod[method.upper()] + ) + ) + ) + agg.c_obj = move( + libcudf_aggregation. + make_rank_aggregation[groupby_scan_aggregation]( + c_method, + (libcudf_types.order.ASCENDING if ascending else + libcudf_types.order.DESCENDING), + (libcudf_types.null_policy.EXCLUDE if na_option == "keep" else + libcudf_types.null_policy.INCLUDE), + (libcudf_types.null_order.BEFORE + if (na_option == "top") == ascending else + libcudf_types.null_order.AFTER), + (libcudf_aggregation.rank_percentage.ZERO_NORMALIZED + if pct else + libcudf_aggregation.rank_percentage.NONE) + )) + return agg + cdef class ReduceAggregation: """A Cython wrapper for reduce aggregations. diff --git a/python/cudf/cudf/_lib/cpp/aggregation.pxd b/python/cudf/cudf/_lib/cpp/aggregation.pxd index 399deb74c9c..a1d1485e1e8 100644 --- a/python/cudf/cudf/_lib/cpp/aggregation.pxd +++ b/python/cudf/cudf/_lib/cpp/aggregation.pxd @@ -1,5 +1,6 @@ # Copyright (c) 2020-2022, NVIDIA CORPORATION. from libc.stdint cimport int32_t +from libcpp cimport bool from libcpp.memory cimport unique_ptr from libcpp.string cimport string from libcpp.vector cimport vector @@ -7,11 +8,14 @@ from libcpp.vector cimport vector from cudf._lib.cpp.types cimport ( data_type, interpolation, + null_order, null_policy, + order, size_type, ) ctypedef int32_t underlying_type_t_correlation_type +ctypedef int32_t underlying_type_t_rank_method cdef extern from "cudf/aggregation.hpp" namespace "cudf" nogil: @@ -35,6 +39,7 @@ cdef extern from "cudf/aggregation.hpp" namespace "cudf" nogil: ARGMIN 'cudf::aggregation::ARGMIN' NUNIQUE 'cudf::aggregation::NUNIQUE' NTH_ELEMENT 'cudf::aggregation::NTH_ELEMENT' + RANK 'cudf::aggregation::RANK' COLLECT 'cudf::aggregation::COLLECT_LIST' COLLECT_SET 'cudf::aggregation::COLLECT_SET' PTX 'cudf::aggregation::PTX' @@ -68,6 +73,18 @@ cdef extern from "cudf/aggregation.hpp" namespace "cudf" nogil: KENDALL 'cudf::correlation_type::KENDALL' SPEARMAN 'cudf::correlation_type::SPEARMAN' + ctypedef enum rank_method: + FIRST "cudf::rank_method::FIRST" + AVERAGE "cudf::rank_method::AVERAGE" + MIN "cudf::rank_method::MIN" + MAX "cudf::rank_method::MAX" + DENSE "cudf::rank_method::DENSE" + + ctypedef enum rank_percentage: + NONE "cudf::rank_percentage::NONE" + ZERO_NORMALIZED "cudf::rank_percentage::ZERO_NORMALIZED" + ONE_NORMALIZED "cudf::rank_percentage::ONE_NORMALIZED" + cdef unique_ptr[T] make_sum_aggregation[T]() except + cdef unique_ptr[T] make_product_aggregation[T]() except + @@ -127,3 +144,10 @@ cdef extern from "cudf/aggregation.hpp" namespace "cudf" nogil: cdef unique_ptr[T] make_covariance_aggregation[T]( size_type min_periods, size_type ddof) except + + + cdef unique_ptr[T] make_rank_aggregation[T]( + rank_method method, + order column_order, + null_policy null_handling, + null_order null_precedence, + rank_percentage percentage) except + diff --git a/python/cudf/cudf/_lib/cpp/sorting.pxd b/python/cudf/cudf/_lib/cpp/sorting.pxd index 243b841ce4b..c6c42c327ac 100644 --- a/python/cudf/cudf/_lib/cpp/sorting.pxd +++ b/python/cudf/cudf/_lib/cpp/sorting.pxd @@ -7,20 +7,13 @@ from libcpp.vector cimport vector from cudf._lib.types import cudf_to_np_types, np_to_cudf_types cimport cudf._lib.cpp.types as libcudf_types +from cudf._lib.cpp.aggregation cimport rank_method from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view -cdef extern from "cudf/sorting.hpp" namespace "cudf" nogil: - ctypedef enum rank_method: - FIRST "cudf::rank_method::FIRST" - AVERAGE "cudf::rank_method::AVERAGE" - MIN "cudf::rank_method::MIN" - MAX "cudf::rank_method::MAX" - DENSE "cudf::rank_method::DENSE" - cdef extern from "cudf/sorting.hpp" namespace "cudf" nogil: cdef unique_ptr[column] sorted_order( table_view source_table, diff --git a/python/cudf/cudf/_lib/groupby.pyx b/python/cudf/cudf/_lib/groupby.pyx index 48f566b846d..be5bb2741b4 100644 --- a/python/cudf/cudf/_lib/groupby.pyx +++ b/python/cudf/cudf/_lib/groupby.pyx @@ -341,7 +341,7 @@ cdef class GroupBy: return columns_from_unique_ptr(move(c_result.second)) -_GROUPBY_SCANS = {"cumcount", "cumsum", "cummin", "cummax"} +_GROUPBY_SCANS = {"cumcount", "cumsum", "cummin", "cummax", "rank"} def _is_all_scan_aggregate(all_aggs): diff --git a/python/cudf/cudf/_lib/sort.pxd b/python/cudf/cudf/_lib/sort.pxd deleted file mode 100644 index d7488889555..00000000000 --- a/python/cudf/cudf/_lib/sort.pxd +++ /dev/null @@ -1,3 +0,0 @@ -from libc.stdint cimport int32_t - -ctypedef int32_t underlying_type_t_rank_method diff --git a/python/cudf/cudf/_lib/sort.pyx b/python/cudf/cudf/_lib/sort.pyx index faa4279c1ca..1d7204a0a39 100644 --- a/python/cudf/cudf/_lib/sort.pyx +++ b/python/cudf/cudf/_lib/sort.pyx @@ -8,19 +8,21 @@ from libcpp.vector cimport vector from enum import IntEnum from cudf._lib.column cimport Column +from cudf._lib.cpp.aggregation cimport ( + rank_method, + underlying_type_t_rank_method, +) from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.search cimport lower_bound, upper_bound from cudf._lib.cpp.sorting cimport ( is_sorted as cpp_is_sorted, rank, - rank_method, sorted_order, ) from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.table.table_view cimport table_view from cudf._lib.cpp.types cimport null_order, null_policy, order -from cudf._lib.sort cimport underlying_type_t_rank_method from cudf._lib.utils cimport columns_from_unique_ptr, table_view_from_columns @@ -190,14 +192,6 @@ def digitize(list source_columns, list bins, bool right=False): return Column.from_unique_ptr(move(c_result)) -class RankMethod(IntEnum): - FIRST = < underlying_type_t_rank_method > rank_method.FIRST - AVERAGE = < underlying_type_t_rank_method > rank_method.AVERAGE - MIN = < underlying_type_t_rank_method > rank_method.MIN - MAX = < underlying_type_t_rank_method > rank_method.MAX - DENSE = < underlying_type_t_rank_method > rank_method.DENSE - - def rank_columns(list source_columns, object method, str na_option, bool ascending, bool pct ): diff --git a/python/cudf/cudf/core/groupby/groupby.py b/python/cudf/cudf/core/groupby/groupby.py index 1af84920057..013ae7ad033 100644 --- a/python/cudf/cudf/core/groupby/groupby.py +++ b/python/cudf/cudf/core/groupby/groupby.py @@ -207,6 +207,30 @@ def cumcount(self): .reset_index(drop=True) ) + def rank( + self, + method="average", + ascending=True, + na_option="keep", + pct=False, + axis=0, + ): + """ + Return the rank of values within each group. + """ + if not axis == 0: + raise NotImplementedError("Only axis=0 is supported.") + + def rank(x): + return getattr(x, "rank")( + method=method, + ascending=ascending, + na_option=na_option, + pct=pct, + ) + + return self.agg(rank) + @cached_property def _groupby(self): return libgroupby.GroupBy( diff --git a/python/cudf/cudf/core/indexed_frame.py b/python/cudf/cudf/core/indexed_frame.py index a77fca098bc..1361fc56fa0 100644 --- a/python/cudf/cudf/core/indexed_frame.py +++ b/python/cudf/cudf/core/indexed_frame.py @@ -3632,7 +3632,7 @@ def rank( if method not in {"average", "min", "max", "first", "dense"}: raise KeyError(method) - method_enum = libcudf.sort.RankMethod[method.upper()] + method_enum = libcudf.aggregation.RankMethod[method.upper()] if na_option not in {"keep", "top", "bottom"}: raise ValueError( "na_option must be one of 'keep', 'top', or 'bottom'" diff --git a/python/cudf/cudf/tests/test_groupby.py b/python/cudf/cudf/tests/test_groupby.py index 1411d7ba64c..9e87fdbd3be 100644 --- a/python/cudf/cudf/tests/test_groupby.py +++ b/python/cudf/cudf/tests/test_groupby.py @@ -1811,6 +1811,50 @@ def test_groupby_2keys_scan(nelem, func): assert_groupby_results_equal(got_df, expect_df, check_dtype=check_dtype) +@pytest.mark.parametrize("nelem", [100, 1000]) +@pytest.mark.parametrize("method", ["average", "min", "max", "first", "dense"]) +@pytest.mark.parametrize("ascending", [True, False]) +@pytest.mark.parametrize("na_option", ["keep", "top", "bottom"]) +@pytest.mark.parametrize("pct", [False, True]) +def test_groupby_2keys_rank(nelem, method, ascending, na_option, pct): + t = rand_dataframe( + dtypes_meta=[ + {"dtype": "int64", "null_frequency": 0, "cardinality": 10}, + {"dtype": "int64", "null_frequency": 0, "cardinality": 10}, + {"dtype": "int64", "null_frequency": 0.4, "cardinality": 10}, + ], + rows=nelem, + use_threads=False, + ) + pdf = t.to_pandas() + pdf.columns = ["x", "y", "z"] + gdf = cudf.from_pandas(pdf) + expect_df = pdf.groupby(["x", "y"], sort=True).rank( + method=method, ascending=ascending, na_option=na_option, pct=pct + ) + got_df = gdf.groupby(["x", "y"], sort=True).rank( + method=method, ascending=ascending, na_option=na_option, pct=pct + ) + + assert_groupby_results_equal(got_df, expect_df, check_dtype=False) + + +def test_groupby_rank_fails(): + gdf = cudf.DataFrame( + {"x": [1, 2, 3, 4], "y": [1, 2, 3, 4], "z": [1, 2, 3, 4]} + ) + with pytest.raises(NotImplementedError): + gdf.groupby(["x", "y"]).rank(method="min", axis=1) + gdf = cudf.DataFrame( + { + "a": [1, 1, 1, 2, 2, 2], + "b": [[1, 2], [3, None, 5], None, [], [7, 8], [9]], + } + ) + with pytest.raises(NotImplementedError): + gdf.groupby(["a"]).rank(method="min", axis=1) + + def test_groupby_mix_agg_scan(): err_msg = "Cannot perform both aggregation and scan in one operation" func = ["cumsum", "sum"] From 280acdfd65b12b4ac953c193c7d7fd35809e41be Mon Sep 17 00:00:00 2001 From: Vukasin Milovanovic Date: Thu, 28 Apr 2022 14:25:04 -0700 Subject: [PATCH 131/246] Partial cuIO GPU decompression refactor (#10699) Required to expand future nvcomp integration. - [x] Moving nvcomp integration in ORC and Parquet readers to common code. Enables nvcomp use for multiple compression type without code duplication. - [x] `gpu_inflate_input_s` refactor to facilitate unified host/device decompressor interface. Enables further changes to unify CPU and GPU decompression API, which in turn enables ZSTD use in ORC. Authors: - Vukasin Milovanovic (https://github.com/vuule) Approvers: - Robert Maynard (https://github.com/robertmaynard) - Elias Stehle (https://github.com/elstehle) - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/cudf/pull/10699 --- cpp/CMakeLists.txt | 2 + cpp/src/io/avro/reader_impl.cu | 82 +++---- cpp/src/io/comp/debrotli.cu | 75 +++---- cpp/src/io/comp/gpuinflate.cu | 113 +++++----- cpp/src/io/comp/gpuinflate.h | 97 ++++----- cpp/src/io/comp/nvcomp_adapter.cpp | 86 ++++++++ cpp/src/io/comp/nvcomp_adapter.cu | 73 +++++++ cpp/src/io/comp/nvcomp_adapter.cuh | 55 +++++ cpp/src/io/comp/nvcomp_adapter.hpp | 45 ++++ cpp/src/io/comp/snap.cu | 45 ++-- cpp/src/io/comp/unsnap.cu | 68 +++--- cpp/src/io/orc/orc_gpu.h | 32 +-- cpp/src/io/orc/reader_impl.cu | 118 +++------- cpp/src/io/orc/stripe_enc.cu | 101 +++++---- cpp/src/io/orc/stripe_init.cu | 83 ++++--- cpp/src/io/orc/writer_impl.cu | 12 +- cpp/src/io/orc/writer_impl.hpp | 2 +- cpp/src/io/parquet/page_enc.cu | 42 ++-- cpp/src/io/parquet/parquet_gpu.hpp | 16 +- cpp/src/io/parquet/reader_impl.cu | 239 ++++++--------------- cpp/src/io/parquet/writer_impl.cu | 53 ++--- cpp/src/io/utilities/hostdevice_vector.hpp | 6 +- cpp/tests/io/comp/decomp_test.cpp | 100 ++++----- 23 files changed, 834 insertions(+), 711 deletions(-) create mode 100644 cpp/src/io/comp/nvcomp_adapter.cpp create mode 100644 cpp/src/io/comp/nvcomp_adapter.cu create mode 100644 cpp/src/io/comp/nvcomp_adapter.cuh create mode 100644 cpp/src/io/comp/nvcomp_adapter.hpp diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 91f67fd0420..15caaec9bec 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -302,6 +302,8 @@ add_library( src/io/comp/cpu_unbz2.cpp src/io/comp/debrotli.cu src/io/comp/gpuinflate.cu + src/io/comp/nvcomp_adapter.cpp + src/io/comp/nvcomp_adapter.cu src/io/comp/snap.cu src/io/comp/uncomp.cpp src/io/comp/unsnap.cu diff --git a/cpp/src/io/avro/reader_impl.cu b/cpp/src/io/avro/reader_impl.cu index 5885b61b35b..556ca6b9d80 100644 --- a/cpp/src/io/avro/reader_impl.cu +++ b/cpp/src/io/avro/reader_impl.cu @@ -162,62 +162,66 @@ rmm::device_buffer decompress_data(datasource& source, rmm::cuda_stream_view stream) { if (meta.codec == "deflate") { - size_t uncompressed_data_size = 0; + auto inflate_in = hostdevice_vector>(meta.block_list.size(), stream); + auto inflate_out = hostdevice_vector>(meta.block_list.size(), stream); + auto inflate_stats = hostdevice_vector(meta.block_list.size(), stream); - auto inflate_in = hostdevice_vector(meta.block_list.size(), stream); - auto inflate_out = hostdevice_vector(meta.block_list.size(), stream); + // Guess an initial maximum uncompressed block size. We estimate the compression factor is two + // and round up to the next multiple of 4096 bytes. + uint32_t const initial_blk_len = meta.max_block_size * 2 + (meta.max_block_size * 2) % 4096; + size_t const uncomp_size = initial_blk_len * meta.block_list.size(); - // Guess an initial maximum uncompressed block size - uint32_t initial_blk_len = (meta.max_block_size * 2 + 0xfff) & ~0xfff; - uncompressed_data_size = initial_blk_len * meta.block_list.size(); - for (size_t i = 0; i < inflate_in.size(); ++i) { - inflate_in[i].dstSize = initial_blk_len; - } - - rmm::device_buffer decomp_block_data(uncompressed_data_size, stream); + rmm::device_buffer decomp_block_data(uncomp_size, stream); auto const base_offset = meta.block_list[0].offset; for (size_t i = 0, dst_pos = 0; i < meta.block_list.size(); i++) { auto const src_pos = meta.block_list[i].offset - base_offset; - inflate_in[i].srcDevice = static_cast(comp_block_data.data()) + src_pos; - inflate_in[i].srcSize = meta.block_list[i].size; - inflate_in[i].dstDevice = static_cast(decomp_block_data.data()) + dst_pos; + inflate_in[i] = {static_cast(comp_block_data.data()) + src_pos, + meta.block_list[i].size}; + inflate_out[i] = {static_cast(decomp_block_data.data()) + dst_pos, initial_blk_len}; // Update blocks offsets & sizes to refer to uncompressed data meta.block_list[i].offset = dst_pos; - meta.block_list[i].size = static_cast(inflate_in[i].dstSize); + meta.block_list[i].size = static_cast(inflate_out[i].size()); dst_pos += meta.block_list[i].size; } + inflate_in.host_to_device(stream); for (int loop_cnt = 0; loop_cnt < 2; loop_cnt++) { - inflate_in.host_to_device(stream); - CUDF_CUDA_TRY( - cudaMemsetAsync(inflate_out.device_ptr(), 0, inflate_out.memory_size(), stream.value())); - CUDF_CUDA_TRY(gpuinflate( - inflate_in.device_ptr(), inflate_out.device_ptr(), inflate_in.size(), 0, stream)); - inflate_out.device_to_host(stream, true); + inflate_out.host_to_device(stream); + CUDF_CUDA_TRY(cudaMemsetAsync( + inflate_stats.device_ptr(), 0, inflate_stats.memory_size(), stream.value())); + gpuinflate(inflate_in, inflate_out, inflate_stats, gzip_header_included::NO, stream); + inflate_stats.device_to_host(stream, true); // Check if larger output is required, as it's not known ahead of time if (loop_cnt == 0) { - size_t actual_uncompressed_size = 0; - for (size_t i = 0; i < meta.block_list.size(); i++) { - // If error status is 1 (buffer too small), the `bytes_written` field - // is actually contains the uncompressed data size - if (inflate_out[i].status == 1 && inflate_out[i].bytes_written > inflate_in[i].dstSize) { - inflate_in[i].dstSize = inflate_out[i].bytes_written; - } - actual_uncompressed_size += inflate_in[i].dstSize; - } - if (actual_uncompressed_size > uncompressed_data_size) { - decomp_block_data.resize(actual_uncompressed_size, stream); - for (size_t i = 0, dst_pos = 0; i < meta.block_list.size(); i++) { - auto dst_base = static_cast(decomp_block_data.data()); - inflate_in[i].dstDevice = dst_base + dst_pos; - - meta.block_list[i].offset = dst_pos; - meta.block_list[i].size = static_cast(inflate_in[i].dstSize); - dst_pos += meta.block_list[i].size; + std::vector actual_uncomp_sizes; + actual_uncomp_sizes.reserve(inflate_out.size()); + std::transform(inflate_out.begin(), + inflate_out.end(), + inflate_stats.begin(), + std::back_inserter(actual_uncomp_sizes), + [](auto const& inf_out, auto const& inf_stats) { + // If error status is 1 (buffer too small), the `bytes_written` field + // actually contains the uncompressed data size + return inf_stats.status == 1 + ? std::max(inf_out.size(), inf_stats.bytes_written) + : inf_out.size(); + }); + auto const total_actual_uncomp_size = + std::accumulate(actual_uncomp_sizes.cbegin(), actual_uncomp_sizes.cend(), 0ul); + if (total_actual_uncomp_size > uncomp_size) { + decomp_block_data.resize(total_actual_uncomp_size, stream); + for (size_t i = 0; i < meta.block_list.size(); ++i) { + meta.block_list[i].offset = + i > 0 ? (meta.block_list[i - 1].size + meta.block_list[i - 1].offset) : 0; + meta.block_list[i].size = static_cast(actual_uncomp_sizes[i]); + + inflate_out[i] = { + static_cast(decomp_block_data.data()) + meta.block_list[i].offset, + meta.block_list[i].size}; } } else { break; diff --git a/cpp/src/io/comp/debrotli.cu b/cpp/src/io/comp/debrotli.cu index 631cf19b2aa..cf4d1b0e0f4 100644 --- a/cpp/src/io/comp/debrotli.cu +++ b/cpp/src/io/comp/debrotli.cu @@ -1904,41 +1904,42 @@ static __device__ void ProcessCommands(debrotli_state_s* s, const brotli_diction * * blockDim = {block_size,1,1} * - * @param[in] inputs Source/Destination buffer information per block - * @param[out] outputs Decompressor status per block + * @param[in] inputs Source buffer per block + * @param[out] outputs Destination buffer per block + * @param[out] statuses Decompressor status per block * @param scratch Intermediate device memory heap space (will be dynamically shared between blocks) * @param scratch_size Size of scratch heap space (smaller sizes may result in serialization between - *blocks) - * @param count Number of blocks to decompress + * blocks) */ -extern "C" __global__ void __launch_bounds__(block_size, 2) - gpu_debrotli_kernel(gpu_inflate_input_s* inputs, - gpu_inflate_status_s* outputs, +__global__ void __launch_bounds__(block_size, 2) + gpu_debrotli_kernel(device_span const> inputs, + device_span const> outputs, + device_span statuses, uint8_t* scratch, - uint32_t scratch_size, - uint32_t count) + uint32_t scratch_size) { __shared__ __align__(16) debrotli_state_s state_g; int t = threadIdx.x; - int z = blockIdx.x; + auto const block_id = blockIdx.x; debrotli_state_s* const s = &state_g; - if (z >= count) { return; } + if (block_id >= inputs.size()) { return; } // Thread0: initializes shared state and decode stream header if (!t) { - auto const* src = static_cast(inputs[z].srcDevice); - size_t src_size = inputs[z].srcSize; + auto const src = inputs[block_id].data(); + auto const src_size = inputs[block_id].size(); if (src && src_size >= 8) { - s->error = 0; - s->out = s->outbase = static_cast(inputs[z].dstDevice); - s->bytes_left = inputs[z].dstSize; - s->mtf_upper_bound = 63; - s->dist_rb[0] = 16; - s->dist_rb[1] = 15; - s->dist_rb[2] = 11; - s->dist_rb[3] = 4; - s->dist_rb_idx = 0; + s->error = 0; + s->out = outputs[block_id].data(); + s->outbase = s->out; + s->bytes_left = outputs[block_id].size(); + s->mtf_upper_bound = 63; + s->dist_rb[0] = 16; + s->dist_rb[1] = 15; + s->dist_rb[2] = 11; + s->dist_rb[3] = 4; + s->dist_rb_idx = 0; s->p1 = s->p2 = 0; initbits(s, src, src_size); DecodeStreamHeader(s); @@ -2015,9 +2016,10 @@ extern "C" __global__ void __launch_bounds__(block_size, 2) __syncthreads(); // Output decompression status if (!t) { - outputs[z].bytes_written = s->out - s->outbase; - outputs[z].status = s->error; - outputs[z].reserved = s->fb_size; // Return ext heap used by last block (statistics) + statuses[block_id].bytes_written = s->out - s->outbase; + statuses[block_id].status = s->error; + // Return ext heap used by last block (statistics) + statuses[block_id].reserved = s->fb_size; } } @@ -2075,20 +2077,21 @@ size_t __host__ get_gpu_debrotli_scratch_size(int max_num_inputs) #include #endif -cudaError_t __host__ gpu_debrotli(gpu_inflate_input_s* inputs, - gpu_inflate_status_s* outputs, - void* scratch, - size_t scratch_size, - int count, - rmm::cuda_stream_view stream) +void gpu_debrotli(device_span const> inputs, + device_span const> outputs, + device_span statuses, + void* scratch, + size_t scratch_size, + rmm::cuda_stream_view stream) { - uint32_t count32 = (count > 0) ? count : 0; + auto const count = inputs.size(); uint32_t fb_heap_size; auto* scratch_u8 = static_cast(scratch); dim3 dim_block(block_size, 1); - dim3 dim_grid(count32, 1); // TODO: Check max grid dimensions vs max expected count + dim3 dim_grid(count, 1); // TODO: Check max grid dimensions vs max expected count - if (scratch_size < sizeof(brotli_dictionary_s)) { return cudaErrorLaunchOutOfResources; } + CUDF_EXPECTS(scratch_size >= sizeof(brotli_dictionary_s), + "Insufficient scratch space for debrotli"); scratch_size = min(scratch_size, (size_t)0xffffffffu); fb_heap_size = (uint32_t)((scratch_size - sizeof(brotli_dictionary_s)) & ~0xf); @@ -2101,7 +2104,7 @@ cudaError_t __host__ gpu_debrotli(gpu_inflate_input_s* inputs, cudaMemcpyHostToDevice, stream.value())); gpu_debrotli_kernel<<>>( - inputs, outputs, scratch_u8, fb_heap_size, count32); + inputs, outputs, statuses, scratch_u8, fb_heap_size); #if DUMP_FB_HEAP uint32_t dump[2]; uint32_t cur = 0; @@ -2114,8 +2117,6 @@ cudaError_t __host__ gpu_debrotli(gpu_inflate_input_s* inputs, cur = (dump[0] > cur) ? dump[0] : 0xffffffffu; } #endif - - return cudaSuccess; } } // namespace io diff --git a/cpp/src/io/comp/gpuinflate.cu b/cpp/src/io/comp/gpuinflate.cu index 508e960430d..0d33158da2b 100644 --- a/cpp/src/io/comp/gpuinflate.cu +++ b/cpp/src/io/comp/gpuinflate.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020, 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. @@ -124,8 +124,8 @@ struct inflate_state_s { uint8_t* outbase; ///< start of output buffer uint8_t* outend; ///< end of output buffer // Input state - uint8_t* cur; ///< input buffer - uint8_t* end; ///< end of input buffer + uint8_t const* cur; ///< input buffer + uint8_t const* end; ///< end of input buffer uint2 bitbuf; ///< bit buffer (64-bit) uint32_t bitpos; ///< position in bit buffer @@ -180,10 +180,10 @@ inline __device__ void skipbits(inflate_state_s* s, uint32_t n) { uint32_t bitpos = s->bitpos + n; if (bitpos >= 32) { - uint8_t* cur = s->cur + 8; - s->bitbuf.x = s->bitbuf.y; - s->bitbuf.y = (cur < s->end) ? *reinterpret_cast(cur) : 0; - s->cur = cur - 4; + auto cur = s->cur + 8; + s->bitbuf.x = s->bitbuf.y; + s->bitbuf.y = (cur < s->end) ? *reinterpret_cast(cur) : 0; + s->cur = cur - 4; bitpos &= 0x1f; } s->bitpos = bitpos; @@ -510,8 +510,8 @@ __device__ void decode_symbols(inflate_state_s* s) { uint32_t bitpos = s->bitpos; uint2 bitbuf = s->bitbuf; - uint8_t* cur = s->cur; - uint8_t* end = s->end; + auto cur = s->cur; + auto end = s->end; int32_t batch = 0; int32_t sym, batch_len; @@ -871,13 +871,11 @@ __device__ int init_stored(inflate_state_s* s) /// Copy bytes from stored block to destination __device__ void copy_stored(inflate_state_s* s, int t) { - int len = s->stored_blk_len; - uint8_t* cur = s->cur + (s->bitpos >> 3); - uint8_t* out = s->out; - uint8_t* outend = s->outend; - uint8_t* cur4; - int slow_bytes = min(len, (int)((16 - (size_t)out) & 0xf)); - int fast_bytes, bitpos; + auto len = s->stored_blk_len; + auto cur = s->cur + s->bitpos / 8; + auto out = s->out; + auto outend = s->outend; + auto const slow_bytes = min(len, (int)((16 - reinterpret_cast(out)) % 16)); // Slow copy until output is 16B aligned if (slow_bytes) { @@ -890,11 +888,11 @@ __device__ void copy_stored(inflate_state_s* s, int t) out += slow_bytes; len -= slow_bytes; } - fast_bytes = len; + auto fast_bytes = len; if (out < outend) { fast_bytes = (int)min((size_t)fast_bytes, (outend - out)); } fast_bytes &= ~0xf; - bitpos = ((int)(3 & (size_t)cur)) << 3; - cur4 = cur - (bitpos >> 3); + auto bitpos = ((int)((size_t)cur % 4)) * 8; + auto cur4 = cur - (bitpos / 8); if (out < outend) { // Fast copy 16 bytes at a time for (int i = t * 16; i < fast_bytes; i += blockDim.x * 16) { @@ -926,13 +924,13 @@ __device__ void copy_stored(inflate_state_s* s, int t) __syncthreads(); if (t == 0) { // Reset bitstream to end of block - uint8_t* p = cur + len; + auto p = cur + len; auto prefix_bytes = (uint32_t)(((size_t)p) & 3); p -= prefix_bytes; s->cur = p; - s->bitbuf.x = (p < s->end) ? *reinterpret_cast(p) : 0; + s->bitbuf.x = (p < s->end) ? *reinterpret_cast(p) : 0; p += 4; - s->bitbuf.y = (p < s->end) ? *reinterpret_cast(p) : 0; + s->bitbuf.y = (p < s->end) ? *reinterpret_cast(p) : 0; s->bitpos = prefix_bytes * 8; s->out = out; } @@ -1021,12 +1019,16 @@ __device__ int parse_gzip_header(const uint8_t* src, size_t src_size) * * @tparam block_size Thread block dimension for this call * @param inputs Source and destination buffer information per block - * @param outputs Decompression status buffer per block + * @param outputs Destination buffer information per block + * @param statuses Decompression status buffer per block * @param parse_hdr If nonzero, indicates that the compressed bitstream includes a GZIP header */ template __global__ void __launch_bounds__(block_size) - inflate_kernel(gpu_inflate_input_s* inputs, gpu_inflate_status_s* outputs, int parse_hdr) + inflate_kernel(device_span const> inputs, + device_span const> outputs, + device_span statuses, + gzip_header_included parse_hdr) { __shared__ __align__(16) inflate_state_s state_g; @@ -1035,12 +1037,11 @@ __global__ void __launch_bounds__(block_size) inflate_state_s* state = &state_g; if (!t) { - auto* p = const_cast(static_cast(inputs[z].srcDevice)); - size_t src_size = inputs[z].srcSize; - uint32_t prefix_bytes; + auto p = inputs[z].data(); + auto src_size = inputs[z].size(); // Parse header if needed state->err = 0; - if (parse_hdr) { + if (parse_hdr == gzip_header_included::YES) { int hdr_len = parse_gzip_header(p, src_size); src_size = (src_size >= 8) ? src_size - 8 : 0; // ignore footer if (hdr_len >= 0) { @@ -1051,16 +1052,16 @@ __global__ void __launch_bounds__(block_size) } } // Initialize shared state - state->out = const_cast(static_cast(inputs[z].dstDevice)); - state->outbase = state->out; - state->outend = state->out + inputs[z].dstSize; - state->end = p + src_size; - prefix_bytes = (uint32_t)(((size_t)p) & 3); + state->out = outputs[z].data(); + state->outbase = state->out; + state->outend = state->out + outputs[z].size(); + state->end = p + src_size; + auto const prefix_bytes = (uint32_t)(((size_t)p) & 3); p -= prefix_bytes; state->cur = p; - state->bitbuf.x = (p < state->end) ? *reinterpret_cast(p) : 0; + state->bitbuf.x = (p < state->end) ? *reinterpret_cast(p) : 0; p += 4; - state->bitbuf.y = (p < state->end) ? *reinterpret_cast(p) : 0; + state->bitbuf.y = (p < state->end) ? *reinterpret_cast(p) : 0; state->bitpos = prefix_bytes * 8; } __syncthreads(); @@ -1132,9 +1133,9 @@ __global__ void __launch_bounds__(block_size) // Output buffer too small state->err = 1; } - outputs[z].bytes_written = state->out - state->outbase; - outputs[z].status = state->err; - outputs[z].reserved = (int)(state->end - state->cur); // Here mainly for debug purposes + statuses[z].bytes_written = state->out - state->outbase; + statuses[z].status = state->err; + statuses[z].reserved = (int)(state->end - state->cur); // Here mainly for debug purposes } } @@ -1145,7 +1146,9 @@ __global__ void __launch_bounds__(block_size) * * @param inputs Source and destination information per block */ -__global__ void __launch_bounds__(1024) copy_uncompressed_kernel(gpu_inflate_input_s* inputs) +__global__ void __launch_bounds__(1024) + copy_uncompressed_kernel(device_span const> inputs, + device_span const> outputs) { __shared__ const uint8_t* volatile src_g; __shared__ uint8_t* volatile dst_g; @@ -1158,9 +1161,9 @@ __global__ void __launch_bounds__(1024) copy_uncompressed_kernel(gpu_inflate_inp uint32_t len, src_align_bytes, src_align_bits, dst_align_bytes; if (!t) { - src = static_cast(inputs[z].srcDevice); - dst = static_cast(inputs[z].dstDevice); - len = min((uint32_t)inputs[z].srcSize, (uint32_t)inputs[z].dstSize); + src = inputs[z].data(); + dst = outputs[z].data(); + len = static_cast(min(inputs[z].size(), outputs[z].size())); src_g = src; dst_g = dst; copy_len_g = len; @@ -1195,26 +1198,26 @@ __global__ void __launch_bounds__(1024) copy_uncompressed_kernel(gpu_inflate_inp if (t < len) { dst[t] = src[t]; } } -cudaError_t __host__ gpuinflate(gpu_inflate_input_s* inputs, - gpu_inflate_status_s* outputs, - int count, - int parse_hdr, - rmm::cuda_stream_view stream) +void gpuinflate(device_span const> inputs, + device_span const> outputs, + device_span statuses, + gzip_header_included parse_hdr, + rmm::cuda_stream_view stream) { constexpr int block_size = 128; // Threads per block - if (count > 0) { + if (inputs.size() > 0) { inflate_kernel - <<>>(inputs, outputs, parse_hdr); + <<>>(inputs, outputs, statuses, parse_hdr); } - return cudaSuccess; } -cudaError_t __host__ gpu_copy_uncompressed_blocks(gpu_inflate_input_s* inputs, - int count, - rmm::cuda_stream_view stream) +void gpu_copy_uncompressed_blocks(device_span const> inputs, + device_span const> outputs, + rmm::cuda_stream_view stream) { - if (count > 0) { copy_uncompressed_kernel<<>>(inputs); } - return cudaSuccess; + if (inputs.size() > 0) { + copy_uncompressed_kernel<<>>(inputs, outputs); + } } } // namespace io diff --git a/cpp/src/io/comp/gpuinflate.h b/cpp/src/io/comp/gpuinflate.h index 29856bcd3f3..3870b2ac3b3 100644 --- a/cpp/src/io/comp/gpuinflate.h +++ b/cpp/src/io/comp/gpuinflate.h @@ -16,75 +16,70 @@ #pragma once -#include +#include #include +#include + namespace cudf { namespace io { -/** - * @brief Input parameters for the decompression interface - */ -struct gpu_inflate_input_s { - const void* srcDevice; - uint64_t srcSize; - void* dstDevice; - uint64_t dstSize; -}; /** * @brief Output parameters for the decompression interface */ -struct gpu_inflate_status_s { +struct decompress_status { uint64_t bytes_written; uint32_t status; uint32_t reserved; }; +enum class gzip_header_included { NO, YES }; + /** * @brief Interface for decompressing GZIP-compressed data * * Multiple, independent chunks of compressed data can be decompressed by using - * separate gpu_inflate_input_s/gpu_inflate_status_s pairs for each chunk. + * separate input/output/status for each chunk. * - * @param[in] inputs List of input argument structures - * @param[out] outputs List of output status structures - * @param[in] count Number of input/output structures + * @param[in] inputs List of input buffers + * @param[out] outputs List of output buffers + * @param[out] statuses List of output status structures * @param[in] parse_hdr Whether or not to parse GZIP header * @param[in] stream CUDA stream to use */ -cudaError_t gpuinflate(gpu_inflate_input_s* inputs, - gpu_inflate_status_s* outputs, - int count, - int parse_hdr, - rmm::cuda_stream_view stream); +void gpuinflate(device_span const> inputs, + device_span const> outputs, + device_span statuses, + gzip_header_included parse_hdr, + rmm::cuda_stream_view stream); /** * @brief Interface for copying uncompressed byte blocks * - * @param[in] inputs List of input argument structures - * @param[in] count Number of input structures + * @param[in] inputs List of input buffers + * @param[out] outputs List of output buffers * @param[in] stream CUDA stream to use */ -cudaError_t gpu_copy_uncompressed_blocks(gpu_inflate_input_s* inputs, - int count, - rmm::cuda_stream_view stream); +void gpu_copy_uncompressed_blocks(device_span const> inputs, + device_span const> outputs, + rmm::cuda_stream_view stream); /** * @brief Interface for decompressing Snappy-compressed data * * Multiple, independent chunks of compressed data can be decompressed by using - * separate gpu_inflate_input_s/gpu_inflate_status_s pairs for each chunk. + * separate input/output/status for each chunk. * - * @param[in] inputs List of input argument structures - * @param[out] outputs List of output status structures - * @param[in] count Number of input/output structures + * @param[in] inputs List of input buffers + * @param[out] outputs List of output buffers + * @param[out] statuses List of output status structures * @param[in] stream CUDA stream to use */ -cudaError_t gpu_unsnap(gpu_inflate_input_s* inputs, - gpu_inflate_status_s* outputs, - int count, - rmm::cuda_stream_view stream); +void gpu_unsnap(device_span const> inputs, + device_span const> outputs, + device_span statuses, + rmm::cuda_stream_view stream); /** * @brief Computes the size of temporary memory for Brotli decompression @@ -99,37 +94,37 @@ size_t get_gpu_debrotli_scratch_size(int max_num_inputs = 0); * @brief Interface for decompressing Brotli-compressed data * * Multiple, independent chunks of compressed data can be decompressed by using - * separate gpu_inflate_input_s/gpu_inflate_status_s pairs for each chunk. + * separate input/output/status pairs for each chunk. * - * @param[in] inputs List of input argument structures - * @param[out] outputs List of output status structures + * @param[in] inputs List of input buffers + * @param[out] outputs List of output buffers + * @param[out] statuses List of output status structures * @param[in] scratch Temporary memory for intermediate work * @param[in] scratch_size Size in bytes of the temporary memory - * @param[in] count Number of input/output structures * @param[in] stream CUDA stream to use */ -cudaError_t gpu_debrotli(gpu_inflate_input_s* inputs, - gpu_inflate_status_s* outputs, - void* scratch, - size_t scratch_size, - int count, - rmm::cuda_stream_view stream); +void gpu_debrotli(device_span const> inputs, + device_span const> outputs, + device_span statuses, + void* scratch, + size_t scratch_size, + rmm::cuda_stream_view stream); /** * @brief Interface for compressing data with Snappy * * Multiple, independent chunks of compressed data can be compressed by using - * separate gpu_inflate_input_s/gpu_inflate_status_s pairs for each chunk. + * separate input/output/status for each chunk. * - * @param[in] inputs List of input argument structures - * @param[out] outputs List of output status structures - * @param[in] count Number of input/output structures + * @param[in] inputs List of input buffers + * @param[out] outputs List of output buffers + * @param[out] statuses List of output status structures * @param[in] stream CUDA stream to use */ -cudaError_t gpu_snap(gpu_inflate_input_s* inputs, - gpu_inflate_status_s* outputs, - int count, - rmm::cuda_stream_view stream); +void gpu_snap(device_span const> inputs, + device_span const> outputs, + device_span statuses, + rmm::cuda_stream_view stream); } // namespace io } // namespace cudf diff --git a/cpp/src/io/comp/nvcomp_adapter.cpp b/cpp/src/io/comp/nvcomp_adapter.cpp new file mode 100644 index 00000000000..b2e6f07b80b --- /dev/null +++ b/cpp/src/io/comp/nvcomp_adapter.cpp @@ -0,0 +1,86 @@ +/* + * 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 "nvcomp_adapter.hpp" +#include "nvcomp_adapter.cuh" + +#include + +#include + +namespace cudf::io::nvcomp { + +template +auto batched_decompress_get_temp_size(compression_type type, Args&&... args) +{ + switch (type) { + case compression_type::SNAPPY: + return nvcompBatchedSnappyDecompressGetTempSize(std::forward(args)...); + default: CUDF_FAIL("Unsupported compression type"); + } +}; + +template +auto batched_decompress_async(compression_type type, Args&&... args) +{ + switch (type) { + case compression_type::SNAPPY: + return nvcompBatchedSnappyDecompressAsync(std::forward(args)...); + default: CUDF_FAIL("Unsupported compression type"); + } +}; + +size_t get_temp_size(compression_type type, size_t num_chunks, size_t max_uncomp_chunk_size) +{ + size_t temp_size = 0; + nvcompStatus_t nvcomp_status = + batched_decompress_get_temp_size(type, num_chunks, max_uncomp_chunk_size, &temp_size); + CUDF_EXPECTS(nvcomp_status == nvcompStatus_t::nvcompSuccess, + "Unable to get scratch size for decompression"); + + return temp_size; +} + +void batched_decompress(compression_type type, + device_span const> inputs, + device_span const> outputs, + device_span statuses, + size_t max_uncomp_chunk_size, + rmm::cuda_stream_view stream) +{ + auto const num_chunks = inputs.size(); + + // cuDF inflate inputs converted to nvcomp inputs + auto const nvcomp_args = create_batched_nvcomp_args(inputs, outputs, stream); + rmm::device_uvector actual_uncompressed_data_sizes(num_chunks, stream); + rmm::device_uvector nvcomp_statuses(num_chunks, stream); + // Temporary space required for decompression + rmm::device_buffer scratch(get_temp_size(type, num_chunks, max_uncomp_chunk_size), stream); + auto const nvcomp_status = batched_decompress_async(type, + nvcomp_args.compressed_data_ptrs.data(), + nvcomp_args.compressed_data_sizes.data(), + nvcomp_args.uncompressed_data_sizes.data(), + actual_uncompressed_data_sizes.data(), + num_chunks, + scratch.data(), + scratch.size(), + nvcomp_args.uncompressed_data_ptrs.data(), + nvcomp_statuses.data(), + stream.value()); + CUDF_EXPECTS(nvcomp_status == nvcompStatus_t::nvcompSuccess, "unable to perform decompression"); + + convert_status(nvcomp_statuses, actual_uncompressed_data_sizes, statuses, stream); +} +} // namespace cudf::io::nvcomp diff --git a/cpp/src/io/comp/nvcomp_adapter.cu b/cpp/src/io/comp/nvcomp_adapter.cu new file mode 100644 index 00000000000..ce294cc9b00 --- /dev/null +++ b/cpp/src/io/comp/nvcomp_adapter.cu @@ -0,0 +1,73 @@ +/* + * 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 "nvcomp_adapter.cuh" + +#include + +#include + +namespace cudf::io::nvcomp { + +batched_args create_batched_nvcomp_args(device_span const> inputs, + device_span const> outputs, + rmm::cuda_stream_view stream) +{ + size_t num_comp_pages = inputs.size(); + rmm::device_uvector compressed_data_ptrs(num_comp_pages, stream); + rmm::device_uvector compressed_data_sizes(num_comp_pages, stream); + rmm::device_uvector uncompressed_data_ptrs(num_comp_pages, stream); + rmm::device_uvector uncompressed_data_sizes(num_comp_pages, stream); + + // Prepare the input vectors + auto ins_it = + thrust::make_zip_iterator(compressed_data_ptrs.begin(), compressed_data_sizes.begin()); + thrust::transform( + rmm::exec_policy(stream), inputs.begin(), inputs.end(), ins_it, [] __device__(auto const& in) { + return thrust::make_tuple(in.data(), in.size()); + }); + + // Prepare the output vectors + auto outs_it = + thrust::make_zip_iterator(uncompressed_data_ptrs.begin(), uncompressed_data_sizes.begin()); + thrust::transform( + rmm::exec_policy(stream), + outputs.begin(), + outputs.end(), + outs_it, + [] __device__(auto const& out) { return thrust::make_tuple(out.data(), out.size()); }); + + return {std::move(compressed_data_ptrs), + std::move(compressed_data_sizes), + std::move(uncompressed_data_ptrs), + std::move(uncompressed_data_sizes)}; +} + +void convert_status(device_span nvcomp_stats, + device_span actual_uncompressed_sizes, + device_span cudf_stats, + rmm::cuda_stream_view stream) +{ + thrust::transform( + rmm::exec_policy(stream), + nvcomp_stats.begin(), + nvcomp_stats.end(), + actual_uncompressed_sizes.begin(), + cudf_stats.begin(), + [] __device__(auto const& status, auto const& size) { + return decompress_status{size, status == nvcompStatus_t::nvcompSuccess ? 0u : 1u}; + }); +} +} // namespace cudf::io::nvcomp diff --git a/cpp/src/io/comp/nvcomp_adapter.cuh b/cpp/src/io/comp/nvcomp_adapter.cuh new file mode 100644 index 00000000000..a76ddcf6813 --- /dev/null +++ b/cpp/src/io/comp/nvcomp_adapter.cuh @@ -0,0 +1,55 @@ +/* + * 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. + */ + +#pragma once + +#include "gpuinflate.h" + +#include + +#include + +#include +#include + +namespace cudf::io::nvcomp { + +struct batched_args { + rmm::device_uvector compressed_data_ptrs; + rmm::device_uvector compressed_data_sizes; + rmm::device_uvector uncompressed_data_ptrs; + rmm::device_uvector uncompressed_data_sizes; +}; + +/** + * @brief Split lists of src/dst device spans into lists of pointers/sizes. + * + * @param[in] inputs List of input buffers + * @param[in] outputs List of output buffers + * @param[in] stream CUDA stream to use + */ +batched_args create_batched_nvcomp_args(device_span const> inputs, + device_span const> outputs, + rmm::cuda_stream_view stream); + +/** + * @brief Convert nvcomp statuses into cuIO compression statuses. + */ +void convert_status(device_span nvcomp_stats, + device_span actual_uncompressed_sizes, + device_span cudf_stats, + rmm::cuda_stream_view stream); +} // namespace cudf::io::nvcomp diff --git a/cpp/src/io/comp/nvcomp_adapter.hpp b/cpp/src/io/comp/nvcomp_adapter.hpp new file mode 100644 index 00000000000..a0eb6bc4fbf --- /dev/null +++ b/cpp/src/io/comp/nvcomp_adapter.hpp @@ -0,0 +1,45 @@ +/* + * 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. + */ + +#pragma once + +#include "gpuinflate.h" + +#include + +#include + +namespace cudf::io::nvcomp { + +enum class compression_type { SNAPPY }; + +/** + * @brief Device batch decompression of given type. + * + * @param[in] type Compression type + * @param[in] inputs List of input buffers + * @param[out] outputs List of output buffers + * @param[out] statuses List of output status structures + * @param[in] max_uncomp_page_size maximum size of uncompressed block + * @param[in] stream CUDA stream to use + */ +void batched_decompress(compression_type type, + device_span const> inputs, + device_span const> outputs, + device_span statuses, + size_t max_uncomp_page_size, + rmm::cuda_stream_view stream); +} // namespace cudf::io::nvcomp diff --git a/cpp/src/io/comp/snap.cu b/cpp/src/io/comp/snap.cu index 9f0a610f8f7..d64eea06631 100644 --- a/cpp/src/io/comp/snap.cu +++ b/cpp/src/io/comp/snap.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020, 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. @@ -258,7 +258,9 @@ static __device__ uint32_t Match60(const uint8_t* src1, * @param[in] count Number of blocks to compress */ __global__ void __launch_bounds__(128) - snap_kernel(gpu_inflate_input_s* inputs, gpu_inflate_status_s* outputs, int count) + snap_kernel(device_span const> inputs, + device_span const> outputs, + device_span statuses) { __shared__ __align__(16) snap_state_s state_g; @@ -268,15 +270,15 @@ __global__ void __launch_bounds__(128) const uint8_t* src; if (!t) { - const auto* src = static_cast(inputs[blockIdx.x].srcDevice); - auto src_len = static_cast(inputs[blockIdx.x].srcSize); - auto* dst = static_cast(inputs[blockIdx.x].dstDevice); - auto dst_len = static_cast(inputs[blockIdx.x].dstSize); - uint8_t* end = dst + dst_len; - s->src = src; - s->src_len = src_len; - s->dst_base = dst; - s->end = end; + auto const src = inputs[blockIdx.x].data(); + auto src_len = static_cast(inputs[blockIdx.x].size()); + auto dst = outputs[blockIdx.x].data(); + auto const dst_len = static_cast(outputs[blockIdx.x].size()); + auto const end = dst + dst_len; + s->src = src; + s->src_len = src_len; + s->dst_base = dst; + s->end = end; while (src_len > 0x7f) { if (dst < end) { dst[0] = src_len | 0x80; } dst++; @@ -335,23 +337,22 @@ __global__ void __launch_bounds__(128) } __syncthreads(); if (!t) { - outputs[blockIdx.x].bytes_written = s->dst - s->dst_base; - outputs[blockIdx.x].status = (s->dst > s->end) ? 1 : 0; - outputs[blockIdx.x].reserved = 0; + statuses[blockIdx.x].bytes_written = s->dst - s->dst_base; + statuses[blockIdx.x].status = (s->dst > s->end) ? 1 : 0; + statuses[blockIdx.x].reserved = 0; } } -cudaError_t __host__ gpu_snap(gpu_inflate_input_s* inputs, - gpu_inflate_status_s* outputs, - int count, - rmm::cuda_stream_view stream) +void gpu_snap(device_span const> inputs, + device_span const> outputs, + device_span statuses, + rmm::cuda_stream_view stream) { dim3 dim_block(128, 1); // 4 warps per stream, 1 stream per block - dim3 dim_grid(count, 1); - if (count > 0) { - snap_kernel<<>>(inputs, outputs, count); + dim3 dim_grid(inputs.size(), 1); + if (inputs.size() > 0) { + snap_kernel<<>>(inputs, outputs, statuses); } - return cudaSuccess; } } // namespace io diff --git a/cpp/src/io/comp/unsnap.cu b/cpp/src/io/comp/unsnap.cu index 791a16bc912..dc44b9fcd59 100644 --- a/cpp/src/io/comp/unsnap.cu +++ b/cpp/src/io/comp/unsnap.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020, 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. @@ -64,14 +64,15 @@ struct unsnap_queue_s { * @brief snappy decompression state */ struct unsnap_state_s { - const uint8_t* base; ///< base ptr of compressed stream - const uint8_t* end; ///< end of compressed stream - uint32_t uncompressed_size; ///< uncompressed stream size - uint32_t bytes_left; ///< bytes to uncompressed remaining - int32_t error; ///< current error status - uint32_t tstart; ///< start time for perf logging - volatile unsnap_queue_s q; ///< queue for cross-warp communication - gpu_inflate_input_s in; ///< input parameters for current block + const uint8_t* base; ///< base ptr of compressed stream + const uint8_t* end; ///< end of compressed stream + uint32_t uncompressed_size; ///< uncompressed stream size + uint32_t bytes_left; ///< remaining bytes to decompress + int32_t error; ///< current error status + uint32_t tstart; ///< start time for perf logging + volatile unsnap_queue_s q; ///< queue for cross-warp communication + device_span src; ///< input for current block + device_span dst; ///< output for current block }; inline __device__ volatile uint8_t& byte_access(unsnap_state_s* s, uint32_t pos) @@ -497,9 +498,9 @@ __device__ void snappy_decode_symbols(unsnap_state_s* s, uint32_t t) template __device__ void snappy_process_symbols(unsnap_state_s* s, int t, Storage& temp_storage) { - const uint8_t* literal_base = s->base; - auto* out = static_cast(s->in.dstDevice); - int batch = 0; + auto const literal_base = s->base; + auto out = s->dst.data(); + int batch = 0; do { volatile unsnap_batch_s* b = &s->q.batch[batch * batch_size]; @@ -624,7 +625,9 @@ __device__ void snappy_process_symbols(unsnap_state_s* s, int t, Storage& temp_s */ template __global__ void __launch_bounds__(block_size) - unsnap_kernel(gpu_inflate_input_s* inputs, gpu_inflate_status_s* outputs) + unsnap_kernel(device_span const> inputs, + device_span const> outputs, + device_span statuses) { __shared__ __align__(16) unsnap_state_s state_g; __shared__ cub::WarpReduce::TempStorage temp_storage; @@ -632,16 +635,14 @@ __global__ void __launch_bounds__(block_size) unsnap_state_s* s = &state_g; int strm_id = blockIdx.x; - if (t < sizeof(gpu_inflate_input_s) / sizeof(uint32_t)) { - reinterpret_cast(&s->in)[t] = reinterpret_cast(&inputs[strm_id])[t]; - __threadfence_block(); - } if (t < batch_count) { s->q.batch_len[t] = 0; } __syncthreads(); if (!t) { - const auto* cur = static_cast(s->in.srcDevice); - const uint8_t* end = cur + s->in.srcSize; - s->error = 0; + s->src = inputs[strm_id]; + s->dst = outputs[strm_id]; + auto cur = s->src.begin(); + auto const end = s->src.end(); + s->error = 0; if (log_cyclecount) { s->tstart = clock(); } if (cur < end) { // Read uncompressed size (varint), limited to 32-bit @@ -672,7 +673,7 @@ __global__ void __launch_bounds__(block_size) s->bytes_left = uncompressed_size; s->base = cur; s->end = end; - if ((cur >= end && uncompressed_size != 0) || (uncompressed_size > s->in.dstSize)) { + if ((cur >= end && uncompressed_size != 0) || (uncompressed_size > s->dst.size())) { s->error = -1; } } else { @@ -697,28 +698,25 @@ __global__ void __launch_bounds__(block_size) __syncthreads(); } if (!t) { - outputs[strm_id].bytes_written = s->uncompressed_size - s->bytes_left; - outputs[strm_id].status = s->error; + statuses[strm_id].bytes_written = s->uncompressed_size - s->bytes_left; + statuses[strm_id].status = s->error; if (log_cyclecount) { - outputs[strm_id].reserved = clock() - s->tstart; + statuses[strm_id].reserved = clock() - s->tstart; } else { - outputs[strm_id].reserved = 0; + statuses[strm_id].reserved = 0; } } } -cudaError_t __host__ gpu_unsnap(gpu_inflate_input_s* inputs, - gpu_inflate_status_s* outputs, - int count, - rmm::cuda_stream_view stream) +void gpu_unsnap(device_span const> inputs, + device_span const> outputs, + device_span statuses, + rmm::cuda_stream_view stream) { - uint32_t count32 = (count > 0) ? count : 0; - dim3 dim_block(128, 1); // 4 warps per stream, 1 stream per block - dim3 dim_grid(count32, 1); // TODO: Check max grid dimensions vs max expected count - - unsnap_kernel<128><<>>(inputs, outputs); + dim3 dim_block(128, 1); // 4 warps per stream, 1 stream per block + dim3 dim_grid(inputs.size(), 1); // TODO: Check max grid dimensions vs max expected count - return cudaSuccess; + unsnap_kernel<128><<>>(inputs, outputs, statuses); } } // namespace io diff --git a/cpp/src/io/orc/orc_gpu.h b/cpp/src/io/orc/orc_gpu.h index d94aa00c7b9..837fd03a112 100644 --- a/cpp/src/io/orc/orc_gpu.h +++ b/cpp/src/io/orc/orc_gpu.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -43,9 +43,10 @@ struct CompressedStreamInfo { : compressed_data(compressed_data_), uncompressed_data(nullptr), compressed_data_size(compressed_size_), - decctl(nullptr), - decstatus(nullptr), - copyctl(nullptr), + dec_in_ctl(nullptr), + dec_out_ctl(nullptr), + copy_in_ctl(nullptr), + copy_out_ctl(nullptr), num_compressed_blocks(0), num_uncompressed_blocks(0), max_uncompressed_size(0), @@ -54,14 +55,15 @@ struct CompressedStreamInfo { } const uint8_t* compressed_data; // [in] base ptr to compressed stream data uint8_t* uncompressed_data; // [in] base ptr to uncompressed stream data or NULL if not known yet - size_t compressed_data_size; // [in] compressed data size for this stream - gpu_inflate_input_s* decctl; // [in] base ptr to decompression structure to be filled - gpu_inflate_status_s* decstatus; // [in] results of decompression - gpu_inflate_input_s* - copyctl; // [in] base ptr to copy structure to be filled for uncompressed blocks + size_t compressed_data_size; // [in] compressed data size for this stream + device_span* dec_in_ctl; // [in] input buffer to decompress + device_span* dec_out_ctl; // [in] output buffer to decompress into + device_span decstatus; // [in] results of decompression + device_span* copy_in_ctl; // [out] input buffer to copy + device_span* copy_out_ctl; // [out] output buffer to copy to uint32_t num_compressed_blocks; // [in,out] number of entries in decctl(in), number of compressed // blocks(out) - uint32_t num_uncompressed_blocks; // [in,out] number of entries in copyctl(in), number of + uint32_t num_uncompressed_blocks; // [in,out] number of entries in dec_in_ctl(in), number of // uncompressed blocks(out) uint64_t max_uncompressed_size; // [out] maximum uncompressed data size of stream uint32_t max_uncompressed_block_size; // [out] maximum uncompressed size of any block in stream @@ -345,8 +347,9 @@ void CompactOrcDataStreams(device_2dspan strm_desc, * @param[in] max_comp_blk_size Max size of any block after compression * @param[in,out] strm_desc StripeStream device array [stripe][stream] * @param[in,out] enc_streams chunk streams device array [column][rowgroup] - * @param[out] comp_in Per-block compression input parameters - * @param[out] comp_out Per-block compression status + * @param[out] comp_in Per-block compression input buffers + * @param[out] comp_out Per-block compression output buffers + * @param[out] comp_stat Per-block compression status * @param[in] stream CUDA stream used for device memory operations and kernel launches */ void CompressOrcDataStreams(uint8_t* compressed_data, @@ -356,8 +359,9 @@ void CompressOrcDataStreams(uint8_t* compressed_data, uint32_t max_comp_blk_size, device_2dspan strm_desc, device_2dspan enc_streams, - device_span comp_in, - device_span comp_out, + device_span> comp_in, + device_span> comp_out, + device_span comp_stat, rmm::cuda_stream_view stream); /** diff --git a/cpp/src/io/orc/reader_impl.cu b/cpp/src/io/orc/reader_impl.cu index a768d568178..139eb28d1a1 100644 --- a/cpp/src/io/orc/reader_impl.cu +++ b/cpp/src/io/orc/reader_impl.cu @@ -25,6 +25,7 @@ #include "timezone.cuh" #include +#include #include #include @@ -40,8 +41,6 @@ #include #include -#include - #include #include #include @@ -262,7 +261,7 @@ auto decimal_column_type(std::vector const& decimal128_columns, } // namespace -__global__ void decompress_check_kernel(device_span stats, +__global__ void decompress_check_kernel(device_span stats, bool* any_block_failure) { auto tid = blockIdx.x * blockDim.x + threadIdx.x; @@ -273,7 +272,7 @@ __global__ void decompress_check_kernel(device_span } } -void decompress_check(device_span stats, +void decompress_check(device_span stats, bool* any_block_failure, rmm::cuda_stream_view stream) { @@ -284,74 +283,6 @@ void decompress_check(device_span stats, decompress_check_kernel<<>>(stats, any_block_failure); } -__global__ void convert_nvcomp_status(device_span nvcomp_stats, - device_span actual_uncompressed_sizes, - device_span stats) -{ - auto tid = blockIdx.x * blockDim.x + threadIdx.x; - if (tid < stats.size()) { - stats[tid].status = nvcomp_stats[tid] == nvcompStatus_t::nvcompSuccess ? 0 : 1; - stats[tid].bytes_written = actual_uncompressed_sizes[tid]; - } -} - -void snappy_decompress(device_span comp_in, - device_span comp_stat, - size_t max_uncomp_page_size, - rmm::cuda_stream_view stream) -{ - size_t num_blocks = comp_in.size(); - size_t temp_size; - - auto status = - nvcompBatchedSnappyDecompressGetTempSize(num_blocks, max_uncomp_page_size, &temp_size); - CUDF_EXPECTS(nvcompStatus_t::nvcompSuccess == status, - "Unable to get scratch size for snappy decompression"); - - rmm::device_buffer scratch(temp_size, stream); - rmm::device_uvector compressed_data_ptrs(num_blocks, stream); - rmm::device_uvector compressed_data_sizes(num_blocks, stream); - rmm::device_uvector uncompressed_data_ptrs(num_blocks, stream); - rmm::device_uvector uncompressed_data_sizes(num_blocks, stream); - - rmm::device_uvector actual_uncompressed_data_sizes(num_blocks, stream); - rmm::device_uvector statuses(num_blocks, stream); - - device_span actual_uncompressed_sizes_span(actual_uncompressed_data_sizes.data(), - actual_uncompressed_data_sizes.size()); - device_span statuses_span(statuses.data(), statuses.size()); - - // Prepare the vectors - auto comp_it = thrust::make_zip_iterator(compressed_data_ptrs.begin(), - compressed_data_sizes.begin(), - uncompressed_data_ptrs.begin(), - uncompressed_data_sizes.data()); - thrust::transform(rmm::exec_policy(stream), - comp_in.begin(), - comp_in.end(), - comp_it, - [] __device__(gpu_inflate_input_s in) { - return thrust::make_tuple(in.srcDevice, in.srcSize, in.dstDevice, in.dstSize); - }); - - status = nvcompBatchedSnappyDecompressAsync(compressed_data_ptrs.data(), - compressed_data_sizes.data(), - uncompressed_data_sizes.data(), - actual_uncompressed_data_sizes.data(), - num_blocks, - scratch.data(), - scratch.size(), - uncompressed_data_ptrs.data(), - statuses.data(), - stream.value()); - CUDF_EXPECTS(nvcompStatus_t::nvcompSuccess == status, "unable to perform snappy decompression"); - - dim3 block(128); - dim3 grid(cudf::util::div_rounding_up_safe(num_blocks, static_cast(block.x))); - convert_nvcomp_status<<>>( - statuses_span, actual_uncompressed_sizes_span, comp_stat); -} - rmm::device_buffer reader::impl::decompress_stripe_data( cudf::detail::hostdevice_2dvector& chunks, const std::vector& stripe_data, @@ -396,9 +327,11 @@ rmm::device_buffer reader::impl::decompress_stripe_data( CUDF_EXPECTS(total_decomp_size > 0, "No decompressible data found"); rmm::device_buffer decomp_data(total_decomp_size, stream); - rmm::device_uvector inflate_in( + rmm::device_uvector> inflate_in( + num_compressed_blocks + num_uncompressed_blocks, stream); + rmm::device_uvector> inflate_out( num_compressed_blocks + num_uncompressed_blocks, stream); - rmm::device_uvector inflate_out(num_compressed_blocks, stream); + rmm::device_uvector inflate_stats(num_compressed_blocks, stream); // Parse again to populate the decompression input/output buffers size_t decomp_offset = 0; @@ -408,9 +341,11 @@ rmm::device_buffer reader::impl::decompress_stripe_data( for (size_t i = 0; i < compinfo.size(); ++i) { auto dst_base = static_cast(decomp_data.data()); compinfo[i].uncompressed_data = dst_base + decomp_offset; - compinfo[i].decctl = inflate_in.data() + start_pos; - compinfo[i].decstatus = inflate_out.data() + start_pos; - compinfo[i].copyctl = inflate_in.data() + start_pos_uncomp; + compinfo[i].dec_in_ctl = inflate_in.data() + start_pos; + compinfo[i].dec_out_ctl = inflate_out.data() + start_pos; + compinfo[i].decstatus = {inflate_stats.data() + start_pos, compinfo[i].num_compressed_blocks}; + compinfo[i].copy_in_ctl = inflate_in.data() + start_pos_uncomp; + compinfo[i].copy_out_ctl = inflate_out.data() + start_pos_uncomp; stream_info[i].dst_pos = decomp_offset; decomp_offset += compinfo[i].max_uncompressed_size; @@ -428,29 +363,36 @@ rmm::device_buffer reader::impl::decompress_stripe_data( // Dispatch batches of blocks to decompress if (num_compressed_blocks > 0) { - device_span inflate_out_view(inflate_out.data(), num_compressed_blocks); + device_span> inflate_in_view{inflate_in.data(), + num_compressed_blocks}; + device_span> inflate_out_view{inflate_out.data(), num_compressed_blocks}; switch (decompressor->GetKind()) { case orc::ZLIB: - CUDF_CUDA_TRY( - gpuinflate(inflate_in.data(), inflate_out.data(), num_compressed_blocks, 0, stream)); + gpuinflate( + inflate_in_view, inflate_out_view, inflate_stats, gzip_header_included::NO, stream); break; case orc::SNAPPY: if (nvcomp_integration::is_stable_enabled()) { - device_span inflate_in_view{inflate_in.data(), - num_compressed_blocks}; - snappy_decompress(inflate_in_view, inflate_out_view, max_uncomp_block_size, stream); + nvcomp::batched_decompress(nvcomp::compression_type::SNAPPY, + inflate_in_view, + inflate_out_view, + inflate_stats, + max_uncomp_block_size, + stream); } else { - CUDF_CUDA_TRY( - gpu_unsnap(inflate_in.data(), inflate_out.data(), num_compressed_blocks, stream)); + gpu_unsnap(inflate_in_view, inflate_out_view, inflate_stats, stream); } break; default: CUDF_FAIL("Unexpected decompression dispatch"); break; } - decompress_check(inflate_out_view, any_block_failure.device_ptr(), stream); + decompress_check(inflate_stats, any_block_failure.device_ptr(), stream); } if (num_uncompressed_blocks > 0) { - CUDF_CUDA_TRY(gpu_copy_uncompressed_blocks( - inflate_in.data() + num_compressed_blocks, num_uncompressed_blocks, stream)); + device_span> copy_in_view{inflate_in.data() + num_compressed_blocks, + num_uncompressed_blocks}; + device_span> copy_out_view{inflate_out.data() + num_compressed_blocks, + num_uncompressed_blocks}; + gpu_copy_uncompressed_blocks(copy_in_view, copy_out_view, stream); } gpu::PostDecompressionReassemble(compinfo.device_ptr(), compinfo.size(), stream); diff --git a/cpp/src/io/orc/stripe_enc.cu b/cpp/src/io/orc/stripe_enc.cu index f1d524058d2..3fe623be5b1 100644 --- a/cpp/src/io/orc/stripe_enc.cu +++ b/cpp/src/io/orc/stripe_enc.cu @@ -1141,8 +1141,9 @@ __global__ void __launch_bounds__(1024) * * @param[in] strm_desc StripeStream device array [stripe][stream] * @param[in] chunks EncChunk device array [rowgroup][column] - * @param[out] comp_in Per-block compression input parameters - * @param[out] comp_out Per-block compression status + * @param[out] inputs Per-block compression input buffers + * @param[out] outputs Per-block compression output buffers + * @param[out] statuses Per-block compression status * @param[in] compressed_bfr Compression output buffer * @param[in] comp_blk_size Compression block size * @param[in] max_comp_blk_size Max size of any block after compression @@ -1151,8 +1152,9 @@ __global__ void __launch_bounds__(1024) __global__ void __launch_bounds__(256) gpuInitCompressionBlocks(device_2dspan strm_desc, device_2dspan streams, // const? - device_span comp_in, - device_span comp_out, + device_span> inputs, + device_span> outputs, + device_span statuses, uint8_t* compressed_bfr, uint32_t comp_blk_size, uint32_t max_comp_blk_size) @@ -1175,16 +1177,11 @@ __global__ void __launch_bounds__(256) dst = compressed_bfr + ss.bfr_offset; num_blocks = (ss.stream_size > 0) ? (ss.stream_size - 1) / comp_blk_size + 1 : 1; for (uint32_t b = t; b < num_blocks; b += 256) { - gpu_inflate_input_s* blk_in = &comp_in[ss.first_block + b]; - gpu_inflate_status_s* blk_out = &comp_out[ss.first_block + b]; uint32_t blk_size = min(comp_blk_size, ss.stream_size - min(b * comp_blk_size, ss.stream_size)); - blk_in->srcDevice = src + b * comp_blk_size; - blk_in->srcSize = blk_size; - blk_in->dstDevice = dst + b * (BLOCK_HEADER_SIZE + max_comp_blk_size) + BLOCK_HEADER_SIZE; - blk_in->dstSize = max_comp_blk_size; - blk_out->bytes_written = blk_size; - blk_out->status = 1; - blk_out->reserved = 0; + inputs[ss.first_block + b] = {src + b * comp_blk_size, blk_size}; + outputs[ss.first_block + b] = { + dst + b * (BLOCK_HEADER_SIZE + max_comp_blk_size) + BLOCK_HEADER_SIZE, max_comp_blk_size}; + statuses[ss.first_block + b] = {blk_size, 1, 0}; } } @@ -1194,8 +1191,9 @@ __global__ void __launch_bounds__(256) * * @param[in,out] strm_desc StripeStream device array [stripe][stream] * @param[in] chunks EncChunk device array [rowgroup][column] - * @param[in] comp_in Per-block compression input parameters - * @param[in] comp_out Per-block compression status + * @param[out] inputs Per-block compression input buffers + * @param[out] outputs Per-block compression output buffers + * @param[out] statuses Per-block compression status * @param[in] compressed_bfr Compression output buffer * @param[in] comp_blk_size Compression block size * @param[in] max_comp_blk_size Max size of any block after compression @@ -1203,8 +1201,9 @@ __global__ void __launch_bounds__(256) // blockDim {1024,1,1} __global__ void __launch_bounds__(1024) gpuCompactCompressedBlocks(device_2dspan strm_desc, - device_span comp_in, - device_span comp_out, + device_span const> inputs, + device_span const> outputs, + device_span statuses, uint8_t* compressed_bfr, uint32_t comp_blk_size, uint32_t max_comp_blk_size) @@ -1228,21 +1227,21 @@ __global__ void __launch_bounds__(1024) b = 0; do { if (t == 0) { - gpu_inflate_input_s* blk_in = &comp_in[ss.first_block + b]; - gpu_inflate_status_s* blk_out = &comp_out[ss.first_block + b]; - uint32_t src_len = + auto const src_len = min(comp_blk_size, ss.stream_size - min(b * comp_blk_size, ss.stream_size)); - uint32_t dst_len = (blk_out->status == 0) ? blk_out->bytes_written : src_len; - uint32_t blk_size24; + auto dst_len = (statuses[ss.first_block + b].status == 0) + ? statuses[ss.first_block + b].bytes_written + : src_len; + uint32_t blk_size24{}; if (dst_len >= src_len) { // Copy from uncompressed source - src = static_cast(blk_in->srcDevice); - blk_out->bytes_written = src_len; - dst_len = src_len; - blk_size24 = dst_len * 2 + 1; + src = inputs[ss.first_block + b].data(); + statuses[ss.first_block + b].bytes_written = src_len; + dst_len = src_len; + blk_size24 = dst_len * 2 + 1; } else { // Compressed block - src = static_cast(blk_in->dstDevice); + src = outputs[ss.first_block + b].data(); blk_size24 = dst_len * 2 + 0; } dst[0] = static_cast(blk_size24 >> 0); @@ -1311,14 +1310,21 @@ void CompressOrcDataStreams(uint8_t* compressed_data, uint32_t max_comp_blk_size, device_2dspan strm_desc, device_2dspan enc_streams, - device_span comp_in, - device_span comp_out, + device_span> comp_in, + device_span> comp_out, + device_span comp_stat, rmm::cuda_stream_view stream) { dim3 dim_block_init(256, 1); dim3 dim_grid(strm_desc.size().first, strm_desc.size().second); - gpuInitCompressionBlocks<<>>( - strm_desc, enc_streams, comp_in, comp_out, compressed_data, comp_blk_size, max_comp_blk_size); + gpuInitCompressionBlocks<<>>(strm_desc, + enc_streams, + comp_in, + comp_out, + comp_stat, + compressed_data, + comp_blk_size, + max_comp_blk_size); if (compression == SNAPPY) { if (detail::nvcomp_integration::is_stable_enabled()) { try { @@ -1336,15 +1342,18 @@ void CompressOrcDataStreams(uint8_t* compressed_data, rmm::device_uvector compressed_bytes_written(num_compressed_blocks, stream); auto comp_it = thrust::make_zip_iterator(uncompressed_data_ptrs.begin(), - uncompressed_data_sizes.begin(), - compressed_data_ptrs.begin()); + uncompressed_data_sizes.begin()); + thrust::transform( + rmm::exec_policy(stream), + comp_in.begin(), + comp_in.end(), + comp_it, + [] __device__(auto const& in) { return thrust::make_tuple(in.data(), in.size()); }); thrust::transform(rmm::exec_policy(stream), - comp_in.begin(), - comp_in.end(), - comp_it, - [] __device__(gpu_inflate_input_s in) { - return thrust::make_tuple(in.srcDevice, in.srcSize, in.dstDevice); - }); + comp_out.begin(), + comp_out.end(), + compressed_data_ptrs.begin(), + [] __device__(auto const& out) { return out.data(); }); nvcomp_status = nvcompBatchedSnappyCompressAsync(uncompressed_data_ptrs.data(), uncompressed_data_sizes.data(), max_comp_blk_size, @@ -1361,9 +1370,9 @@ void CompressOrcDataStreams(uint8_t* compressed_data, thrust::transform(rmm::exec_policy(stream), compressed_bytes_written.begin(), compressed_bytes_written.end(), - comp_out.begin(), + comp_stat.begin(), [] __device__(size_t size) { - gpu_inflate_status_s status{}; + decompress_status status{}; status.bytes_written = size; return status; }); @@ -1371,18 +1380,18 @@ void CompressOrcDataStreams(uint8_t* compressed_data, // If we reach this then there was an error in compressing so set an error status for each // block thrust::for_each(rmm::exec_policy(stream), - comp_out.begin(), - comp_out.end(), - [] __device__(gpu_inflate_status_s & stat) { stat.status = 1; }); + comp_stat.begin(), + comp_stat.end(), + [] __device__(decompress_status & stat) { stat.status = 1; }); }; } else { - gpu_snap(comp_in.data(), comp_out.data(), num_compressed_blocks, stream); + gpu_snap(comp_in, comp_out, comp_stat, stream); } } dim3 dim_block_compact(1024, 1); gpuCompactCompressedBlocks<<>>( - strm_desc, comp_in, comp_out, compressed_data, comp_blk_size, max_comp_blk_size); + strm_desc, comp_in, comp_out, comp_stat, compressed_data, comp_blk_size, max_comp_blk_size); } } // namespace gpu diff --git a/cpp/src/io/orc/stripe_init.cu b/cpp/src/io/orc/stripe_init.cu index 276a1f49abf..e44ca10922f 100644 --- a/cpp/src/io/orc/stripe_init.cu +++ b/cpp/src/io/orc/stripe_init.cu @@ -26,9 +26,16 @@ namespace cudf { namespace io { namespace orc { namespace gpu { + +struct comp_in_out { + uint8_t const* in_ptr; + size_t in_size; + uint8_t* out_ptr; + size_t out_size; +}; struct compressed_stream_s { CompressedStreamInfo info; - gpu_inflate_input_s ctl; + comp_in_out ctl; }; // blockDim {128,1,1} @@ -57,7 +64,8 @@ extern "C" __global__ void __launch_bounds__(128, 8) gpuParseCompressedStripeDat uint32_t block_len = shuffle((lane_id == 0) ? cur[0] | (cur[1] << 8) | (cur[2] << 16) : 0); uint32_t is_uncompressed = block_len & 1; uint32_t uncompressed_size; - gpu_inflate_input_s* init_ctl = nullptr; + device_span* init_in_ctl = nullptr; + device_span* init_out_ctl = nullptr; block_len >>= 1; cur += BLOCK_HEADER_SIZE; if (block_len > block_size || cur + block_len > end) { @@ -82,27 +90,34 @@ extern "C" __global__ void __launch_bounds__(128, 8) gpuParseCompressedStripeDat uncompressed[max_uncompressed_size + lane_id] = cur[lane_id]; } } else { - init_ctl = s->info.copyctl; - init_ctl = (init_ctl && num_uncompressed_blocks < s->info.num_uncompressed_blocks) - ? &init_ctl[num_uncompressed_blocks] - : nullptr; + init_in_ctl = + (s->info.copy_in_ctl && num_uncompressed_blocks < s->info.num_uncompressed_blocks) + ? &s->info.copy_in_ctl[num_uncompressed_blocks] + : nullptr; + init_out_ctl = + (s->info.copy_out_ctl && num_uncompressed_blocks < s->info.num_uncompressed_blocks) + ? &s->info.copy_out_ctl[num_uncompressed_blocks] + : nullptr; num_uncompressed_blocks++; } } else { - init_ctl = s->info.decctl; - init_ctl = (init_ctl && num_compressed_blocks < s->info.num_compressed_blocks) - ? &init_ctl[num_compressed_blocks] - : nullptr; + init_in_ctl = (s->info.dec_in_ctl && num_compressed_blocks < s->info.num_compressed_blocks) + ? &s->info.dec_in_ctl[num_compressed_blocks] + : nullptr; + init_out_ctl = + (s->info.dec_out_ctl && num_compressed_blocks < s->info.num_compressed_blocks) + ? &s->info.dec_out_ctl[num_compressed_blocks] + : nullptr; num_compressed_blocks++; } - if (!lane_id && init_ctl) { - s->ctl.srcDevice = const_cast(cur); - s->ctl.srcSize = block_len; - s->ctl.dstDevice = uncompressed + max_uncompressed_size; - s->ctl.dstSize = uncompressed_size; + if (!lane_id && init_in_ctl) { + s->ctl = {cur, block_len, uncompressed + max_uncompressed_size, uncompressed_size}; } __syncwarp(); - if (init_ctl && lane_id == 0) *init_ctl = s->ctl; + if (init_in_ctl && lane_id == 0) { + *init_in_ctl = {s->ctl.in_ptr, s->ctl.in_size}; + *init_out_ctl = {s->ctl.out_ptr, s->ctl.out_size}; + } cur += block_len; max_uncompressed_size += uncompressed_size; max_uncompressed_block_size = max(max_uncompressed_block_size, uncompressed_size); @@ -137,14 +152,14 @@ extern "C" __global__ void __launch_bounds__(128, 8) s->info.num_compressed_blocks + s->info.num_uncompressed_blocks > 0 && s->info.max_uncompressed_size > 0) { // Walk through the compressed blocks - const uint8_t* cur = s->info.compressed_data; - const uint8_t* end = cur + s->info.compressed_data_size; - const gpu_inflate_input_s* dec_in = s->info.decctl; - const gpu_inflate_status_s* dec_out = s->info.decstatus; - uint8_t* uncompressed_actual = s->info.uncompressed_data; - uint8_t* uncompressed_estimated = uncompressed_actual; - uint32_t num_compressed_blocks = 0; - uint32_t max_compressed_blocks = s->info.num_compressed_blocks; + const uint8_t* cur = s->info.compressed_data; + const uint8_t* end = cur + s->info.compressed_data_size; + auto dec_out = s->info.dec_out_ctl; + auto dec_status = s->info.decstatus; + uint8_t* uncompressed_actual = s->info.uncompressed_data; + uint8_t* uncompressed_estimated = uncompressed_actual; + uint32_t num_compressed_blocks = 0; + uint32_t max_compressed_blocks = s->info.num_compressed_blocks; while (cur + BLOCK_HEADER_SIZE < end) { uint32_t block_len = shuffle((lane_id == 0) ? cur[0] | (cur[1] << 8) | (cur[2] << 16) : 0); @@ -158,14 +173,14 @@ extern "C" __global__ void __launch_bounds__(128, 8) uncompressed_size_actual = block_len; } else { if (num_compressed_blocks > max_compressed_blocks) { break; } - if (shuffle((lane_id == 0) ? dec_out[num_compressed_blocks].status : 0) != 0) { + if (shuffle((lane_id == 0) ? dec_status[num_compressed_blocks].status : 0) != 0) { // Decompression failed, not much point in doing anything else break; } - uncompressed_size_est = - shuffle((lane_id == 0) ? *(const uint32_t*)&dec_in[num_compressed_blocks].dstSize : 0); - uncompressed_size_actual = shuffle( - (lane_id == 0) ? *(const uint32_t*)&dec_out[num_compressed_blocks].bytes_written : 0); + uint32_t const dst_size = dec_out[num_compressed_blocks].size(); + uncompressed_size_est = shuffle((lane_id == 0) ? dst_size : 0); + uint32_t const bytes_written = dec_status[num_compressed_blocks].bytes_written; + uncompressed_size_actual = shuffle((lane_id == 0) ? bytes_written : 0); } // In practice, this should never happen with a well-behaved writer, as we would expect the // uncompressed size to always be equal to the compression block size except for the last @@ -360,11 +375,11 @@ static __device__ void gpuMapRowIndexToUncompressed(rowindex_state_s* s, if (strm_len > 0) { int32_t compressed_offset = (t < num_rowgroups) ? s->compressed_offset[t][ci_id] : 0; if (compressed_offset > 0) { - const uint8_t* start = s->strm_info[ci_id].compressed_data; - const uint8_t* cur = start; - const uint8_t* end = cur + s->strm_info[ci_id].compressed_data_size; - gpu_inflate_status_s* decstatus = s->strm_info[ci_id].decstatus; - uint32_t uncomp_offset = 0; + const uint8_t* start = s->strm_info[ci_id].compressed_data; + const uint8_t* cur = start; + const uint8_t* end = cur + s->strm_info[ci_id].compressed_data_size; + auto decstatus = s->strm_info[ci_id].decstatus.data(); + uint32_t uncomp_offset = 0; for (;;) { uint32_t block_len, is_uncompressed; diff --git a/cpp/src/io/orc/writer_impl.cu b/cpp/src/io/orc/writer_impl.cu index 779d0390751..ecd2d6f6ec0 100644 --- a/cpp/src/io/orc/writer_impl.cu +++ b/cpp/src/io/orc/writer_impl.cu @@ -1314,7 +1314,7 @@ void writer::impl::write_index_stream(int32_t stripe_id, file_segmentation const& segmentation, host_2dspan enc_streams, host_2dspan strm_desc, - host_span comp_out, + host_span comp_out, std::vector const& rg_stats, StripeInformation* stripe, orc_streams* streams, @@ -2050,8 +2050,9 @@ void writer::impl::write(table_view const& table) // Compress the data streams rmm::device_buffer compressed_data(compressed_bfr_size, stream); - hostdevice_vector comp_out(num_compressed_blocks, stream); - hostdevice_vector comp_in(num_compressed_blocks, stream); + hostdevice_vector> comp_in(num_compressed_blocks, stream); + hostdevice_vector> comp_out(num_compressed_blocks, stream); + hostdevice_vector comp_stats(num_compressed_blocks, stream); if (compression_kind_ != NONE) { strm_descs.host_to_device(stream); gpu::CompressOrcDataStreams(static_cast(compressed_data.data()), @@ -2063,9 +2064,10 @@ void writer::impl::write(table_view const& table) enc_data.streams, comp_in, comp_out, + comp_stats, stream); strm_descs.device_to_host(stream); - comp_out.device_to_host(stream, true); + comp_stats.device_to_host(stream, true); } ProtobufWriter pbw_(&buffer_); @@ -2097,7 +2099,7 @@ void writer::impl::write(table_view const& table) segmentation, enc_data.streams, strm_descs, - comp_out, + comp_stats, intermediate_stats.rowgroup_blobs, &stripe, &streams, diff --git a/cpp/src/io/orc/writer_impl.hpp b/cpp/src/io/orc/writer_impl.hpp index 5f981793762..d823c73007f 100644 --- a/cpp/src/io/orc/writer_impl.hpp +++ b/cpp/src/io/orc/writer_impl.hpp @@ -386,7 +386,7 @@ class writer::impl { file_segmentation const& segmentation, host_2dspan enc_streams, host_2dspan strm_desc, - host_span comp_out, + host_span comp_out, std::vector const& rg_stats, StripeInformation* stripe, orc_streams* streams, diff --git a/cpp/src/io/parquet/page_enc.cu b/cpp/src/io/parquet/page_enc.cu index 61bd29399cd..f05f0af2a79 100644 --- a/cpp/src/io/parquet/page_enc.cu +++ b/cpp/src/io/parquet/page_enc.cu @@ -81,8 +81,6 @@ struct page_enc_state_s { EncPage page; EncColumnChunk ck; parquet_column_device_view col; - gpu_inflate_input_s comp_in; - gpu_inflate_status_s comp_stat; uint16_t vals[rle_buffer_size]; }; @@ -750,8 +748,9 @@ static __device__ std::pair convert_nanoseconds(timesta template __global__ void __launch_bounds__(128, 8) gpuEncodePages(device_span pages, - device_span comp_in, - device_span comp_stat) + device_span> comp_in, + device_span> comp_out, + device_span comp_stats) { __shared__ __align__(8) page_enc_state_s state_g; using block_scan = cub::BlockScan; @@ -761,6 +760,7 @@ __global__ void __launch_bounds__(128, 8) uint32_t t = threadIdx.x; if (t == 0) { + state_g = page_enc_state_s{}; s->page = pages[blockIdx.x]; s->ck = *s->page.chunk; s->col = *s->ck.col_desc; @@ -1085,21 +1085,14 @@ __global__ void __launch_bounds__(128, 8) auto actual_data_size = static_cast(s->cur - base); uint32_t compressed_bfr_size = GetMaxCompressedBfrSize(actual_data_size); s->page.max_data_size = actual_data_size; - s->comp_in.srcDevice = base; - s->comp_in.srcSize = actual_data_size; - s->comp_in.dstDevice = s->page.compressed_data + s->page.max_hdr_size; - s->comp_in.dstSize = compressed_bfr_size; - s->comp_stat.bytes_written = 0; - s->comp_stat.status = ~0; - s->comp_stat.reserved = 0; - } - __syncthreads(); - if (t == 0) { + if (not comp_in.empty()) { + comp_in[blockIdx.x] = {base, actual_data_size}; + comp_out[blockIdx.x] = {s->page.compressed_data + s->page.max_hdr_size, compressed_bfr_size}; + } pages[blockIdx.x] = s->page; - if (not comp_in.empty()) comp_in[blockIdx.x] = s->comp_in; - if (not comp_stat.empty()) { - comp_stat[blockIdx.x] = s->comp_stat; - pages[blockIdx.x].comp_stat = &comp_stat[blockIdx.x]; + if (not comp_stats.empty()) { + comp_stats[blockIdx.x] = {0, ~0u}; + pages[blockIdx.x].comp_stat = &comp_stats[blockIdx.x]; } } } @@ -1317,7 +1310,7 @@ __device__ uint8_t* EncodeStatistics(uint8_t* start, // blockDim(128, 1, 1) __global__ void __launch_bounds__(128) gpuEncodePageHeaders(device_span pages, - device_span comp_stat, + device_span comp_stat, device_span page_stats, const statistics_chunk* chunk_stats) { @@ -1946,14 +1939,15 @@ void InitEncoderPages(device_2dspan chunks, } void EncodePages(device_span pages, - device_span comp_in, - device_span comp_stat, + device_span> comp_in, + device_span> comp_out, + device_span comp_stats, rmm::cuda_stream_view stream) { auto num_pages = pages.size(); // A page is part of one column. This is launching 1 block per page. 1 block will exclusively // deal with one datatype. - gpuEncodePages<128><<>>(pages, comp_in, comp_stat); + gpuEncodePages<128><<>>(pages, comp_in, comp_out, comp_stats); } void DecideCompression(device_span chunks, rmm::cuda_stream_view stream) @@ -1962,7 +1956,7 @@ void DecideCompression(device_span chunks, rmm::cuda_stream_view } void EncodePageHeaders(device_span pages, - device_span comp_stat, + device_span comp_stats, device_span page_stats, const statistics_chunk* chunk_stats, rmm::cuda_stream_view stream) @@ -1970,7 +1964,7 @@ void EncodePageHeaders(device_span pages, // TODO: single thread task. No need for 128 threads/block. Earlier it used to employ rest of the // threads to coop load structs gpuEncodePageHeaders<<>>( - pages, comp_stat, page_stats, chunk_stats); + pages, comp_stats, page_stats, chunk_stats); } void GatherPages(device_span chunks, diff --git a/cpp/src/io/parquet/parquet_gpu.hpp b/cpp/src/io/parquet/parquet_gpu.hpp index 53b82c73a35..057b9a87214 100644 --- a/cpp/src/io/parquet/parquet_gpu.hpp +++ b/cpp/src/io/parquet/parquet_gpu.hpp @@ -378,7 +378,7 @@ struct EncPage { uint32_t num_leaf_values; //!< Values in page. Different from num_rows in case of nested types uint32_t num_values; //!< Number of def/rep level values in page. Includes null/empty elements in //!< non-leaf levels - gpu_inflate_status_s* comp_stat; //!< Ptr to compression status + decompress_status* comp_stat; //!< Ptr to compression status }; /** @@ -584,13 +584,15 @@ void InitEncoderPages(cudf::detail::device_2dspan chunks, * @brief Launches kernel for packing column data into parquet pages * * @param[in,out] pages Device array of EncPages (unordered) - * @param[out] comp_in Optionally initializes compressor input params - * @param[out] comp_out Optionally initializes compressor output params + * @param[out] comp_in Compressor input buffers + * @param[out] comp_in Compressor output buffers + * @param[out] comp_stats Compressor statuses * @param[in] stream CUDA stream to use, default 0 */ void EncodePages(device_span pages, - device_span comp_in, - device_span comp_out, + device_span> comp_in, + device_span> comp_out, + device_span comp_stats, rmm::cuda_stream_view stream); /** @@ -605,13 +607,13 @@ void DecideCompression(device_span chunks, rmm::cuda_stream_view * @brief Launches kernel to encode page headers * * @param[in,out] pages Device array of EncPages - * @param[in] comp_out Compressor status or nullptr if no compression + * @param[in] comp_stats Compressor status * @param[in] page_stats Optional page-level statistics to be included in page header * @param[in] chunk_stats Optional chunk-level statistics to be encoded * @param[in] stream CUDA stream to use, default 0 */ void EncodePageHeaders(device_span pages, - device_span comp_out, + device_span comp_stats, device_span page_stats, const statistics_chunk* chunk_stats, rmm::cuda_stream_view stream); diff --git a/cpp/src/io/parquet/reader_impl.cu b/cpp/src/io/parquet/reader_impl.cu index cfca0bad518..a40993ee2dd 100644 --- a/cpp/src/io/parquet/reader_impl.cu +++ b/cpp/src/io/parquet/reader_impl.cu @@ -24,6 +24,7 @@ #include "compact_protocol_reader.hpp" #include +#include #include #include @@ -38,10 +39,9 @@ #include #include -#include - #include #include +#include #include #include @@ -1050,96 +1050,13 @@ void reader::impl::decode_page_headers(hostdevice_vector& pages.device_to_host(stream, true); } -__global__ void decompress_check_kernel(device_span stats, - bool* any_block_failure) -{ - auto tid = blockIdx.x * blockDim.x + threadIdx.x; - if (tid < stats.size()) { - if (stats[tid].status != 0) { - *any_block_failure = true; // Doesn't need to be atomic - } - } -} - -void decompress_check(device_span stats, - bool* any_block_failure, - rmm::cuda_stream_view stream) -{ - if (stats.empty()) { return; } // early exit for empty stats - - dim3 block(128); - dim3 grid(cudf::util::div_rounding_up_safe(stats.size(), static_cast(block.x))); - decompress_check_kernel<<>>(stats, any_block_failure); -} - -__global__ void convert_nvcomp_status(device_span nvcomp_stats, - device_span stats) -{ - auto tid = blockIdx.x * blockDim.x + threadIdx.x; - if (tid < stats.size()) { - stats[tid].status = nvcomp_stats[tid] == nvcompStatus_t::nvcompSuccess ? 0 : 1; - } -} - -void snappy_decompress(device_span comp_in, - device_span comp_stat, - size_t max_uncomp_page_size, - rmm::cuda_stream_view stream) +void decompress_check(device_span stats, rmm::cuda_stream_view stream) { - size_t num_comp_pages = comp_in.size(); - size_t temp_size; - - nvcompStatus_t nvcomp_status = - nvcompBatchedSnappyDecompressGetTempSize(num_comp_pages, max_uncomp_page_size, &temp_size); - CUDF_EXPECTS(nvcomp_status == nvcompStatus_t::nvcompSuccess, - "Unable to get scratch size for snappy decompression"); - - // Not needed now but nvcomp API makes no promises about future - rmm::device_buffer scratch(temp_size, stream); - // Analogous to comp_in.srcDevice - rmm::device_uvector compressed_data_ptrs(num_comp_pages, stream); - // Analogous to comp_in.srcSize - rmm::device_uvector compressed_data_sizes(num_comp_pages, stream); - // Analogous to comp_in.dstDevice - rmm::device_uvector uncompressed_data_ptrs(num_comp_pages, stream); - // Analogous to comp_in.dstSize - rmm::device_uvector uncompressed_data_sizes(num_comp_pages, stream); - - // Analogous to comp_stat.bytes_written - rmm::device_uvector actual_uncompressed_data_sizes(num_comp_pages, stream); - // Convertible to comp_stat.status - rmm::device_uvector statuses(num_comp_pages, stream); - device_span statuses_span(statuses.data(), statuses.size()); - - // Prepare the vectors - auto comp_it = thrust::make_zip_iterator(compressed_data_ptrs.begin(), - compressed_data_sizes.begin(), - uncompressed_data_ptrs.begin(), - uncompressed_data_sizes.data()); - thrust::transform(rmm::exec_policy(stream), - comp_in.begin(), - comp_in.end(), - comp_it, - [] __device__(gpu_inflate_input_s in) { - return thrust::make_tuple(in.srcDevice, in.srcSize, in.dstDevice, in.dstSize); - }); - - nvcomp_status = nvcompBatchedSnappyDecompressAsync(compressed_data_ptrs.data(), - compressed_data_sizes.data(), - uncompressed_data_sizes.data(), - actual_uncompressed_data_sizes.data(), - num_comp_pages, - scratch.data(), - scratch.size(), - uncompressed_data_ptrs.data(), - statuses.data(), - stream.value()); - CUDF_EXPECTS(nvcomp_status == nvcompStatus_t::nvcompSuccess, - "unable to perform snappy decompression"); - - dim3 block(128); - dim3 grid(cudf::util::div_rounding_up_safe(num_comp_pages, static_cast(block.x))); - convert_nvcomp_status<<>>(statuses_span, comp_stat); + CUDF_EXPECTS(thrust::all_of(rmm::exec_policy(stream), + stats.begin(), + stats.end(), + [] __device__(auto const& stat) { return stat.status == 0; }), + "Error during decompression"); } /** @@ -1175,9 +1092,9 @@ rmm::device_buffer reader::impl::decompress_page_data( int32_t max_decompressed_size; }; - std::array codecs{codec_stats{parquet::GZIP, 0, 0}, - codec_stats{parquet::SNAPPY, 0, 0}, - codec_stats{parquet::BROTLI, 0, 0}}; + std::array codecs{codec_stats{parquet::GZIP, 0, 0}, + codec_stats{parquet::SNAPPY, 0, 0}, + codec_stats{parquet::BROTLI, 0, 0}}; auto is_codec_supported = [&codecs](int8_t codec) { if (codec == parquet::UNCOMPRESSED) return true; @@ -1207,91 +1124,73 @@ rmm::device_buffer reader::impl::decompress_page_data( // Dispatch batches of pages to decompress for each codec rmm::device_buffer decomp_pages(total_decomp_size, stream); - hostdevice_vector inflate_in(0, num_comp_pages, stream); - hostdevice_vector inflate_out(0, num_comp_pages, stream); - hostdevice_vector any_block_failure(1, stream); - any_block_failure[0] = false; - any_block_failure.host_to_device(stream); + std::vector> comp_in; + comp_in.reserve(num_comp_pages); + std::vector> comp_out; + comp_out.reserve(num_comp_pages); - device_span inflate_in_view(inflate_in.device_ptr(), inflate_in.size()); - device_span inflate_out_view(inflate_out.device_ptr(), inflate_out.size()); + rmm::device_uvector comp_stats(num_comp_pages, stream); + thrust::fill(rmm::exec_policy(stream), + comp_stats.begin(), + comp_stats.end(), + decompress_status{0, static_cast(-1000), 0}); size_t decomp_offset = 0; - int32_t argc = 0; + int32_t start_pos = 0; for (const auto& codec : codecs) { - if (codec.num_pages > 0) { - int32_t start_pos = argc; - - for_each_codec_page(codec.compression_type, [&](size_t page) { - auto dst_base = static_cast(decomp_pages.data()); - inflate_in[argc].srcDevice = pages[page].page_data; - inflate_in[argc].srcSize = pages[page].compressed_page_size; - inflate_in[argc].dstDevice = dst_base + decomp_offset; - inflate_in[argc].dstSize = pages[page].uncompressed_page_size; - - inflate_out[argc].bytes_written = 0; - inflate_out[argc].status = static_cast(-1000); - inflate_out[argc].reserved = 0; - - pages[page].page_data = static_cast(inflate_in[argc].dstDevice); - decomp_offset += inflate_in[argc].dstSize; - argc++; - }); + if (codec.num_pages == 0) { continue; } - CUDF_CUDA_TRY(cudaMemcpyAsync(inflate_in.device_ptr(start_pos), - inflate_in.host_ptr(start_pos), - sizeof(decltype(inflate_in)::value_type) * (argc - start_pos), - cudaMemcpyHostToDevice, - stream.value())); - CUDF_CUDA_TRY(cudaMemcpyAsync(inflate_out.device_ptr(start_pos), - inflate_out.host_ptr(start_pos), - sizeof(decltype(inflate_out)::value_type) * (argc - start_pos), - cudaMemcpyHostToDevice, - stream.value())); - - switch (codec.compression_type) { - case parquet::GZIP: - CUDF_CUDA_TRY(gpuinflate(inflate_in.device_ptr(start_pos), - inflate_out.device_ptr(start_pos), - argc - start_pos, - 1, - stream)) - break; - case parquet::SNAPPY: - if (nvcomp_integration::is_stable_enabled()) { - snappy_decompress(inflate_in_view.subspan(start_pos, argc - start_pos), - inflate_out_view.subspan(start_pos, argc - start_pos), - codec.max_decompressed_size, - stream); - } else { - CUDF_CUDA_TRY(gpu_unsnap(inflate_in.device_ptr(start_pos), - inflate_out.device_ptr(start_pos), - argc - start_pos, - stream)); - } - break; - case parquet::BROTLI: - CUDF_CUDA_TRY(gpu_debrotli(inflate_in.device_ptr(start_pos), - inflate_out.device_ptr(start_pos), - debrotli_scratch.data(), - debrotli_scratch.size(), - argc - start_pos, - stream)); - break; - default: CUDF_FAIL("Unexpected decompression dispatch"); break; - } - CUDF_CUDA_TRY(cudaMemcpyAsync(inflate_out.host_ptr(start_pos), - inflate_out.device_ptr(start_pos), - sizeof(decltype(inflate_out)::value_type) * (argc - start_pos), - cudaMemcpyDeviceToHost, - stream.value())); + for_each_codec_page(codec.compression_type, [&](size_t page) { + auto dst_base = static_cast(decomp_pages.data()); + comp_in.emplace_back(pages[page].page_data, + static_cast(pages[page].compressed_page_size)); + comp_out.emplace_back(dst_base + decomp_offset, + static_cast(pages[page].uncompressed_page_size)); + + pages[page].page_data = static_cast(comp_out.back().data()); + decomp_offset += comp_out.back().size(); + }); + + host_span const> comp_in_view{comp_in.data() + start_pos, + codec.num_pages}; + auto const d_comp_in = cudf::detail::make_device_uvector_async(comp_in_view, stream); + host_span const> comp_out_view(comp_out.data() + start_pos, + codec.num_pages); + auto const d_comp_out = cudf::detail::make_device_uvector_async(comp_out_view, stream); + device_span d_comp_stats_view(comp_stats.data() + start_pos, + codec.num_pages); + + switch (codec.compression_type) { + case parquet::GZIP: + gpuinflate(d_comp_in, d_comp_out, d_comp_stats_view, gzip_header_included::YES, stream); + break; + case parquet::SNAPPY: + if (nvcomp_integration::is_stable_enabled()) { + nvcomp::batched_decompress(nvcomp::compression_type::SNAPPY, + d_comp_in, + d_comp_out, + d_comp_stats_view, + codec.max_decompressed_size, + stream); + } else { + gpu_unsnap(d_comp_in, d_comp_out, d_comp_stats_view, stream); + } + break; + case parquet::BROTLI: + gpu_debrotli(d_comp_in, + d_comp_out, + d_comp_stats_view, + debrotli_scratch.data(), + debrotli_scratch.size(), + stream); + break; + default: CUDF_FAIL("Unexpected decompression dispatch"); break; } + start_pos += codec.num_pages; } - decompress_check(inflate_out_view, any_block_failure.device_ptr(), stream); - any_block_failure.device_to_host(stream, true); // synchronizes stream - CUDF_EXPECTS(not any_block_failure[0], "Error during decompression"); + decompress_check(comp_stats, stream); // Update the page information in device memory with the updated value of // page_data; it now points to the uncompressed data buffer diff --git a/cpp/src/io/parquet/writer_impl.cu b/cpp/src/io/parquet/writer_impl.cu index 75a50714407..dbbd39fb508 100644 --- a/cpp/src/io/parquet/writer_impl.cu +++ b/cpp/src/io/parquet/writer_impl.cu @@ -984,8 +984,9 @@ void writer::impl::init_encoder_pages(hostdevice_2dvector& stream.synchronize(); } -void snappy_compress(device_span comp_in, - device_span comp_stat, +void snappy_compress(device_span const> comp_in, + device_span const> comp_out, + device_span comp_stats, size_t max_page_uncomp_data_size, rmm::cuda_stream_view stream) { @@ -1012,16 +1013,20 @@ void snappy_compress(device_span comp_in, // the space allocated unless one uses the API nvcompBatchedSnappyCompressGetOutputSize() // Prepare the vectors - auto comp_it = thrust::make_zip_iterator(uncompressed_data_ptrs.begin(), - uncompressed_data_sizes.begin(), - compressed_data_ptrs.begin()); + auto comp_it = + thrust::make_zip_iterator(uncompressed_data_ptrs.begin(), uncompressed_data_sizes.begin()); + thrust::transform( + rmm::exec_policy(stream), + comp_in.begin(), + comp_in.end(), + comp_it, + [] __device__(auto const& in) { return thrust::make_tuple(in.data(), in.size()); }); + thrust::transform(rmm::exec_policy(stream), - comp_in.begin(), - comp_in.end(), - comp_it, - [] __device__(gpu_inflate_input_s in) { - return thrust::make_tuple(in.srcDevice, in.srcSize, in.dstDevice); - }); + comp_out.begin(), + comp_out.end(), + compressed_data_ptrs.begin(), + [] __device__(auto const& out) { return out.data(); }); nvcomp_status = nvcompBatchedSnappyCompressAsync(uncompressed_data_ptrs.data(), uncompressed_data_sizes.data(), max_page_uncomp_data_size, @@ -1041,9 +1046,9 @@ void snappy_compress(device_span comp_in, thrust::transform(rmm::exec_policy(stream), compressed_bytes_written.begin(), compressed_bytes_written.end(), - comp_stat.begin(), + comp_stats.begin(), [] __device__(size_t size) { - gpu_inflate_status_s status{}; + decompress_status status{}; status.bytes_written = size; return status; }); @@ -1051,9 +1056,9 @@ void snappy_compress(device_span comp_in, } catch (...) { // If we reach this then there was an error in compressing so set an error status for each page thrust::for_each(rmm::exec_policy(stream), - comp_stat.begin(), - comp_stat.end(), - [] __device__(gpu_inflate_status_s & stat) { stat.status = 1; }); + comp_stats.begin(), + comp_stats.end(), + [] __device__(decompress_status & stat) { stat.status = 1; }); }; } @@ -1077,19 +1082,17 @@ void writer::impl::encode_pages(hostdevice_2dvector& chunks uint32_t max_comp_pages = (compression_ != parquet::Compression::UNCOMPRESSED) ? pages_in_batch : 0; - rmm::device_uvector compression_input(max_comp_pages, stream); - rmm::device_uvector compression_status(max_comp_pages, stream); - - device_span comp_in{compression_input.data(), compression_input.size()}; - device_span comp_stat{compression_status.data(), compression_status.size()}; + rmm::device_uvector> comp_in(max_comp_pages, stream); + rmm::device_uvector> comp_out(max_comp_pages, stream); + rmm::device_uvector comp_stats(max_comp_pages, stream); - gpu::EncodePages(batch_pages, comp_in, comp_stat, stream); + gpu::EncodePages(batch_pages, comp_in, comp_out, comp_stats, stream); switch (compression_) { case parquet::Compression::SNAPPY: if (nvcomp_integration::is_stable_enabled()) { - snappy_compress(comp_in, comp_stat, max_page_uncomp_data_size, stream); + snappy_compress(comp_in, comp_out, comp_stats, max_page_uncomp_data_size, stream); } else { - CUDF_CUDA_TRY(gpu_snap(comp_in.data(), comp_stat.data(), pages_in_batch, stream)); + gpu_snap(comp_in, comp_out, comp_stats, stream); } break; default: break; @@ -1098,7 +1101,7 @@ void writer::impl::encode_pages(hostdevice_2dvector& chunks // chunk-level auto d_chunks_in_batch = chunks.device_view().subspan(first_rowgroup, rowgroups_in_batch); DecideCompression(d_chunks_in_batch.flat_view(), stream); - EncodePageHeaders(batch_pages, comp_stat, batch_pages_stats, chunk_stats, stream); + EncodePageHeaders(batch_pages, comp_stats, batch_pages_stats, chunk_stats, stream); GatherPages(d_chunks_in_batch.flat_view(), pages, stream); auto h_chunks_in_batch = chunks.host_view().subspan(first_rowgroup, rowgroups_in_batch); diff --git a/cpp/src/io/utilities/hostdevice_vector.hpp b/cpp/src/io/utilities/hostdevice_vector.hpp index a754f7cf7d3..30c7b6ec326 100644 --- a/cpp/src/io/utilities/hostdevice_vector.hpp +++ b/cpp/src/io/utilities/hostdevice_vector.hpp @@ -51,10 +51,10 @@ class hostdevice_vector { } explicit hostdevice_vector(size_t initial_size, size_t max_size, rmm::cuda_stream_view stream) - : num_elements(initial_size), max_elements(max_size) + : max_elements(max_size), num_elements(initial_size) { if (max_elements != 0) { - CUDF_CUDA_TRY(cudaMallocHost(&h_data, sizeof(T) * max_elements)); + CUDF_CUDA_TRY(cudaMallocHost(reinterpret_cast(&h_data), sizeof(T) * max_elements)); d_data.resize(sizeof(T) * max_elements, stream); } } @@ -62,7 +62,7 @@ class hostdevice_vector { ~hostdevice_vector() { if (max_elements != 0) { - auto const free_result = cudaFreeHost(h_data); + [[maybe_unused]] auto const free_result = cudaFreeHost(h_data); assert(free_result == cudaSuccess); } } diff --git a/cpp/tests/io/comp/decomp_test.cpp b/cpp/tests/io/comp/decomp_test.cpp index dd00b201df9..a325cadf6a5 100644 --- a/cpp/tests/io/comp/decomp_test.cpp +++ b/cpp/tests/io/comp/decomp_test.cpp @@ -15,6 +15,7 @@ */ #include +#include #include @@ -24,6 +25,8 @@ #include +using cudf::device_span; + /** * @brief Base test fixture for decompression * @@ -32,19 +35,6 @@ */ template struct DecompressTest : public cudf::test::BaseFixture { - void SetUp() override - { - ASSERT_CUDA_SUCCEEDED(cudaMallocHost((void**)&inf_args, sizeof(cudf::io::gpu_inflate_input_s))); - ASSERT_CUDA_SUCCEEDED( - cudaMallocHost((void**)&inf_stat, sizeof(cudf::io::gpu_inflate_status_s))); - } - - void TearDown() override - { - ASSERT_CUDA_SUCCEEDED(cudaFreeHost(inf_stat)); - ASSERT_CUDA_SUCCEEDED(cudaFreeHost(inf_args)); - } - std::vector vector_from_string(const char* str) const { return std::vector(reinterpret_cast(str), @@ -55,49 +45,43 @@ struct DecompressTest : public cudf::test::BaseFixture { const uint8_t* compressed, size_t compressed_size) { - rmm::device_buffer src{compressed, compressed_size, rmm::cuda_stream_default}; - rmm::device_buffer dst{decompressed->size(), rmm::cuda_stream_default}; - - inf_args->srcDevice = static_cast(src.data()); - inf_args->dstDevice = static_cast(dst.data()); - inf_args->srcSize = src.size(); - inf_args->dstSize = dst.size(); - rmm::device_uvector d_inf_args(1, rmm::cuda_stream_default); - rmm::device_uvector d_inf_stat(1, rmm::cuda_stream_default); - ASSERT_CUDA_SUCCEEDED(cudaMemcpyAsync(d_inf_args.data(), - inf_args, - sizeof(cudf::io::gpu_inflate_input_s), - cudaMemcpyHostToDevice, - 0)); - ASSERT_CUDA_SUCCEEDED(cudaMemcpyAsync(d_inf_stat.data(), - inf_stat, - sizeof(cudf::io::gpu_inflate_status_s), - cudaMemcpyHostToDevice, - 0)); - ASSERT_CUDA_SUCCEEDED( - static_cast(this)->dispatch(d_inf_args.data(), d_inf_stat.data())); - ASSERT_CUDA_SUCCEEDED(cudaMemcpyAsync(inf_stat, - d_inf_stat.data(), - sizeof(cudf::io::gpu_inflate_status_s), - cudaMemcpyDeviceToHost, - 0)); - ASSERT_CUDA_SUCCEEDED(cudaMemcpyAsync( - decompressed->data(), inf_args->dstDevice, inf_args->dstSize, cudaMemcpyDeviceToHost, 0)); - ASSERT_CUDA_SUCCEEDED(cudaStreamSynchronize(0)); + auto stream = rmm::cuda_stream_default; + rmm::device_buffer src{compressed, compressed_size, stream}; + rmm::device_uvector dst{decompressed->size(), stream}; + + hostdevice_vector> inf_in(1, stream); + inf_in[0] = {static_cast(src.data()), src.size()}; + inf_in.host_to_device(stream); + + hostdevice_vector> inf_out(1, stream); + inf_out[0] = dst; + inf_out.host_to_device(stream); + + hostdevice_vector inf_stat(1, stream); + inf_stat[0] = {}; + inf_stat.host_to_device(stream); + + static_cast(this)->dispatch(inf_in, inf_out, inf_stat); + cudaMemcpyAsync( + decompressed->data(), dst.data(), dst.size(), cudaMemcpyDeviceToHost, stream.value()); + inf_stat.device_to_host(stream, true); + ASSERT_EQ(inf_stat[0].status, 0); } - - cudf::io::gpu_inflate_input_s* inf_args = nullptr; - cudf::io::gpu_inflate_status_s* inf_stat = nullptr; }; /** * @brief Derived fixture for GZIP decompression */ struct GzipDecompressTest : public DecompressTest { - cudaError_t dispatch(cudf::io::gpu_inflate_input_s* d_inf_args, - cudf::io::gpu_inflate_status_s* d_inf_stat) + void dispatch(device_span> d_inf_in, + device_span> d_inf_out, + device_span d_inf_stat) { - return cudf::io::gpuinflate(d_inf_args, d_inf_stat, 1, 1, rmm::cuda_stream_default); + cudf::io::gpuinflate(d_inf_in, + d_inf_out, + d_inf_stat, + cudf::io::gzip_header_included::YES, + rmm::cuda_stream_default); } }; @@ -105,10 +89,11 @@ struct GzipDecompressTest : public DecompressTest { * @brief Derived fixture for Snappy decompression */ struct SnappyDecompressTest : public DecompressTest { - cudaError_t dispatch(cudf::io::gpu_inflate_input_s* d_inf_args, - cudf::io::gpu_inflate_status_s* d_inf_stat) + void dispatch(device_span> d_inf_in, + device_span> d_inf_out, + device_span d_inf_stat) { - return cudf::io::gpu_unsnap(d_inf_args, d_inf_stat, 1, rmm::cuda_stream_default); + cudf::io::gpu_unsnap(d_inf_in, d_inf_out, d_inf_stat, rmm::cuda_stream_default); } }; @@ -116,14 +101,19 @@ struct SnappyDecompressTest : public DecompressTest { * @brief Derived fixture for Brotli decompression */ struct BrotliDecompressTest : public DecompressTest { - cudaError_t dispatch(cudf::io::gpu_inflate_input_s* d_inf_args, - cudf::io::gpu_inflate_status_s* d_inf_stat) + void dispatch(device_span> d_inf_in, + device_span> d_inf_out, + device_span d_inf_stat) { rmm::device_buffer d_scratch{cudf::io::get_gpu_debrotli_scratch_size(1), rmm::cuda_stream_default}; - return cudf::io::gpu_debrotli( - d_inf_args, d_inf_stat, d_scratch.data(), d_scratch.size(), 1, rmm::cuda_stream_default); + cudf::io::gpu_debrotli(d_inf_in, + d_inf_out, + d_inf_stat, + d_scratch.data(), + d_scratch.size(), + rmm::cuda_stream_default); } }; From 84f88ceb18225850835a9912a18e4c82245d5620 Mon Sep 17 00:00:00 2001 From: MithunR Date: Thu, 28 Apr 2022 23:45:40 -0700 Subject: [PATCH 132/246] Support purging non-empty null elements from LIST/STRING columns (#10701) Fixes #10291. With certain operations in `libcudf`, it is possible to produce `LIST` columns with `NULL` rows that are not also empty. For instance, consider a `STRUCT` column is constructed with an explicit validity buffer and a `LIST` child column: ```c++ auto const lists = lists_column_wrapper{ {0,1}, {2,3}, {4,5} }; auto const structs = structs_column_wrapper{ {lists}, null_at(1) }; ``` Since `structs[1] == NULL`, its `LIST` member is also deemed null. However, for efficiency, the null-ness is recorded in the `LIST`'s validity buffer, without purging the unnecessary values from its child. The `LIST` columns appears as follows: ``` Validity: 101 Offsets: [0, 2, 4, 6] Child: [0, 1, 2, 3, 4, 5] ``` Even though Row#1 is null, its size is `4-2 = 2`, and not `0`. (Row#1 is thus a non-empty null row.) This commit adds a `cudf::purge_nonempty_nulls()` function that purges such rows, and reduces such columns to a more space-efficient representation, i.e.: ``` Validity: 101 Offsets: [0, 2, 2, 4] Child: [0, 1, 4, 5] ``` This commit also modifies `cudf::gather()` not to produce `STRING`/`LIST` columns with "dirty" rows. Further, it adds two new functions to determine if a specified column needs such purging: 1. `cudf::may_have_nonempty_nulls()`: A fast check to check a column for the *possibility* of having non-empty nulls. This only checks whether the column or its descendants have null rows at all. If there are no nulls anywhere in the hierarchy, it does not need purging. 2. `cudf::has_nonempty_nulls()`: A deeper, more expensive check that categorically confirms whether non-empty null rows exist in any column in the hierarchy. Authors: - MithunR (https://github.com/mythrocks) Approvers: - Jake Hemstad (https://github.com/jrhemstad) - https://github.com/nvdbaranec - Jordan Jacobelli (https://github.com/Ethyling) URL: https://github.com/rapidsai/cudf/pull/10701 --- conda/recipes/libcudf/meta.yaml | 1 + cpp/CMakeLists.txt | 1 + cpp/include/cudf/copying.hpp | 153 ++++++ cpp/include/cudf/detail/copy.cuh | 47 ++ cpp/include/cudf/detail/copy.hpp | 19 +- cpp/include/cudf/lists/detail/gather.cuh | 45 +- cpp/include/cudf/strings/detail/gather.cuh | 20 +- .../cudf/structs/structs_column_view.hpp | 7 +- cpp/src/copying/purge_nonempty_nulls.cu | 134 ++++++ cpp/src/structs/structs_column_view.cpp | 2 + cpp/tests/CMakeLists.txt | 1 + cpp/tests/column/factories_test.cpp | 2 +- .../copying/purge_nonempty_nulls_tests.cpp | 437 ++++++++++++++++++ 13 files changed, 847 insertions(+), 22 deletions(-) create mode 100644 cpp/include/cudf/detail/copy.cuh create mode 100644 cpp/src/copying/purge_nonempty_nulls.cu create mode 100644 cpp/tests/copying/purge_nonempty_nulls_tests.cpp diff --git a/conda/recipes/libcudf/meta.yaml b/conda/recipes/libcudf/meta.yaml index 0806bb964cf..68008e13897 100644 --- a/conda/recipes/libcudf/meta.yaml +++ b/conda/recipes/libcudf/meta.yaml @@ -79,6 +79,7 @@ outputs: - test -f $PREFIX/include/cudf/detail/calendrical_month_sequence.cuh - test -f $PREFIX/include/cudf/detail/concatenate.hpp - test -f $PREFIX/include/cudf/detail/copy.hpp + - test -f $PREFIX/include/cudf/detail/copy.cuh - test -f $PREFIX/include/cudf/detail/datetime.hpp - test -f $PREFIX/include/cudf/detail/fill.hpp - test -f $PREFIX/include/cudf/detail/gather.hpp diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 15caaec9bec..cbe2811afe4 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -238,6 +238,7 @@ add_library( src/copying/gather.cu src/copying/get_element.cu src/copying/pack.cpp + src/copying/purge_nonempty_nulls.cu src/copying/reverse.cu src/copying/sample.cu src/copying/scatter.cu diff --git a/cpp/include/cudf/copying.hpp b/cpp/include/cudf/copying.hpp index 2e559afef4f..8f1ad7da9b6 100644 --- a/cpp/include/cudf/copying.hpp +++ b/cpp/include/cudf/copying.hpp @@ -17,7 +17,10 @@ #pragma once #include +#include #include +#include +#include #include #include @@ -939,5 +942,155 @@ std::unique_ptr
sample( int64_t const seed = 0, rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); +/** + * @brief Checks if a column or its descendants have non-empty null rows + * + * @note This function is exact. If it returns `true`, there exists one or more + * non-empty null elements. + * + * A LIST or STRING column might have non-empty rows that are marked as null. + * A STRUCT OR LIST column might have child columns that have non-empty null rows. + * Other types of columns are deemed incapable of having non-empty null rows. + * E.g. Fixed width columns have no concept of an "empty" row. + * + * @param input The column which is (and whose descendants are) to be checked for + * non-empty null rows. + * @return true If either the column or its descendants have non-empty null rows. + * @return false If neither the column or its descendants have non-empty null rows. + */ +bool has_nonempty_nulls(column_view const& input); + +/** + * @brief Approximates if a column or its descendants *may* have non-empty null elements + * + * @note This function is approximate. + * - `true`: Non-empty null elements could exist + * - `false`: Non-empty null elements definitely do not exist + * + * False positives are possible, but false negatives are not. + * + * Compared to the exact `has_nonempty_nulls()` function, this function is typically + * more efficient. + * + * Complexity: + * - Best case: `O(count_descendants(input))` + * - Worst case: `O(count_descendants(input)) * m`, where `m` is the number of rows in the largest + * descendant + * + * @param input The column which is (and whose descendants are) to be checked for + * non-empty null rows + * @return true If either the column or its decendants have null rows + * @return false If neither the column nor its descendants have null rows + */ +bool may_have_nonempty_nulls(column_view const& input); + +/** + * @brief Copies `input`, purging any non-empty null rows in the column or its descendants + * + * LIST columns may have non-empty null rows. + * For example: + * @code{.pseudo} + * + * auto const lists = lists_column_wrapper{ {0,1}, {2,3}, {4,5} }.release(); + * cudf::detail::set_null_mask(lists->null_mask(), 1, 2, false); + * + * lists[1] is now null, but the lists child column still stores `{2,3}`. + * The lists column contents will be: + * Validity: 101 + * Offsets: [0, 2, 4, 6] + * Child: [0, 1, 2, 3, 4, 5] + * + * After purging the contents of the list's null rows, the column's contents + * will be: + * Validity: 101 + * Offsets: [0, 2, 2, 4] + * Child: [0, 1, 4, 5] + * @endcode + * + * The purge operation only applies directly to LIST and STRING columns, but it + * applies indirectly to STRUCT columns as well, since LIST and STRUCT columns + * may have child/decendant columns that are LIST or STRING. + * + * @param input The column whose null rows are to be checked and purged + * @param mr Device memory resource used to allocate the returned column's device memory + * @return std::unique_ptr Column with equivalent contents to `input`, but with + * the contents of null rows purged + */ +std::unique_ptr purge_nonempty_nulls( + lists_column_view const& input, + rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); + +/** + * @brief Copies `input`, purging any non-empty null rows in the column or its descendants + * + * STRING columns may have non-empty null rows. + * For example: + * @code{.pseudo} + * + * auto const strings = strings_column_wrapper{ "AB", "CD", "EF" }.release(); + * cudf::detail::set_null_mask(strings->null_mask(), 1, 2, false); + * + * strings[1] is now null, but the strings column still stores `"CD"`. + * The lists column contents will be: + * Validity: 101 + * Offsets: [0, 2, 4, 6] + * Child: [A, B, C, D, E, F] + * + * After purging the contents of the list's null rows, the column's contents + * will be: + * Validity: 101 + * Offsets: [0, 2, 2, 4] + * Child: [A, B, E, F] + * @endcode + * + * The purge operation only applies directly to LIST and STRING columns, but it + * applies indirectly to STRUCT columns as well, since LIST and STRUCT columns + * may have child/decendant columns that are LIST or STRING. + * + * @param input The column whose null rows are to be checked and purged + * @param mr Device memory resource used to allocate the returned column's device memory + * @return std::unique_ptr Column with equivalent contents to `input`, but with + * the contents of null rows purged + */ +std::unique_ptr purge_nonempty_nulls( + strings_column_view const& input, + rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); + +/** + * @brief Copies `input`, purging any non-empty null rows in the column or its descendants + * + * STRUCTS columns may have null rows, with non-empty child rows. + * For example: + * @code{.pseudo} + * + * auto const lists = lists_column_wrapper{ {0,1}, {2,3}, {4,5} }; + * auto const structs = structs_column_wrapper{ {lists}, null_at(1) }; + * + * structs[1].child is now null, but the lists column still stores `{2,3}`. + * The lists column contents will be: + * Validity: 101 + * Offsets: [0, 2, 4, 6] + * Child: [0, 1, 2, 3, 4, 5] + * + * After purging the contents of the list's null rows, the column's contents + * will be: + * Validity: 101 + * Offsets: [0, 2, 2, 4] + * Child: [0, 1, 4, 5] + * @endcode + * + * The purge operation only applies directly to LIST and STRING columns, but it + * applies indirectly to STRUCT columns as well, since LIST and STRUCT columns + * may have child/decendant columns that are LIST or STRING. + * + * @param input The column whose null rows are to be checked and purged + * @param mr Device memory resource used to allocate the returned column's device memory + * @return std::unique_ptr Column with equivalent contents to `input`, but with + * the contents of null rows purged + */ +std::unique_ptr purge_nonempty_nulls( + structs_column_view const& input, + rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); + /** @} */ } // namespace cudf diff --git a/cpp/include/cudf/detail/copy.cuh b/cpp/include/cudf/detail/copy.cuh new file mode 100644 index 00000000000..773bce7131f --- /dev/null +++ b/cpp/include/cudf/detail/copy.cuh @@ -0,0 +1,47 @@ +/* + * 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 +#include + +namespace cudf::detail { + +/** + * @copydoc cudf::purge_nonempty_nulls(structs_column_view const&, rmm::mr::device_memory_resource*) + * + * @tparam ColumnViewT View type (lists_column_view, strings_column_view, or strings_column_view) + * @param stream CUDA stream used for device memory operations and kernel launches + */ +template +std::unique_ptr purge_nonempty_nulls(ColumnViewT const& input, + rmm::cuda_stream_view stream, + rmm::mr::device_memory_resource* mr) +{ + // Implement via identity gather. + auto const input_column = input.parent(); + auto const gather_begin = thrust::counting_iterator(0); + auto const gather_end = gather_begin + input_column.size(); + + auto gathered_table = cudf::detail::gather(table_view{{input_column}}, + gather_begin, + gather_end, + out_of_bounds_policy::DONT_CHECK, + stream, + mr); + return std::move(gathered_table->release()[0]); +} + +} // namespace cudf::detail diff --git a/cpp/include/cudf/detail/copy.hpp b/cpp/include/cudf/detail/copy.hpp index 50157d16876..abd14fbda89 100644 --- a/cpp/include/cudf/detail/copy.hpp +++ b/cpp/include/cudf/detail/copy.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. @@ -299,5 +299,22 @@ std::unique_ptr get_element( size_type index, rmm::cuda_stream_view stream = rmm::cuda_stream_default, rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); + +/** + * @copydoc cudf::has_nonempty_nulls + * + * @param stream CUDA stream used for device memory operations and kernel launches. + */ +bool has_nonempty_nulls(column_view const& input, + rmm::cuda_stream_view stream = rmm::cuda_stream_default); + +/** + * @copydoc cudf::may_have_nonempty_nulls + * + * @param stream CUDA stream used for device memory operations and kernel launches. + */ +bool may_have_nonempty_nulls(column_view const& input, + rmm::cuda_stream_view stream = rmm::cuda_stream_default); + } // namespace detail } // namespace cudf diff --git a/cpp/include/cudf/lists/detail/gather.cuh b/cpp/include/cudf/lists/detail/gather.cuh index c637ad041ba..7df36be2385 100644 --- a/cpp/include/cudf/lists/detail/gather.cuh +++ b/cpp/include/cudf/lists/detail/gather.cuh @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -82,6 +83,7 @@ gather_data make_gather_data(cudf::lists_column_view const& source_column, auto dst_offsets_c = cudf::make_fixed_width_column( data_type{type_id::INT32}, offset_count, mask_state::UNALLOCATED, stream, mr); mutable_column_view dst_offsets_v = dst_offsets_c->mutable_view(); + auto const source_column_nullmask = source_column.null_mask(); // generate the compacted outgoing offsets. auto count_iter = thrust::make_counting_iterator(0); @@ -90,12 +92,23 @@ gather_data make_gather_data(cudf::lists_column_view const& source_column, count_iter, count_iter + offset_count, dst_offsets_v.begin(), - [gather_map, output_count, src_offsets, src_size] __device__(int32_t index) -> int32_t { + [source_column_nullmask, + source_column_offset = source_column.offset(), + gather_map, + output_count, + src_offsets, + src_size] __device__(int32_t index) -> int32_t { int32_t offset_index = index < output_count ? gather_map[index] : 0; // if this is an invalid index, this will be a NULL list if (NullifyOutOfBounds && ((offset_index < 0) || (offset_index >= src_size))) { return 0; } + // If the source row is null, the output row size must be 0. + if (source_column_nullmask != nullptr && + not cudf::bit_is_set(source_column_nullmask, source_column_offset + offset_index)) { + return 0; + } + // the length of this list return src_offsets[offset_index + 1] - src_offsets[offset_index]; }, @@ -110,15 +123,27 @@ gather_data make_gather_data(cudf::lists_column_view const& source_column, // generate the base offsets rmm::device_uvector base_offsets = rmm::device_uvector(output_count, stream); - thrust::transform(rmm::exec_policy(stream), - gather_map, - gather_map + output_count, - base_offsets.data(), - [src_offsets, src_size, shift] __device__(int32_t index) { - // if this is an invalid index, this will be a NULL list - if (NullifyOutOfBounds && ((index < 0) || (index >= src_size))) { return 0; } - return src_offsets[index] - shift; - }); + thrust::transform( + rmm::exec_policy(stream), + gather_map, + gather_map + output_count, + base_offsets.data(), + [source_column_nullmask, + source_column_offset = source_column.offset(), + src_offsets, + src_size, + shift] __device__(int32_t index) { + // if this is an invalid index, this will be a NULL list + if (NullifyOutOfBounds && ((index < 0) || (index >= src_size))) { return 0; } + + // If the source row is null, the output row size must be 0. + if (source_column_nullmask != nullptr && + not cudf::bit_is_set(source_column_nullmask, source_column_offset + index)) { + return 0; + } + + return src_offsets[index] - shift; + }); // Retrieve size of the resulting gather map for level N+1 (the last offset) size_type child_gather_map_size = diff --git a/cpp/include/cudf/strings/detail/gather.cuh b/cpp/include/cudf/strings/detail/gather.cuh index 1b10c70d6d6..d46ab3a91a1 100644 --- a/cpp/include/cudf/strings/detail/gather.cuh +++ b/cpp/include/cudf/strings/detail/gather.cuh @@ -303,14 +303,17 @@ std::unique_ptr gather( data_type{type_id::INT32}, output_count + 1, mask_state::UNALLOCATED, stream, mr); auto const d_out_offsets = out_offsets_column->mutable_view().template data(); auto const d_in_offsets = (strings_count > 0) ? strings.offsets_begin() : nullptr; - thrust::transform(rmm::exec_policy(stream), - begin, - end, - d_out_offsets, - [d_in_offsets, strings_count] __device__(size_type in_idx) { - if (NullifyOutOfBounds && (in_idx < 0 || in_idx >= strings_count)) return 0; - return d_in_offsets[in_idx + 1] - d_in_offsets[in_idx]; - }); + auto const d_strings = column_device_view::create(strings.parent(), stream); + thrust::transform( + rmm::exec_policy(stream), + begin, + end, + d_out_offsets, + [d_strings = *d_strings, d_in_offsets, strings_count] __device__(size_type in_idx) { + if (NullifyOutOfBounds && (in_idx < 0 || in_idx >= strings_count)) return 0; + if (not d_strings.is_valid(in_idx)) return 0; + return d_in_offsets[in_idx + 1] - d_in_offsets[in_idx]; + }); // check total size is not too large size_t const total_bytes = thrust::transform_reduce( @@ -329,7 +332,6 @@ std::unique_ptr gather( // build chars column cudf::device_span const d_out_offsets_span(d_out_offsets, output_count + 1); - auto const d_strings = column_device_view::create(strings.parent(), stream); auto out_chars_column = gather_chars(d_strings->begin(), begin, end, diff --git a/cpp/include/cudf/structs/structs_column_view.hpp b/cpp/include/cudf/structs/structs_column_view.hpp index 329c24cfe0a..ca866d8555e 100644 --- a/cpp/include/cudf/structs/structs_column_view.hpp +++ b/cpp/include/cudf/structs/structs_column_view.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * 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. @@ -41,6 +41,11 @@ class structs_column_view : public column_view { explicit structs_column_view(column_view const& rhs); + /** + * @brief Returns the parent column. + */ + [[nodiscard]] column_view parent() const; + using column_view::child_begin; using column_view::child_end; using column_view::has_nulls; diff --git a/cpp/src/copying/purge_nonempty_nulls.cu b/cpp/src/copying/purge_nonempty_nulls.cu new file mode 100644 index 00000000000..778d6c4df55 --- /dev/null +++ b/cpp/src/copying/purge_nonempty_nulls.cu @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2019-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 +#include + +#include + +namespace cudf { +namespace detail { + +using cudf::type_id; + +namespace { + +/// Check if nonempty-null checks can be skipped for a given type. +bool type_may_have_nonempty_nulls(cudf::type_id const& type) +{ + return type == type_id::STRING || type == type_id::LIST || type == type_id::STRUCT; +} + +/// Check if the (STRING/LIST) column has any null rows with non-zero length. +bool has_nonempty_null_rows(cudf::column_view const& input, rmm::cuda_stream_view stream) +{ + if (not input.has_nulls()) { return false; } // No nulls => no dirty rows. + + // Cross-reference nullmask and offsets. + auto const type = input.type().id(); + auto const offsets = (type == type_id::STRING) ? (strings_column_view{input}).offsets() + : (lists_column_view{input}).offsets(); + auto const d_input = cudf::column_device_view::create(input); + auto const is_dirty_row = [d_input = *d_input, offsets = offsets.begin()] __device__( + size_type const& row_idx) { + return d_input.is_null_nocheck(row_idx) && (offsets[row_idx] != offsets[row_idx + 1]); + }; + + auto const row_begin = thrust::counting_iterator(0); + auto const row_end = row_begin + input.size(); + return thrust::count_if(rmm::exec_policy(stream), row_begin, row_end, is_dirty_row) > 0; +} + +} // namespace + +/** + * @copydoc cudf::detail::has_nonempty_nulls + */ +bool has_nonempty_nulls(cudf::column_view const& input, rmm::cuda_stream_view stream) +{ + auto const type = input.type().id(); + + if (not type_may_have_nonempty_nulls(type)) { return false; } + + // For types with variable-length rows, check if any rows are "dirty". + // A dirty row is a null row with non-zero length. + if ((type == type_id::STRING || type == type_id::LIST) && has_nonempty_null_rows(input, stream)) { + return true; + } + + // For complex types, check if child columns need purging. + if ((type == type_id::STRUCT || type == type_id::LIST) && + std::any_of(input.child_begin(), input.child_end(), [stream](auto const& child) { + return cudf::detail::has_nonempty_nulls(child, stream); + })) { + return true; + } + + return false; +} +} // namespace detail + +/** + * @copydoc cudf::may_have_nonempty_nulls + */ +bool may_have_nonempty_nulls(column_view const& input) +{ + auto const type = input.type().id(); + + if (not detail::type_may_have_nonempty_nulls(type)) { return false; } + + if ((type == type_id::STRING || type == type_id::LIST) && input.has_nulls()) { return true; } + + if ((type == type_id::STRUCT || type == type_id::LIST) && + std::any_of(input.child_begin(), input.child_end(), may_have_nonempty_nulls)) { + return true; + } + + return false; +} + +/** + * @copydoc cudf::has_nonempty_nulls + */ +bool has_nonempty_nulls(column_view const& input) { return detail::has_nonempty_nulls(input); } + +/** + * @copydoc cudf::purge_nonempty_nulls(lists_column_view const&, rmm::mr::device_memory_resource*) + */ +std::unique_ptr purge_nonempty_nulls(lists_column_view const& input, + rmm::mr::device_memory_resource* mr) +{ + return detail::purge_nonempty_nulls(input, rmm::cuda_stream_default, mr); +} + +/** + * @copydoc cudf::purge_nonempty_nulls(structs_column_view const&, rmm::mr::device_memory_resource*) + */ +std::unique_ptr purge_nonempty_nulls(structs_column_view const& input, + rmm::mr::device_memory_resource* mr) +{ + return detail::purge_nonempty_nulls(input, rmm::cuda_stream_default, mr); +} + +/** + * @copydoc cudf::purge_nonempty_nulls(strings_column_view const&, rmm::mr::device_memory_resource*) + */ +std::unique_ptr purge_nonempty_nulls(strings_column_view const& input, + rmm::mr::device_memory_resource* mr) +{ + return detail::purge_nonempty_nulls(input, rmm::cuda_stream_default, mr); +} + +} // namespace cudf diff --git a/cpp/src/structs/structs_column_view.cpp b/cpp/src/structs/structs_column_view.cpp index 681f13386ff..7d8c8837d2d 100644 --- a/cpp/src/structs/structs_column_view.cpp +++ b/cpp/src/structs/structs_column_view.cpp @@ -25,6 +25,8 @@ structs_column_view::structs_column_view(column_view const& rhs) : column_view{r CUDF_EXPECTS(type().id() == type_id::STRUCT, "structs_column_view only supports struct columns"); } +column_view structs_column_view::parent() const { return *this; } + column_view structs_column_view::get_sliced_child(int index) const { std::vector children; diff --git a/cpp/tests/CMakeLists.txt b/cpp/tests/CMakeLists.txt index e016f47616b..95c54d7596e 100644 --- a/cpp/tests/CMakeLists.txt +++ b/cpp/tests/CMakeLists.txt @@ -250,6 +250,7 @@ ConfigureTest( copying/gather_tests.cpp copying/get_value_tests.cpp copying/pack_tests.cpp + copying/purge_nonempty_nulls_tests.cpp copying/sample_tests.cpp copying/scatter_tests.cpp copying/scatter_list_tests.cpp diff --git a/cpp/tests/column/factories_test.cpp b/cpp/tests/column/factories_test.cpp index 4e0e70bf15c..44a79e63cd8 100644 --- a/cpp/tests/column/factories_test.cpp +++ b/cpp/tests/column/factories_test.cpp @@ -645,7 +645,7 @@ TYPED_TEST(ListsStructsLeafTest, FromNonNested) 0, cudf::create_null_mask(2, cudf::mask_state::UNALLOCATED)); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*col, *expected); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*col, *expected); } TYPED_TEST(ListsStructsLeafTest, FromNested) diff --git a/cpp/tests/copying/purge_nonempty_nulls_tests.cpp b/cpp/tests/copying/purge_nonempty_nulls_tests.cpp new file mode 100644 index 00000000000..77fd3f66ee5 --- /dev/null +++ b/cpp/tests/copying/purge_nonempty_nulls_tests.cpp @@ -0,0 +1,437 @@ +/* + * 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 +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +namespace cudf::test { + +using iterators::no_nulls; +using iterators::null_at; +using iterators::nulls_at; +using T = int32_t; // The actual type of the leaf node isn't really important. +using values_col_t = fixed_width_column_wrapper; +using offsets_col_t = fixed_width_column_wrapper; +using gather_map_t = fixed_width_column_wrapper; + +template +using LCW = cudf::test::lists_column_wrapper; + +struct PurgeNonEmptyNullsTest : public cudf::test::BaseFixture { + /// Helper to run gather() on a single column, and extract the single column from the result. + std::unique_ptr gather(column_view const& input, gather_map_t const& gather_map) + { + auto gathered = + cudf::gather(cudf::table_view{{input}}, gather_map, out_of_bounds_policy::NULLIFY); + return std::move(gathered->release()[0]); + } + + /// Verify that the result of `sanitize()` is equivalent to the unsanitized input, + /// except that the null rows are also empty. + template + void test_purge(ColumnViewT const& unpurged) + { + auto const purged = cudf::purge_nonempty_nulls(unpurged); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(unpurged.parent(), *purged); + EXPECT_FALSE(cudf::has_nonempty_nulls(*purged)); + } +}; + +// List. +TEST_F(PurgeNonEmptyNullsTest, SingleLevelList) +{ + auto const input = LCW{{{{1, 2, 3, 4}, null_at(2)}, + {5}, + {6, 7}, // <--- Will be set to NULL. Unsanitized row. + {8, 9, 10}}, + no_nulls()} + .release(); + EXPECT_FALSE(cudf::may_have_nonempty_nulls(*input)); + EXPECT_FALSE(cudf::has_nonempty_nulls(*input)); + + // Set nullmask, post construction. + cudf::detail::set_null_mask(input->mutable_view().null_mask(), 2, 3, false); + EXPECT_TRUE(cudf::may_have_nonempty_nulls(*input)); + EXPECT_TRUE(cudf::has_nonempty_nulls(*input)); + + test_purge(lists_column_view{*input}); + + { + // Selecting all rows from input, in different order. + auto const results = gather(input->view(), {1, 2, 0, 3}); + auto const results_list_view = lists_column_view(*results); + + auto const expected = LCW{{{5}, + {}, // NULL. + {{1, 2, 3, 4}, null_at(2)}, + {8, 9, 10}}, + null_at(1)}; + + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(results_list_view.offsets(), offsets_col_t{0, 1, 1, 5, 8}); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(results_list_view.child(), + values_col_t{{5, 1, 2, 3, 4, 8, 9, 10}, null_at(3)}); + EXPECT_TRUE(cudf::may_have_nonempty_nulls(*results)); + EXPECT_FALSE(cudf::has_nonempty_nulls(*results)); + } + { + // Test when gather selects rows preceded by unsanitized rows. + auto const results = gather(input->view(), {3, 100, 0}); + auto const expected = LCW{{ + {8, 9, 10}, + {}, // NULL. + {{1, 2, 3, 4}, null_at(2)}, + }, + null_at(1)}; + CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), expected); + EXPECT_TRUE(cudf::may_have_nonempty_nulls(*results)); + EXPECT_FALSE(cudf::has_nonempty_nulls(*results)); + } + { + // Test when gather selects rows followed by unsanitized rows. + auto const results = gather(input->view(), {1, 100, 0}); + auto const expected = LCW{{ + {5}, + {}, // NULL. + {{1, 2, 3, 4}, null_at(2)}, + }, + null_at(1)}; + CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), expected); + EXPECT_TRUE(cudf::may_have_nonempty_nulls(*results)); + EXPECT_FALSE(cudf::has_nonempty_nulls(*results)); + } + { + // Test when gather selects unsanitized row specifically. + auto const results = gather(input->view(), {2}); + auto const results_lists_view = lists_column_view(*results); + auto const expected = LCW{{ + LCW{} // NULL. + }, + null_at(0)}; + CUDF_TEST_EXPECT_COLUMNS_EQUAL(results->view(), expected); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(results_lists_view.offsets(), offsets_col_t{0, 0}); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(results_lists_view.child(), values_col_t{}); + EXPECT_TRUE(cudf::may_have_nonempty_nulls(*results)); + EXPECT_FALSE(cudf::has_nonempty_nulls(*results)); + } +} + +// List>. +TEST_F(PurgeNonEmptyNullsTest, TwoLevelList) +{ + auto const input = + LCW{ + {{{1, 2, 3}, {4, 5, 6, 7}, {8}, {9, 1}, {2}}, + {{11, 12}, {13, 14, 15}, {16, 17, 18}, {19}}, + {{21}, {22, 23}, {24, 25, 26}}, + {{31, 32}, {33, 34, 35, 36}, {}, {37, 38}}, //<--- Will be set to NULL. Unsanitized row. + {{41}, {42, 43}}}, + no_nulls()} + .release(); + EXPECT_FALSE(cudf::may_have_nonempty_nulls(*input)); + EXPECT_FALSE(cudf::has_nonempty_nulls(*input)); + + // Set nullmask, post construction. + cudf::detail::set_null_mask(input->mutable_view().null_mask(), 3, 4, false); + EXPECT_TRUE(cudf::may_have_nonempty_nulls(*input)); + EXPECT_TRUE(cudf::has_nonempty_nulls(*input)); + + test_purge(lists_column_view{*input}); + + { + // Verify that gather() output is sanitized. + auto const results = gather(input->view(), {100, 3, 0, 1}); + auto const results_lists_view = lists_column_view(*results); + + auto const expected = LCW{{ + LCW{}, // NULL, because of out of bounds. + LCW{}, // NULL, because input row was null. + {{1, 2, 3}, {4, 5, 6, 7}, {8}, {9, 1}, {2}}, // i.e. input[0] + {{11, 12}, {13, 14, 15}, {16, 17, 18}, {19}} // i.e. input[1] + }, + nulls_at({0, 1})}; + + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(results_lists_view.offsets(), offsets_col_t{0, 0, 0, 5, 9}); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + results_lists_view.child(), + LCW{ + {1, 2, 3}, {4, 5, 6, 7}, {8}, {9, 1}, {2}, {11, 12}, {13, 14, 15}, {16, 17, 18}, {19}}); + + auto const child_lists_view = lists_column_view(results_lists_view.child()); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(child_lists_view.offsets(), + offsets_col_t{0, 3, 7, 8, 10, 11, 13, 16, 19, 20}); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + child_lists_view.child(), + values_col_t{1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 11, 12, 13, 14, 15, 16, 17, 18, 19}); + EXPECT_TRUE(cudf::may_have_nonempty_nulls(*results)); + EXPECT_FALSE(cudf::has_nonempty_nulls(*results)); + } +} + +// List>>. +TEST_F(PurgeNonEmptyNullsTest, ThreeLevelList) +{ + auto const input = LCW{{{{{1, 2}, {3}}, {{4, 5}, {6, 7}}, {{8, 8}, {}}, {{9, 1}}, {{2, 3}}}, + {{{11, 12}}, {{13}, {14, 15}}, {{16, 17, 18}}, {{19, 19}, {}}}, + {{{21, 21}}, {{22, 23}, {}}, {{24, 25}, {26}}}, + {{{31, 32}, {}}, + {{33, 34, 35}, {36}}, + {}, + {{37, 38}}}, //<--- Will be set to NULL. Unsanitized row. + {{{41, 41, 41}}, {{42, 43}}}}, + no_nulls()} + .release(); + EXPECT_FALSE(cudf::may_have_nonempty_nulls(*input)); + EXPECT_FALSE(cudf::has_nonempty_nulls(*input)); + + // Set nullmask, post construction. + cudf::detail::set_null_mask(input->mutable_view().null_mask(), 3, 4, false); + EXPECT_TRUE(cudf::may_have_nonempty_nulls(*input)); + EXPECT_TRUE(cudf::has_nonempty_nulls(*input)); + + test_purge(lists_column_view{*input}); + + { + auto const results = gather(input->view(), {100, 3, 0, 1}); + auto const results_lists_view = lists_column_view(*results); + + auto const expected = LCW{ + { + LCW{}, // NULL, because of out of bounds. + LCW{}, // NULL, because input row was null. + {{{1, 2}, {3}}, {{4, 5}, {6, 7}}, {{8, 8}, {}}, {{9, 1}}, {{2, 3}}}, // i.e. input[0] + {{{11, 12}}, {{13}, {14, 15}}, {{16, 17, 18}}, {{19, 19}, {}}} // i.e. input[1] + }, + nulls_at({0, 1})}; + + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(results_lists_view.offsets(), offsets_col_t{0, 0, 0, 5, 9}); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(results_lists_view.child(), + LCW{{{1, 2}, {3}}, + {{4, 5}, {6, 7}}, + {{8, 8}, {}}, + {{9, 1}}, + {{2, 3}}, + {{11, 12}}, + {{13}, {14, 15}}, + {{16, 17, 18}}, + {{19, 19}, {}}}); + EXPECT_TRUE(cudf::may_have_nonempty_nulls(*results)); + EXPECT_FALSE(cudf::has_nonempty_nulls(*results)); + } +} + +// List. +TEST_F(PurgeNonEmptyNullsTest, ListOfStrings) +{ + using T = string_view; + + auto const input = LCW{{{{"1", "22", "", "4444"}, null_at(2)}, + {"55555"}, + {"666666", "7777777"}, // <--- Will be set to NULL. Unsanitized row. + {"88888888", "999999999", "1010101010"}, + {"11", "22", "33", "44"}, + {"55", "66", "77", "88"}}, + no_nulls()} + .release(); + EXPECT_TRUE(cudf::may_have_nonempty_nulls(*input)); + EXPECT_FALSE(cudf::has_nonempty_nulls(*input)); + + // Set nullmask, post construction. + cudf::detail::set_null_mask(input->mutable_view().null_mask(), 2, 3, false); + EXPECT_TRUE(cudf::may_have_nonempty_nulls(*input)); + EXPECT_TRUE(cudf::has_nonempty_nulls(*input)); + + test_purge(lists_column_view{*input}); + + { + // Selecting all rows from input, in different order. + auto const results = gather(input->view(), {1, 2, 0, 3}); + auto const results_list_view = lists_column_view(*results); + + auto const expected = LCW{{{"55555"}, + {}, // NULL. + {{"1", "22", "", "4444"}, null_at(2)}, + {"88888888", "999999999", "1010101010"}}, + null_at(1)}; + + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(results_list_view.offsets(), offsets_col_t{0, 1, 1, 5, 8}); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + results_list_view.child(), + strings_column_wrapper{ + {"55555", "1", "22", "", "4444", "88888888", "999999999", "1010101010"}, null_at(3)}); + EXPECT_TRUE(cudf::may_have_nonempty_nulls(*results)); + EXPECT_FALSE(cudf::has_nonempty_nulls(*results)); + } + { + // Gathering from a sliced column. + auto const sliced = cudf::slice({input->view()}, {1, 5})[0]; // Lop off 1 row at each end. + EXPECT_TRUE(cudf::may_have_nonempty_nulls(sliced)); + EXPECT_TRUE(cudf::has_nonempty_nulls(sliced)); + + auto const results = gather(sliced, {1, 2, 0, 3}); + auto const results_list_view = lists_column_view(*results); + auto const expected = LCW{{ + {}, + {"88888888", "999999999", "1010101010"}, + {"55555"}, + {"11", "22", "33", "44"}, + }, + null_at(0)}; + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*results, expected); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(results_list_view.offsets(), offsets_col_t{0, 0, 3, 4, 8}); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + results_list_view.child(), + strings_column_wrapper{ + "88888888", "999999999", "1010101010", "55555", "11", "22", "33", "44"}); + EXPECT_TRUE(cudf::may_have_nonempty_nulls(*results)); + EXPECT_FALSE(cudf::has_nonempty_nulls(*results)); + } +} + +// List. +TEST_F(PurgeNonEmptyNullsTest, UnsanitizedListOfUnsanitizedStrings) +{ + auto strings = + strings_column_wrapper{ + {"1", "22", "3", "44", "5", "66", "7", "8888", "9", "1010"}, //<--- "8888" will be + // unsanitized. + no_nulls()} + .release(); + EXPECT_FALSE(cudf::may_have_nonempty_nulls(*strings)); + EXPECT_FALSE(cudf::has_nonempty_nulls(*strings)); + + // Set strings nullmask, post construction. + set_null_mask(strings->mutable_view().null_mask(), 7, 8, false); + EXPECT_TRUE(cudf::may_have_nonempty_nulls(*strings)); + EXPECT_TRUE(cudf::has_nonempty_nulls(*strings)); + + test_purge(strings_column_view{*strings}); + + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + strings_column_view(*strings).offsets(), offsets_col_t{0, 1, 3, 4, 6, 7, 9, 10, 14, 15, 19} + // 10-14 indicates that "8888" is unsanitized. + ); + + // Construct a list column from the strings column. + auto const lists = make_lists_column(4, + offsets_col_t{0, 4, 5, 7, 10}.release(), + std::move(strings), + 0, + detail::make_null_mask(no_nulls(), no_nulls() + 4)); + EXPECT_TRUE(cudf::may_have_nonempty_nulls(*lists)); + EXPECT_TRUE(cudf::has_nonempty_nulls(*lists)); + + // Set lists nullmask, post construction. + cudf::detail::set_null_mask(lists->mutable_view().null_mask(), 2, 3, false); + EXPECT_TRUE(cudf::may_have_nonempty_nulls(*lists)); + EXPECT_TRUE(cudf::has_nonempty_nulls(*lists)); + + test_purge(lists_column_view{*lists}); + + // At this point, + // 1. {"66", "7"} will be unsanitized. + // 2. {"8888", "9", "1010"} will be actually be {NULL, "9", "1010"}. + + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + lists_column_view(*lists).offsets(), + offsets_col_t{0, 4, 5, 7, 10}); // 5-7 indicates that list row#2 is unsanitized. + + auto const result = gather(lists->view(), {1, 2, 0, 3}); + auto const expected = LCW{{{"5"}, + {}, // NULL. + {"1", "22", "3", "44"}, + {{"", "9", "1010"}, null_at(0)}}, + null_at(1)}; + CUDF_TEST_EXPECT_COLUMNS_EQUAL(*result, expected); + + // Ensure row#2 has been sanitized. + auto const results_lists_view = lists_column_view(*result); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(results_lists_view.offsets(), offsets_col_t{0, 1, 1, 5, 8} + // 1-1 indicates that row#2 is sanitized. + ); + + // Ensure that "8888" has been sanitized, and stored as "". + auto const child_strings_view = strings_column_view(results_lists_view.child()); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(child_strings_view.offsets(), + offsets_col_t{0, 1, 2, 4, 5, 7, 7, 8, 12}); + EXPECT_TRUE(cudf::may_have_nonempty_nulls(*result)); + EXPECT_FALSE(cudf::has_nonempty_nulls(*result)); +} + +// Struct>. +TEST_F(PurgeNonEmptyNullsTest, StructOfList) +{ + auto const structs_input = + [] { + auto child = LCW{{{{1, 2, 3, 4}, null_at(2)}, + {5}, + {6, 7}, //<--- Unsanitized row. + {8, 9, 10}}, + no_nulls()}; + EXPECT_FALSE(cudf::has_nonempty_nulls(child)); + return structs_column_wrapper{{child}, null_at(2)}; + }() + .release(); + + EXPECT_TRUE(cudf::may_have_nonempty_nulls(*structs_input)); + EXPECT_TRUE(cudf::has_nonempty_nulls(*structs_input)); + + test_purge(structs_column_view{*structs_input}); + + // At this point, even though the structs column has a null at index 2, + // the child column has a non-empty list row at index 2: {6, 7}. + CUDF_TEST_EXPECT_COLUMNS_EQUAL(lists_column_view(structs_input->child(0)).child(), + values_col_t{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, null_at(2)}); + + { + // Test rearrange. + auto const gather_map = gather_map_t{1, 2, 0, 3}; + auto const result = gather(structs_input->view(), gather_map); + auto const expected_result = [] { + auto child = LCW{{{5}, + LCW{}, //<--- Now, sanitized. + {{1, 2, 3, 4}, null_at(2)}, + {8, 9, 10}}, + null_at(1)}; + return structs_column_wrapper{{child}, null_at(1)}; + }(); + + CUDF_TEST_EXPECT_COLUMNS_EQUAL(result->view(), expected_result); + auto const results_child = lists_column_view(result->child(0)); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(results_child.offsets(), offsets_col_t{0, 1, 1, 5, 8}); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(results_child.child(), + values_col_t{{5, 1, 2, 3, 4, 8, 9, 10}, null_at(3)}); + EXPECT_TRUE(cudf::may_have_nonempty_nulls(*result)); + EXPECT_FALSE(cudf::has_nonempty_nulls(*result)); + } +} + +} // namespace cudf::test From 3c208a618f7f3443d021c01ad27f560a7d71e7d7 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Fri, 29 Apr 2022 09:36:29 -0400 Subject: [PATCH 133/246] Enable pydocstyle rules involving quotes (#10748) This PR enables D30* errors for pydocstyle. It also sets up the `ignore-decorators` configuration so that future PRs involving D10* errors will treat docutils decorators appropriately. Contributes to #10711. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/cudf/pull/10748 --- .pre-commit-config.yaml | 15 ++++++ python/.flake8 | 24 +++++----- python/cudf/cudf/comm/gpuarrow.py | 4 +- python/cudf/cudf/core/column/string.py | 66 +++++++++++++------------- python/cudf/cudf/core/frame.py | 4 +- python/cudf/cudf/core/series.py | 4 +- 6 files changed, 66 insertions(+), 51 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5f690f5f827..cd7b8aea6d7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,3 +1,5 @@ +# Copyright (c) 2019-2022, NVIDIA CORPORATION. + repos: - repo: https://github.com/PyCQA/isort rev: 5.6.4 @@ -56,6 +58,19 @@ repos: hooks: - id: pydocstyle args: ["--config=python/.flake8"] + exclude: | + (?x)^( + ci| + cpp| + conda| + docs| + java| + notebooks| + python/dask_cudf| + python/cudf_kafka| + python/custreamz| + python/cudf/cudf/tests + ) - repo: https://github.com/pre-commit/mirrors-clang-format rev: v11.1.0 hooks: diff --git a/python/.flake8 b/python/.flake8 index c645c46a216..667875030cc 100644 --- a/python/.flake8 +++ b/python/.flake8 @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2021, NVIDIA CORPORATION. +# Copyright (c) 2020-2022, NVIDIA CORPORATION. [flake8] exclude = __init__.py @@ -9,14 +9,14 @@ ignore = E203 [pydocstyle] -match = ^(.*abc\.py|.*api/types\.py|.*single_column_frame\.py|.*indexed_frame\.py)$ -# Due to https://github.com/PyCQA/pydocstyle/issues/363, we must exclude rather than include using match-dir. -match-dir = ^(?!ci|cpp|python/dask_cudf|python/cudf_kafka|python/custreamz).*$ -# In addition to numpy style, we additionally ignore: -add-ignore = - # magic methods - D105, - # no docstring in __init__ - D107, - # newlines before docstrings - D204 +# Due to https://github.com/PyCQA/pydocstyle/issues/363, we must exclude rather +# than include using match-dir. Note that as discussed in +# https://stackoverflow.com/questions/65478393/how-to-filter-directories-using-the-match-dir-flag-for-pydocstyle, +# unlike the match option above this match-dir will have no effect when +# pydocstyle is invoked from pre-commit. Therefore this exclusion list must +# also be maintained in the pre-commit config file. +match-dir = ^(?!(ci|cpp|conda|docs|java|notebooks|dask_cudf|cudf_kafka|custreamz|tests)).*$ +# Allow missing docstrings for docutils +ignore-decorators = .*(docutils|doc_apply|copy_docstring).* +select = + D30 diff --git a/python/cudf/cudf/comm/gpuarrow.py b/python/cudf/cudf/comm/gpuarrow.py index 09b4cc5ffba..0c4d9d7f77e 100644 --- a/python/cudf/cudf/comm/gpuarrow.py +++ b/python/cudf/cudf/comm/gpuarrow.py @@ -119,12 +119,12 @@ def null(self): @property def data_raw(self): - "Accessor for the data buffer as a device array" + """Accessor for the data buffer as a device array""" return self._series._column.data_array_view @property def null_raw(self): - "Accessor for the null buffer as a device array" + """Accessor for the null buffer as a device array""" return self._series._column.mask_array_view def make_series(self): diff --git a/python/cudf/cudf/core/column/string.py b/python/cudf/cudf/core/column/string.py index 1d836d9b759..0db7e7d9a27 100644 --- a/python/cudf/cudf/core/column/string.py +++ b/python/cudf/cudf/core/column/string.py @@ -201,7 +201,7 @@ def __getitem__(self, key): return self.get(key) def len(self) -> SeriesOrIndex: - """ + r""" Computes the length of each element in the Series/Index. Returns @@ -213,7 +213,7 @@ def len(self) -> SeriesOrIndex: Examples -------- >>> import cudf - >>> s = cudf.Series(["dog", "", "\\n", None]) + >>> s = cudf.Series(["dog", "", "\n", None]) >>> s.str.len() 0 3 1 0 @@ -960,7 +960,7 @@ def replace( ) def replace_with_backrefs(self, pat: str, repl: str) -> SeriesOrIndex: - """ + r""" Use the ``repl`` back-ref template to create a new string with the extracted elements found using the ``pat`` expression. @@ -980,7 +980,7 @@ def replace_with_backrefs(self, pat: str, repl: str) -> SeriesOrIndex: -------- >>> import cudf >>> s = cudf.Series(["A543","Z756"]) - >>> s.str.replace_with_backrefs('(\\\\d)(\\\\d)', 'V\\\\2\\\\1') + >>> s.str.replace_with_backrefs('(\\d)(\\d)', 'V\\2\\1') 0 AV453 1 ZV576 dtype: object @@ -1195,7 +1195,7 @@ def istimestamp(self, format: str) -> SeriesOrIndex: ) def isfloat(self) -> SeriesOrIndex: - """ + r""" Check whether all characters in each string form floating value. If a string has zero characters, False is returned for @@ -1249,7 +1249,7 @@ def isfloat(self) -> SeriesOrIndex: 4 True 5 False dtype: bool - >>> s = cudf.Series(["this is plain text", "\\t\\n", "9.9", "9.9.9"]) + >>> s = cudf.Series(["this is plain text", "\t\n", "9.9", "9.9.9"]) >>> s.str.isfloat() 0 False 1 False @@ -2239,7 +2239,7 @@ def get(self, i: int = 0) -> SeriesOrIndex: return self._return_or_inplace(libstrings.get(self._column, i)) def get_json_object(self, json_path): - """ + r""" Applies a JSONPath string to an input strings column where each row in the column is a valid json string @@ -2258,7 +2258,7 @@ def get_json_object(self, json_path): >>> import cudf >>> s = cudf.Series( [ - \\"\\"\\" + \"\"\" { "store":{ "book":[ @@ -2277,13 +2277,13 @@ def get_json_object(self, json_path): ] } } - \\"\\"\\" + \"\"\" ]) >>> s - 0 {"store": {\\n "book": [\\n { "cat... + 0 {"store": {\n "book": [\n { "cat... dtype: object >>> s.str.get_json_object("$.store.book") - 0 [\\n { "category": "reference",\\n ... + 0 [\n { "category": "reference",\n ... dtype: object """ @@ -3138,7 +3138,7 @@ def rjust(self, width: int, fillchar: str = " ") -> SeriesOrIndex: ) def strip(self, to_strip: str = None) -> SeriesOrIndex: - """ + r""" Remove leading and trailing characters. Strip whitespaces (including newlines) or a set of @@ -3169,11 +3169,11 @@ def strip(self, to_strip: str = None) -> SeriesOrIndex: Examples -------- >>> import cudf - >>> s = cudf.Series(['1. Ant. ', '2. Bee!\\n', '3. Cat?\\t', None]) + >>> s = cudf.Series(['1. Ant. ', '2. Bee!\n', '3. Cat?\t', None]) >>> s 0 1. Ant. - 1 2. Bee!\\n - 2 3. Cat?\\t + 1 2. Bee!\n + 2 3. Cat?\t 3 dtype: object >>> s.str.strip() @@ -3182,7 +3182,7 @@ def strip(self, to_strip: str = None) -> SeriesOrIndex: 2 3. Cat? 3 dtype: object - >>> s.str.strip('123.!? \\n\\t') + >>> s.str.strip('123.!? \n\t') 0 Ant 1 Bee 2 Cat @@ -3197,7 +3197,7 @@ def strip(self, to_strip: str = None) -> SeriesOrIndex: ) def lstrip(self, to_strip: str = None) -> SeriesOrIndex: - """ + r""" Remove leading and trailing characters. Strip whitespaces (including newlines) @@ -3228,11 +3228,11 @@ def lstrip(self, to_strip: str = None) -> SeriesOrIndex: Examples -------- >>> import cudf - >>> s = cudf.Series(['1. Ant. ', '2. Bee!\\n', '3. Cat?\\t', None]) + >>> s = cudf.Series(['1. Ant. ', '2. Bee!\n', '3. Cat?\t', None]) >>> s.str.lstrip('123.') 0 Ant. - 1 Bee!\\n - 2 Cat?\\t + 1 Bee!\n + 2 Cat?\t 3 dtype: object """ @@ -3244,7 +3244,7 @@ def lstrip(self, to_strip: str = None) -> SeriesOrIndex: ) def rstrip(self, to_strip: str = None) -> SeriesOrIndex: - """ + r""" Remove leading and trailing characters. Strip whitespaces (including newlines) @@ -3277,14 +3277,14 @@ def rstrip(self, to_strip: str = None) -> SeriesOrIndex: Examples -------- >>> import cudf - >>> s = cudf.Series(['1. Ant. ', '2. Bee!\\n', '3. Cat?\\t', None]) + >>> s = cudf.Series(['1. Ant. ', '2. Bee!\n', '3. Cat?\t', None]) >>> s 0 1. Ant. - 1 2. Bee!\\n - 2 3. Cat?\\t + 1 2. Bee!\n + 2 3. Cat?\t 3 dtype: object - >>> s.str.rstrip('.!? \\n\\t') + >>> s.str.rstrip('.!? \n\t') 0 1. Ant 1 2. Bee 2 3. Cat @@ -3299,7 +3299,7 @@ def rstrip(self, to_strip: str = None) -> SeriesOrIndex: ) def wrap(self, width: int, **kwargs) -> SeriesOrIndex: - """ + r""" Wrap long strings in the Series/Index to be formatted in paragraphs with length less than a given width. @@ -3340,8 +3340,8 @@ def wrap(self, width: int, **kwargs) -> SeriesOrIndex: >>> data = ['line to be wrapped', 'another line to be wrapped'] >>> s = cudf.Series(data) >>> s.str.wrap(12) - 0 line to be\\nwrapped - 1 another line\\nto be\\nwrapped + 0 line to be\nwrapped + 1 another line\nto be\nwrapped dtype: object """ if not is_integer(width): @@ -3575,7 +3575,7 @@ def isempty(self) -> SeriesOrIndex: return self._return_or_inplace((self._column == "").fillna(False)) def isspace(self) -> SeriesOrIndex: - """ + r""" Check whether all characters in each string are whitespace. This is equivalent to running the Python string method @@ -3623,7 +3623,7 @@ def isspace(self) -> SeriesOrIndex: Examples -------- >>> import cudf - >>> s = cudf.Series([' ', '\\t\\r\\n ', '']) + >>> s = cudf.Series([' ', '\t\r\n ', '']) >>> s.str.isspace() 0 True 1 True @@ -4271,7 +4271,7 @@ def normalize_spaces(self) -> SeriesOrIndex: ) def normalize_characters(self, do_lower: bool = True) -> SeriesOrIndex: - """ + r""" Normalizes strings characters for tokenizing. This uses the normalizer that is built into the @@ -4280,7 +4280,7 @@ def normalize_characters(self, do_lower: bool = True) -> SeriesOrIndex: - adding padding around punctuation (unicode category starts with "P") as well as certain ASCII symbols like "^" and "$" - adding padding around the CJK Unicode block characters - - changing whitespace (e.g. ``\\t``, ``\\n``, ``\\r``) to space + - changing whitespace (e.g. ``\t``, ``\n``, ``\r``) to space - removing control characters (unicode categories "Cc" and "Cf") If `do_lower_case = true`, lower-casing also removes the accents. @@ -4303,7 +4303,7 @@ def normalize_characters(self, do_lower: bool = True) -> SeriesOrIndex: Examples -------- >>> import cudf - >>> ser = cudf.Series(["héllo, \\tworld","ĂĆCĖÑTED","$99"]) + >>> ser = cudf.Series(["héllo, \tworld","ĂĆCĖÑTED","$99"]) >>> ser.str.normalize_characters() 0 hello , world 1 accented diff --git a/python/cudf/cudf/core/frame.py b/python/cudf/cudf/core/frame.py index 104ed3eeb67..d0e9e6d94c1 100644 --- a/python/cudf/cudf/core/frame.py +++ b/python/cudf/cudf/core/frame.py @@ -3356,7 +3356,7 @@ def to_dlpack(self): @_cudf_nvtx_annotate def to_string(self): - """ + r""" Convert to string cuDF uses Pandas internals for efficient string formatting. @@ -3373,7 +3373,7 @@ def to_string(self): >>> df['key'] = [0, 1, 2] >>> df['val'] = [float(i + 10) for i in range(3)] >>> df.to_string() - ' key val\\n0 0 10.0\\n1 1 11.0\\n2 2 12.0' + ' key val\n0 0 10.0\n1 1 11.0\n2 2 12.0' """ return repr(self) diff --git a/python/cudf/cudf/core/series.py b/python/cudf/cudf/core/series.py index 4ff671509a0..d813db58d1e 100644 --- a/python/cudf/cudf/core/series.py +++ b/python/cudf/cudf/core/series.py @@ -4614,13 +4614,13 @@ def _align_indices(series_list, how="outer", allow_non_unique=False): @_cudf_nvtx_annotate def isclose(a, b, rtol=1e-05, atol=1e-08, equal_nan=False): - """Returns a boolean array where two arrays are equal within a tolerance. + r"""Returns a boolean array where two arrays are equal within a tolerance. Two values in ``a`` and ``b`` are considered equal when the following equation is satisfied. .. math:: - |a - b| \\le \\mathrm{atol} + \\mathrm{rtol} |b| + |a - b| \le \mathrm{atol} + \mathrm{rtol} |b| Parameters ---------- From 15e49824a8cb2a5a7ec6a6e5f273589a66f1c120 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Fri, 29 Apr 2022 10:22:10 -0500 Subject: [PATCH 134/246] Enable pydocstyle for all packages. (#10759) Follow-up to #10748 to enable the base pydocstyle rules on all Python packages (`dask_cudf`, `cudf_kafka`, `custreamz`) and test files. Contributes to #10711, #10758. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - GALI PREM SAGAR (https://github.com/galipremsagar) URL: https://github.com/rapidsai/cudf/pull/10759 --- .pre-commit-config.yaml | 6 +----- python/.flake8 | 2 +- python/custreamz/custreamz/kafka.py | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cd7b8aea6d7..46d5223f7d3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -65,11 +65,7 @@ repos: conda| docs| java| - notebooks| - python/dask_cudf| - python/cudf_kafka| - python/custreamz| - python/cudf/cudf/tests + notebooks ) - repo: https://github.com/pre-commit/mirrors-clang-format rev: v11.1.0 diff --git a/python/.flake8 b/python/.flake8 index 667875030cc..b763c209fc1 100644 --- a/python/.flake8 +++ b/python/.flake8 @@ -15,7 +15,7 @@ ignore = # unlike the match option above this match-dir will have no effect when # pydocstyle is invoked from pre-commit. Therefore this exclusion list must # also be maintained in the pre-commit config file. -match-dir = ^(?!(ci|cpp|conda|docs|java|notebooks|dask_cudf|cudf_kafka|custreamz|tests)).*$ +match-dir = ^(?!(ci|cpp|conda|docs|java|notebooks)).*$ # Allow missing docstrings for docutils ignore-decorators = .*(docutils|doc_apply|copy_docstring).* select = diff --git a/python/custreamz/custreamz/kafka.py b/python/custreamz/custreamz/kafka.py index f5d5031602f..0198757c68d 100644 --- a/python/custreamz/custreamz/kafka.py +++ b/python/custreamz/custreamz/kafka.py @@ -95,7 +95,7 @@ def read_gdf( message_format="json", ): - """ + r""" Read messages from the underlying KafkaDatasource connection and create a cudf Dataframe From 3c4e72e68d9406d65939b7d2fdf28b0b921840dd Mon Sep 17 00:00:00 2001 From: Devavret Makkar Date: Fri, 29 Apr 2022 21:24:12 +0530 Subject: [PATCH 135/246] Add row hasher with nested column support (#10641) Contributes to #10186 Authors: - Devavret Makkar (https://github.com/devavret) - Vyas Ramasubramani (https://github.com/vyasr) - Bradley Dice (https://github.com/bdice) Approvers: - Yunsong Wang (https://github.com/PointKernel) - Bradley Dice (https://github.com/bdice) - Nghia Truong (https://github.com/ttnghia) URL: https://github.com/rapidsai/cudf/pull/10641 --- cpp/benchmarks/stream_compaction/distinct.cpp | 41 +++ cpp/include/cudf/detail/hashing.hpp | 5 +- cpp/include/cudf/detail/iterator.cuh | 8 +- .../cudf/detail/utilities/algorithm.cuh | 28 ++ cpp/include/cudf/detail/utilities/column.hpp | 10 +- .../cudf/table/experimental/row_operators.cuh | 273 +++++++++++++++--- cpp/src/hash/hashing.cu | 29 +- cpp/src/hash/murmur_hash.cu | 28 +- cpp/src/stream_compaction/distinct.cu | 18 +- .../stream_compaction_common.cuh | 22 ++ cpp/src/table/row_operators.cu | 60 ++-- cpp/tests/hashing/hash_test.cpp | 224 +++++++++++++- cpp/tests/reductions/list_rank_test.cpp | 4 +- .../stream_compaction/distinct_tests.cpp | 242 ++++++++++++++++ python/cudf/cudf/tests/test_dataframe.py | 2 +- 15 files changed, 880 insertions(+), 114 deletions(-) create mode 100644 cpp/include/cudf/detail/utilities/algorithm.cuh diff --git a/cpp/benchmarks/stream_compaction/distinct.cpp b/cpp/benchmarks/stream_compaction/distinct.cpp index 749badc715d..149c6ad7219 100644 --- a/cpp/benchmarks/stream_compaction/distinct.cpp +++ b/cpp/benchmarks/stream_compaction/distinct.cpp @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -55,3 +56,43 @@ NVBENCH_BENCH_TYPES(nvbench_distinct, NVBENCH_TYPE_AXES(data_type)) .set_name("distinct") .set_type_axes_names({"Type"}) .add_int64_axis("NumRows", {10'000, 100'000, 1'000'000, 10'000'000}); + +template +void nvbench_distinct_list(nvbench::state& state, nvbench::type_list) +{ + cudf::rmm_pool_raii pool_raii; + + auto const size = state.get_int64("ColumnSize"); + auto const dtype = cudf::type_to_id(); + double const null_frequency = state.get_float64("null_frequency"); + + data_profile table_data_profile; + if (dtype == cudf::type_id::LIST) { + table_data_profile.set_distribution_params(dtype, distribution_id::UNIFORM, 0, 4); + table_data_profile.set_distribution_params( + cudf::type_id::INT32, distribution_id::UNIFORM, 0, 4); + table_data_profile.set_list_depth(1); + } else { + // We're comparing distinct() on a non-nested column to that on a list column with the same + // number of distinct rows. The max list size is 4 and the number of distinct values in the + // list's child is 5. So the number of distinct rows in the list = 1 + 5 + 5^2 + 5^3 + 5^4 = 781 + // We want this column to also have 781 distinct values. + table_data_profile.set_distribution_params(dtype, distribution_id::UNIFORM, 0, 781); + } + table_data_profile.set_null_frequency(null_frequency); + + auto const table = create_random_table( + {dtype}, table_size_bytes{static_cast(size)}, table_data_profile, 0); + + state.exec(nvbench::exec_tag::sync, [&](nvbench::launch& launch) { + rmm::cuda_stream_view stream_view{launch.get_stream()}; + auto result = cudf::detail::distinct(*table, {0}, cudf::null_equality::EQUAL, stream_view); + }); +} + +NVBENCH_BENCH_TYPES(nvbench_distinct_list, + NVBENCH_TYPE_AXES(nvbench::type_list)) + .set_name("distinct_list") + .set_type_axes_names({"Type"}) + .add_float64_axis("null_frequency", {0.0, 0.1}) + .add_int64_axis("ColumnSize", {100'000'000}); diff --git a/cpp/include/cudf/detail/hashing.hpp b/cpp/include/cudf/detail/hashing.hpp index e8e100aaec5..9958fa8f3a4 100644 --- a/cpp/include/cudf/detail/hashing.hpp +++ b/cpp/include/cudf/detail/hashing.hpp @@ -33,19 +33,20 @@ namespace detail { std::unique_ptr hash( table_view const& input, hash_id hash_function = hash_id::HASH_MURMUR3, - uint32_t seed = 0, + uint32_t seed = cudf::DEFAULT_HASH_SEED, rmm::cuda_stream_view stream = rmm::cuda_stream_default, rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); std::unique_ptr murmur_hash3_32( table_view const& input, + uint32_t seed = cudf::DEFAULT_HASH_SEED, rmm::cuda_stream_view stream = rmm::cuda_stream_default, rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); template