Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEA] Add initial CMakeLists.txt #198

Closed
wants to merge 172 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
172 commits
Select commit Hold shift + click to select a range
3c62325
add initial CMakeLists.txt
trxcllnt Apr 15, 2022
edaaa64
Merge branch 'branch-22.05' of github.com:nv-legate/legate.core into …
trxcllnt Apr 19, 2022
bb9d71c
initialize CMake vars with fallbacks to envvars or default values
trxcllnt Apr 26, 2022
3b6cb9d
set CMake policy to fix issue when -DLegion_USE_LLVM=ON with -DLegion…
trxcllnt Apr 26, 2022
128ece2
call cmake_policy() too
trxcllnt Apr 26, 2022
4853690
Merge branch 'branch-22.05' of github.com:nv-legate/legate.core into …
trxcllnt Apr 26, 2022
ca467b7
Update c++ version, add new src/headers/compiler defs
trxcllnt Apr 26, 2022
bca6ea3
* Initialize CMAKE_CUDA_ARCHITECTURES from the legacy GPU_ARCHS envvar
trxcllnt Apr 29, 2022
ad3e1af
add missing legion library aliases
trxcllnt Apr 29, 2022
c30d94f
remove Legion workarounds
trxcllnt May 3, 2022
241c272
set Legion_VERSION to legate.core version so find_package generates t…
trxcllnt May 3, 2022
822b34e
use realm_defines and legion_defines from the build dir if it's defined
trxcllnt May 3, 2022
959a683
Merge branch 'branch-22.07' of github.com:nv-legate/legate.core into …
trxcllnt May 25, 2022
2feed33
print warning when Legion_HIJACK_CUDART is true, use Legion's BUILD_M…
trxcllnt May 26, 2022
46af220
Merge branch 'branch-22.07' of github.com:nv-legate/legate.core into …
trxcllnt May 26, 2022
bec12e3
add new-install.py that uses CMake
trxcllnt May 26, 2022
9cf0384
Merge branch 'branch-22.07' of github.com:nv-legate/legate.core into …
trxcllnt May 27, 2022
a4ed9e9
Merge branch 'fea/add-cmake' into fea/install-py-uses-cmake
trxcllnt May 27, 2022
b1f4e8f
incorporate latest 22.07 changes
trxcllnt May 27, 2022
47a43ae
promote flags to out_var in outer scope
trxcllnt May 27, 2022
1a548ee
Merge branch 'fea/add-cmake' into fea/install-py-uses-cmake
trxcllnt May 27, 2022
b81948c
get new-install.py working
trxcllnt May 27, 2022
eaa6d0d
update version numbers
trxcllnt May 27, 2022
dffddc5
auto-detect conda envs
trxcllnt May 27, 2022
13e7481
support linking cudart statically and dynamically
trxcllnt May 27, 2022
090a127
Merge branch 'fea/add-cmake' into fea/install-py-uses-cmake
trxcllnt May 27, 2022
ebb2da5
replace install.py with new-install.py
trxcllnt May 27, 2022
8e1a646
pass extra args to legion's setup.py install rule
trxcllnt May 28, 2022
5f638a5
pass extra args to legion's setup.py install rule
trxcllnt May 28, 2022
92b82f8
guard against RealmRuntime and LegionRuntime targets not existing
trxcllnt Jun 1, 2022
2edb0f1
Merge branch 'fea/add-cmake' into fea/install-py-uses-cmake
trxcllnt Jun 1, 2022
ba31558
fully support building without CUDA and OpenMP
trxcllnt Jun 4, 2022
8316850
fix initialization of CUDA architectures
trxcllnt Jun 4, 2022
546ba24
print messages for CI
trxcllnt Jun 4, 2022
f6f6f04
Merge branch 'fea/add-cmake' into fea/install-py-uses-cmake
trxcllnt Jun 4, 2022
2185266
adjust -isystem flag to support clangd
trxcllnt Jun 4, 2022
6237c67
adjust -isystem flag to support clangd
trxcllnt Jun 4, 2022
51d6491
Merge branch 'fea/add-cmake' into fea/install-py-uses-cmake
trxcllnt Jun 4, 2022
9dea844
Merge branch 'branch-22.07' of github.com:nv-legate/legate.core into …
trxcllnt Jun 4, 2022
0dde34c
Merge branch 'branch-22.07' of github.com:nv-legate/legate.core into …
trxcllnt Jun 4, 2022
0eb09e1
Merge branch 'fea/add-cmake' into fea/install-py-uses-cmake
trxcllnt Jun 4, 2022
1024e97
set CUDA_PATH for Legion's FindCUDA
trxcllnt Jun 4, 2022
f95ac9e
Merge branch 'fea/add-cmake' into fea/install-py-uses-cmake
trxcllnt Jun 4, 2022
a925c90
guard setting newer cmake policies
trxcllnt Jun 6, 2022
416feea
accommodate Legion's FindCUDA.cmake on CPU-only builds
trxcllnt Jun 6, 2022
e16dc35
Merge branch 'fea/add-cmake' into fea/install-py-uses-cmake
trxcllnt Jun 6, 2022
193b028
fix build flags for make
trxcllnt Jun 6, 2022
d56a387
add missing include
trxcllnt Jun 6, 2022
85b99ac
Merge branch 'fea/add-cmake' into fea/install-py-uses-cmake
trxcllnt Jun 6, 2022
20d7dfd
fix include
trxcllnt Jun 6, 2022
6b08747
Merge branch 'fea/add-cmake' into fea/install-py-uses-cmake
trxcllnt Jun 6, 2022
5765981
detect and set CMAKE_LIBRARY_PATH from LIBRARY_PATH envvar
trxcllnt Jun 6, 2022
fa55082
Merge branch 'fea/add-cmake' into fea/install-py-uses-cmake
trxcllnt Jun 6, 2022
3076c8f
Toggle Python, CUDA, OpenMP, and GASNet based on the found Legion pac…
trxcllnt Jun 6, 2022
5f74cb6
Merge branch 'fea/add-cmake' into fea/install-py-uses-cmake
trxcllnt Jun 6, 2022
80ce103
write config values to legate_core-config.cmake for package consumers
trxcllnt Jun 7, 2022
451d4ad
Merge branch 'fea/add-cmake' into fea/install-py-uses-cmake
trxcllnt Jun 7, 2022
8a14562
fix CMAKE_CUDA_ARCHITECTURES parsing
trxcllnt Jun 7, 2022
8b621a3
Merge branch 'fea/add-cmake' into fea/install-py-uses-cmake
trxcllnt Jun 7, 2022
2636813
print message when Legion is found
trxcllnt Jun 7, 2022
ac376f4
Merge branch 'fea/add-cmake' into fea/install-py-uses-cmake
trxcllnt Jun 7, 2022
63dde5d
combine multiple conditional blocks into one
trxcllnt Jun 7, 2022
f61da7d
Merge branch 'fea/add-cmake' into fea/install-py-uses-cmake
trxcllnt Jun 7, 2022
ff60f3a
pass thrust_dir to CMake
trxcllnt Jun 7, 2022
589c070
add versions.json file to control versions of rapids-cmake preconfigu…
trxcllnt Jun 8, 2022
ada4011
Merge branch 'fea/add-cmake' into fea/install-py-uses-cmake
trxcllnt Jun 8, 2022
c73bcd9
remove unnecessary line
trxcllnt Jun 8, 2022
f1e1836
remove unnecessary line
trxcllnt Jun 8, 2022
d53bdc7
Merge branch 'branch-22.07' of github.com:nv-legate/legate.core into …
trxcllnt Jun 14, 2022
de6b3d7
Speed up FetchContent_Populate by downloading a tarball (if possible)…
trxcllnt Jun 14, 2022
224f9e6
make required CMake version match conda-forge's CMake
trxcllnt Jun 14, 2022
25cd318
Merge branch 'fea/add-cmake' into fea/install-py-uses-cmake
trxcllnt Jun 14, 2022
ff713bd
specify install dir with --prefix flag
trxcllnt Jun 15, 2022
1331266
place libraries in build/lib
trxcllnt Jun 15, 2022
bd92329
Merge branch 'fea/add-cmake' into fea/install-py-uses-cmake
trxcllnt Jun 15, 2022
1b5e556
add target to preprocess legate_c.h for use with Python CFFI
trxcllnt Jun 15, 2022
c44461c
Merge branch 'fea/add-cmake' into fea/install-py-uses-cmake
trxcllnt Jun 15, 2022
1a28f32
use the preprocessed legate_c.h.i generated by CMake instead of doing…
trxcllnt Jun 15, 2022
bc7b3bc
remove dead code
trxcllnt Jun 15, 2022
3e1043a
Merge branch 'branch-22.07' of github.com:nv-legate/legate.core into …
trxcllnt Jun 15, 2022
c620f15
Merge branch 'branch-22.07' of github.com:nv-legate/legate.core into …
trxcllnt Jun 15, 2022
695e279
add latest sources and headers
trxcllnt Jun 15, 2022
924028e
Merge branch 'fea/add-cmake' into fea/install-py-uses-cmake
trxcllnt Jun 15, 2022
ae8d07c
convert setup.py to use scikit-build
trxcllnt Jun 15, 2022
64b2d88
clean up legate binary
trxcllnt Jun 16, 2022
a8d1130
Merge branch 'fea/install-py-uses-cmake-wip' into fea/install-py-uses…
trxcllnt Jun 16, 2022
da6874f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 16, 2022
83392a5
rename skbuild.cmake -> legate_core_python.cmake
trxcllnt Jun 20, 2022
5cbc713
remove cutensor from build dependencies as it isn't used
trxcllnt Jun 20, 2022
2e93320
raise exception if _deps/legion-src doesn't exist
trxcllnt Jun 20, 2022
715f21c
fix gitlab archive URI for branches with slashes in the name
trxcllnt Jun 21, 2022
0b6974e
Merge branch 'fea/add-cmake' into fea/install-py-uses-cmake
trxcllnt Jun 21, 2022
2974985
fix lint
trxcllnt Jun 21, 2022
b2d9b26
remove cutensor from `install_requires`
trxcllnt Jun 21, 2022
54bd7e0
make install_info a package so it can be excluded by setuptools
trxcllnt Jun 21, 2022
172c689
fix typo
trxcllnt Jun 22, 2022
59af0bf
allow overriding Legion_PYTHON_EXTRA_INSTALL_ARGS
trxcllnt Jul 1, 2022
791f187
set Legion_USE_PYTHON to ON when configuring via scikit-build
trxcllnt Jul 1, 2022
ea44df0
support a variety of Legion and legate_core paths
trxcllnt Jul 1, 2022
ab171ae
Build Legion python bindings when building w/ scikit-build
trxcllnt Jul 1, 2022
140dd53
handle the installed case
trxcllnt Jul 1, 2022
8230628
invoke setup.py via python -m pip install .
trxcllnt Jul 1, 2022
a288892
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 1, 2022
9ceba46
add --no-deps and --no-build-isolation only if doing an editable install
trxcllnt Jul 1, 2022
b424065
Merge branch 'fea/install-py-uses-cmake' of github.com:trxcllnt/legat…
trxcllnt Jul 1, 2022
7225617
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 1, 2022
2af880d
rename back to install_info.py.in
trxcllnt Jul 6, 2022
93ca2c9
rename LEGATE_CORE_ options to legate_core_
trxcllnt Jul 6, 2022
d094b59
ignore _cmake_test_compile_ dirs
trxcllnt Jul 6, 2022
6730237
remove cython and versioneer, add ninja to pyproject.toml's build-sys…
trxcllnt Jul 6, 2022
4d1b488
Delete __init__.py
trxcllnt Jul 6, 2022
c08fb92
update install.py to use ninja, work around Legion's Python bindings …
trxcllnt Jul 6, 2022
e994df0
update legate launcher to handle local no-install builds
trxcllnt Jul 6, 2022
8e04cc6
add build script examples
trxcllnt Jul 6, 2022
da075b0
remove old setup.py
trxcllnt Jul 6, 2022
9aaaea0
Merge pull request #1 from trxcllnt/fea/install-py-uses-cmake
trxcllnt Jul 6, 2022
781d59f
Merge branch 'branch-22.07' of github.com:nv-legate/legate.core into …
trxcllnt Jul 6, 2022
28b7dce
remove redundant code
trxcllnt Jul 6, 2022
18d0e4b
remove redundant version check
trxcllnt Jul 6, 2022
f115a41
cleanup
trxcllnt Jul 6, 2022
d65fb1e
pass script name down to read-legion-root.sh
trxcllnt Jul 6, 2022
84eecad
build legion_core C++ into ${cmake_current_source_dir}/build
trxcllnt Jul 7, 2022
5ba1f12
clean cpp build dir, remove dead code
trxcllnt Jul 7, 2022
3875b7f
export LIBRARY_PATH if not set
trxcllnt Jul 7, 2022
fab14cb
resolve relative path in build scripts
trxcllnt Jul 7, 2022
1a26f06
add __future__ imports back in
trxcllnt Jul 7, 2022
9e3223c
don't use defaults
trxcllnt Jul 7, 2022
ea6f87d
use Readline so tab completion works
trxcllnt Jul 7, 2022
076abd8
set CMAKE_BUILD_PARALLEL_LEVEL
trxcllnt Jul 7, 2022
335ebab
fix get_libpath
trxcllnt Jul 7, 2022
02b0509
exec numactl in bind.sh
trxcllnt Jul 8, 2022
16db1c3
Merge branch 'branch-22.07' of github.com:nv-legate/legate.core into …
trxcllnt Jul 11, 2022
5328f34
set optimization level -O2
trxcllnt Jul 12, 2022
44bb111
ensure CUDA architectures are set correctly
trxcllnt Jul 12, 2022
1653bab
ensure CUDA architectures are detected correctly
trxcllnt Jul 12, 2022
bcd3de3
detect CUDA archs before building Legion so we can pass the appropria…
trxcllnt Jul 12, 2022
30e39a9
Merge branch 'branch-22.07' of github.com:nv-legate/legate.core into …
trxcllnt Jul 13, 2022
d329108
use --upgrade instead of --force-install
trxcllnt Jul 13, 2022
7b8d9ac
remove todo
trxcllnt Jul 13, 2022
7f9ade6
make _find_package_Python3 a macro
trxcllnt Jul 13, 2022
c6a90b4
find exact Legion and legate_core package versions
trxcllnt Jul 13, 2022
9d84ee2
do pip install --upgrade if not editable
trxcllnt Jul 13, 2022
e88af88
set REQUIRED if Legion_ROOT is defined
trxcllnt Jul 14, 2022
05a1ab4
update conda recipe to use CMake and scikit-build
trxcllnt Jul 14, 2022
14082b6
add example conda build script
trxcllnt Jul 19, 2022
f627dcc
build conda package into legate_core subdirectory
trxcllnt Jul 19, 2022
71e1a58
pin __cuda
trxcllnt Jul 19, 2022
ab4ea9c
move __cuda metapackage pin to run_constrained
trxcllnt Jul 19, 2022
269b74e
install llvm-openmp not openmp
trxcllnt Jul 19, 2022
4dff803
remove --prefix-length arg
trxcllnt Jul 19, 2022
71c9eab
Merge branch 'branch-22.07' of github.com:nv-legate/legate.core into …
trxcllnt Jul 19, 2022
a1c0991
Fixes for Legion sub-build
jjwilke Jul 22, 2022
2702a35
Merge pull request #2 from jjwilke/fea/add-cmake
trxcllnt Jul 22, 2022
de03e0a
Merge branch 'fea/add-cmake' of github.com:trxcllnt/legate.core into …
trxcllnt Jul 22, 2022
5ecf506
default CMAKE_CUDA_ARCHITECTURES to NATIVE
trxcllnt Jul 22, 2022
1d5321b
fix typo
trxcllnt Jul 22, 2022
6e9dcfe
Merge branch 'branch-22.07' of github.com:nv-legate/legate.core into …
trxcllnt Jul 22, 2022
7338a77
move make/cmake/ninja to build requirements
trxcllnt Jul 22, 2022
7a0f1ad
add build and runtime dependencies to dev conda envs
trxcllnt Jul 22, 2022
40815aa
remove legion_helpers.cmake
trxcllnt Jul 25, 2022
d2027cd
ensure CUDA language is enabled if we find a Legion built with CUDA s…
trxcllnt Jul 28, 2022
c3f908b
clean up flow of CUDA enable logic with Legion
jjwilke Jul 28, 2022
23bae1c
Merge pull request #3 from jjwilke/fea/add-cmake
trxcllnt Jul 28, 2022
7956958
Merge branch 'branch-22.07' of github.com:nv-legate/legate.core into …
trxcllnt Aug 3, 2022
b1d01cd
force CMAKE_BUILD_TYPE Release if building Legion
trxcllnt Aug 3, 2022
eae2b36
fix hijack cudart default value
jjwilke Aug 4, 2022
5e02a2d
fix mypy pre-commit errors
jjwilke Aug 4, 2022
4987186
don't force CMAKE_BUILD_TYPE to be Release for Legion builds
trxcllnt Aug 9, 2022
921f767
Merge branch 'fea/add-cmake' of github.com:trxcllnt/legate.core into …
trxcllnt Aug 9, 2022
21abaf4
only pass `--root /` when also passing `--prefix`
trxcllnt Aug 15, 2022
0050338
Merge branch 'branch-22.10' of github.com:nv-legate/legate.core into …
trxcllnt Aug 15, 2022
e0581d3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 15, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
legate/_version.py export-subst
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,16 @@
*.json
*.dylib
legate/core/install_info.py
/dist
/build
/legion
/install*
/_skbuild
config.mk
/docs/legate/core/build
/docs/legate/core/source/api/generated
*.egg-info
.cache
.vscode
_cmake_test_compile
!cmake/versions.json
71 changes: 71 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#=============================================================================
# Copyright 2022 NVIDIA Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#=============================================================================

cmake_minimum_required(VERSION 3.22.1 FATAL_ERROR)

if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.13)
cmake_policy(SET CMP0077 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
endif()

if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.16)
cmake_policy(SET CMP0096 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0096 NEW)
endif()

if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.21)
cmake_policy(SET CMP0126 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0126 NEW)
endif()

##############################################################################
# - Download and initialize RAPIDS CMake helpers -----------------------------

if(NOT EXISTS ${CMAKE_BINARY_DIR}/RAPIDS.cmake)
file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-22.08/RAPIDS.cmake
${CMAKE_BINARY_DIR}/RAPIDS.cmake)
endif()
include(${CMAKE_BINARY_DIR}/RAPIDS.cmake)
include(rapids-cmake)
include(rapids-cpm)
include(rapids-cuda)
include(rapids-export)
include(rapids-find)

set(legate_core_version 22.07.00)

# For now we want the optimization flags to match on both normal make and cmake
# builds so we override the cmake defaults here for release, this changes
# -O3 to -O2 and removes -DNDEBUG
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
set(CMAKE_CUDA_FLAGS_RELEASE "-O2")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
set(CMAKE_CUDA_FLAGS_RELWITHDEBINFO "-O2 -g")

if(NOT SKBUILD)
project(legate_core VERSION ${legate_core_version} LANGUAGES C CXX)
include(${CMAKE_CURRENT_SOURCE_DIR}/legate_core_cpp.cmake)
else()
project(
legate_core_python
VERSION ${legate_core_version}
LANGUAGES # TODO: Building Python extension modules via the python_extension_module requires the C
# language to be enabled here. The test project that is built in scikit-build to verify
# various linking options for the python library is hardcoded to build with C, so until
# that is fixed we need to keep C.
C CXX)
include(${CMAKE_CURRENT_SOURCE_DIR}/legate_core_python.cmake)
endif()
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include versioneer.py
include legate/_version.py
2 changes: 1 addition & 1 deletion bind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,4 @@ if [[ -n "${NICS+x}" ]]; then
;;
esac
fi
numactl "$@"
exec numactl "$@"
53 changes: 53 additions & 0 deletions cmake/Modules/cpm_helpers.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#=============================================================================
# Copyright 2022 NVIDIA Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#=============================================================================

function(get_cpm_git_args _out_var)

set(oneValueArgs TAG BRANCH REPOSITORY)
cmake_parse_arguments(GIT "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})

set(repo_tag "")
set(gh_tag_prefix "")
# Default to specifying `GIT_REPOSITORY` and `GIT_TAG`
set(cpm_git_args GIT_REPOSITORY ${GIT_REPOSITORY})

if(GIT_BRANCH)
set(gh_tag_prefix "heads")
set(repo_tag "${GIT_BRANCH}")
list(APPEND cpm_git_args GIT_TAG ${GIT_BRANCH})
elseif(GIT_TAG)
set(gh_tag_prefix "tags")
set(repo_tag "${GIT_TAG}")
list(APPEND cpm_git_args GIT_TAG ${GIT_TAG})
endif()

# Remove `.git` suffix from repo URL
if(GIT_REPOSITORY MATCHES "^(.*)(\.git)$")
set(GIT_REPOSITORY "${CMAKE_MATCH_1}")
endif()
if(GIT_REPOSITORY MATCHES "github\.com")
# If retrieving from github use `.zip` URL to download faster
set(cpm_git_args URL "${GIT_REPOSITORY}/archive/refs/${gh_tag_prefix}/${repo_tag}.zip")
elseif(GIT_REPOSITORY MATCHES "gitlab\.com")
# GitLab archive URIs replace slashes with dashes
string(REPLACE "/" "-" archive_tag "${repo_tag}")
# If retrieving from gitlab use `.zip` URL to download faster
set(cpm_git_args URL "${GIT_REPOSITORY}/-/archive/${repo_tag}/legion-${archive_tag}.zip")
endif()

set(${_out_var} ${cpm_git_args} PARENT_SCOPE)

endfunction()
88 changes: 88 additions & 0 deletions cmake/Modules/cuda_arch_helpers.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#=============================================================================
# Copyright 2022 NVIDIA Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#=============================================================================

function(set_cuda_arch_from_names)
set(cuda_archs "")
# translate legacy arch names into numbers
if(CMAKE_CUDA_ARCHITECTURES MATCHES "fermi")
trxcllnt marked this conversation as resolved.
Show resolved Hide resolved
list(APPEND cuda_archs 20)
endif()
if(CMAKE_CUDA_ARCHITECTURES MATCHES "kepler")
list(APPEND cuda_archs 30)
endif()
if(CMAKE_CUDA_ARCHITECTURES MATCHES "k20")
list(APPEND cuda_archs 35)
endif()
if(CMAKE_CUDA_ARCHITECTURES MATCHES "k80")
list(APPEND cuda_archs 37)
endif()
if(CMAKE_CUDA_ARCHITECTURES MATCHES "maxwell")
list(APPEND cuda_archs 52)
endif()
if(CMAKE_CUDA_ARCHITECTURES MATCHES "pascal")
list(APPEND cuda_archs 60)
endif()
if(CMAKE_CUDA_ARCHITECTURES MATCHES "volta")
list(APPEND cuda_archs 70)
endif()
if(CMAKE_CUDA_ARCHITECTURES MATCHES "turing")
list(APPEND cuda_archs 75)
endif()
if(CMAKE_CUDA_ARCHITECTURES MATCHES "ampere")
list(APPEND cuda_archs 80)
endif()

if(cuda_archs)
list(LENGTH cuda_archs num_archs)
if(num_archs GREATER 1)
# A CMake architecture list entry of "80" means to build both compute and sm.
# What we want is for the newest arch only to build that way, while the rest
# build only for sm.
list(POP_BACK cuda_archs latest_arch)
list(TRANSFORM cuda_archs APPEND "-real")
list(APPEND cuda_archs ${latest_arch})
else()
list(TRANSFORM cuda_archs APPEND "-real")
endif()
set(CMAKE_CUDA_ARCHITECTURES ${cuda_archs} PARENT_SCOPE)
endif()
endfunction()

function(add_cuda_architecture_defines defs)
message(VERBOSE "legate.core: CMAKE_CUDA_ARCHITECTURES=${CMAKE_CUDA_ARCHITECTURES}")

set(_defs ${${defs}})

macro(add_def_if_arch_enabled arch def)
if("${arch}" IN_LIST CMAKE_CUDA_ARCHITECTURES OR
("${arch}-real" IN_LIST CMAKE_CUDA_ARCHITECTURES) OR
("${arch}-virtual" IN_LIST CMAKE_CUDA_ARCHITECTURES))
list(APPEND _defs ${def})
endif()
endmacro()

add_def_if_arch_enabled("20" "FERMI_ARCH")
add_def_if_arch_enabled("30" "KEPLER_ARCH")
add_def_if_arch_enabled("35" "K20_ARCH")
add_def_if_arch_enabled("37" "K80_ARCH")
add_def_if_arch_enabled("52" "MAXWELL_ARCH")
add_def_if_arch_enabled("60" "PASCAL_ARCH")
add_def_if_arch_enabled("70" "VOLTA_ARCH")
add_def_if_arch_enabled("75" "TURING_ARCH")
add_def_if_arch_enabled("80" "AMPERE_ARCH")

set(${defs} ${_defs} PARENT_SCOPE)
endfunction()
121 changes: 121 additions & 0 deletions cmake/Modules/legate_core_options.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
#=============================================================================
# Copyright 2022 NVIDIA Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#=============================================================================

option(BUILD_SHARED_LIBS "Build legate.core shared libraries" ON)

function(set_or_default var_name var_env)
list(LENGTH ARGN num_extra_args)
if(num_extra_args GREATER 0)
list(GET ARGN 0 var_default)
endif()
if(DEFINED ${var_name})
message(VERBOSE "legate.core: ${var_name}=${${var_name}}")
elseif(DEFINED ENV{${var_env}})
set(${var_name} $ENV{${var_env}} PARENT_SCOPE)
message(VERBOSE "legate.core: ${var_name}=$ENV{${var_env}} (from envvar '${var_env}')")
elseif(DEFINED var_default)
set(${var_name} ${var_default} PARENT_SCOPE)
message(VERBOSE "legate.core: ${var_name}=${var_default} (from default value)")
else()
message(VERBOSE "legate.core: not setting ${var_name}")
endif()
endfunction()

# Initialize these vars from the CLI, then fallback to an envvar or a default value.
set_or_default(Legion_SPY USE_SPY OFF)
set_or_default(Legion_USE_LLVM USE_LLVM OFF)
set_or_default(Legion_USE_CUDA USE_CUDA OFF)
set_or_default(Legion_USE_HDF5 USE_HDF OFF)
set_or_default(Legion_USE_GASNet USE_GASNET OFF)
set_or_default(Legion_USE_OpenMP USE_OPENMP OFF)
set_or_default(Legion_BOUNDS_CHECKS CHECK_BOUNDS OFF)

option(Legion_SPY "Enable detailed logging for Legion Spy" OFF)
option(Legion_USE_LLVM "Use LLVM JIT operations" OFF)
option(Legion_USE_HDF5 "Enable support for HDF5" OFF)
option(Legion_USE_CUDA "Enable Legion support for the CUDA runtime" OFF)
option(Legion_USE_GASNet "Enable the distributed GASNet backend" OFF)
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_USE_GASNet)
set_or_default(GASNet_ROOT_DIR GASNET)
set_or_default(GASNet_CONDUIT CONDUIT "udp")

if(Legion_USE_GASNet AND (NOT GASNet_ROOT_DIR))
option(Legion_EMBED_GASNet "Embed a custom GASNet build into Legion" ON)
endif()
endif()

set_or_default(Legion_MAX_DIM LEGION_MAX_DIM 4)
jjwilke marked this conversation as resolved.
Show resolved Hide resolved

# Check the max dimensions
if((Legion_MAX_DIM LESS 1) OR (Legion_MAX_DIM GREATER 9))
message(FATAL_ERROR "The maximum number of Legate dimensions must be between 1 and 9 inclusive")
endif()

set_or_default(Legion_MAX_FIELDS LEGION_MAX_FIELDS 256)

# Check that max fields is between 32 and 4096 and is a power of 2
if(NOT Legion_MAX_FIELDS MATCHES "^(32|64|128|256|512|1024|2048|4096)$")
message(FATAL_ERROR "The maximum number of Legate fields must be a power of 2 between 32 and 4096 inclusive")
endif()


option(legate_core_STATIC_CUDA_RUNTIME "Statically link the cuda runtime library" OFF)
option(legate_core_EXCLUDE_LEGION_FROM_ALL "Exclude Legion targets from legate.core's 'all' target" OFF)

set_or_default(NCCL_DIR NCCL_PATH)
set_or_default(Thrust_DIR THRUST_PATH)
set_or_default(CUDA_TOOLKIT_ROOT_DIR CUDA)
set_or_default(CMAKE_CUDA_ARCHITECTURES GPU_ARCH NATIVE)
set_or_default(Legion_HIJACK_CUDART USE_CUDART_HIJACK OFF)

include(CMakeDependentOption)
cmake_dependent_option(Legion_HIJACK_CUDART
"Allow Legion to hijack and rewrite application calls into the CUDA runtime"
ON
"Legion_USE_CUDA;Legion_HIJACK_CUDART"
OFF)
# This needs to be added as an option to force values to be visible in Legion build
option(Legion_HIJACK_CUDART "Replace default CUDA runtime with the Realm version" OFF)

if(Legion_HIJACK_CUDART)
message(WARNING [=[
#####################################################################
Warning: Realm's CUDA runtime hijack is incompatible with NCCL.
Please note that your code will crash catastrophically as soon as it
calls into NCCL either directly or through some other Legate library.
#####################################################################
]=])
endif()

if(BUILD_SHARED_LIBS)
if(Legion_HIJACK_CUDART)
# Statically link CUDA if HIJACK_CUDART is set
set(Legion_CUDA_DYNAMIC_LOAD OFF)
set(CUDA_USE_STATIC_CUDA_RUNTIME ON)
elseif(NOT DEFINED Legion_CUDA_DYNAMIC_LOAD)
# If HIJACK_CUDART isn't set and BUILD_SHARED_LIBS is true, default Legion_CUDA_DYNAMIC_LOAD to true
set(Legion_CUDA_DYNAMIC_LOAD ON)
set(CUDA_USE_STATIC_CUDA_RUNTIME OFF)
endif()
elseif(NOT DEFINED Legion_CUDA_DYNAMIC_LOAD)
# If BUILD_SHARED_LIBS is false, default Legion_CUDA_DYNAMIC_LOAD to false also
set(Legion_CUDA_DYNAMIC_LOAD OFF)
set(CUDA_USE_STATIC_CUDA_RUNTIME ON)
endif()
Loading