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

Add CMake build for C++ and scikit-build infrastructure for Python package installation #514

Merged
merged 184 commits into from
Sep 21, 2022
Merged
Show file tree
Hide file tree
Changes from 145 commits
Commits
Show all changes
184 commits
Select commit Hold shift + click to select a range
60c5e23
add initial CMake build
trxcllnt Apr 29, 2022
8d568d8
fix compile error
trxcllnt Apr 29, 2022
7224a2d
point to nv-legate repo
trxcllnt May 3, 2022
6fda29b
use realm_defines and legion_defines from the build dir if it's defined
trxcllnt May 3, 2022
665676d
Merge branch 'branch-22.07' of github.com:nv-legate/cunumeric into fe…
trxcllnt May 25, 2022
ec74eb4
Merge branch 'branch-22.07' of github.com:nv-legate/cunumeric into fe…
trxcllnt May 26, 2022
6790c6e
Merge branch 'branch-22.07' of github.com:nv-legate/cunumeric into fe…
trxcllnt May 27, 2022
fa236e1
update version
trxcllnt May 27, 2022
e177a8d
guard against RealmRuntime and LegionRuntime targets not existing
trxcllnt Jun 1, 2022
8a826c8
fix version number
trxcllnt Jun 3, 2022
14e2c9e
fully support building without CUDA and OpenMP, detect support for bo…
trxcllnt Jun 4, 2022
63416a4
use compiler cache to speed up tblis builds
trxcllnt Jun 4, 2022
4cbd319
toggle tblis openmp via CUNUMERIC_USE_OPENMP
trxcllnt Jun 4, 2022
a5058de
print messages for CI
trxcllnt Jun 4, 2022
1f76d9b
adjust -isystem flag to support clangd
trxcllnt Jun 4, 2022
141d307
Merge branch 'branch-22.07' of github.com:nv-legate/cunumeric into fe…
trxcllnt Jun 4, 2022
cdbc3d8
Merge branch 'branch-22.07' of github.com:nv-legate/cunumeric into fe…
trxcllnt Jun 6, 2022
843b61e
Toggle CUDA, OpenMP, and bounds checking based on the found legate.co…
trxcllnt Jun 7, 2022
6cbf7e3
print message when legate_core is found
trxcllnt Jun 7, 2022
a86db0a
fix typo
trxcllnt Jun 7, 2022
6d2bd14
use CMAKE_SHARED_LIBRARY_SUFFIX for tblis shared library
trxcllnt Jun 13, 2022
2f5b492
remove dot
trxcllnt Jun 13, 2022
244ef17
handle case where build_shared_libs is off
trxcllnt Jun 13, 2022
be9f3d2
Merge branch 'branch-22.07' of github.com:nv-legate/cunumeric into fe…
trxcllnt Jun 14, 2022
80cbc73
Speed up FetchContent_Populate by downloading a tarball (if possible)…
trxcllnt Jun 14, 2022
8ed6721
cleanup
trxcllnt Jun 14, 2022
9b0e7d1
make required CMake version match conda-forge's CMake
trxcllnt Jun 14, 2022
5c1e78c
Use CPM to find or build OpenBLAS
trxcllnt Jun 14, 2022
51851fc
only create alias targets if OpenBLAS was added
trxcllnt Jun 14, 2022
bccfdef
initial commit of CMake-based install.py
trxcllnt Jun 14, 2022
32c1ffb
make install-2.py work with legate build dirs
trxcllnt Jun 15, 2022
6253e9b
place libraries in build/lib
trxcllnt Jun 15, 2022
7f04ef4
add target to preprocess cunumeric_c.h for use with Python CFFI
trxcllnt Jun 15, 2022
9938308
Merge branch 'fea/add-cmake' into fea/install-py-uses-cmake
trxcllnt Jun 15, 2022
a370ead
ignore install dir
trxcllnt Jun 15, 2022
19f84f8
use the preprocessed cunumeric_c.h.i generated by CMake instead of do…
trxcllnt Jun 15, 2022
51579ee
remove unused vars
trxcllnt Jun 15, 2022
6fbed41
Merge branch 'fea/add-cmake' into fea/install-py-uses-cmake
trxcllnt Jun 15, 2022
d35383c
Merge branch 'branch-22.07' of github.com:nv-legate/cunumeric into fe…
trxcllnt Jun 15, 2022
f48ac50
Merge branch 'branch-22.07' of github.com:nv-legate/cunumeric into fe…
trxcllnt Jun 15, 2022
6f9c0a8
Merge branch 'fea/add-cmake' into fea/install-py-uses-cmake
trxcllnt Jun 15, 2022
d4171cf
fix gitlab archive URI for branches with slashes in the name
trxcllnt Jun 21, 2022
1337bae
update rapids-cmake version
trxcllnt Jun 21, 2022
07e5758
Merge branch 'fea/add-cmake' into fea/install-py-uses-cmake
trxcllnt Jun 21, 2022
cdc7902
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 6, 2022
e9a3b39
Merge branch 'branch-22.07' of github.com:nv-legate/cunumeric into fe…
trxcllnt Jul 6, 2022
167e8a1
Merge branch 'fea/add-cmake' of github.com:trxcllnt/cunumeric into fe…
trxcllnt Jul 6, 2022
a352dd3
add scikit-build
trxcllnt Jul 7, 2022
9db95d6
make install.py call pip install .
trxcllnt Jul 7, 2022
8fbe28c
fix lint
trxcllnt Jul 7, 2022
eeae89c
remove debugging lines
trxcllnt Jul 7, 2022
800fb99
clean up
trxcllnt Jul 7, 2022
c015ae8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 7, 2022
ba3d2de
fix default legate branch
trxcllnt Jul 7, 2022
3115798
assume legion_core is already installed in build-install.sh example s…
trxcllnt Jul 7, 2022
548299d
export LIBRARY_PATH if not set
trxcllnt Jul 7, 2022
0e8534b
resolve relative path in build scripts
trxcllnt Jul 7, 2022
48f08a9
formatting
trxcllnt Jul 7, 2022
852849f
apply Bryan's fixes for tests
trxcllnt Jul 7, 2022
143ef38
don't use defaults
trxcllnt Jul 7, 2022
3fdc0bb
fix lint
trxcllnt Jul 7, 2022
fbbd4a3
use Readline so tab completion works
trxcllnt Jul 7, 2022
fd7ebe1
set CMAKE_BUILD_PARALLEL_LEVEL
trxcllnt Jul 7, 2022
7438060
build tblis on cmake --build instead of cmake configure
trxcllnt Jul 7, 2022
ffffd34
fix get_libpath
trxcllnt Jul 7, 2022
d03ab1a
fix separate tblis configure/build stages to correctly link to libtbl…
trxcllnt Jul 7, 2022
85c5db2
use add_custom_command so tblis isn't always rebuilt
trxcllnt Jul 7, 2022
b75f0d2
use my legate.core branch temporarily in CI
trxcllnt Jul 8, 2022
cddc14f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 8, 2022
3e84571
default branch and url in install.py temporarily
trxcllnt Jul 8, 2022
7b651fc
Merge branch 'branch-22.07' of github.com:nv-legate/cunumeric into fe…
trxcllnt Jul 8, 2022
7f66ca8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 8, 2022
0b35b33
Merge branch 'branch-22.07' of github.com:nv-legate/cunumeric into fe…
trxcllnt Jul 11, 2022
ad836da
set optimization level -O2
trxcllnt Jul 12, 2022
102461b
Merge branch 'fea/add-cmake' of github.com:trxcllnt/cunumeric into fe…
trxcllnt Jul 12, 2022
2bc4f54
ensure CUDA architectures are detected correctly
trxcllnt Jul 12, 2022
c2e6a15
add searchsorted sources
trxcllnt Jul 12, 2022
8884cf3
fix typos
trxcllnt Jul 12, 2022
8476ea8
install tblis if we built it
trxcllnt Jul 12, 2022
b0aaa8a
clean out tblis lib and include dirs
trxcllnt Jul 12, 2022
6df103b
use --upgrade instead of --force-install
trxcllnt Jul 13, 2022
1369001
remove todo
trxcllnt Jul 13, 2022
0f34c07
find exact legate_core and cunumeric package versions
trxcllnt Jul 13, 2022
d8bb811
do pip install --upgrade if not editable
trxcllnt Jul 13, 2022
f927d88
set REQUIRED if legate_core_ROOT is defined
trxcllnt Jul 14, 2022
8443118
Update conda recipe to use CMake
trxcllnt Jul 19, 2022
dcf7dab
Merge branch 'branch-22.07' of github.com:nv-legate/cunumeric into fe…
trxcllnt Jul 19, 2022
2ff2211
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 19, 2022
42526a8
add new source files
trxcllnt Jul 19, 2022
51f688e
Merge branch 'fea/add-cmake' of github.com:trxcllnt/cunumeric into fe…
trxcllnt Jul 19, 2022
784f644
fix bad merge
trxcllnt Jul 19, 2022
ebea196
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 19, 2022
87b92f8
test legate_core_DIR/ROOT for truthy-ness
trxcllnt Jul 22, 2022
7b8c205
Merge branch 'branch-22.07' of github.com:nv-legate/cunumeric into fe…
trxcllnt Jul 22, 2022
318ed23
fix lint
trxcllnt Jul 22, 2022
e4ffe6e
add back in optional --legate argument to test.py
trxcllnt Jul 22, 2022
51f6367
fix legate_path to be str instead of Path
trxcllnt Jul 22, 2022
b25c40c
fix lint
trxcllnt Jul 22, 2022
05bcf8a
move make/cmake/ninja to build requirements
trxcllnt Jul 22, 2022
4cf0b93
add build and runtime dependencies to dev conda envs
trxcllnt Jul 22, 2022
230157e
Merge branch 'branch-22.07' of github.com:nv-legate/cunumeric into fe…
trxcllnt Jul 25, 2022
0e67f09
fix lint
trxcllnt Jul 25, 2022
49a2d6f
remove legion_helpers.cmake
trxcllnt Jul 25, 2022
4c9c585
Enable using tblis_ROOT to find external tblis installations
jjwilke Jul 26, 2022
b4805ce
add build and install export sets to rapids_cpm_find
trxcllnt Jul 26, 2022
b247d04
Merge pull request #1 from jjwilke/fea/add-cmake
trxcllnt Jul 26, 2022
d7376cd
Merge branch 'branch-22.07' of github.com:nv-legate/cunumeric into fe…
trxcllnt Jul 29, 2022
b4be507
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 29, 2022
1b7444d
add separate build scripts to build with/without prebuilt legate.core
trxcllnt Aug 3, 2022
1fb9263
Merge branch 'fea/add-cmake' of github.com:trxcllnt/cunumeric into fe…
trxcllnt Aug 3, 2022
8ffef20
Merge branch 'branch-22.07' of github.com:nv-legate/cunumeric into fe…
trxcllnt Aug 3, 2022
d0c075c
update cunumeric_cpp.cmake for new files
trxcllnt Aug 3, 2022
c607011
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 3, 2022
2ff0c6a
fix bad merge
trxcllnt Aug 3, 2022
1893816
export tblis_BINARY_DIR to PARENT_SCOPE
trxcllnt Aug 4, 2022
6979771
Merge branch 'branch-22.10' of github.com:nv-legate/cunumeric into ad…
jjwilke Aug 8, 2022
ab99e04
Merge branch 'branch-22.10' of github.com:nv-legate/cunumeric into ad…
jjwilke Aug 9, 2022
bd3f7b4
do not reference undefined env "_" in tests
jjwilke Aug 10, 2022
895f8f4
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 10, 2022
90f7d47
fix tblis flag in install.py
jjwilke Aug 11, 2022
ec1a94d
fix flake8 issues on test_patch
jjwilke Aug 11, 2022
931148d
mypy fixes
jjwilke Aug 12, 2022
a047586
Merge branch 'branch-22.10' of github.com:nv-legate/cunumeric into ad…
jjwilke Aug 12, 2022
1bf7ef2
Merge pull request #2 from jjwilke/add-cmake-pr
trxcllnt Aug 15, 2022
73d0cfa
update conda-build/build.sh
trxcllnt Aug 15, 2022
c44f5e8
Merge branch 'branch-22.10' of github.com:nv-legate/cunumeric into fe…
trxcllnt Aug 15, 2022
c9d9099
Merge branch 'branch-22.10' of github.com:nv-legate/cunumeric into ad…
trxcllnt Aug 16, 2022
3ebd9ac
add initial build directions
jjwilke Aug 18, 2022
a49b368
formatting fixes
jjwilke Aug 18, 2022
b6e602f
more build information
jjwilke Aug 18, 2022
ce1cfc1
add conda directions
jjwilke Aug 18, 2022
7533352
exclude legate files from mypy again
trxcllnt Aug 18, 2022
40226ef
Merge branch 'branch-22.10' of github.com:nv-legate/cunumeric into ad…
trxcllnt Aug 19, 2022
2fec0e4
update default legate core branch and repos
trxcllnt Aug 19, 2022
155172e
ensure sccache is used in conda build
trxcllnt Aug 19, 2022
56513af
allow sccache envvars from external environment
trxcllnt Aug 19, 2022
012b751
ensure SETUPTOOLS_ENABLE_FEATURES is set to "legacy-editable"
trxcllnt Aug 22, 2022
d8e27fc
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 22, 2022
b868dc0
translate gpu name to cuda architectures
trxcllnt Aug 22, 2022
4981b9c
Merge branch 'add-cmake-pr' of github.com:jjwilke/cunumeric into add-…
trxcllnt Aug 22, 2022
ca881ac
remove unnecessary cmake define
trxcllnt Aug 24, 2022
12ec0a1
link to curand
trxcllnt Aug 24, 2022
25d1132
fix install.py --with-core arg
trxcllnt Aug 24, 2022
0e5dba0
Apply suggestions from code review
bryevdv Aug 24, 2022
49c85f2
fix gitlab tgz urls
trxcllnt Aug 24, 2022
66e15f4
Apply suggestions from code review
bryevdv Aug 24, 2022
36b5029
don't link curand
trxcllnt Aug 24, 2022
f74deb9
use if(POLICY)
trxcllnt Aug 24, 2022
cb52b27
Merge branch 'add-cmake-pr' of github.com:jjwilke/cunumeric into add-…
trxcllnt Aug 24, 2022
f30c071
Merge branch 'branch-22.10' of github.com:nv-legate/cunumeric into ad…
trxcllnt Aug 24, 2022
a03cf93
enable cmake policy 0135
trxcllnt Aug 24, 2022
ad1a493
add extra target to update build.ninja mtime so rebuilding doesn't re…
trxcllnt Aug 25, 2022
e1fcfd4
remove easy-install.pth
trxcllnt Aug 25, 2022
01bd274
ensure libcunumeric.so is found if installed into a non-standard inst…
trxcllnt Aug 25, 2022
9a1b4be
better handle --prefix flag, remove --python-only flag
trxcllnt Aug 25, 2022
72fcdc7
infer legate_dir from an existing legate.core python install (includi…
trxcllnt Aug 25, 2022
d43f765
don't remove easy-install.pth
trxcllnt Aug 25, 2022
4e1c8c9
mirror flags in legate.core example build scripts
trxcllnt Aug 25, 2022
f75f787
add argwhere sources
trxcllnt Aug 25, 2022
ef7b075
update mypy paths to ignore new location of install_info
trxcllnt Aug 25, 2022
c2e64f0
ensure build dir is cleaned if the value of --build-isolation is diff…
trxcllnt Aug 25, 2022
7a1853d
cmake cleanup
trxcllnt Aug 25, 2022
14b152f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 25, 2022
e2d35d0
add --max_dim --max_fields --spy --openmp --llvm --hdf --gasnet --gas…
trxcllnt Aug 26, 2022
1ffebb0
Merge branch 'branch-22.10' of github.com:nv-legate/cunumeric into ad…
trxcllnt Aug 26, 2022
7dd9c2b
define CUDAHOSTCXX envvar
trxcllnt Aug 27, 2022
6a6bb31
define flags for debug and minsizerel build types
trxcllnt Aug 29, 2022
84e0665
update package version
trxcllnt Aug 29, 2022
38907a4
Merge branch 'branch-22.10' of github.com:nv-legate/cunumeric into ad…
trxcllnt Aug 29, 2022
3494f1f
parse BUILD_MARCH and/or BUILD_MCPU configuration flags
trxcllnt Aug 29, 2022
1aba142
add openmpi to conda envs
trxcllnt Aug 29, 2022
126f65c
use correct dynamic library extension for other OS's
trxcllnt Aug 30, 2022
bcaae19
fix typo
trxcllnt Aug 30, 2022
51217d0
add py.typed for mypy, fix typings
trxcllnt Aug 31, 2022
2a4eef0
Merge branch 'branch-22.10' of github.com:nv-legate/cunumeric into ad…
trxcllnt Sep 2, 2022
a93501d
add wrap to sources list
trxcllnt Sep 2, 2022
e0a219d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 2, 2022
b00791b
Merge branch 'branch-22.10' of github.com:nv-legate/cunumeric into ad…
trxcllnt Sep 2, 2022
ebc81f3
remove unused # type: ignore comment
trxcllnt Sep 2, 2022
3486379
Merge branch 'branch-22.10' of github.com:nv-legate/cunumeric into ad…
trxcllnt Sep 12, 2022
7b9cb55
Merge branch 'branch-22.10' of github.com:nv-legate/cunumeric into ad…
trxcllnt Sep 13, 2022
2db9288
Update get_legate_core.cmake
bryevdv Sep 21, 2022
580a396
Update install.py
bryevdv Sep 21, 2022
f4cc8fe
Update install.py
bryevdv Sep 21, 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 @@
cunumeric/_version.py export-subst
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,10 @@ cunumeric/install_info.py
/docs/cunumeric/source/api/generated
/docs/cunumeric/source/comparison/comparison_table.rst.inc
*.egg-info
.cache
.vscode
.pytest_cache
/install*
/dist
/_skbuild
/_cmake_test_compile
131 changes: 131 additions & 0 deletions BUILD.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
<!--
Copyright 2021-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.

-->

# Overview

The build system is designed to enable two different modes of use:
1. Simple `pip install` for users
2. Highly customizable incremental builds for developers

We review each of these modes with examples.


# Building for Users

## Using install.py

For releases <= 22.07, the main method for building cuNumeric was the `install.py` script.
Although the underlying implementation has significantly changed, `install.py` still supports the
same usage and same set of flags. For a full list of flags, users can run:

```
$ ./install.py --help
```

## Using Conda

cuNumeric can be installed using Conda by pointing to the required channels (`-c`):

```
conda install -c nvidia -c conda-forge -c legate legate-core
```

## Using pip

cuNumeric is not yet registered in a standard pip repository. However, users can still use the
pip installer to build and install cuNumeric. After downloading or cloning the cunumeric source,
users can run the following in the cunumeric folder:

```
$ pip install .
```
or
```
$ python3 -m pip install .
```

This will install cuNumeric in the standard packages directory for the environment Python.
Note: This is currently not sufficient for running cuNumeric programs. cuNumeric relies
on the `legate` launcher from Legate core, which must be installed separately.
For details on installing Legate, consult the [Legate repository](https://github.com/nv-legate/legate.core).

### Advanced Customization

If users need to customize details of the underlying CMake build, they can pass
CMake flags through the `SKBUILD_CONFIGURE_OPTIONS` environment variable:

```
$ SKBUILD_CONFIGURE_OPTIONS="-D Legion_USE_CUDA:BOOL=ON" \
pip install .
```
An alternative syntax using `setup.py` with `scikit-build` is
```
$ python setup.py install -- -DLegion_USE_CUDA:BOOL=ON
```

# Building for Developers

## Overview

pip uses [scikit-build](https://scikit-build.readthedocs.io/en/latest/)
in `setup.py` to drive the build and installation. A `pip install` will trigger three general actions:

1. CMake build and installation of C++ libraries
2. CMake generation of configuration files and build-dependent Python files
3. pip installation of Python files

The CMake build can be configured independently of `pip`, allowing incremental C++ builds directly through CMake.
This simplifies rebuilding `libcunumeric.so` either via command-line or via IDE.
After building the C++ libraries, the `pip install` can be done in "editable" mode using the `-e` flag.
This configures the Python site packages to import the Python source tree directly.
The Python source can then be edited and used directly for testing without requiring a `pip install`.

## Example

There are several examples in the `scripts` folder. We walk through the steps in the `build-with-legate-separately-no-install.sh` here.
We assume a pre-existing Legate CUDA build. For details on building Legate, consult the [Legate repository](https://github.com/nv-legate/legate.core).
First, the CMake build needs to be configured:

```
$ cmake -S . -B build -GNinja -D legate_core_ROOT:STRING=path/to/legate/build
```

We point cuNumeric to the Legate *build* tree, not an installation.
This generates all build-dependent headers and Python files.
Once configured, we can build the C++ libraries:

```
$ cmake --build build
```

This will invoke Ninja (or make) to execute the build.
Once the C++ libraries are available, we can do an editable (development) pip installation.

```
$ SKBUILD_BUILD_OPTIONS="-D FIND_CUNUMERIC_CPP=ON -D cunumeric_ROOT=$(pwd)/build" \
python3 -m pip install \
--root / --no-deps --no-build-isolation
--editable .
```

The Python source tree and CMake build tree are now available with the environment Python
for running cuNumeric programs. The diagram below illustrates the
complete workflow for building both Legate core and cuNumeric.

<img src="docs/figures/developer-build.png" alt="drawing" width="600"/>


66 changes: 66 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#=============================================================================
# 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()

##############################################################################
# - 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(cunumeric_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(cunumeric VERSION ${cunumeric_version} LANGUAGES C CXX)
include(cunumeric_cpp.cmake)
else()
project(
cunumeric_python
VERSION ${cunumeric_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(cunumeric_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 cunumeric/_version.py
18 changes: 8 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ issues on GitHub.

## Building from Source

Installation of cuNumeric is done with either `setup.py` for simple
uses cases or `install.py` for more advanced use cases. The most common
installation command is:
Installation can be done the `install.py` script.
For releases >= 22.10, `pip install` is now available.
The most common installation command is:

```
python setup.py --with-core <path-to-legate-core-installation>
./install.py --with-core <path-to-legate-core-installation>
```

This will build cuNumeric against the Legate Core installation and then
Expand All @@ -106,7 +106,7 @@ If Legate Core has been installed with CUDA support, a working cuTENSOR
installation must also be provided to the installation command with the
`--with-cutensor` option:
```
python setup.py --with-core <path-to-legate-core-installation> --with-cutensor <path-to-cutensor-installation>
./install.py --with-core <path-to-legate-core-installation> --with-cutensor <path-to-cutensor-installation>
```

You can also specify an installation of [OpenBLAS](https://www.openblas.net/)
Expand All @@ -115,16 +115,14 @@ machine, you can inform the installation script using the `--with-openblas`
option:

```
python setup.py --with-openblas <path-to-OpenBLAS>
./install.py --with-openblas <path-to-OpenBLAS>
```

Advanced users can also invoke `install.py --help` to see options for
configuring cuNumeric by invoking the `install.py` script directly.
More information on building - including development workflows - can be found
in the [build instructions](BUILD.md)

Note that after the first invocation of `setup.py` or `install.py` this
repository will remember the paths you provided with the installation options
and they can be omitted in subsequent invocations unless you want to change
them.

## Usage and Execution

Expand Down
57 changes: 57 additions & 0 deletions cmake/Modules/cpm_helpers.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#=============================================================================
# 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}")
string(LENGTH "${GIT_REPOSITORY}" repo_name_len)
string(FIND "${GIT_REPOSITORY}" "/" repo_name_idx REVERSE)
math(EXPR repo_name_len "${repo_name_len} - ${repo_name_idx}")
string(SUBSTRING "${GIT_REPOSITORY}" ${repo_name_idx} ${repo_name_len} repo_name)
# If retrieving from gitlab use `.zip` URL to download faster
set(cpm_git_args URL "${GIT_REPOSITORY}/-/archive/${repo_tag}/${repo_name}-${archive_tag}.zip")
endif()

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

endfunction()
Loading