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

[REVIEW] [ENH] Ability to use ccache to speedup local builds #729

Merged
merged 4 commits into from
Jul 7, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
36 changes: 27 additions & 9 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ ARGS=$*
# script, and that this script resides in the repo dir!
REPODIR=$(cd $(dirname $0); pwd)

VALIDARGS="clean libraft pyraft pylibraft docs tests bench clean -v -g --install --compile-libs --compile-nn --compile-dist --allgpuarch --sccache --no-nvtx --show_depr_warn -h --buildfaiss --minimal-deps"
HELP="$0 [<target> ...] [<flag> ...] [--cmake-args=\"<args>\"]
VALIDARGS="clean libraft pyraft pylibraft docs tests bench clean -v -g --install --compile-libs --compile-nn --compile-dist --allgpuarch --no-nvtx --show_depr_warn -h --buildfaiss --minimal-deps"
HELP="$0 [<target> ...] [<flag> ...] [--cmake-args=\"<args>\"] [--cache-tool=<tool>]
where <target> is:
clean - remove all existing build artifacts and configuration (start over)
libraft - build the raft C++ code only. Also builds the C-wrapper library
Expand All @@ -33,7 +33,6 @@ HELP="$0 [<target> ...] [<flag> ...] [--cmake-args=\"<args>\"]
and <flag> is:
-v - verbose build mode
-g - build for debug
--sccache - enable sccache
--compile-libs - compile shared libraries for all components
--compile-nn - compile shared library for nn component
--compile-dist - compile shared library for distance component
Expand All @@ -45,6 +44,8 @@ HELP="$0 [<target> ...] [<flag> ...] [--cmake-args=\"<args>\"]
--no-nvtx - disable nvtx (profiling markers), but allow enabling it in downstream projects
--show_depr_warn - show cmake deprecation warnings
--cmake-args=\\\"<args>\\\" - pass arbitrary list of CMake configuration options (escape all quotes in argument)
--ccache-tool=<tool> - pass the build ccache tool (eg: ccache, sccache, distcc) that will be used
to speedup the build process.
-h - print this text

default action (no args) is to build both libraft and pyraft targets
Expand All @@ -69,7 +70,7 @@ ENABLE_NN_DEPENDENCIES=OFF

ENABLE_thrust_DEPENDENCY=ON

SCCACHE_ARGS=""
CCACHE_ARGS=""
NVTX=ON
CLEAN=0
UNINSTALL=0
Expand Down Expand Up @@ -113,6 +114,26 @@ function cmakeArgs {
fi
}

function ccacheTool {
# Check for multiple ccache options
if [[ $(echo $ARGS | { grep -Eo "\-\-ccache\-tool" || true; } | wc -l ) -gt 1 ]]; then
echo "Multiple --ccache-tool options were provided, please provide only one: ${ARGS}"
exit 1
fi
# Check for ccache tool option
if [[ -n $(echo $ARGS | { grep -E "\-\-ccache\-tool" || true; } ) ]]; then
# There are possible weird edge cases that may cause this regex filter to output nothing and fail silently
# the true pipe will catch any weird edge cases that may happen and will cause the program to fall back
# on the invalid option error
CCACHE_TOOL=$(echo $ARGS | sed -e 's/.*--ccache-tool=//' -e 's/ .*//')
if [[ -n ${CCACHE_TOOL} ]]; then
# Remove the full CCACHE_TOOL argument from list of args so that it passes validArgs function
ARGS=${ARGS//--ccache-tool=$CCACHE_TOOL/}
CCACHE_ARGS="-DCMAKE_CUDA_COMPILER_LAUNCHER=${CCACHE_TOOL} -DCMAKE_C_COMPILER_LAUNCHER=${CCACHE_TOOL} -DCMAKE_CXX_COMPILER_LAUNCHER=${CCACHE_TOOL}"
fi
fi
}

if hasArg -h || hasArg --help; then
echo "${HELP}"
exit 0
Expand All @@ -121,6 +142,7 @@ fi
# Check for valid usage
if (( ${NUMARGS} != 0 )); then
cmakeArgs
ccacheTool
for a in ${ARGS}; do
if ! (echo " ${VALIDARGS} " | grep -q " ${a} "); then
echo "Invalid option: ${a}"
Expand All @@ -134,10 +156,6 @@ if hasArg --install; then
INSTALL_TARGET="install"
fi

if hasArg --sccache; then
SCCACHE_ARGS="-DCMAKE_CUDA_COMPILER_LAUNCHER=sccache -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache"
fi

if hasArg --minimal-deps; then
ENABLE_thrust_DEPENDENCY=OFF
fi
Expand Down Expand Up @@ -257,7 +275,7 @@ if (( ${NUMARGS} == 0 )) || hasArg libraft || hasArg docs || hasArg tests || has
-DRAFT_COMPILE_DIST_LIBRARY=${COMPILE_DIST_LIBRARY} \
-DRAFT_USE_FAISS_STATIC=${BUILD_STATIC_FAISS} \
-DRAFT_ENABLE_thrust_DEPENDENCY=${ENABLE_thrust_DEPENDENCY} \
${SCCACHE_ARGS} \
${CCACHE_ARGS} \
${EXTRA_CMAKE_ARGS}

if [[ ${CMAKE_TARGET} != "" ]]; then
Expand Down
1 change: 1 addition & 0 deletions conda/environments/raft_dev_cuda11.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ dependencies:
- doxygen>=1.8.20
- libfaiss>=1.7.0
- faiss-proc=*=cuda
- ccache
- pip
- pip:
- sphinx_markdown_tables
Expand Down
1 change: 1 addition & 0 deletions conda/environments/raft_dev_cuda11.2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ dependencies:
- doxygen>=1.8.20
- libfaiss>=1.7.0
- faiss-proc=*=cuda
- ccache
- pip
- pip:
- sphinx_markdown_tables
Expand Down
1 change: 1 addition & 0 deletions conda/environments/raft_dev_cuda11.4.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ dependencies:
- doxygen>=1.8.20
- libfaiss>=1.7.0
- faiss-proc=*=cuda
- ccache
- pip
- pip:
- sphinx_markdown_tables
Expand Down
1 change: 1 addition & 0 deletions conda/environments/raft_dev_cuda11.5.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ dependencies:
- doxygen>=1.8.20
- libfaiss>=1.7.0
- faiss-proc=*=cuda
- ccache
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we do the same changes in cuml? I personally always use cuml_dev environment for raft development, and I suspect that's not me only.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with you. If this PR gets accepted by ops team, we could do the same in cuML too.

- pip
- pip:
- sphinx_markdown_tables
Expand Down