Searches for the NVSHMEM include and library directories. Returns ------- A tuple containing the path to the include directory and the library directory.
()
| 763 | |
| 764 | |
| 765 | def find_nvshmem_paths() -> tuple[str, str]: |
| 766 | """ |
| 767 | Searches for the NVSHMEM include and library directories. |
| 768 | |
| 769 | Returns |
| 770 | ------- |
| 771 | A tuple containing the path to the include directory and the library directory. |
| 772 | """ |
| 773 | candidate_roots = [] |
| 774 | |
| 775 | # 1. NVSHMEM_HOME env variable |
| 776 | if "NVSHMEM_HOME" in os.environ: |
| 777 | candidate_roots.append(os.environ["NVSHMEM_HOME"]) |
| 778 | |
| 779 | # 2. CUDA Toolkit |
| 780 | try: |
| 781 | cuda_home = find_cuda_path() |
| 782 | candidate_roots.append(cuda_home) |
| 783 | except RuntimeError: |
| 784 | pass |
| 785 | |
| 786 | # 3. Other common system installation paths |
| 787 | candidate_roots.extend(["/usr/local", "/usr"]) |
| 788 | |
| 789 | seen = set() |
| 790 | unique_candidates = [] |
| 791 | for path in candidate_roots: |
| 792 | if path and path not in seen: |
| 793 | seen.add(path) |
| 794 | unique_candidates.append(path) |
| 795 | |
| 796 | for root in unique_candidates: |
| 797 | # Check both standard include path and versioned subdirectories (e.g., nvshmem_12) |
| 798 | include_paths_to_check = [os.path.join(root, "include")] |
| 799 | |
| 800 | # Add versioned subdirectories like include/nvshmem_* |
| 801 | versioned_includes = glob.glob(os.path.join(root, "include", "nvshmem_*")) |
| 802 | include_paths_to_check.extend(versioned_includes) |
| 803 | |
| 804 | # Check standard and architecture-specific lib directories |
| 805 | lib_paths_to_check = [ |
| 806 | os.path.join(root, "lib64"), |
| 807 | os.path.join(root, "lib"), |
| 808 | ] |
| 809 | |
| 810 | # Add architecture-specific lib paths (e.g., lib/x86_64-linux-gnu) |
| 811 | machine = platform.machine() |
| 812 | system = platform.system().lower() |
| 813 | lib_paths_to_check.extend( |
| 814 | [ |
| 815 | os.path.join(root, "lib", f"{machine}-{system}-gnu"), |
| 816 | os.path.join(root, "lib64", f"{machine}-{system}-gnu"), |
| 817 | ] |
| 818 | ) |
| 819 | |
| 820 | for include_path in include_paths_to_check: |
| 821 | if os.path.isfile(os.path.join(include_path, "nvshmem.h")): |
| 822 | for lib_path in lib_paths_to_check: |
no test coverage detected
searching dependent graphs…