Skip to content

Commit

Permalink
make velox_wave standalone and explicitly link it
Browse files Browse the repository at this point in the history
  • Loading branch information
assignUser committed Dec 6, 2024
1 parent 53e6ebe commit 803d4d6
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 20 deletions.
25 changes: 19 additions & 6 deletions CMake/VeloxUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,26 @@ function(velox_link_libraries TARGET)
# TODO(assignUser): Handle scope keywords (they currently are empty calls ala
# target_link_libraries(target PRIVATE))
if(VELOX_MONO_LIBRARY)
message(DEBUG "${TARGET}: ${ARGN}")
foreach(_lib ${ARGN})
if("${_lib}" MATCHES "^velox_*")
message(DEBUG "\t\tDROP: ${_lib}")
# These targets follow the velox_* name for consistency but are NOT actually
# aliases to velox when building the mono lib and need to be linked
# explicitly (this is a hack)
set(explicit_targets
velox_exec_test_lib
# see velox/experimental/wave/README.md
velox_wave_common
velox_wave_decode
velox_wave_dwio
velox_wave_exec
velox_wave_stream
velox_wave_vector)

foreach(_arg ${ARGN})
list(FIND explicit_targets ${_arg} _explicit)
if(_explicit EQUAL -1 AND "${_arg}" MATCHES "^velox_*")
message(DEBUG "\t\tDROP: ${_arg}")
else()
message(DEBUG "\t\tADDING: ${_lib}")
target_link_libraries(velox ${_lib})
message(DEBUG "\t\tADDING: ${_arg}")
target_link_libraries(velox ${_arg})
endif()
endforeach()
else()
Expand Down
9 changes: 8 additions & 1 deletion velox/experimental/gpu/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@
# 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.
list(APPEND CMAKE_PREFIX_PATH "${CUDAToolkit_LIBRARY_DIR}/cmake")
find_package(CUB REQUIRED)

add_executable(velox_gpu_hash_table_test HashTableTest.cu)
target_link_libraries(
velox_gpu_hash_table_test Folly::folly gflags::gflags)
velox_gpu_hash_table_test
Folly::folly
gflags::gflags
glog::glog
CUB::CUB
CUDA::cudart)
33 changes: 33 additions & 0 deletions velox/experimental/wave/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!--
Copyright (c) Facebook, Inc. and its affiliates.
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: Use Base Functions

> [!IMPORTANT] Please use `target_link_libraries` and `add_library`
> instead of the `velox_*` functions when adding or linking to targets
> within wave/ and label tests with `cuda_driver`.
The `wave` GPU component links against the CUDA driver in several targets.
They can be built on machines without the actual driver installed, this
requires the relevant 'stub' packages to be installed (see setup scripts).

Any library that statically links against the stubs **can not** run on a
machine without an actual CUDA driver installed (like our CI).
For this reason we need to use the base functions to create standalone
libraries for wave to avoid linking statically against the stubs when
building the monolithic library and label any tests with 'cuda_driver'
to allow excluding them from ctest on machines without the driver.

4 changes: 2 additions & 2 deletions velox/experimental/wave/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ target_link_libraries(
velox_common_base
velox_type
CUDA::cuda_driver
CUDA::cudart
CUDA::nvrtc)
CUDA::nvrtc
CUDA::cudart)

if(${VELOX_BUILD_TESTING})
add_subdirectory(tests)
Expand Down
1 change: 1 addition & 0 deletions velox/experimental/wave/common/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ target_include_directories(velox_wave_common_test PRIVATE ../../../breeze)
target_link_libraries(
velox_wave_common_test
velox_wave_common
xsimd
GTest::gtest
GTest::gtest_main
CUDA::cudart)
11 changes: 4 additions & 7 deletions velox/experimental/wave/dwio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@

add_subdirectory(decode)

velox_add_library(
velox_wave_dwio
ColumnReader.cpp
FormatData.cpp
ReadStream.cpp
StructColumnReader.cpp)
add_library(velox_wave_dwio ColumnReader.cpp FormatData.cpp ReadStream.cpp
StructColumnReader.cpp)

velox_link_libraries(velox_wave_dwio Folly::folly fmt::fmt xsimd)
target_link_libraries(
velox_wave_dwio Folly::folly fmt::fmt xsimd)
2 changes: 1 addition & 1 deletion velox/experimental/wave/dwio/decode/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ add_subdirectory(tests)
add_library(velox_wave_decode GpuDecoder.cu)

target_link_libraries(
velox_wave_decode velox_wave_common)
velox_wave_decode velox_wave_common CUDA::cudart)
3 changes: 2 additions & 1 deletion velox/experimental/wave/exec/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ target_link_libraries(
velox_wave_stream
velox_exception
velox_common_base
velox_exec)
velox_exec
CUDA::cudart)

if(${VELOX_BUILD_TESTING})
add_subdirectory(tests)
Expand Down
5 changes: 3 additions & 2 deletions velox/experimental/wave/vector/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

velox_add_library(velox_wave_vector WaveVector.cpp)
velox_link_libraries(velox_wave_vector velox_vector velox_common_base)
add_library(velox_wave_vector WaveVector.cpp)
target_link_libraries(
velox_wave_vector velox_vector velox_common_base)

0 comments on commit 803d4d6

Please sign in to comment.