Skip to content
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
13 changes: 2 additions & 11 deletions cuda_core/tests/helpers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import os
import pathlib
import platform
import sys

CUDA_PATH = os.environ.get("CUDA_PATH")
Expand All @@ -20,16 +19,8 @@


try:
import cuda_python_test_helpers
from cuda_python_test_helpers import * # noqa: F403
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a good place to use import *, since we are trying to merge modules defined in different places, we control both, and the source has an __all__ list.

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
7 changes: 1 addition & 6 deletions cuda_core/tests/helpers/buffers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down
2 changes: 1 addition & 1 deletion cuda_core/tests/helpers/latch.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __init__(self, device, timeout_sec=60):
}

// Avoid 100% spin.
__nanosleep(10000000); // 10 ms
__nanosleep(1000000); // 1 ms
}
}
"""
Expand Down
22 changes: 16 additions & 6 deletions cuda_python_test_helpers/cuda_python_test_helpers/__init__.py
Original file line number Diff line number Diff line change
@@ -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 = ""
Expand All @@ -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
Expand Down Expand Up @@ -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",
]
Loading