Skip to content

Commit 31f2465

Browse files
committed
Fixed the tests.
1 parent e9e87d3 commit 31f2465

File tree

5 files changed

+18
-17
lines changed

5 files changed

+18
-17
lines changed

kernel_tuner/backends/nvcuda.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
try:
1414
from cuda.bindings import driver, runtime, nvrtc
1515
except ImportError:
16-
cuda = None
16+
driver = None
1717

1818

1919
class CudaFunctions(GPUBackend):
@@ -39,7 +39,7 @@ def __init__(self, device=0, iterations=7, compiler_options=None, observers=None
3939
"""
4040
self.allocations = []
4141
self.texrefs = []
42-
if not cuda:
42+
if not driver:
4343
raise ImportError(
4444
"cuda-python not installed, install using 'pip install cuda-python', or check https://kerneltuner.github.io/kernel_tuner/stable/install.html#cuda-and-pycuda."
4545
)

kernel_tuner/observers/nvcuda.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import numpy as np
22

33
try:
4-
from cuda.bindings import cudart
4+
from cuda.bindings import runtime
55
except ImportError:
66
cuda = None
77

@@ -21,7 +21,7 @@ def __init__(self, dev):
2121

2222
def after_finish(self):
2323
# Time is measured in milliseconds
24-
err, time = cudart.cudaEventElapsedTime(self.start, self.end)
24+
err, time = runtime.cudaEventElapsedTime(self.start, self.end)
2525
cuda_error_check(err)
2626
self.times.append(time)
2727

test/test_cuda_functions.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from .test_runners import env # noqa: F401
1010

1111
try:
12-
from cuda import cuda
12+
from cuda.bindings import driver
1313
except Exception:
1414
pass
1515

@@ -27,9 +27,9 @@ def test_ready_argument_list():
2727
dev = nvcuda.CudaFunctions(0)
2828
gpu_args = dev.ready_argument_list(arguments)
2929

30-
assert isinstance(gpu_args[0], cuda.CUdeviceptr)
30+
assert isinstance(gpu_args[0], driver.CUdeviceptr)
3131
assert isinstance(gpu_args[1], np.int32)
32-
assert isinstance(gpu_args[2], cuda.CUdeviceptr)
32+
assert isinstance(gpu_args[2], driver.CUdeviceptr)
3333

3434

3535
@skip_if_no_cuda

test/test_util_functions.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -162,16 +162,6 @@ def test_get_thread_block_dimensions():
162162
assert threads[2] == 1
163163

164164

165-
def test_to_valid_nvrtc_gpu_arch_cc():
166-
assert to_valid_nvrtc_gpu_arch_cc("89") == "89"
167-
assert to_valid_nvrtc_gpu_arch_cc("88") == "87"
168-
assert to_valid_nvrtc_gpu_arch_cc("86") == "80"
169-
assert to_valid_nvrtc_gpu_arch_cc("40") == "52"
170-
assert to_valid_nvrtc_gpu_arch_cc("90b") == "90a"
171-
assert to_valid_nvrtc_gpu_arch_cc("91c") == "90a"
172-
assert to_valid_nvrtc_gpu_arch_cc("1234") == "52"
173-
174-
175165
def test_prepare_kernel_string():
176166
kernel = "this is a weird kernel"
177167
grid = (3, 7)

test/utils/nvcuda.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from kernel_tuner.utils.nvcuda import to_valid_nvrtc_gpu_arch_cc
2+
3+
4+
def test_to_valid_nvrtc_gpu_arch_cc():
5+
assert to_valid_nvrtc_gpu_arch_cc("89") == "89"
6+
assert to_valid_nvrtc_gpu_arch_cc("88") == "87"
7+
assert to_valid_nvrtc_gpu_arch_cc("86") == "80"
8+
assert to_valid_nvrtc_gpu_arch_cc("40") == "52"
9+
assert to_valid_nvrtc_gpu_arch_cc("90b") == "90a"
10+
assert to_valid_nvrtc_gpu_arch_cc("91c") == "90a"
11+
assert to_valid_nvrtc_gpu_arch_cc("1234") == "52"

0 commit comments

Comments
 (0)