"spack external find": also find library-only packages (#28005)

Update "spack external find --all" to also find library-only packages.
A Package can add a ".libraries" attribute, which is a list of regular
expressions to use to find libraries associated with the Package.
"spack external find --all" will search LD_LIBRARY_PATH for potential
libraries.

This PR adds examples for NCCL, RCCL, and hipblas packages. These
examples specify the suffix ".so" for the regular expressions used
to find libraries, so generally are only useful for detecting library
packages on Linux.
This commit is contained in:
Brian Van Essen
2022-04-01 13:30:10 -07:00
committed by GitHub
parent a58fa289b9
commit 29da99427e
10 changed files with 263 additions and 13 deletions

View File

@@ -3,6 +3,8 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import re
from spack import *
@@ -15,6 +17,7 @@ class Hipblas(CMakePackage):
url = "https://github.com/ROCmSoftwarePlatform/hipBLAS/archive/rocm-5.0.2.tar.gz"
maintainers = ['srekolam', 'arjun-raj-kuppala', 'haampie']
libraries = ['libhipblas.so']
version('5.0.2', sha256='201772bfc422ecb2c50e898dccd7d3d376cf34a2b795360e34bf71326aa37646')
version('5.0.0', sha256='63cffe748ed4a86fc80f408cb9e8a9c6c55c22a2b65c0eb9a76360b97bbb9d41')
@@ -54,6 +57,18 @@ def check(self):
depends_on('comgr@' + ver, type='build', when='@' + ver)
depends_on('rocm-cmake@' + ver, type='build', when='@' + ver)
@classmethod
def determine_version(cls, lib):
match = re.search(r'lib\S*\.so\.\d+\.\d+\.(\d)(\d\d)(\d\d)',
lib)
if match:
ver = '{0}.{1}.{2}'.format(int(match.group(1)),
int(match.group(2)),
int(match.group(3)))
else:
ver = None
return ver
def cmake_args(self):
args = [
# Make sure find_package(HIP) finds the module.

View File

@@ -3,6 +3,8 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import re
from spack import *
@@ -13,6 +15,7 @@ class Nccl(MakefilePackage, CudaPackage):
url = "https://github.com/NVIDIA/nccl/archive/v2.7.3-1.tar.gz"
maintainers = ['adamjstewart']
libraries = ['libnccl.so']
version('2.11.4-1', sha256='db4e9a0277a64f9a31ea9b5eea22e63f10faaed36dded4587bbc8a0d8eceed10')
version('2.10.3-1', sha256='55de166eb7dcab9ecef2629cdb5fb0c5ebec4fae03589c469ebe5dcb5716b3c5')
@@ -49,6 +52,12 @@ class Nccl(MakefilePackage, CudaPackage):
msg='Must specify CUDA compute capabilities of your GPU, see '
'https://developer.nvidia.com/cuda-gpus')
@classmethod
def determine_version(cls, lib):
match = re.search(r'lib\S*\.so\.(\d+\.\d+\.\d+)',
lib)
return match.group(1) if match else None
@property
def build_targets(self):
cuda_arch = self.spec.variants['cuda_arch'].value

View File

@@ -3,6 +3,8 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import re
from spack import *
@@ -17,6 +19,7 @@ class Rccl(CMakePackage):
url = "https://github.com/ROCmSoftwarePlatform/rccl/archive/rocm-5.0.0.tar.gz"
maintainers = ['srekolam', 'arjun-raj-kuppala']
libraries = ['librccl.so']
version('5.0.2', sha256='a2377ad2332b93d3443a8ee74f4dd9f965ae8cbbfad473f8f57ca17905389a39')
version('5.0.0', sha256='80eb70243f11b80e215458a67c278cd5a655f6e486289962b92ba3504e50af5c')
@@ -53,6 +56,18 @@ class Rccl(CMakePackage):
for ver in ['4.5.0', '4.5.2', '5.0.0', '5.0.2']:
depends_on('rocm-smi-lib@' + ver, when='@' + ver)
@classmethod
def determine_version(cls, lib):
match = re.search(r'lib\S*\.so\.\d+\.\d+\.(\d)(\d\d)(\d\d)',
lib)
if match:
ver = '{0}.{1}.{2}'.format(int(match.group(1)),
int(match.group(2)),
int(match.group(3)))
else:
ver = None
return ver
def setup_build_environment(self, env):
env.set('CXX', self.spec['hip'].hipcc)

View File

@@ -3,6 +3,8 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import re
from spack import *
@@ -11,6 +13,7 @@ class RdmaCore(CMakePackage):
homepage = "https://github.com/linux-rdma/rdma-core"
url = "https://github.com/linux-rdma/rdma-core/releases/download/v17.1/rdma-core-17.1.tar.gz"
libraries = ['librdmacm.so']
version('39.0', sha256='f6eaf0de9fe386e234e00a18a553f591143f50e03342c9fdd703fa8747bf2378')
version('34.0', sha256='3d9ccf66468cf78f4c39bebb8bd0c5eb39150ded75f4a88a3455c4f625408be8')
@@ -34,6 +37,12 @@ class RdmaCore(CMakePackage):
conflicts('platform=darwin', msg='rdma-core requires FreeBSD or Linux')
conflicts('%intel', msg='rdma-core cannot be built with intel (use gcc instead)')
@classmethod
def determine_version(cls, lib):
match = re.search(r'lib\S*\.so\.\d+\.\d+\.(\d+\.\d+)',
lib)
return match.group(1) if match else None
# NOTE: specify CMAKE_INSTALL_RUNDIR explicitly to prevent rdma-core from
# using the spack staging build dir (which may be a very long file
# system path) as a component in compile-time static strings such as