Skip to content

Commit

Permalink
refactor mvc tests
Browse files Browse the repository at this point in the history
  • Loading branch information
brandon-b-miller committed Nov 17, 2023
1 parent 5e8b604 commit 35b7e59
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 49 deletions.
87 changes: 87 additions & 0 deletions python/cudf/cudf/tests/test_mvc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Copyright (c) 2023, NVIDIA CORPORATION.
import subprocess
import sys

import pytest

IS_CUDA_11 = False
IS_CUDA_12 = False
try:
from ptxcompiler.patch import safe_get_versions
except ModuleNotFoundError:
from cudf.utils._ptxcompiler import safe_get_versions

versions = safe_get_versions()
driver_version, runtime_version = versions

if (11, 0) <= driver_version < (12, 0):
IS_CUDA_11 = True
if (12, 0) <= driver_version < (13, 0):
IS_CUDA_12 = True


TEST_BODY = """
@numba.cuda.jit
def test_kernel(x):
id = numba.cuda.grid(1)
if id < len(x):
x[id] += 1
s = cudf.Series([1, 2, 3])
with _CUDFNumbaConfig():
test_kernel.forall(len(s))(s)
"""

CUDA_11_TEST = (
"""
import numba.cuda
import cudf
from cudf.utils._numba import _CUDFNumbaConfig, patch_numba_linker_cuda_11
patch_numba_linker_cuda_11()
"""
+ TEST_BODY
)


CUDA_12_TEST = (
"""
import numba.cuda
import cudf
from cudf.utils._numba import _CUDFNumbaConfig
from pynvjitlink.patch import patch_numba_linker_cuda_12
patch_numba_linker_cuda_12()
"""
+ TEST_BODY
)


@pytest.mark.parametrize(
"test",
[
pytest.param(
CUDA_11_TEST,
marks=pytest.mark.skipif(
not IS_CUDA_11,
reason="Minor Version Compatibility test for CUDA 11",
),
),
pytest.param(
CUDA_12_TEST,
marks=pytest.mark.skipif(
not IS_CUDA_12,
reason="Minor Version Compatibility test for CUDA 12",
),
),
],
)
def test_numba_mvc(test):
cp = subprocess.run(
[sys.executable, "-c", test],
capture_output=True,
cwd="/",
)

assert cp.returncode == 0
49 changes: 0 additions & 49 deletions python/cudf/cudf/tests/test_numba_import.py

This file was deleted.

0 comments on commit 35b7e59

Please sign in to comment.