diff --git a/cuda_core/tests/helpers/__init__.py b/cuda_core/tests/helpers/__init__.py index d081f1185..02cbe6d8e 100644 --- a/cuda_core/tests/helpers/__init__.py +++ b/cuda_core/tests/helpers/__init__.py @@ -3,7 +3,6 @@ import os import pathlib -import platform import sys CUDA_PATH = os.environ.get("CUDA_PATH") @@ -20,16 +19,8 @@ try: - import cuda_python_test_helpers + from cuda_python_test_helpers import * # noqa: F403 except ImportError: # Import shared platform helpers for tests across repos sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[3] / "cuda_python_test_helpers")) - import cuda_python_test_helpers - - -IS_WSL = cuda_python_test_helpers.IS_WSL -supports_ipc_mempool = cuda_python_test_helpers.supports_ipc_mempool -IS_WINDOWS = platform.system() == "Windows" - - -del cuda_python_test_helpers + from cuda_python_test_helpers import * # noqa: F403 diff --git a/cuda_core/tests/helpers/buffers.py b/cuda_core/tests/helpers/buffers.py index 52220956d..972e83e13 100644 --- a/cuda_core/tests/helpers/buffers.py +++ b/cuda_core/tests/helpers/buffers.py @@ -2,16 +2,11 @@ # SPDX-License-Identifier: Apache-2.0 import ctypes -import sys from cuda.core.experimental import Buffer, MemoryResource from cuda.core.experimental._utils.cuda_utils import driver, handle_return -if sys.platform.startswith("win"): - libc = ctypes.CDLL("msvcrt.dll") -else: - libc = ctypes.CDLL("libc.so.6") - +from . import libc __all__ = ["DummyUnifiedMemoryResource", "PatternGen", "make_scratch_buffer", "compare_equal_buffers"] diff --git a/cuda_core/tests/helpers/latch.py b/cuda_core/tests/helpers/latch.py index 6dcc1c964..46516c1b0 100644 --- a/cuda_core/tests/helpers/latch.py +++ b/cuda_core/tests/helpers/latch.py @@ -45,7 +45,7 @@ def __init__(self, device, timeout_sec=60): } // Avoid 100% spin. - __nanosleep(10000000); // 10 ms + __nanosleep(1000000); // 1 ms } } """ diff --git a/cuda_python_test_helpers/cuda_python_test_helpers/__init__.py b/cuda_python_test_helpers/cuda_python_test_helpers/__init__.py index 5996498d9..a661b4f1a 100644 --- a/cuda_python_test_helpers/cuda_python_test_helpers/__init__.py +++ b/cuda_python_test_helpers/cuda_python_test_helpers/__init__.py @@ -1,13 +1,23 @@ # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 +import ctypes import functools import os +import platform +import sys from contextlib import suppress from typing import Union from cuda.core.experimental._utils.cuda_utils import handle_return +__all__ = [ + "IS_WINDOWS", + "IS_WSL", + "libc", + "supports_ipc_mempool", +] + def _detect_wsl() -> bool: data = "" @@ -19,6 +29,12 @@ def _detect_wsl() -> bool: IS_WSL: bool = _detect_wsl() +IS_WINDOWS: bool = platform.system() == "Windows" or sys.platform.startswith("win") + +if IS_WINDOWS: + libc = ctypes.CDLL("msvcrt.dll") +else: + libc = ctypes.CDLL("libc.so.6") @functools.cache @@ -54,9 +70,3 @@ def supports_ipc_mempool(device_id: Union[int, object]) -> bool: return (int(mask) & int(posix_fd)) != 0 except Exception: return False - - -__all__ = [ - "IS_WSL", - "supports_ipc_mempool", -]