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

Link libcudf_kafka against cuDF CMake export targets (CPM) #7484

Closed
wants to merge 36 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
48edee7
REL v0.13.0 release
GPUtester Mar 31, 2020
54ceb3a
enable cudf_kafka to use CPMFindPackage
jdye64 Mar 2, 2021
9e7f3f9
fixed copy/paste errors
jdye64 Mar 2, 2021
25468f6
enable cudf_kafka to use CPMFindPackage
jdye64 Mar 2, 2021
beaf86e
update libcudf_kafka version with each release
jdye64 Mar 2, 2021
464bcdd
change version to 0.19 from 0.19.0 which leads to a branch that does …
jdye64 Mar 2, 2021
c3df905
checkpoint commit, does it build without tests in ci?
jdye64 Mar 3, 2021
089855c
updated to include ConfigureCUDA like cudf
jdye64 Mar 4, 2021
c8ffeaa
update GPU Eval script location
jdye64 Mar 4, 2021
8fb7ae5
Add Set/Get GPU eval cmake files
jdye64 Mar 4, 2021
be8ea10
Merge remote-tracking branch 'upstream/branch-0.19' into link_against…
jdye64 Mar 5, 2021
2a84c8f
Merge remote-tracking branch 'upstream/branch-0.19' into link_against…
jdye64 Mar 8, 2021
52a138b
isort modified file
jdye64 Mar 9, 2021
f1c2682
use cuDF branch that exports cudftestutil, build tests
trxcllnt Mar 11, 2021
a52f735
updated to include the headers for libcudf
jdye64 Mar 11, 2021
1e0d1f6
oops, link against actual cudf_kafka target
jdye64 Mar 11, 2021
9d235fb
set target for includes
jdye64 Mar 12, 2021
4c5b318
remove option to build arrow static as the property is inheritied fro…
jdye64 Mar 12, 2021
263ea8e
Removed cmake get gtest as it is no longer needed
jdye64 Mar 12, 2021
904253d
added back arrow static option as it was still needed
jdye64 Mar 12, 2021
f40aabe
add cmake option for using arrow static or not
jdye64 Mar 16, 2021
ed3148d
add cmake option for using arrow static or not
jdye64 Mar 16, 2021
7368830
move cudf repo from test repo back to rapidsai repo
jdye64 Mar 17, 2021
73a68a3
default to cudf_use_arrow_static being OFF
jdye64 Mar 17, 2021
b97138d
remove reference to cudf static arrow as it is no longer needed
jdye64 Mar 17, 2021
ddfe13b
remove unused cpm options, and remove commented out librdkafka cpm code
jdye64 Mar 17, 2021
0da5d04
use parent cmake thirdparty/Modules where needed
jdye64 Mar 18, 2021
985f3ea
Add CUDF_SOURCE_DIR so that parent cudf cmake Modules can resolve the…
jdye64 Mar 18, 2021
3c75483
create RDKAFKA target
jdye64 Mar 18, 2021
5656c4f
Remove cmake BUILD_TESTS and ARROW_STATIC arguments
jdye64 Mar 18, 2021
74a98d6
couple of build fixes
jdye64 Mar 18, 2021
bb60e88
small build updates
jdye64 Mar 18, 2021
21a0502
updates from review
jdye64 Mar 19, 2021
bc3880f
remove custom test target from build.sh file
jdye64 Mar 20, 2021
59855da
return if rmm::rmm target already exists
jdye64 Mar 22, 2021
db4704c
syntax issue
jdye64 Mar 22, 2021
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
10 changes: 4 additions & 6 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -193,17 +193,15 @@ fi
if hasArg libcudf_kafka; then
cmake -S $REPODIR/cpp/libcudf_kafka -B ${KAFKA_LIB_BUILD_DIR} \
-DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \
-DBUILD_TESTS=${BUILD_TESTS} \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE}


cd ${KAFKA_LIB_BUILD_DIR}
cmake --build . -j${PARALLEL_LEVEL} ${VERBOSE_FLAG}

if [[ ${INSTALL_TARGET} != "" ]]; then
cmake --build . -j${PARALLEL_LEVEL} --target install ${VERBOSE_FLAG}
else
cmake --build . -j${PARALLEL_LEVEL} --target libcudf_kafka ${VERBOSE_FLAG}
fi

if [[ ${BUILD_TESTS} == "ON" ]]; then
cmake --build . -j${PARALLEL_LEVEL} --target build_tests_libcudf_kafka ${VERBOSE_FLAG}
fi
fi

Expand Down
3 changes: 3 additions & 0 deletions ci/release/update-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ function sed_runner() {
# cpp update
sed_runner 's/'"CUDA_DATAFRAME VERSION .* LANGUAGES"'/'"CUDA_DATAFRAME VERSION ${NEXT_FULL_TAG} LANGUAGES"'/g' cpp/CMakeLists.txt

# cpp libcudf_kafka update
sed_runner 's/'"CUDA_KAFKA VERSION .* LANGUAGES"'/'"CUDA_KAFKA VERSION ${NEXT_FULL_TAG} LANGUAGES"'/g' cpp/libcudf_kafka/CMakeLists.txt

# doxyfile update
sed_runner 's/PROJECT_NUMBER = .*/PROJECT_NUMBER = '${NEXT_FULL_TAG}'/g' cpp/doxygen/Doxyfile

Expand Down
6 changes: 6 additions & 0 deletions cpp/cmake/thirdparty/CUDF_GetRMM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ function(cudf_restore_if_enabled var)
endfunction()

function(find_and_configure_rmm VERSION)

# Check for an existing rmm::rmm target
if(TARGET rmm::rmm)
return()
endif()

# Consumers have two options for local source builds:
# 1. Pass `-D CPM_rmm_SOURCE=/path/to/rmm` to build a local RMM source tree
# 2. Pass `-D CMAKE_PREFIX_PATH=/path/to/rmm/build` to use an existing local
Expand Down
131 changes: 27 additions & 104 deletions cpp/libcudf_kafka/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,112 +13,60 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#=============================================================================
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)

project(CUDA_KAFKA VERSION 0.15.0 LANGUAGES C CXX CUDA)

# TODO: Since we have no actual CUDA code in cudf_kafka this should be removed in the future
# in favor of using FindCUDAToolkit to get the needed CUDA include headers
if(NOT CMAKE_CUDA_COMPILER)
message(SEND_ERROR "CMake cannot locate a CUDA compiler")
endif(NOT CMAKE_CUDA_COMPILER)
cmake_minimum_required(VERSION 3.18 FATAL_ERROR)
project(CUDA_KAFKA VERSION 0.19.0 LANGUAGES C CXX)

###################################################################################################
# - build type ------------------------------------------------------------------------------------
# - Build options

option(BUILD_TESTS "Build tests for libcudf_kafka" ON)

# Set a default build type if none was specified
set(DEFAULT_BUILD_TYPE "Release")
message(VERBOSE "CUDF_KAFKA: Build gtests: ${BUILD_TESTS}")

if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to '${DEFAULT_BUILD_TYPE}' since none specified.")
set(CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}" CACHE
STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
# Set CUDF_SOURCE_DIR to ensure that cmake Modules from parent cudf have the correct context
set(CUDF_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../")

###################################################################################################
# - compiler options ------------------------------------------------------------------------------

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# To apply RUNPATH to transitive dependencies (this is a temporary solution)
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--disable-new-dtags")
set(CMAKE_EXE_LINKER_FLAGS "-Wl,--disable-new-dtags")

# Build options
option(BUILD_TESTS "Configure CMake to build tests" ON)
# * find CUDAToolkit package
# * determine GPU architectures
# * enable the CMake CUDA language
# * set other CUDA compilation flags
include(../cmake/Modules/ConfigureCUDA.cmake)
Comment on lines +32 to +36
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this is causing problems. There's no device code / actual cuda configuration needed for libcudf, and we're doing this before importing cudf / rmm / etc. which causes the CUDA language to be enabled which breaks things I think?

Copy link
Contributor

Choose a reason for hiding this comment

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

In my dummy CMakeLists.txt for #7658, CUDA had to be enabled for the find_package(cudf) to succeed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, that would make sense actually since I removed CUDA in a previous commit. Both @kkraus14 and I were both under the impression it was not needed since libcudf_kafka doesn't use CUDA explicitly. Are you saying I need to add it back?

Copy link
Collaborator

Choose a reason for hiding this comment

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

My thought is that if someone needs to enable CUDA before doing find_package(cudf), we have something broken in our cudf cmake config.

Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like cuftestutil and cudf both have some CUDA information in the export information. That would require downstream consumers to enable CUDA.

  • cuftestutil is tricky as it is a static library with CUDA sources, so CMake needs to export that when linking downstream it has CUDA dependencies ( so you need to enable the language )
  • cudf is leaking via compile flags, would could be fixed

Copy link
Contributor

Choose a reason for hiding this comment

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

Both of these should be resolved by having cudf-config.cmake have ( enable_language(CUDA) ) in the short term while we sort out the above two issues.


###################################################################################################
# - cmake modules ---------------------------------------------------------------------------------

message(VERBOSE "CMAKE_CURRENT_SOURCE_DIR: ${CMAKE_CURRENT_SOURCE_DIR}")
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/" ${CMAKE_MODULE_PATH})
# - Dependencies

include(FeatureSummary)
include(CheckIncludeFiles)
include(CheckLibraryExists)
# CPM
include(../cmake/thirdparty/CUDF_GetCPM.cmake)

###################################################################################################
# - conda environment -----------------------------------------------------------------------------

if("$ENV{CONDA_BUILD}" STREQUAL "1")
set(CMAKE_SYSTEM_PREFIX_PATH "$ENV{BUILD_PREFIX};$ENV{PREFIX};${CMAKE_SYSTEM_PREFIX_PATH}")
set(CONDA_INCLUDE_DIRS "$ENV{BUILD_PREFIX}/include" "$ENV{PREFIX}/include")
set(CONDA_LINK_DIRS "$ENV{BUILD_PREFIX}/lib" "$ENV{PREFIX}/lib")
message(VERBOSE "Conda build detected, CMAKE_SYSTEM_PREFIX_PATH set to: ${CMAKE_SYSTEM_PREFIX_PATH}")
endif()
# libcudf
include(cmake/thirdparty/CUDF_KAFKA_GetCUDF.cmake)

###################################################################################################
# - add gtest -------------------------------------------------------------------------------------
# librdkafka
include(cmake/thirdparty/CUDF_KAFKA_GetRDKafka.cmake)

# TODO: This is currently using a nearly duplicate Google Test Module due to CMake source limitations.
# this should be standardized in the future to use the same Google Test Module as cudf
if(BUILD_TESTS)
# # GTests if enabled
if (BUILD_TESTS)
# include CTest module -- automatically calls enable_testing()
include(CTest)
include(ConfigureGoogleTest)

if(GTEST_FOUND)
message(VERBOSE "Google C++ Testing Framework (Google Test) found in ${GTEST_ROOT}")
include_directories(${GTEST_INCLUDE_DIR})
add_subdirectory(${CMAKE_SOURCE_DIR}/tests)
else()
message(AUTHOR_WARNING "Google C++ Testing Framework (Google Test) not found: automated tests are disabled.")
endif(GTEST_FOUND)
endif(BUILD_TESTS)

message(VERBOSE "CUDF_KAFKA_TEST_LIST set to: ${CUDF_KAFKA_TEST_LIST}")
add_subdirectory(tests)
endif()

###################################################################################################
# - include paths ---------------------------------------------------------------------------------

if(CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES)
include_directories("${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}")
endif(CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES)

include_directories("${CMAKE_BINARY_DIR}/include"
"${CMAKE_BINARY_DIR}/include/jit"
"${CMAKE_SOURCE_DIR}/include"
"${CMAKE_SOURCE_DIR}/src")

if(CONDA_INCLUDE_DIRS)
include_directories("${CONDA_INCLUDE_DIRS}")
endif(CONDA_INCLUDE_DIRS)

###################################################################################################
# - library paths ---------------------------------------------------------------------------------

link_directories("${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}" # CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES is an undocumented/unsupported variable containing the link directories for nvcc
"${CMAKE_BINARY_DIR}/lib"
"${CMAKE_BINARY_DIR}"
"${GTEST_LIBRARY_DIR}"
"${RMM_LIBRARY}")

if(CONDA_LINK_DIRS)
link_directories("${CONDA_LINK_DIRS}")
endif(CONDA_LINK_DIRS)
"${CMAKE_BINARY_DIR}")

###################################################################################################
# - library target --------------------------------------------------------------------------------
Expand All @@ -127,37 +75,12 @@ add_library(cudf_kafka SHARED
src/kafka_consumer.cpp
)

set_target_properties(cudf_kafka PROPERTIES BUILD_RPATH "\$ORIGIN")

# Include paths
include_directories("${CMAKE_SOURCE_DIR}/include"
"${CMAKE_CURRENT_SOURCE_DIR}/include/cudf")

###################################################################################################
# cudf_kafka - librdkafka -------------------------------------------------------------------------

find_path(RDKAFKA_INCLUDE "librdkafka" HINTS "$ENV{RDKAFKA_ROOT}/include")
find_library(RDKAFKA++_LIBRARY "rdkafka++" HINTS "$ENV{RDKAFKA_ROOT}/lib" "$ENV{RDKAFKA_ROOT}/build")

message(VERBOSE "RDKAFKA: RDKAFKA++_LIBRARY set to ${RDKAFKA++_LIBRARY}")
message(VERBOSE "RDKAFKA: RDKAFKA_INCLUDE set to ${RDKAFKA_INCLUDE}")

target_link_libraries(cudf_kafka ${RDKAFKA++_LIBRARY})
include_directories("${RDKAFKA_INCLUDE}")

###################################################################################################
# - cudf_kafka Install ----------------------------------------------------------------------------
target_link_libraries(cudf_kafka cudf)
target_link_libraries(cudf_kafka cudf::cudf RDKAFKA::RDKAFKA)

install(TARGETS cudf_kafka
DESTINATION lib)

install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include
DESTINATION include)

add_custom_target(build_tests_libcudf_kafka
DEPENDS ${CUDF_KAFKA_TEST_LIST})

add_custom_target(test_libcudf_kafka
COMMAND ctest
DEPENDS build_tests_libcudf_kafka)
46 changes: 0 additions & 46 deletions cpp/libcudf_kafka/cmake/Modules/ConfigureGoogleTest.cmake

This file was deleted.

This file was deleted.

52 changes: 52 additions & 0 deletions cpp/libcudf_kafka/cmake/thirdparty/CUDF_KAFKA_GetCUDF.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#=============================================================================
# Copyright (c) 2021, 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(cudfkafka_save_if_enabled var)
if(CUDF_KAFKA_${var})
unset(${var} PARENT_SCOPE)
unset(${var} CACHE)
endif()
endfunction()

function(cudfkafka_restore_if_enabled var)
if(CUDF_KAFKA_${var})
set(${var} ON CACHE INTERNAL "" FORCE)
endif()
endfunction()

function(find_and_configure_cudf VERSION)
kkraus14 marked this conversation as resolved.
Show resolved Hide resolved
cudfkafka_save_if_enabled(BUILD_TESTS)
cudfkafka_save_if_enabled(BUILD_BENCHMARKS)
CPMFindPackage(NAME cudf
VERSION ${VERSION}
GIT_REPOSITORY https://github.com/rapidsai/cudf.git
GIT_TAG branch-${VERSION}
GIT_SHALLOW TRUE
SOURCE_SUBDIR cpp
OPTIONS "BUILD_TESTS OFF"
"BUILD_BENCHMARKS OFF")
cudfkafka_restore_if_enabled(BUILD_TESTS)
cudfkafka_restore_if_enabled(BUILD_BENCHMARKS)

if(NOT cudf_BINARY_DIR IN_LIST CMAKE_PREFIX_PATH)
list(APPEND CMAKE_PREFIX_PATH "${cudf_BINARY_DIR}")
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} PARENT_SCOPE)
endif()

endfunction()

set(CUDF_KAFKA_MIN_VERSION_cudf 0.19)
find_and_configure_cudf(${CUDF_KAFKA_MIN_VERSION_cudf})
25 changes: 25 additions & 0 deletions cpp/libcudf_kafka/cmake/thirdparty/CUDF_KAFKA_GetRDKafka.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#=============================================================================
# Copyright (c) 2021, 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.
#=============================================================================

find_path(RDKAFKA_INCLUDE "librdkafka" HINTS "$ENV{RDKAFKA_ROOT}/include")
jdye64 marked this conversation as resolved.
Show resolved Hide resolved
find_library(RDKAFKA++_LIBRARY "rdkafka++" HINTS "$ENV{RDKAFKA_ROOT}/lib" "$ENV{RDKAFKA_ROOT}/build")

if(RDKAFKA_INCLUDE AND RDKAFKA++_LIBRARY)
add_library(rdkafka INTERFACE)
target_link_libraries(rdkafka INTERFACE "${RDKAFKA++_LIBRARY}")
target_include_directories(rdkafka INTERFACE "${RDKAFKA_INCLUDE}")
add_library(RDKAFKA::RDKAFKA ALIAS rdkafka)
endif()
Loading