MCPcopy Create free account
hub / github.com/apache/tvm / find_nvshmem_paths

Function find_nvshmem_paths

python/tvm/support/nvcc.py:765–848  ·  view source on GitHub ↗

Searches for the NVSHMEM include and library directories. Returns ------- A tuple containing the path to the include directory and the library directory.

()

Source from the content-addressed store, hash-verified

763
764
765def 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:

Callers 2

_compile_cuda_nvccFunction · 0.85
_compile_cuda_nvrtcFunction · 0.85

Calls 5

find_cuda_pathFunction · 0.85
extendMethod · 0.80
appendMethod · 0.45
addMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…