Skip to content

fix skip in test_core when no GPU available #752

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Dec 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions stumpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@
from .core import _gpu_aampdist_driver_not_found as gpu_aampdist # noqa: F401
from .core import _gpu_stimp_driver_not_found as gpu_stimp # noqa: F401
from .core import _gpu_aamp_stimp_driver_not_found as gpu_aamp_stimp # noqa: F401

from . import core

core._gpu_searchsorted_left = core._gpu_searchsorted_left_driver_not_found
core._gpu_searchsorted_right = core._gpu_searchsorted_right_driver_not_found

import ast
import pathlib

Expand Down
35 changes: 12 additions & 23 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@
import naive

if cuda.is_available():
from stumpy.core import _gpu_searchsorted_left, _gpu_searchsorted_right
else: # pragma: no cover
from stumpy.core import (
_gpu_searchsorted_left_driver_not_found as _gpu_searchsorted_left,
)
from stumpy.core import (
_gpu_searchsorted_right_driver_not_found as _gpu_searchsorted_right,
)

@cuda.jit("(f8[:, :], f8[:], i8[:], i8, b1, i8[:])")
def _gpu_searchsorted_kernel(a, v, bfs, nlevel, is_left, idx):
# A wrapper kernel for calling device function _gpu_searchsorted_left/right.
i = cuda.grid(1)
if i < a.shape[0]:
if is_left:
idx[i] = core._gpu_searchsorted_left(a[i], v[i], bfs, nlevel)
else:
idx[i] = core._gpu_searchsorted_right(a[i], v[i], bfs, nlevel)


try:
from numba.errors import NumbaPerformanceWarning
Expand All @@ -28,20 +31,6 @@

TEST_THREADS_PER_BLOCK = 10

if not cuda.is_available(): # pragma: no cover
pytest.skip("Skipping Tests No GPUs Available", allow_module_level=True)


@cuda.jit("(f8[:, :], f8[:], i8[:], i8, b1, i8[:])")
def _gpu_searchsorted_kernel(a, v, bfs, nlevel, is_left, idx):
# A wrapper kernel for calling device function _gpu_searchsorted_left/right.
i = cuda.grid(1)
if i < a.shape[0]:
if is_left:
idx[i] = _gpu_searchsorted_left(a[i], v[i], bfs, nlevel)
else:
idx[i] = _gpu_searchsorted_right(a[i], v[i], bfs, nlevel)


def naive_rolling_window_dot_product(Q, T):
window = len(Q)
Expand Down Expand Up @@ -1403,7 +1392,7 @@ def test_find_matches_maxmatch():
@patch("stumpy.config.STUMPY_THREADS_PER_BLOCK", TEST_THREADS_PER_BLOCK)
def test_gpu_searchsorted():
if not cuda.is_available(): # pragma: no cover
pytest.skip("Skipping Tests No GPUs Available", allow_module_level=True)
pytest.skip("Skipping Tests No GPUs Available")

n = 3 * config.STUMPY_THREADS_PER_BLOCK + 1
V = np.empty(n, dtype=np.float64)
Expand Down