From dbcfa363754f84a043cafe6707b1e98112814e69 Mon Sep 17 00:00:00 2001 From: Manolis Papadakis Date: Thu, 6 Apr 2023 18:40:23 -0700 Subject: [PATCH 1/6] Always build (and require) Legion with python support and bindings --- cmake/Modules/legate_core_options.cmake | 1 - cmake/thirdparty/get_legion.cmake | 15 ++++++++++++--- conda/conda-build/build.sh | 3 +-- install.py | 1 - legate_core_cpp.cmake | 18 +++++------------- legate_core_python.cmake | 2 -- scripts/build-separately-no-install.sh | 2 -- 7 files changed, 18 insertions(+), 24 deletions(-) diff --git a/cmake/Modules/legate_core_options.cmake b/cmake/Modules/legate_core_options.cmake index 62fd1e7592..c9b8bf299e 100644 --- a/cmake/Modules/legate_core_options.cmake +++ b/cmake/Modules/legate_core_options.cmake @@ -49,7 +49,6 @@ option(Legion_USE_HDF5 "Enable support for HDF5" OFF) option(Legion_USE_CUDA "Enable Legion support for the CUDA runtime" OFF) option(Legion_NETWORKS "Networking backends to use (semicolon-separated)" "") option(Legion_USE_OpenMP "Use OpenMP" OFF) -option(Legion_USE_Python "Use Python" OFF) option(Legion_BOUNDS_CHECKS "Enable bounds checking in Legion accessors" OFF) if("${Legion_NETWORKS}" MATCHES ".*gasnet(1|ex).*") diff --git a/cmake/thirdparty/get_legion.cmake b/cmake/thirdparty/get_legion.cmake index 71ce33fb1e..721b41222d 100644 --- a/cmake/thirdparty/get_legion.cmake +++ b/cmake/thirdparty/get_legion.cmake @@ -195,19 +195,28 @@ function(find_or_configure_legion) "Legion_USE_CUDA ${Legion_USE_CUDA}" "Legion_NETWORKS ${Legion_NETWORKS}" "Legion_USE_OpenMP ${Legion_USE_OpenMP}" - "Legion_USE_Python ${Legion_USE_Python}" + "Legion_USE_Python ON" "Legion_BOUNDS_CHECKS ${Legion_BOUNDS_CHECKS}" ) endif() set(Legion_USE_CUDA ${Legion_USE_CUDA} PARENT_SCOPE) set(Legion_USE_OpenMP ${Legion_USE_OpenMP} PARENT_SCOPE) - set(Legion_USE_Python ${Legion_USE_Python} PARENT_SCOPE) set(Legion_NETWORKS ${Legion_NETWORKS} PARENT_SCOPE) + # Check that required Legion options are set + # for cases where we used an existing Legion installation + if(NOT Legion_USE_Python) + message(FATAL_ERROR "Legion was not compiled with Legion_USE_Python") + endif() + + # TODO: The following should also be checked, but are not currently reported by Legion: + # Legion_BUILD_BINDINGS + # Legion_REDOP_HALF + # Legion_REDOP_COMPLEX + message(VERBOSE "Legion_USE_CUDA=${Legion_USE_CUDA}") message(VERBOSE "Legion_USE_OpenMP=${Legion_USE_OpenMP}") - message(VERBOSE "Legion_USE_Python=${Legion_USE_Python}") message(VERBOSE "Legion_NETWORKS=${Legion_NETWORKS}") endfunction() diff --git a/conda/conda-build/build.sh b/conda/conda-build/build.sh index 317947dc4d..e0dae42394 100644 --- a/conda/conda-build/build.sh +++ b/conda/conda-build/build.sh @@ -9,8 +9,7 @@ CMAKE_ARGS+=" --log-level=VERBOSE -DBUILD_MARCH=haswell -DLegion_USE_OpenMP=ON --DLegion_USE_Python=ON --DLegion_BUILD_BINDINGS=ON" +" # We rely on an environment variable to determine if we need to build cpu-only bits if [ -z "$CPU_ONLY" ]; then diff --git a/install.py b/install.py index 25bf4e7992..fbdde7e836 100755 --- a/install.py +++ b/install.py @@ -436,7 +436,6 @@ def validate_path(path): -DLegion_USE_LLVM={("ON" if llvm else "OFF")} -DLegion_NETWORKS={";".join(networks)} -DLegion_USE_HDF5={("ON" if hdf else "OFF")} --DLegion_USE_Python=ON -DLegion_Python_Version={pyversion} -DLegion_REDOP_COMPLEX=ON -DLegion_REDOP_HALF=ON diff --git a/legate_core_cpp.cmake b/legate_core_cpp.cmake index 588a15b83b..d376940b94 100644 --- a/legate_core_cpp.cmake +++ b/legate_core_cpp.cmake @@ -89,11 +89,9 @@ macro(_enable_cuda_language) endif() endmacro() -if(Legion_USE_Python) - _find_package_Python3() - if(Python3_FOUND AND Python3_VERSION) - set(Legion_Python_Version ${Python3_VERSION}) - endif() +_find_package_Python3() +if(Python3_FOUND AND Python3_VERSION) + set(Legion_Python_Version ${Python3_VERSION}) endif() if(Legion_USE_CUDA) @@ -102,8 +100,8 @@ endif() ### # If we find Legion already configured on the system, it will report whether it -# was compiled with Python (Legion_USE_PYTHON), CUDA (Legion_USE_CUDA), OpenMP -# (Legion_USE_OpenMP), and networking (Legion_NETWORKS). +# was compiled with CUDA (Legion_USE_CUDA), OpenMP (Legion_USE_OpenMP), and +# networking (Legion_NETWORKS). # # We use the same variables as Legion because we want to enable/disable each of # these features based on how Legion was configured (it doesn't make sense to @@ -111,11 +109,6 @@ endif() ### include(cmake/thirdparty/get_legion.cmake) -# If Legion_USE_Python was toggled ON by find_package(Legion), find Python3 -if(Legion_USE_Python AND (NOT Python3_FOUND)) - _find_package_Python3() -endif() - if(Legion_NETWORKS) find_package(MPI REQUIRED COMPONENTS CXX) endif() @@ -458,7 +451,6 @@ endif() ]=] "set(Legion_USE_CUDA ${Legion_USE_CUDA})" "set(Legion_USE_OpenMP ${Legion_USE_OpenMP})" - "set(Legion_USE_Python ${Legion_USE_Python})" "set(Legion_NETWORKS ${Legion_NETWORKS})" "set(Legion_BOUNDS_CHECKS ${Legion_BOUNDS_CHECKS})" [=[ diff --git a/legate_core_python.cmake b/legate_core_python.cmake index 3c8b3e2346..0ad535a4d7 100644 --- a/legate_core_python.cmake +++ b/legate_core_python.cmake @@ -37,8 +37,6 @@ endif() if(NOT legate_core_FOUND) set(SKBUILD OFF) - set(Legion_USE_Python ON) - set(Legion_BUILD_BINDINGS ON) add_subdirectory(. "${CMAKE_CURRENT_SOURCE_DIR}/build") set(SKBUILD ON) endif() diff --git a/scripts/build-separately-no-install.sh b/scripts/build-separately-no-install.sh index e8d1e64c58..f82cc57e10 100755 --- a/scripts/build-separately-no-install.sh +++ b/scripts/build-separately-no-install.sh @@ -20,8 +20,6 @@ if [[ -n "$(which ninja)" ]]; then cmake_args+=" -GNinja"; fi cmake_args+=" -D Legion_USE_CUDA=ON -D Legion_USE_OpenMP=ON --D Legion_USE_Python=ON --D Legion_BUILD_BINDINGS=ON -D CMAKE_CUDA_ARCHITECTURES=NATIVE "; From e2671dd29ca5f9b882d3ebee7853d02dfa4a6a5e Mon Sep 17 00:00:00 2001 From: Manolis Papadakis Date: Thu, 6 Apr 2023 19:07:57 -0700 Subject: [PATCH 2/6] Move unconditional Legion configuration flags out of install.py --- cmake/thirdparty/get_legion.cmake | 3 +++ install.py | 9 +++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cmake/thirdparty/get_legion.cmake b/cmake/thirdparty/get_legion.cmake index 721b41222d..2aab1a53da 100644 --- a/cmake/thirdparty/get_legion.cmake +++ b/cmake/thirdparty/get_legion.cmake @@ -179,6 +179,7 @@ function(find_or_configure_legion) FIND_PACKAGE_ARGUMENTS EXACT EXCLUDE_FROM_ALL ${exclude_from_all} OPTIONS ${_legion_cuda_options} + "BUILD_SHARED_LIBS ON" "CMAKE_CXX_STANDARD ${_cxx_std}" "Legion_VERSION ${version}" "Legion_BUILD_BINDINGS ON" @@ -197,6 +198,8 @@ function(find_or_configure_legion) "Legion_USE_OpenMP ${Legion_USE_OpenMP}" "Legion_USE_Python ON" "Legion_BOUNDS_CHECKS ${Legion_BOUNDS_CHECKS}" + "Legion_BUILD_JUPYTER ON" + "Legion_EMBED_GASNet_CONFIGURE_ARGS --with-ibv-max-hcas=8" ) endif() diff --git a/install.py b/install.py index fbdde7e836..53206c43b7 100755 --- a/install.py +++ b/install.py @@ -420,11 +420,13 @@ def validate_path(path): if debug or verbose: cmake_flags += [f"--log-level={'DEBUG' if debug else 'VERBOSE'}"] + # NOTE: Any unconditional Legion configuration settings should be added to + # cmake/thirdparty/get_legion.cmake, so that pure-cmake builds will also + # pick them up. cmake_flags += f"""\ -DCMAKE_BUILD_TYPE={( "Debug" if debug else "RelWithDebInfo" if debug_release else "Release" )} --DBUILD_SHARED_LIBS=ON -DBUILD_MARCH={march} -DCMAKE_CUDA_ARCHITECTURES={arch} -DLegion_MAX_DIM={str(maxdim)} @@ -437,11 +439,6 @@ def validate_path(path): -DLegion_NETWORKS={";".join(networks)} -DLegion_USE_HDF5={("ON" if hdf else "OFF")} -DLegion_Python_Version={pyversion} --DLegion_REDOP_COMPLEX=ON --DLegion_REDOP_HALF=ON --DLegion_BUILD_BINDINGS=ON --DLegion_BUILD_JUPYTER=ON --DLegion_EMBED_GASNet_CONFIGURE_ARGS="--with-ibv-max-hcas=8" """.splitlines() if nccl_dir: From 1594c959616e1ee30d8d2e926aea8ce80389a74e Mon Sep 17 00:00:00 2001 From: Manolis Papadakis Date: Thu, 6 Apr 2023 19:08:57 -0700 Subject: [PATCH 3/6] Document major required Legion configuration flags --- install.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/install.py b/install.py index 53206c43b7..e50b3228d6 100755 --- a/install.py +++ b/install.py @@ -743,14 +743,18 @@ def driver(): dest="legion_dir", required=False, default=None, - help="Path to an existing Legion build directory.", + help="Path to an existing Legion build directory. A recent checkout " + "of the control_replication branch is required, configured with " + "Legion_BUILD_BINDINGS=ON, Legion_REDOP_HALF=ON, " + "Legion_REDOP_COMPLEX=ON, Legion_USE_Python=ON.", ) parser.add_argument( "--legion-src-dir", dest="legion_src_dir", required=False, default=None, - help="Path to an existing Legion source directory.", + help="Path to an existing Legion source directory. A recent checkout " + "of the control_replication branch is required.", ) parser.add_argument( "--legion-url", From bda225b5985081d7884783f5a15e97f968564238 Mon Sep 17 00:00:00 2001 From: Manolis Papadakis Date: Thu, 6 Apr 2023 19:24:08 -0700 Subject: [PATCH 4/6] Move the legion configuration check to the right place --- cmake/thirdparty/get_legion.cmake | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/cmake/thirdparty/get_legion.cmake b/cmake/thirdparty/get_legion.cmake index 2aab1a53da..41b32202d6 100644 --- a/cmake/thirdparty/get_legion.cmake +++ b/cmake/thirdparty/get_legion.cmake @@ -70,6 +70,16 @@ function(find_or_configure_legion) if(Legion_FOUND) message(STATUS "CPM: using local package Legion@${version}") + + # Check that required Legion options are set + if(NOT Legion_USE_Python) + message(FATAL_ERROR "Legion was not compiled with Legion_USE_Python") + endif() + + # TODO: The following should also be checked, but are not currently reported by Legion: + # Legion_BUILD_BINDINGS + # Legion_REDOP_HALF + # Legion_REDOP_COMPLEX else() include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/cpm_helpers.cmake) @@ -207,17 +217,6 @@ function(find_or_configure_legion) set(Legion_USE_OpenMP ${Legion_USE_OpenMP} PARENT_SCOPE) set(Legion_NETWORKS ${Legion_NETWORKS} PARENT_SCOPE) - # Check that required Legion options are set - # for cases where we used an existing Legion installation - if(NOT Legion_USE_Python) - message(FATAL_ERROR "Legion was not compiled with Legion_USE_Python") - endif() - - # TODO: The following should also be checked, but are not currently reported by Legion: - # Legion_BUILD_BINDINGS - # Legion_REDOP_HALF - # Legion_REDOP_COMPLEX - message(VERBOSE "Legion_USE_CUDA=${Legion_USE_CUDA}") message(VERBOSE "Legion_USE_OpenMP=${Legion_USE_OpenMP}") message(VERBOSE "Legion_NETWORKS=${Legion_NETWORKS}") From 640bf97b7e632ad65a3b6c0153b528eff13f50c9 Mon Sep 17 00:00:00 2001 From: Manolis Papadakis Date: Thu, 6 Apr 2023 19:26:46 -0700 Subject: [PATCH 5/6] Fix indentation --- conda/conda-build/build.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/conda/conda-build/build.sh b/conda/conda-build/build.sh index e0dae42394..113d5607b3 100644 --- a/conda/conda-build/build.sh +++ b/conda/conda-build/build.sh @@ -8,8 +8,7 @@ CMAKE_ARGS="$(echo "$CMAKE_ARGS" | sed -r "s@_INCLUDE=ONLY@_INCLUDE=BOTH@g")" CMAKE_ARGS+=" --log-level=VERBOSE -DBUILD_MARCH=haswell --DLegion_USE_OpenMP=ON -" +-DLegion_USE_OpenMP=ON" # We rely on an environment variable to determine if we need to build cpu-only bits if [ -z "$CPU_ONLY" ]; then From ee99cd19e24256600349c868e9c9268a0256f63e Mon Sep 17 00:00:00 2001 From: Manolis Papadakis Date: Fri, 7 Apr 2023 09:47:24 -0700 Subject: [PATCH 6/6] Can check REDOP_COMPLEX and REDOP_HALF using #defines --- cmake/thirdparty/get_legion.cmake | 2 -- src/legate_defines.h | 4 ++++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cmake/thirdparty/get_legion.cmake b/cmake/thirdparty/get_legion.cmake index 41b32202d6..766590fb04 100644 --- a/cmake/thirdparty/get_legion.cmake +++ b/cmake/thirdparty/get_legion.cmake @@ -78,8 +78,6 @@ function(find_or_configure_legion) # TODO: The following should also be checked, but are not currently reported by Legion: # Legion_BUILD_BINDINGS - # Legion_REDOP_HALF - # Legion_REDOP_COMPLEX else() include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/cpm_helpers.cmake) diff --git a/src/legate_defines.h b/src/legate_defines.h index 7c08bc3b1f..1920a4bebe 100644 --- a/src/legate_defines.h +++ b/src/legate_defines.h @@ -29,6 +29,10 @@ #define LEGATE_DEVICE_PREFIX #endif +#ifndef LEGION_REDOP_COMPLEX +#error "Legate needs Legion to be compiled with -DLEGION_REDOP_COMPLEX" +#endif + #ifndef LEGION_REDOP_HALF #error "Legate needs Legion to be compiled with -DLEGION_REDOP_HALF" #endif