Chapel 2.2 update (#46593)

* shorten version number validations per reviewer feedback
* rename set_lib_path per reviewer feedback
* Add E4S tag
* Set CHPL_CUDA_PATH to ensure Chapel installer finds the right package
* Update ROCm dependency for Chapel 2.2
* Fix llvm-amdgpu and CHPL_TARGET_* for llvm=bundled
* Ensure CHPL_TARGET_COMPILER is set to "llvm" when required (llvm=spack
   or +cuda or +rocm).
* Ensure CHPL_TARGET_{CC,CXX} are only set when using llvm=spack or llvm=none
* Use hip.prefix to set CHPL_ROCM_PATH
   Since we might not directly depend on llvm-amdgpu, thus it might
   not appear in our spec
* limit m4 dependency to +gmp
* limit names of env vars created from variants
* Ensure that +cuda and +rocm variants are Sticky

The concretizer should never be permitted to select GPU support, because
it's only meaningful and functional when the appropriate hardware is actually
available, and the concretizer cannot reliably determine that.

Also: Chapel's GPU support includes alot of complicated dependencies
and constraints, so leaving that choice free to the concretizer leads to alot
of extraneous and confusing messages when failing to concretize a
non-GPU-enabled spec.

Co-authored-by: Dan Bonachea <dobonachea@lbl.gov>
This commit is contained in:
arezaii 2024-09-26 21:39:14 -06:00 committed by GitHub
parent 20f90dcda2
commit 1d06a324b5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -36,7 +36,7 @@ class Chapel(AutotoolsPackage, CudaPackage, ROCmPackage):
homepage = "https://chapel-lang.org/"
url = "https://github.com/chapel-lang/chapel/archive/refs/tags/2.1.0.tar.gz"
url = "https://github.com/chapel-lang/chapel/archive/refs/tags/2.2.0.tar.gz"
git = "https://github.com/chapel-lang/chapel.git"
test_requires_compiler = True
@ -48,11 +48,14 @@ class Chapel(AutotoolsPackage, CudaPackage, ROCmPackage):
# TODO: add chapel-project github account
maintainers("arezaii", "bonachea")
tags = ["e4s"]
# See https://spdx.org/licenses/ for a list.
license("Apache-2.0")
version("main", branch="main")
version("2.2.0", sha256="9b0ce16ed0b1c777647c3aa852d8d8cacea2c3d8a952548a238f07c0f357a0f9")
version("2.1.0", sha256="8e164d9a9e705e6b816857e84833b0922ce0bde6a36a9f3a29734830aac168ef")
version("2.0.1", sha256="47e1f3789478ea870bd4ecdf52acbe469d171b89b663309325431f3da7c75008")
version("2.0.0", sha256="a8cab99fd034c7b7229be8d4626ec95cf02072646fb148c74b4f48c460c6059c")
@ -435,15 +438,21 @@ class Chapel(AutotoolsPackage, CudaPackage, ROCmPackage):
conflicts("platform=windows") # Support for windows is through WSL only
# Ensure GPU support is Sticky: never allow the concretizer to choose this
variant("rocm", default=False, sticky=True, description="Enable AMD ROCm GPU support")
variant("cuda", default=False, sticky=True, description="Enable Nvidia CUDA GPU support")
conflicts("+rocm", when="+cuda", msg="Chapel must be built with either CUDA or ROCm, not both")
conflicts(
"+rocm", when="@:1.99.99", msg="ROCm support in spack requires Chapel 2.0.0 or later"
)
conflicts("+rocm", when="@:1", msg="ROCm support in spack requires Chapel 2.0.0 or later")
# Chapel restricts the allowable ROCm versions
with when("+rocm"):
with when("@2:2.1 +rocm"):
depends_on("hsa-rocr-dev@4:5.4")
depends_on("hip@4:5.4")
depends_on("llvm-amdgpu@4:5.4")
with when("@2.2: +rocm"):
depends_on("hsa-rocr-dev@4:5.4,6.0:6.2")
depends_on("hip@4:5.4,6.0:6.2")
depends_on("llvm-amdgpu@4:5.4", when="+rocm llvm=spack")
requires("llvm=bundled", when="+rocm ^hip@6.0:6.2", msg="ROCm 6 support requires llvm=bundled")
conflicts(
"comm_substrate=unset",
@ -463,7 +472,7 @@ class Chapel(AutotoolsPackage, CudaPackage, ROCmPackage):
conflicts(
"^python@3.12:",
when="@:2.0.99",
when="@:2.0",
msg="Chapel versions prior to 2.1.0 may produce SyntaxWarnings with Python >= 3.12",
)
@ -508,7 +517,7 @@ class Chapel(AutotoolsPackage, CudaPackage, ROCmPackage):
# with an error about missing plugin-api.h
depends_on("binutils+gold+ld+plugins+headers", when="llvm=bundled")
depends_on("m4")
depends_on("m4", when="gmp=bundled")
# Runtime dependencies:
# Note here "run" is run of the Chapel compiler built by this package,
@ -566,12 +575,18 @@ def setup_chpl_platform(self, env):
def setup_chpl_compilers(self, env):
env.set("CHPL_HOST_COMPILER", self.compiler_map[self.spec.compiler.name])
env.set("CHPL_TARGET_COMPILER", self.compiler_map[self.spec.compiler.name])
if (
self.spec.satisfies("+rocm")
or self.spec.satisfies("+cuda")
or self.spec.satisfies("llvm=spack")
):
env.set("CHPL_TARGET_COMPILER", "llvm")
else:
env.set("CHPL_TARGET_COMPILER", self.compiler_map[self.spec.compiler.name])
# Undo spack compiler wrappers:
# the C/C++ compilers must work post-install
if self.spec.satisfies("+rocm"):
env.set("CHPL_TARGET_COMPILER", "llvm")
if self.spec.satisfies("+rocm llvm=spack"):
env.set(
"CHPL_LLVM_CONFIG",
join_path(self.spec["llvm-amdgpu"].prefix, "bin", "llvm-config"),
@ -585,15 +600,16 @@ def setup_chpl_compilers(self, env):
env.set("CHPL_HOST_CXX", real_cxx)
elif self.spec.satisfies("llvm=spack"):
env.set("CHPL_TARGET_COMPILER", "llvm")
env.set("CHPL_LLVM_CONFIG", join_path(self.spec["llvm"].prefix, "bin", "llvm-config"))
real_cc = join_path(self.spec["llvm"].prefix, "bin", "clang")
real_cxx = join_path(self.spec["llvm"].prefix, "bin", "clang++")
else:
real_cc = self.compiler.cc
real_cxx = self.compiler.cxx
env.set("CHPL_TARGET_CC", real_cc)
env.set("CHPL_TARGET_CXX", real_cxx)
if self.spec.satisfies("llvm=spack") or self.spec.satisfies("llvm=none"):
env.set("CHPL_TARGET_CC", real_cc)
env.set("CHPL_TARGET_CXX", real_cxx)
def setup_chpl_comm(self, env, spec):
env.set("CHPL_COMM", spec.variants["comm"].value)
@ -609,7 +625,7 @@ def setup_gasnet(self):
symlink(self.spec["gasnet"].prefix.src, dst)
def setup_if_not_unset(self, env, var, value):
if value != "unset":
if value != "unset" and var in self.chpl_env_vars:
if value == "spack":
value = "system"
env.set(var, value)
@ -618,7 +634,7 @@ def prepend_cpath_include(self, env, prefix):
if not is_system_path(prefix):
env.prepend_path("CPATH", prefix.include)
def set_lib_path(self, env, prefix):
def update_lib_path(self, env, prefix):
if not is_system_path(prefix):
env.prepend_path("LD_LIBRARY_PATH", prefix.lib)
env.prepend_path("LIBRARY_PATH", prefix.lib)
@ -629,7 +645,7 @@ def setup_env_vars(self, env):
# variants that appear unused by Spack typically correspond directly to
# a CHPL_<variant> variable which will be used by the Chapel build system
for v in self.spec.variants.keys():
self.setup_if_not_unset(env, "CHPL_" + v.upper(), self.spec.variants[v].value)
self.setup_if_not_unset(env, "CHPL_" + v.upper(), str(self.spec.variants[v].value))
self.setup_chpl_compilers(env)
self.setup_chpl_platform(env)
@ -657,10 +673,10 @@ def setup_env_vars(self, env):
# TODO: why must we add to CPATH to find gmp.h
# TODO: why must we add to LIBRARY_PATH to find lgmp
self.prepend_cpath_include(env, self.spec["gmp"].prefix)
self.set_lib_path(env, self.spec["gmp"].prefix)
self.update_lib_path(env, self.spec["gmp"].prefix)
if self.spec.variants["hwloc"].value == "spack":
self.set_lib_path(env, self.spec["hwloc"].prefix)
self.update_lib_path(env, self.spec["hwloc"].prefix)
# Need this for the test env, where it does not appear automatic:
env.prepend_path("PKG_CONFIG_PATH", self.spec["libpciaccess"].prefix.lib.pkgconfig)
@ -673,22 +689,23 @@ def setup_env_vars(self, env):
if self.spec.satisfies("+yaml"):
self.prepend_cpath_include(env, self.spec["libyaml"].prefix)
# could not compile test/library/packages/Yaml/writeAndParse.chpl without this
self.set_lib_path(env, self.spec["libyaml"].prefix)
self.update_lib_path(env, self.spec["libyaml"].prefix)
if self.spec.satisfies("+zmq"):
self.prepend_cpath_include(env, self.spec["libzmq"].prefix)
# could not compile test/library/packages/ZMQ/hello.chpl without this
self.set_lib_path(env, self.spec["libzmq"].prefix)
self.update_lib_path(env, self.spec["libzmq"].prefix)
env.prepend_path("PKG_CONFIG_PATH", self.spec["libsodium"].prefix.lib.pkgconfig)
if self.spec.satisfies("+curl"):
self.prepend_cpath_include(env, self.spec["curl"].prefix)
# could not compile test/library/packages/Curl/check-http.chpl without this
self.set_lib_path(env, self.spec["curl"].prefix)
self.update_lib_path(env, self.spec["curl"].prefix)
if self.spec.satisfies("+cuda"):
# TODO: why must we add to LD_LIBRARY_PATH to find libcudart?
env.prepend_path("LD_LIBRARY_PATH", self.spec["cuda"].prefix.lib64)
env.set("CHPL_CUDA_PATH", self.spec["cuda"].prefix)
env.set("CHPL_LOCALE_MODEL", "gpu")
env.set("CHPL_GPU", "nvidia")
@ -697,9 +714,9 @@ def setup_env_vars(self, env):
env.set("CHPL_GPU", "amd")
env.set("CHPL_GPU_ARCH", self.spec.variants["amdgpu_target"].value[0])
self.prepend_cpath_include(env, self.spec["hip"].prefix)
env.set("CHPL_ROCM_PATH", self.spec["llvm-amdgpu"].prefix)
self.set_lib_path(env, self.spec["hip"].prefix)
self.set_lib_path(env, self.spec["hsa-rocr-dev"].prefix)
env.set("CHPL_ROCM_PATH", self.spec["hip"].prefix)
self.update_lib_path(env, self.spec["hip"].prefix)
self.update_lib_path(env, self.spec["hsa-rocr-dev"].prefix)
self.setup_chpl_comm(env, self.spec)
def setup_build_environment(self, env):
@ -716,7 +733,7 @@ def setup_run_environment(self, env):
@llnl.util.lang.memoized
def _output_version_long(self):
if str(self.spec.version).lower() == "main":
return "2.2.0"
return "2.3.0"
spec_vers_str = str(self.spec.version.up_to(3))
return spec_vers_str
@ -724,7 +741,7 @@ def _output_version_long(self):
@llnl.util.lang.memoized
def _output_version_short(self):
if str(self.spec.version).lower() == "main":
return "2.2"
return "2.3"
spec_vers_str = str(self.spec.version.up_to(2))
return spec_vers_str