summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreugeneswalker <38933153+eugeneswalker@users.noreply.github.com>2021-02-26 01:17:35 -0800
committerGitHub <noreply@github.com>2021-02-26 10:17:35 +0100
commite88fc38cfeaf643fce2b9b714921caffa372f615 (patch)
tree74627d72b99738cb2da35dac0c8c025bca91f2bb
parent27ef9f0e078f5abc897d2fd891a1afe9908b6532 (diff)
downloadspack-e88fc38cfeaf643fce2b9b714921caffa372f615.tar.gz
spack-e88fc38cfeaf643fce2b9b714921caffa372f615.tar.bz2
spack-e88fc38cfeaf643fce2b9b714921caffa372f615.tar.xz
spack-e88fc38cfeaf643fce2b9b714921caffa372f615.zip
hypre: enable cuda variants (#21885)
-rw-r--r--var/spack/repos/builtin/packages/hypre/package.py41
1 files changed, 39 insertions, 2 deletions
diff --git a/var/spack/repos/builtin/packages/hypre/package.py b/var/spack/repos/builtin/packages/hypre/package.py
index 3f8a892395..61ce3a46dc 100644
--- a/var/spack/repos/builtin/packages/hypre/package.py
+++ b/var/spack/repos/builtin/packages/hypre/package.py
@@ -8,7 +8,7 @@ import os
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 @@ class Hypre(Package):
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 @@ class Hypre(Package):
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"):