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

Fix inconsistency between the building doc and CMakeLists.txt #1248

Merged
merged 3 commits into from
Feb 16, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ option(DISABLE_DEPRECATION_WARNINGS "Disable deprecaction warnings " ON)
option(DISABLE_OPENMP "Disable OpenMP" OFF)
option(RAFT_NVTX "Enable nvtx markers" OFF)

option(RAFT_COMPILE_LIBRARIES "Enable building raft shared library instantiations" ${BUILD_TESTS})
option(RAFT_COMPILE_LIBRARIES "Enable building raft shared library instantiations" OFF)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we probably want to leave this as defaulting to ${BUILD_TESTS}, otherwise tests will be extremely slow to compile. Actually, perhaps this really should default to ON if we're building tests or benchmarks, since the same is true in either case. @cjnolet WDYT?

I'm not sure what the best way is to document this default; it may just have to be written in words in build.md rather than relying on a simple ON/OFF entry in the table.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah we definitely want to keep this defaulting to build tests (and I agree it probably should default BUILD_TESTS | BUILD_BENCH. We rely on this to make sure really expensive specializations are compiled once (in libraft-distance/libraft-nn) and reused.

As for the docs, I think we could update the description in this table to maybe mention that it defaults to ON because BUILD_TESTS defaults to on.

Copy link
Contributor Author

@yong-wang yong-wang Feb 9, 2023

Choose a reason for hiding this comment

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

How about filling the "Default Value" column with ${BUILD_TESTS} in the table? Does it look reasonable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I searched the web but didn't find any easy way to evaluate things like BUILD_TESTS OR BUILD_BENCH inside an option().

I'm not familiar with CMake. Any suggestion?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

CMake doesn't support that kind of expression evaluation. AFAIK the canonical solution would be

set(RAFT_COMPILE_LIBRARIES_DEFAULT OFF)
if(${BUILD_TESTS} OR ${BUILD_BENCH})
  set(RAFT_COMPILE_LIBRARIES_DEFAULT OFF)
endif()
option(RAFT_COMPILE_LIBRARIES <description> ${RAFT_COMPILE_LIBRARIES_DEFAULT})

Copy link
Contributor

Choose a reason for hiding this comment

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

Regarding the table, I think no matter what you put in the column you'll probably need to explain it a bit in words.

Copy link
Contributor

Choose a reason for hiding this comment

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

This sounds exactly like the use case for cmake_dependent_option which allows for complex initialization of cache variables.

include(CMakeDependentOption)
cmake_dependent_option(RAFT_COMPILE_LIBRARIES "Enable building raft shared library instantiations" ON "BUILD_TESTS OR BUILD_BENCH" OFF )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the suggestions.
I tried cmake_dependent_option, but when both BUILD_TESTS and BUILD_BENCH are OFF, could not set RAFT_COMPILE_LIBRARIES to ON from the command line. According to CMake doc, RAFT_COMPILE_LIBRARIES is hidden from the user in this case.
So I used Vyas' way to set the default value. Also updated the table.

Copy link
Contributor

Choose a reason for hiding this comment

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

I was not aware of cmake_dependent_option, that's cool. It does seem from the docs like the way the option may be hidden is incompatible with our needs in this case, though.

option(
RAFT_COMPILE_NN_LIBRARY "Enable building raft nearest neighbors shared library instantiations"
${RAFT_COMPILE_LIBRARIES}
Expand All @@ -66,7 +66,7 @@ option(RAFT_COMPILE_DIST_LIBRARY "Enable building raft distant shared library in
${RAFT_COMPILE_LIBRARIES}
)
option(RAFT_ENABLE_NN_DEPENDENCIES "Search for raft::nn dependencies like faiss"
${RAFT_COMPILE_LIBRARIES}
${RAFT_COMPILE_NN_LIBRARY}
)

option(RAFT_ENABLE_thrust_DEPENDENCY "Enable Thrust dependency" ON)
Expand Down
7 changes: 3 additions & 4 deletions docs/source/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,16 +162,15 @@ RAFT's cmake has the following configurable flags available:.
| Flag | Possible Values | Default Value | Behavior |
| --- | --- | --- | --- |
| BUILD_TESTS | ON, OFF | ON | Compile Googletests |
| BUILD_BENCH | ON, OFF | ON | Compile benchmarks |
| BUILD_BENCH | ON, OFF | OFF | Compile benchmarks |
| raft_FIND_COMPONENTS | nn distance | | Configures the optional components as a space-separated list |
| RAFT_COMPILE_LIBRARIES | ON, OFF | OFF | Compiles all `libraft` shared libraries (these are required for Googletests) |
| RAFT_COMPILE_NN_LIBRARY | ON, OFF | OFF | Compiles the `libraft-nn` shared library |
| RAFT_COMPILE_DIST_LIBRARY | ON, OFF | OFF | Compiles the `libraft-distance` shared library |
| RAFT_ENABLE_NN_DEPENDENCIES | ON, OFF | OFF | Searches for dependencies of nearest neighbors API, such as FAISS, and compiles them if not found. Needed for `raft::spatial::knn` |
| RAFT_USE_FAISS_STATIC | ON, OFF | OFF | Statically link FAISS into `libraft-nn` |
| RAFT_STATIC_LINK_LIBRARIES | ON, OFF | ON | Build static link libraries instead of shared libraries |
| DETECT_CONDA_ENV | ON, OFF | ON | Enable detection of conda environment for dependencies |
| NVTX | ON, OFF | OFF | Enable NVTX Markers |
| RAFT_NVTX | ON, OFF | OFF | Enable NVTX Markers |
| CUDA_ENABLE_KERNELINFO | ON, OFF | OFF | Enables `kernelinfo` in nvcc. This is useful for `compute-sanitizer` |
| CUDA_ENABLE_LINEINFO | ON, OFF | OFF | Enable the -lineinfo option for nvcc |
| CUDA_STATIC_RUNTIME | ON, OFF | OFF | Statically link the CUDA runtime |
Expand Down Expand Up @@ -388,4 +387,4 @@ Once built and installed, RAFT can be safely uninstalled using `build.sh` by spe
Leaving off the installed components will uninstall everything that's been installed:
```bash
./build.sh --uninstall
```
```