Skip to content

Commit

Permalink
Merge pull request #9786 from rapidsai/branch-21.12
Browse files Browse the repository at this point in the history
[gpuCI] Forward-merge branch-21.12 to branch-22.02 [skip gpuci]
  • Loading branch information
GPUtester authored Nov 29, 2021
2 parents 0f7c532 + a1ca8c1 commit 83adc4b
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 26 deletions.
3 changes: 2 additions & 1 deletion conda/environments/cudf_dev_cuda11.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies:
- cmake>=3.20.1
- cmake_setuptools>=0.1.3
- python>=3.7,<3.9
- numba>=0.53.1
- numba>=0.54
- numpy
- pandas>=1.0,<1.4.0dev0
- pyarrow=5.0.0=*cuda
Expand Down Expand Up @@ -66,3 +66,4 @@ dependencies:
- git+https://github.com/dask/distributed.git@main
- git+https://github.com/python-streamz/streamz.git@master
- pyorc
- ptxcompiler # [linux64]
3 changes: 2 additions & 1 deletion conda/environments/cudf_dev_cuda11.2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies:
- cmake>=3.20.1
- cmake_setuptools>=0.1.3
- python>=3.7,<3.9
- numba>=0.53.1
- numba>=0.54
- numpy
- pandas>=1.0,<1.4.0dev0
- pyarrow=5.0.0=*cuda
Expand Down Expand Up @@ -66,3 +66,4 @@ dependencies:
- git+https://github.com/dask/distributed.git@main
- git+https://github.com/python-streamz/streamz.git@master
- pyorc
- ptxcompiler # [linux64]
3 changes: 2 additions & 1 deletion conda/environments/cudf_dev_cuda11.5.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies:
- cmake>=3.20.1
- cmake_setuptools>=0.1.3
- python>=3.7,<3.9
- numba>=0.53.1
- numba>=0.54
- numpy
- pandas>=1.0,<1.4.0dev0
- pyarrow=5.0.0=*cuda
Expand Down Expand Up @@ -66,3 +66,4 @@ dependencies:
- git+https://github.com/dask/distributed.git@main
- git+https://github.com/python-streamz/streamz.git@master
- pyorc
- ptxcompiler # [linux64]
5 changes: 3 additions & 2 deletions conda/recipes/cudf/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ requirements:
- python
- cython >=0.29,<0.30
- setuptools
- numba >=0.53.1
- numba >=0.54
- dlpack>=0.5,<0.6.0a0
- pyarrow 5.0.0 *cuda
- libcudf {{ version }}
Expand All @@ -41,7 +41,7 @@ requirements:
- typing_extensions
- pandas >=1.0,<1.4.0dev0
- cupy >=9.5.0,<10.0.0a0
- numba >=0.53.1
- numba >=0.54
- numpy
- {{ pin_compatible('pyarrow', max_pin='x.x.x') }} *cuda
- fastavro >=0.22.0
Expand All @@ -51,6 +51,7 @@ requirements:
- nvtx >=0.2.1
- packaging
- cachetools
- ptxcompiler # [linux64] # CUDA enhanced compatibility. See https://github.com/rapidsai/ptxcompiler

test: # [linux64]
requires: # [linux64]
Expand Down
11 changes: 11 additions & 0 deletions python/cudf/cudf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,17 @@
from cudf.utils.dtypes import _NA_REP
from cudf.utils.utils import set_allocator

try:
from ptxcompiler.patch import patch_numba_codegen_if_needed
except ImportError:
pass
else:
# Patch Numba to support CUDA enhanced compatibility.
# See https://github.com/rapidsai/ptxcompiler for
# details.
patch_numba_codegen_if_needed()
del patch_numba_codegen_if_needed

cuda.set_memory_manager(rmm.RMMNumbaManager)
cupy.cuda.set_allocator(rmm.rmm_cupy_allocator)

Expand Down
57 changes: 36 additions & 21 deletions python/cudf/cudf/tests/test_extension_compilation.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import operator

import cupy as cp
import pytest
from numba import cuda, types
from numba.cuda import compile_ptx
Expand Down Expand Up @@ -71,8 +72,8 @@ def test_execute_masked_binary(op, ty):
def func(x, y):
return op(x, y)

@cuda.jit(debug=True)
def test_kernel(x, y):
@cuda.jit
def test_kernel(x, y, err):
# Reference result with unmasked value
u = func(x, y)

Expand All @@ -87,14 +88,22 @@ def test_kernel(x, y):
# Check masks are as expected, and unmasked result matches masked
# result
if r0.valid:
raise RuntimeError("Expected r0 to be invalid")
# TODO: ideally, we would raise an exception here rather
# than return an "error code", and that is what the
# previous version of this (and below) tests did. But,
# Numba kernels cannot currently use `debug=True` with
# CUDA enhanced compatibility. Once a solution to that is
# reached, we should switch back to raising exceptions
# here.
err[0] = 1
if not r1.valid:
raise RuntimeError("Expected r1 to be valid")
err[0] = 2
if u != r1.value:
print("Values: ", u, r1.value)
raise RuntimeError("u != r1.value")
err[0] = 3

test_kernel[1, 1](1, 2)
err = cp.asarray([0], dtype="int8")
test_kernel[1, 1](1, 2, err)
assert err[0] == 0


@pytest.mark.parametrize("op", ops)
Expand Down Expand Up @@ -187,18 +196,20 @@ def test_is_na(fn):

device_fn = cuda.jit(device=True)(fn)

@cuda.jit(debug=True)
def test_kernel():
@cuda.jit
def test_kernel(err):
valid_is_na = device_fn(valid)
invalid_is_na = device_fn(invalid)

if valid_is_na:
raise RuntimeError("Valid masked value is NA and should not be")
err[0] = 1

if not invalid_is_na:
raise RuntimeError("Invalid masked value is not NA and should be")
err[0] = 2

test_kernel[1, 1]()
err = cp.asarray([0], dtype="int8")
test_kernel[1, 1](err)
assert err[0] == 0


def func_lt_na(x):
Expand Down Expand Up @@ -271,8 +282,8 @@ def test_na_masked_comparisons(fn, ty):

device_fn = cuda.jit(device=True)(fn)

@cuda.jit(debug=True)
def test_kernel():
@cuda.jit
def test_kernel(err):
unmasked = ty(1)
valid_masked = Masked(unmasked, True)
invalid_masked = Masked(unmasked, False)
Expand All @@ -281,12 +292,14 @@ def test_kernel():
invalid_cmp_na = device_fn(invalid_masked)

if valid_cmp_na:
raise RuntimeError("Valid masked value compared True with NA")
err[0] = 1

if invalid_cmp_na:
raise RuntimeError("Invalid masked value compared True with NA")
err[0] = 2

test_kernel[1, 1]()
err = cp.asarray([0], dtype="int8")
test_kernel[1, 1](err)
assert err[0] == 0


# xfail because scalars do not yet cast for a comparison to NA
Expand All @@ -297,13 +310,15 @@ def test_na_scalar_comparisons(fn, ty):

device_fn = cuda.jit(device=True)(fn)

@cuda.jit(debug=True)
def test_kernel():
@cuda.jit
def test_kernel(err):
unmasked = ty(1)

unmasked_cmp_na = device_fn(unmasked)

if unmasked_cmp_na:
raise RuntimeError("Unmasked value compared True with NA")
err[0] = 1

test_kernel[1, 1]()
err = cp.asarray([0], dtype="int8")
test_kernel[1, 1](err)
assert err[0] == 0

0 comments on commit 83adc4b

Please sign in to comment.