legion: add missing build dependency and new variants (#44329)
* legion: add pip dependency for build
pip is needed for the build when the Legion Python binding is enabled
* legion: add variants for gc logging and system OpenMP use
This also removes the `cmake_cxx_flags` variable from `cmake_args()`
because that variable had no effect.
* [@spackbot] updating style on behalf of mpokorny
* legion: use spec.satisfies() in cmake_args()
e.g, replace use of '"+foo" in spec' with 'spec.satisfies("+foo")'
* legion: avoid configuring with multiple "-DLegion_REDOP_COMPLEX=ON" arguments
In the previous version, when both '+redop_complex' and '+bindings'
was set, two instances of "-DLegion_REDOP_COMPLEX=ON" arguments were
generated for cmake configuration.
* legion: fix value of "Legion_OUTPUT_LEVEL" for configuration
the previous version had no effect on setting the configuration value
---------
Co-authored-by: mpokorny <mpokorny@users.noreply.github.com>
			
			
This commit is contained in:
		| @@ -120,6 +120,8 @@ def patch(self): | |||||||
|     depends_on("python@3.8:", when="+python") |     depends_on("python@3.8:", when="+python") | ||||||
|     depends_on("py-cffi", when="+python") |     depends_on("py-cffi", when="+python") | ||||||
|     depends_on("py-numpy", when="+python") |     depends_on("py-numpy", when="+python") | ||||||
|  |     depends_on("py-pip", when="+python", type="build") | ||||||
|  | 
 | ||||||
|     depends_on("papi", when="+papi") |     depends_on("papi", when="+papi") | ||||||
|     depends_on("zlib-api", when="+zlib") |     depends_on("zlib-api", when="+zlib") | ||||||
| 
 | 
 | ||||||
| @@ -288,13 +290,17 @@ def validate_gasnet_root(value): | |||||||
| 
 | 
 | ||||||
|     depends_on("rust@1.74:", type="build", when="+prof") |     depends_on("rust@1.74:", type="build", when="+prof") | ||||||
| 
 | 
 | ||||||
|  |     variant("gc", default=False, description="Enable garbage collector logging") | ||||||
|  |     variant( | ||||||
|  |         "sysomp", default=False, description="Use system OpenMP implementation instead of Realm's" | ||||||
|  |     ) | ||||||
|  | 
 | ||||||
|     def cmake_args(self): |     def cmake_args(self): | ||||||
|         spec = self.spec |         spec = self.spec | ||||||
|         cmake_cxx_flags = [] |  | ||||||
|         from_variant = self.define_from_variant |         from_variant = self.define_from_variant | ||||||
|         options = [from_variant("CMAKE_CXX_STANDARD", "cxxstd")] |         options = [from_variant("CMAKE_CXX_STANDARD", "cxxstd")] | ||||||
| 
 | 
 | ||||||
|         if "network=gasnet" in spec: |         if spec.satisfies("network=gasnet"): | ||||||
|             options.append("-DLegion_NETWORKS=gasnetex") |             options.append("-DLegion_NETWORKS=gasnetex") | ||||||
|             if spec.variants["gasnet_root"].value != "none": |             if spec.variants["gasnet_root"].value != "none": | ||||||
|                 gasnet_dir = spec.variants["gasnet_root"].value |                 gasnet_dir = spec.variants["gasnet_root"].value | ||||||
| @@ -313,109 +319,105 @@ def cmake_args(self): | |||||||
|             else: |             else: | ||||||
|                 options.append("-DGASNet_CONDUIT=%s" % gasnet_conduit) |                 options.append("-DGASNet_CONDUIT=%s" % gasnet_conduit) | ||||||
| 
 | 
 | ||||||
|             if "+gasnet_debug" in spec: |             if spec.satisfies("+gasnet_debug"): | ||||||
|                 options.append("-DLegion_EMBED_GASNet_CONFIGURE_ARGS=--enable-debug") |                 options.append("-DLegion_EMBED_GASNet_CONFIGURE_ARGS=--enable-debug") | ||||||
|         elif "network=mpi" in spec: |         elif spec.satisfies("network=mpi"): | ||||||
|             options.append("-DLegion_NETWORKS=mpi") |             options.append("-DLegion_NETWORKS=mpi") | ||||||
|         elif "network=ucx" in spec: |         elif spec.satisfies("network=ucx"): | ||||||
|             options.append("-DLegion_NETWORKS=ucx") |             options.append("-DLegion_NETWORKS=ucx") | ||||||
|         else: |         else: | ||||||
|             options.append("-DLegion_EMBED_GASNet=OFF") |             options.append("-DLegion_EMBED_GASNet=OFF") | ||||||
| 
 | 
 | ||||||
|         if "+shared" in spec: |         if spec.satisfies("+shared"): | ||||||
|             options.append("-DBUILD_SHARED_LIBS=ON") |             options.append("-DBUILD_SHARED_LIBS=ON") | ||||||
|         else: |         else: | ||||||
|             options.append("-DBUILD_SHARED_LIBS=OFF") |             options.append("-DBUILD_SHARED_LIBS=OFF") | ||||||
| 
 | 
 | ||||||
|         if "+bounds_checks" in spec: |         if spec.satisfies("+bounds_checks"): | ||||||
|             # default is off. |             # default is off. | ||||||
|             options.append("-DLegion_BOUNDS_CHECKS=ON") |             options.append("-DLegion_BOUNDS_CHECKS=ON") | ||||||
|         if "+privilege_checks" in spec: |         if spec.satisfies("+privilege_checks"): | ||||||
|             # default is off. |             # default is off. | ||||||
|             options.append("-DLegion_PRIVILEGE_CHECKS=ON") |             options.append("-DLegion_PRIVILEGE_CHECKS=ON") | ||||||
|         if "output_level" in spec: | 
 | ||||||
|             level = str.upper(spec.variants["output_level"].value) |         options.append(f"-DLegion_OUTPUT_LEVEL={str.upper(spec.variants['output_level'].value)}") | ||||||
|             options.append("-DLegion_OUTPUT_LEVEL=%s" % level) | 
 | ||||||
|         if "+spy" in spec: |         if spec.satisfies("+spy"): | ||||||
|             # default is off. |             # default is off. | ||||||
|             options.append("-DLegion_SPY=ON") |             options.append("-DLegion_SPY=ON") | ||||||
| 
 | 
 | ||||||
|         if "+cuda" in spec: |         if spec.satisfies("+cuda"): | ||||||
|             cuda_arch = spec.variants["cuda_arch"].value |             cuda_arch = spec.variants["cuda_arch"].value | ||||||
|             options.append("-DLegion_USE_CUDA=ON") |             options.append("-DLegion_USE_CUDA=ON") | ||||||
|             options.append("-DLegion_GPU_REDUCTIONS=ON") |             options.append("-DLegion_GPU_REDUCTIONS=ON") | ||||||
|             options.append("-DLegion_CUDA_ARCH=%s" % cuda_arch) |             options.append("-DLegion_CUDA_ARCH=%s" % cuda_arch) | ||||||
|             if "+cuda_hijack" in spec: |             if spec.satisfies("+cuda_hijack"): | ||||||
|                 options.append("-DLegion_HIJACK_CUDART=ON") |                 options.append("-DLegion_HIJACK_CUDART=ON") | ||||||
|             else: |             else: | ||||||
|                 options.append("-DLegion_HIJACK_CUDART=OFF") |                 options.append("-DLegion_HIJACK_CUDART=OFF") | ||||||
| 
 | 
 | ||||||
|             if "+cuda_unsupported_compiler" in spec: |             if spec.satisfies("+cuda_unsupported_compiler"): | ||||||
|                 options.append("-DCUDA_NVCC_FLAGS:STRING=--allow-unsupported-compiler") |                 options.append("-DCUDA_NVCC_FLAGS:STRING=--allow-unsupported-compiler") | ||||||
| 
 | 
 | ||||||
|         if "+rocm" in spec: |         if spec.satisfies("+rocm"): | ||||||
|             options.append("-DLegion_USE_HIP=ON") |             options.append("-DLegion_USE_HIP=ON") | ||||||
|             options.append("-DLegion_GPU_REDUCTIONS=ON") |             options.append("-DLegion_GPU_REDUCTIONS=ON") | ||||||
|             options.append(from_variant("Legion_HIP_TARGET", "hip_target")) |             options.append(from_variant("Legion_HIP_TARGET", "hip_target")) | ||||||
|             options.append(from_variant("Legion_HIP_ARCH", "amdgpu_target")) |             options.append(from_variant("Legion_HIP_ARCH", "amdgpu_target")) | ||||||
|             options.append(from_variant("Legion_HIJACK_HIP", "hip_hijack")) |             options.append(from_variant("Legion_HIJACK_HIP", "hip_hijack")) | ||||||
|             if "@23.03.0:23.12.0" in spec: |             if spec.satisfies("@23.03.0:23.12.0"): | ||||||
|                 options.append(self.define("HIP_PATH", f"{spec['hip'].prefix}/hip")) |                 options.append(self.define("HIP_PATH", f"{spec['hip'].prefix}/hip")) | ||||||
|             else: |             else: | ||||||
|                 options.append(self.define("ROCM_PATH", spec["hip"].prefix)) |                 options.append(self.define("ROCM_PATH", spec["hip"].prefix)) | ||||||
| 
 | 
 | ||||||
|         if "+fortran" in spec: |         if spec.satisfies("+fortran"): | ||||||
|             # default is off. |             # default is off. | ||||||
|             options.append("-DLegion_USE_Fortran=ON") |             options.append("-DLegion_USE_Fortran=ON") | ||||||
| 
 | 
 | ||||||
|         if "+hdf5" in spec: |         if spec.satisfies("+hdf5"): | ||||||
|             # default is off. |             # default is off. | ||||||
|             options.append("-DLegion_USE_HDF5=ON") |             options.append("-DLegion_USE_HDF5=ON") | ||||||
| 
 | 
 | ||||||
|         if "+hwloc" in spec: |         if spec.satisfies("+hwloc"): | ||||||
|             # default is off. |             # default is off. | ||||||
|             options.append("-DLegion_USE_HWLOC=ON") |             options.append("-DLegion_USE_HWLOC=ON") | ||||||
| 
 | 
 | ||||||
|         if "+kokkos" in spec: |         if spec.satisfies("+kokkos"): | ||||||
|             # default is off. |             # default is off. | ||||||
|             options.append("-DLegion_USE_Kokkos=ON") |             options.append("-DLegion_USE_Kokkos=ON") | ||||||
|             os.environ["KOKKOS_CXX_COMPILER"] = spec["kokkos"].kokkos_cxx |             os.environ["KOKKOS_CXX_COMPILER"] = spec["kokkos"].kokkos_cxx | ||||||
| 
 | 
 | ||||||
|         if "+libdl" in spec: |         if spec.satisfies("+libdl"): | ||||||
|             # default is on. |             # default is on. | ||||||
|             options.append("-DLegion_USE_LIBDL=ON") |             options.append("-DLegion_USE_LIBDL=ON") | ||||||
|         else: |         else: | ||||||
|             options.append("-DLegion_USE_LIBDL=OFF") |             options.append("-DLegion_USE_LIBDL=OFF") | ||||||
| 
 | 
 | ||||||
|         if "+openmp" in spec: |         if spec.satisfies("+openmp"): | ||||||
|             # default is off. |             # default is off. | ||||||
|             options.append("-DLegion_USE_OpenMP=ON") |             options.append("-DLegion_USE_OpenMP=ON") | ||||||
| 
 | 
 | ||||||
|         if "+papi" in spec: |         if spec.satisfies("+papi"): | ||||||
|             # default is off. |             # default is off. | ||||||
|             options.append("-DLegion_USE_PAPI=ON") |             options.append("-DLegion_USE_PAPI=ON") | ||||||
| 
 | 
 | ||||||
|         if "+python" in spec: |         if spec.satisfies("+python"): | ||||||
|             # default is off. |             # default is off. | ||||||
|             options.append("-DLegion_USE_Python=ON") |             options.append("-DLegion_USE_Python=ON") | ||||||
| 
 | 
 | ||||||
|         if "+zlib" in spec: |         if spec.satisfies("+zlib"): | ||||||
|             # default is on. |             # default is on. | ||||||
|             options.append("-DLegion_USE_ZLIB=ON") |             options.append("-DLegion_USE_ZLIB=ON") | ||||||
|         else: |         else: | ||||||
|             options.append("-DLegion_USE_ZLIB=OFF") |             options.append("-DLegion_USE_ZLIB=OFF") | ||||||
| 
 | 
 | ||||||
|         if "+redop_complex" in spec: |         if spec.satisfies("+bindings"): | ||||||
|             # default is off. |  | ||||||
|             options.append("-DLegion_REDOP_COMPLEX=ON") |  | ||||||
| 
 |  | ||||||
|         if "+bindings" in spec: |  | ||||||
|             # default is off. |             # default is off. | ||||||
|             options.append("-DLegion_BUILD_BINDINGS=ON") |             options.append("-DLegion_BUILD_BINDINGS=ON") | ||||||
|             options.append("-DLegion_REDOP_COMPLEX=ON")  # required for bindings |  | ||||||
| 
 | 
 | ||||||
|         if spec.variants["build_type"].value == "Debug": |         if spec.satisfies("+redop_complex") or spec.satisfies("+bindings"): | ||||||
|             cmake_cxx_flags.extend(["-DDEBUG_REALM", "-DDEBUG_LEGION", "-ggdb"]) |             # default is off; required for bindings. | ||||||
|  |             options.append("-DLegion_REDOP_COMPLEX=ON") | ||||||
| 
 | 
 | ||||||
|         maxdims = int(spec.variants["max_dims"].value) |         maxdims = int(spec.variants["max_dims"].value) | ||||||
|         # TODO: sanity check if maxdims < 0 || > 9??? |         # TODO: sanity check if maxdims < 0 || > 9??? | ||||||
| @@ -446,6 +448,13 @@ def cmake_args(self): | |||||||
|         # This disables Legion's CMake build system's logic for targeting the native |         # This disables Legion's CMake build system's logic for targeting the native | ||||||
|         # CPU architecture in favor of Spack-provided compiler flags |         # CPU architecture in favor of Spack-provided compiler flags | ||||||
|         options.append("-DBUILD_MARCH:STRING=") |         options.append("-DBUILD_MARCH:STRING=") | ||||||
|  | 
 | ||||||
|  |         if spec.satisfies("+openmp +sysomp"): | ||||||
|  |             options.append("-DLegion_OpenMP_SYSTEM_RUNTIME=ON") | ||||||
|  | 
 | ||||||
|  |         if spec.satisfies("+gc"): | ||||||
|  |             options.append("-DCMAKE_CXX_FLAGS=-DLEGION_GC") | ||||||
|  | 
 | ||||||
|         return options |         return options | ||||||
| 
 | 
 | ||||||
|     def build(self, spec, prefix): |     def build(self, spec, prefix): | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Martin Pokorny
					Martin Pokorny