hypre: Use spec.satisfies to test spec variants (#41627)

* hypre: Use satisfies to test spec constraints

* hypre: Fix variant vs. dependency syntax mixup
This commit is contained in:
Sarah Osborn 2024-01-10 16:02:57 -08:00 committed by GitHub
parent cff4f31bd6
commit d0bc7cb86d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -188,10 +188,10 @@ def configure_args(self):
"--with-blas-lib-dirs=%s" % " ".join(blas.directories), "--with-blas-lib-dirs=%s" % " ".join(blas.directories),
] ]
if "+mpi" in spec: if spec.satisfies("+mpi"):
os.environ["CC"] = spec["mpi"].mpicc os.environ["CC"] = spec["mpi"].mpicc
os.environ["CXX"] = spec["mpi"].mpicxx os.environ["CXX"] = spec["mpi"].mpicxx
if "+fortran" in spec: if spec.satisfies("+fortran"):
os.environ["F77"] = spec["mpi"].mpif77 os.environ["F77"] = spec["mpi"].mpif77
os.environ["FC"] = spec["mpi"].mpifc os.environ["FC"] = spec["mpi"].mpifc
configure_args.append("--with-MPI") configure_args.append("--with-MPI")
@ -202,7 +202,7 @@ def configure_args(self):
configure_args.extend(self.with_or_without("openmp")) configure_args.extend(self.with_or_without("openmp"))
if "+int64" in spec: if spec.satisfies("+int64"):
configure_args.append("--enable-bigint") configure_args.append("--enable-bigint")
else: else:
configure_args.append("--disable-bigint") configure_args.append("--disable-bigint")
@ -211,38 +211,38 @@ def configure_args(self):
configure_args.extend(self.enable_or_disable("complex")) configure_args.extend(self.enable_or_disable("complex"))
if "+shared" in spec: if spec.satisfies("+shared"):
configure_args.append("--enable-shared") configure_args.append("--enable-shared")
if "~internal-superlu" in spec: if spec.satisfies("~internal-superlu"):
configure_args.append("--without-superlu") configure_args.append("--without-superlu")
# MLI and FEI do not build without superlu on Linux # MLI and FEI do not build without superlu on Linux
configure_args.append("--without-mli") configure_args.append("--without-mli")
configure_args.append("--without-fei") configure_args.append("--without-fei")
if "+superlu-dist" in spec: if spec.satisfies("+superlu-dist"):
configure_args.append( configure_args.append(
"--with-dsuperlu-include=%s" % spec["superlu-dist"].prefix.include "--with-dsuperlu-include=%s" % spec["superlu-dist"].prefix.include
) )
configure_args.append("--with-dsuperlu-lib=%s" % spec["superlu-dist"].libs) configure_args.append("--with-dsuperlu-lib=%s" % spec["superlu-dist"].libs)
configure_args.append("--with-dsuperlu") configure_args.append("--with-dsuperlu")
if "+umpire" in spec: if spec.satisfies("+umpire"):
configure_args.append("--with-umpire-include=%s" % spec["umpire"].prefix.include) configure_args.append("--with-umpire-include=%s" % spec["umpire"].prefix.include)
configure_args.append("--with-umpire-lib=%s" % spec["umpire"].libs) configure_args.append("--with-umpire-lib=%s" % spec["umpire"].libs)
if "~cuda~rocm" in spec: if spec.satisfies("~cuda~rocm"):
configure_args.append("--with-umpire-host") configure_args.append("--with-umpire-host")
else: else:
configure_args.append("--with-umpire") configure_args.append("--with-umpire")
if "+caliper" in spec: if spec.satisfies("+caliper"):
configure_args.append("--with-caliper") configure_args.append("--with-caliper")
configure_args.append("--with-caliper-include=%s" % spec["caliper"].prefix.include) configure_args.append("--with-caliper-include=%s" % spec["caliper"].prefix.include)
configure_args.append("--with-caliper-lib=%s" % spec["caliper"].libs) configure_args.append("--with-caliper-lib=%s" % spec["caliper"].libs)
configure_args.extend(self.enable_or_disable("debug")) configure_args.extend(self.enable_or_disable("debug"))
if "+cuda" in spec: if spec.satisfies("+cuda"):
configure_args.extend(["--with-cuda", "--enable-curand", "--enable-cusparse"]) configure_args.extend(["--with-cuda", "--enable-curand", "--enable-cusparse"])
cuda_arch_vals = spec.variants["cuda_arch"].value cuda_arch_vals = spec.variants["cuda_arch"].value
if cuda_arch_vals: if cuda_arch_vals:
@ -250,24 +250,23 @@ def configure_args(self):
cuda_arch = cuda_arch_sorted[0] cuda_arch = cuda_arch_sorted[0]
configure_args.append("--with-gpu-arch={0}".format(cuda_arch)) configure_args.append("--with-gpu-arch={0}".format(cuda_arch))
# New in 2.21.0: replaces --enable-cub # New in 2.21.0: replaces --enable-cub
if "@2.21.0:" in spec: if spec.satisfies("@2.21.0:"):
configure_args.append("--enable-device-memory-pool") configure_args.append("--enable-device-memory-pool")
configure_args.append("--with-cuda-home={0}".format(spec["cuda"].prefix)) configure_args.append("--with-cuda-home={0}".format(spec["cuda"].prefix))
else: else:
configure_args.append("--enable-cub") configure_args.append("--enable-cub")
else: else:
configure_args.extend(["--without-cuda", "--disable-curand", "--disable-cusparse"]) configure_args.extend(["--without-cuda", "--disable-curand", "--disable-cusparse"])
if "@:2.20.99" in spec: if spec.satisfies("@:2.20.99"):
configure_args.append("--disable-cub") configure_args.append("--disable-cub")
if "+rocm" in spec: if spec.satisfies("+rocm"):
rocm_pkgs = ["rocsparse", "rocthrust", "rocprim", "rocrand"] rocm_pkgs = ["rocsparse", "rocthrust", "rocprim", "rocrand"]
if "+superlu-dist" in spec: if spec.satisfies("+superlu-dist"):
rocm_pkgs.append("hipblas") rocm_pkgs.append("hipblas")
rocm_inc = "" rocm_inc = ""
for pkg in rocm_pkgs: for pkg in rocm_pkgs:
if "^" + pkg in spec: rocm_inc += spec[pkg].headers.include_flags + " "
rocm_inc += spec[pkg].headers.include_flags + " "
configure_args.extend( configure_args.extend(
[ [
"--with-hip", "--with-hip",
@ -284,7 +283,7 @@ def configure_args(self):
else: else:
configure_args.extend(["--without-hip", "--disable-rocrand", "--disable-rocsparse"]) configure_args.extend(["--without-hip", "--disable-rocrand", "--disable-rocsparse"])
if "+sycl" in spec: if spec.satisfies("+sycl"):
configure_args.append("--with-sycl") configure_args.append("--with-sycl")
sycl_compatible_compilers = ["dpcpp", "icpx"] sycl_compatible_compilers = ["dpcpp", "icpx"]
if not (os.path.basename(self.compiler.cxx) in sycl_compatible_compilers): if not (os.path.basename(self.compiler.cxx) in sycl_compatible_compilers):
@ -293,10 +292,10 @@ def configure_args(self):
+ " or the oneAPI CXX (icpx) compiler." + " or the oneAPI CXX (icpx) compiler."
) )
if "+unified-memory" in spec: if spec.satisfies("+unified-memory"):
configure_args.append("--enable-unified-memory") configure_args.append("--enable-unified-memory")
if "+magma" in spec: if spec.satisfies("+magma"):
configure_args.append("--with-magma-include=%s" % spec["magma"].prefix.include) configure_args.append("--with-magma-include=%s" % spec["magma"].prefix.include)
configure_args.append("--with-magma-lib=%s" % spec["magma"].libs) configure_args.append("--with-magma-lib=%s" % spec["magma"].libs)
configure_args.append("--with-magma") configure_args.append("--with-magma")
@ -307,19 +306,19 @@ def configure_args(self):
def setup_build_environment(self, env): def setup_build_environment(self, env):
spec = self.spec spec = self.spec
if "+mpi" in spec: if spec.satisfies("+mpi"):
env.set("CC", spec["mpi"].mpicc) env.set("CC", spec["mpi"].mpicc)
env.set("CXX", spec["mpi"].mpicxx) env.set("CXX", spec["mpi"].mpicxx)
if "+fortran" in spec: if spec.satisfies("+fortan"):
env.set("F77", spec["mpi"].mpif77) env.set("F77", spec["mpi"].mpif77)
if "+cuda" in spec: if spec.satisfies("+cuda"):
env.set("CUDA_HOME", spec["cuda"].prefix) env.set("CUDA_HOME", spec["cuda"].prefix)
env.set("CUDA_PATH", spec["cuda"].prefix) env.set("CUDA_PATH", spec["cuda"].prefix)
# In CUDA builds hypre currently doesn't handle flags correctly # In CUDA builds hypre currently doesn't handle flags correctly
env.append_flags("CXXFLAGS", "-O2" if "~debug" in spec else "-g") env.append_flags("CXXFLAGS", "-O2" if "~debug" in spec else "-g")
if "+rocm" in spec: if spec.satisfies("+rocm"):
# As of 2022/04/05, the following are set by 'llvm-amdgpu' and # As of 2022/04/05, the following are set by 'llvm-amdgpu' and
# override hypre's default flags, so we unset them. # override hypre's default flags, so we unset them.
env.unset("CFLAGS") env.unset("CFLAGS")
@ -341,7 +340,7 @@ def install(self, spec, prefix):
sstruct() sstruct()
sstruct("-in", "test/sstruct.in.default", "-solver", "40", "-rhsone") sstruct("-in", "test/sstruct.in.default", "-solver", "40", "-rhsone")
make("install") make("install")
if "+gptune" in self.spec: if spec.satisfies("+gptune"):
make("test") make("test")
self.run_test("mkdir", options=["-p", self.prefix.bin]) self.run_test("mkdir", options=["-p", self.prefix.bin])
self.run_test("cp", options=["test/ij", self.prefix.bin + "/."]) self.run_test("cp", options=["test/ij", self.prefix.bin + "/."])