diff --git a/cuda_pathfinder/AGENTS.md b/cuda_pathfinder/AGENTS.md index 271e5797f82..6fbaa9ff49c 100644 --- a/cuda_pathfinder/AGENTS.md +++ b/cuda_pathfinder/AGENTS.md @@ -32,8 +32,9 @@ Windows. - `_static_libs/locate_file.py` holds the one search that `find_static_lib.py` and `find_bitcode_lib.py` share. - **Process isolation helper**: - - `cuda/pathfinder/_utils/spawned_process_runner.py` is used where process - global dynamic loader state would otherwise leak across tests. + - `cuda/pathfinder/_dynamic_libs/dynamic_lib_subprocess.py` runs in a fresh + Python process: for the CTK-root canary probe, and for tests where process + global dynamic loader state would otherwise leak. ## Editing guidance diff --git a/cuda_pathfinder/cuda/pathfinder/__init__.py b/cuda_pathfinder/cuda/pathfinder/__init__.py index a64b5ef64c7..d81c058ab5b 100644 --- a/cuda_pathfinder/cuda/pathfinder/__init__.py +++ b/cuda_pathfinder/cuda/pathfinder/__init__.py @@ -70,8 +70,8 @@ SUPPORTED_HEADERS_CTK = _SUPPORTED_HEADERS_CTK #: Tuple of supported CUDA binary utility names that can be located -#: via ``find_nvidia_binary_utility()``. Platform-aware (e.g., some -#: utilities may be available only on Linux or Windows). +#: via ``find_nvidia_binary_utility()``. The tuple is the same on every +#: platform; some utilities exist only on Linux or only on Windows. #: Example utilities: ``"nvdisasm"``, ``"cuobjdump"``, ``"nvcc"``. SUPPORTED_BINARY_UTILITIES = _SUPPORTED_BINARIES @@ -91,5 +91,5 @@ SUPPORTED_STATIC_LIBS = _SUPPORTED_STATIC_LIBS # Backward compatibility: _find_nvidia_header_directory was added in release 1.2.2. -# It will be removed in release 1.2.4. +# Its removal was planned for release 1.2.4 and has not happened. _find_nvidia_header_directory = find_nvidia_header_directory diff --git a/cuda_pathfinder/cuda/pathfinder/_binaries/find_nvidia_binary_utility.py b/cuda_pathfinder/cuda/pathfinder/_binaries/find_nvidia_binary_utility.py index b5fa3cc8cc3..c4068207599 100644 --- a/cuda_pathfinder/cuda/pathfinder/_binaries/find_nvidia_binary_utility.py +++ b/cuda_pathfinder/cuda/pathfinder/_binaries/find_nvidia_binary_utility.py @@ -175,9 +175,10 @@ def find_nvidia_binary_utility(utility_name: str) -> str | None: Results are cached using ``@functools.cache`` for performance. The cache persists for the lifetime of the process. - On Windows, executables are identified by their file extensions - (``.exe``, ``.bat``, ``.cmd``). On Unix-like systems, executables - are identified by the ``X_OK`` (execute) permission bit. + On Windows, the search looks for ``.exe``. For + ``compute-sanitizer`` and ``ncu`` it tries ``.bat`` + first. On Unix-like systems, a file counts only if it has the + ``X_OK`` (execute) permission bit. Lookup is restricted to the trusted directories and the canary-derived CTK root listed above. diff --git a/cuda_pathfinder/cuda/pathfinder/_binaries/supported_nvidia_binaries.py b/cuda_pathfinder/cuda/pathfinder/_binaries/supported_nvidia_binaries.py index c2f818da6c0..85483656dc1 100644 --- a/cuda_pathfinder/cuda/pathfinder/_binaries/supported_nvidia_binaries.py +++ b/cuda_pathfinder/cuda/pathfinder/_binaries/supported_nvidia_binaries.py @@ -9,7 +9,8 @@ _NSIGHT_SYSTEMS_BIN = os.path.join("nvidia", "nsight_systems", "bin") _NSIGHT_COMPUTE_BIN = os.path.join("nvidia", "nsight_compute", "bin") -# Common CUDA binary utilities available on both Linux and Windows +# Utility name -> site-packages bin directories to search, in order. +# The table is the same on every platform; some utilities ship for one only. SITE_PACKAGES_BINDIRS = { # Core compilation tools "nvcc": (_CUDA13_BIN, _CUDA_NVCC_BIN), diff --git a/cuda_pathfinder/cuda/pathfinder/_dynamic_libs/load_dl_linux.py b/cuda_pathfinder/cuda/pathfinder/_dynamic_libs/load_dl_linux.py index 484e5724593..5552b2296f4 100644 --- a/cuda_pathfinder/cuda/pathfinder/_dynamic_libs/load_dl_linux.py +++ b/cuda_pathfinder/cuda/pathfinder/_dynamic_libs/load_dl_linux.py @@ -69,7 +69,7 @@ class _LinkMapLNameView(ctypes.Structure): returned by `dlinfo(...)`. - Do **not** instantiate it or pass it **by value** to any C function. - Do **not** access any members beyond those declared here. - - Do **not** rely on `ctypes.sizeof(LinkMapPrefix)` for allocation. + - Do **not** rely on `ctypes.sizeof(_LinkMapLNameView)` for allocation. Rationale: - Defining only the leading fields avoids depending on internal/unstable diff --git a/cuda_pathfinder/cuda/pathfinder/_dynamic_libs/platform_loader.py b/cuda_pathfinder/cuda/pathfinder/_dynamic_libs/platform_loader.py index 1d65f696f04..283578fcfa8 100644 --- a/cuda_pathfinder/cuda/pathfinder/_dynamic_libs/platform_loader.py +++ b/cuda_pathfinder/cuda/pathfinder/_dynamic_libs/platform_loader.py @@ -36,6 +36,6 @@ def load_with_abs_path(self, desc: LibDescriptor, found_path: str, found_via: st else: from cuda.pathfinder._dynamic_libs import load_dl_linux as _impl -# The platform modules already expose functions matching the PlatformLoader -# protocol. Wrap in a simple namespace so callers use LOADER.method() syntax. +# LOADER is the platform module itself. Its functions match the PlatformLoader +# protocol, so callers write LOADER.method(). LOADER: PlatformLoader = _impl