hypre: enable cuda variants (#21885)

This commit is contained in:
eugeneswalker 2021-02-26 01:17:35 -08:00 committed by GitHub
parent 27ef9f0e07
commit e88fc38cfe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -8,7 +8,7 @@
import sys
class Hypre(Package):
class Hypre(Package, CudaPackage):
"""Hypre is a library of high performance preconditioners that
features parallel multigrid methods for both structured and
unstructured grid problems."""
@ -78,6 +78,8 @@ class Hypre(Package):
depends_on("lapack")
depends_on('superlu-dist', when='+superlu-dist+mpi')
conflicts('+cuda', when='+int64')
# Patch to build shared libraries on Darwin does not apply to
# versions before 2.13.0
conflicts("+shared@:2.12.99 platform=darwin")
@ -100,7 +102,8 @@ def url_for_version(self, version):
return url.format(version)
def install(self, spec, prefix):
def _configure_args(self):
spec = self.spec
# Note: --with-(lapack|blas)_libs= needs space separated list of names
lapack = spec['lapack'].libs
blas = spec['blas'].libs
@ -162,6 +165,40 @@ def install(self, spec, prefix):
else:
configure_args.append("--disable-debug")
if '+cuda' in self.spec:
configure_args.extend([
'--with-cuda',
'--enable-curand',
'--enable-cub'
])
else:
configure_args.extend([
'--without-cuda',
'--disable-curand',
'--disable-cub'
])
return configure_args
def setup_build_environment(self, env):
if '+mpi' in self.spec:
env.set('CC', self.spec['mpi'].mpicc)
env.set('CXX', self.spec['mpi'].mpicxx)
env.set('F77', self.spec['mpi'].mpif77)
if '+cuda' in self.spec:
env.set('CUDA_HOME', self.spec['cuda'].prefix)
env.set('CUDA_PATH', self.spec['cuda'].prefix)
cuda_arch = self.spec.variants['cuda_arch'].value
if cuda_arch:
arch_sorted = list(sorted(cuda_arch, reverse=True))
env.set('HYPRE_CUDA_SM', arch_sorted[0])
# In CUDA builds hypre currently doesn't handle flags correctly
env.append_flags(
'CXXFLAGS', '-O2' if '~debug' in self.spec else '-g')
def install(self, spec, prefix):
configure_args = self._configure_args()
# Hypre's source is staged under ./src so we'll have to manually
# cd into it.
with working_dir("src"):