Skip to content

Commit

Permalink
Update to CMake 3.20 features, rapids-cmake and CPM (#187)
Browse files Browse the repository at this point in the history
PR updates RAFT's CMake and uses CPM for dependency management. Still WIP, meant for early 0.20, but opening the PR to start debugging in CI. 

This is heavily based on cuDF's, RMM's and cumlprims' changes. PR does the following:

- [x] Adopt CPM:
    - [x] RMM
    - [x] FAISS
    - [x] GTest
    - [ ] NCCL: Missing building from source, will be added if/when required
    - [ ] UCX: Missing building from source, will be added if/when required
    - [x] CUB for CUDA < 11.0
- [x] Update arch detection 
- [x] Use generators to allow clang compilation as well
- [x] Updates to outdated cmake parts and remove old code
- [x] Update code to aid transition to #83

Authors:
  - Dante Gama Dessavre (https://github.com/dantegd)
  - Robert Maynard (https://github.com/robertmaynard)

Approvers:
  - Robert Maynard (https://github.com/robertmaynard)
  - Rick Ratzel (https://github.com/rlratzel)
  - Divye Gala (https://github.com/divyegala)

URL: #187
  • Loading branch information
dantegd authored May 14, 2021
1 parent c5030a0 commit fe5f40a
Show file tree
Hide file tree
Showing 17 changed files with 547 additions and 975 deletions.
43 changes: 15 additions & 28 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ PYTHON_DEPS_CLONE=${REPODIR}/python/external_repositories
BUILD_DIRS="${CPP_RAFT_BUILD_DIR} ${PY_RAFT_BUILD_DIR} ${PYTHON_DEPS_CLONE}"

# Set defaults for vars modified by flags to this script
VERBOSE=""
VERBOSE_FLAG=""
BUILD_ALL_GPU_ARCH=0
BUILD_GTEST=OFF
BUILD_STATIC_FAISS=OFF
Expand All @@ -58,6 +58,9 @@ INSTALL_PREFIX=${INSTALL_PREFIX:=${PREFIX:=${CONDA_PREFIX}}}
PARALLEL_LEVEL=${PARALLEL_LEVEL:=""}
BUILD_ABI=${BUILD_ABI:=ON}

# Default to Ninja if generator is not specified
export CMAKE_GENERATOR="${CMAKE_GENERATOR:=Ninja}"

function hasArg {
(( ${NUMARGS} != 0 )) && (echo " ${ARGS} " | grep -q " $1 ")
}
Expand All @@ -79,7 +82,8 @@ fi

# Process flags
if hasArg -v; then
VERBOSE=1
VERBOSE_FLAG=-v
set -x
fi
if hasArg -g; then
BUILD_TYPE=Debug
Expand Down Expand Up @@ -130,41 +134,24 @@ fi
# Configure for building all C++ targets
if (( ${NUMARGS} == 0 )) || hasArg cppraft; then
if (( ${BUILD_ALL_GPU_ARCH} == 0 )); then
GPU_ARCH=""
RAFT_CMAKE_CUDA_ARCHITECTURES="NATIVE"
echo "Building for the architecture of the GPU in the system..."
else
GPU_ARCH="-DGPU_ARCHS=ALL"
RAFT_CMAKE_CUDA_ARCHITECTURES="ALL"
echo "Building for *ALL* supported GPU architectures..."
fi

mkdir -p ${CPP_RAFT_BUILD_DIR}
cd ${CPP_RAFT_BUILD_DIR}

cmake -DNVTX=${NVTX} \
-DPARALLEL_LEVEL=${PARALLEL_LEVEL} \
-DNCCL_PATH=${INSTALL_PREFIX} \
cmake -S ${REPODIR}/cpp -B ${CPP_RAFT_BUILD_DIR} \
-DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \
-DCMAKE_CUDA_ARCHITECTURES=${RAFT_CMAKE_CUDA_ARCHITECTURES} \
-DNVTX=${NVTX} \
-DDISABLE_DEPRECATION_WARNING=${BUILD_DISABLE_DEPRECATION_WARNING} \
-DBUILD_GTEST=${BUILD_GTEST} \
-DBUILD_STATIC_FAISS=${BUILD_STATIC_FAISS} \
..

fi

# Run all make targets at once
-DBUILD_STATIC_FAISS=${BUILD_STATIC_FAISS}

MAKE_TARGETS=
if hasArg cppraft; then
MAKE_TARGETS="${MAKE_TARGETS} test_raft"
fi


# If `./build.sh pyraft` is called, don't build C/C++ components
if (( ${NUMARGS} == 0 )) || hasArg cppraft; then
# If there are no targets specified when calling build.sh, it will
# just call `make -j`. This avoids a lot of extra printing
cd ${CPP_RAFT_BUILD_DIR}
make -j${PARALLEL_LEVEL} ${MAKE_TARGETS} VERBOSE=${VERBOSE}

# Run all c++ targets at once
cmake --build ${CPP_RAFT_BUILD_DIR} -j${PARALLEL_LEVEL} ${MAKE_TARGETS} ${VERBOSE_FLAG}
fi


Expand Down
Loading

0 comments on commit fe5f40a

Please sign in to comment.