Skip to content

Commit

Permalink
Update with rapids cmake new features (#1790)
Browse files Browse the repository at this point in the history
This combines some general CMake style cleanup and brings new rapids-cmake features to cugraph including:

- Usage of `rapids_cmake_write_version_file` to simplify cugraph version header writing
- Usage of `rapids_cmake_install_lib_dir` to make sure we install raft correctly on non-debain based distro's ( lib64 ), while also handling conda installation requirements ( always lib no matter the distro )
- Usage of `rapids_cpm` pre-configured pacakges
- Removal of early termination before `rapids_cpm_find` since a better solution now exists ( rapidsai/rapids-cmake#49 )

Authors:
  - Robert Maynard (https://github.com/robertmaynard)

Approvers:
  - Brad Rees (https://github.com/BradReesWork)
  - Rick Ratzel (https://github.com/rlratzel)

URL: #1790
  • Loading branch information
robertmaynard authored Sep 7, 2021
1 parent dcc08bc commit 6f5803c
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 141 deletions.
18 changes: 8 additions & 10 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ project(CUGRAPH VERSION 21.10.00 LANGUAGES C CXX CUDA)
# Remove the following archs from CMAKE_CUDA_ARCHITECTURES that
# cuhornet currently doesn't support
#
# < 60
# >= 86
set(supported_archs "60" "62" "70" "72" "75" "80")
foreach( arch IN LISTS CMAKE_CUDA_ARCHITECTURES)
Expand All @@ -52,8 +51,7 @@ set(CMAKE_CUDA_ARCHITECTURES ${usable_arch_values})


# Write the version header
include(cmake/Modules/Version.cmake)
write_version()
rapids_cmake_write_version_file(include/cugraph/version_config.hpp)

###################################################################################################
# - build type ------------------------------------------------------------------------------------
Expand Down Expand Up @@ -97,13 +95,13 @@ list(APPEND CUGRAPH_CUDA_FLAGS -Xfatbin=-compress-all)
# memchecking
if (CMAKE_CUDA_LINEINFO)
list(APPEND CUGRAPH_CUDA_FLAGS -lineinfo)
endif(CMAKE_CUDA_LINEINFO)
endif()

# Debug options
if(CMAKE_BUILD_TYPE MATCHES Debug)
message(STATUS "Building with debugging flags")
list(APPEND CUGRAPH_CUDA_FLAGS -G -Xcompiler=-rdynamic)
endif(CMAKE_BUILD_TYPE MATCHES Debug)
endif()

###################################################################################################
# - find openmp -----------------------------------------------------------------------------------
Expand All @@ -112,7 +110,7 @@ find_package(OpenMP)
if(OpenMP_FOUND)
# find_package(OPenMP) does not automatically add OpenMP flags to CUDA
list(APPEND CUGRAPH_CUDA_FLAGS -Xcompiler=${OpenMP_CXX_FLAGS})
endif(OpenMP_FOUND)
endif()


###################################################################################################
Expand Down Expand Up @@ -319,7 +317,7 @@ target_link_libraries(cugraph PRIVATE
### set_target_properties(target PROPERTIES
### BUILD_RPATH "${TARGET_BUILD_RPATH}")
${OpenMP_CXX_LIB_NAMES})
endif(OpenMP_CXX_FOUND)
endif()


###################################################################################################
Expand All @@ -328,15 +326,15 @@ endif(OpenMP_CXX_FOUND)
if(BUILD_TESTS)
include(CTest)
add_subdirectory(tests)
endif(BUILD_TESTS)
endif()

###################################################################################################
# - install targets -------------------------------------------------------------------------------

rapids_cmake_install_lib_dir( lib_dir )
include(CPack)

install(TARGETS cugraph
DESTINATION lib
DESTINATION ${lib_dir}
EXPORT cugraph-exports)

install(DIRECTORY include/cugraph/
Expand Down
18 changes: 0 additions & 18 deletions cpp/cmake/Modules/Version.cmake

This file was deleted.

10 changes: 4 additions & 6 deletions cpp/cmake/thirdparty/get_cuco.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,8 @@

function(find_and_configure_cuco VERSION)

if(TARGET cuco::cuco)
return()
endif()

rapids_cpm_find(cuco ${VERSION}
GLOBAL_TARGETS cuco cuco::cuco
GLOBAL_TARGETS cuco::cuco
CPM_ARGS
GIT_REPOSITORY https://github.com/NVIDIA/cuCollections.git
GIT_TAG b1fea0cbe4c384160740af00f7c8760846539abb
Expand All @@ -30,7 +26,9 @@ function(find_and_configure_cuco VERSION)
"BUILD_EXAMPLES OFF"
)

add_library(cuco::cuco ALIAS cuco)
if(TARGET cuco AND NOT TARGET cuco::cuco)
add_library(cuco::cuco ALIAS cuco)
endif()

endfunction()

Expand Down
2 changes: 1 addition & 1 deletion cpp/cmake/thirdparty/get_faiss.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function(find_and_configure_faiss)
)

rapids_cpm_find(FAISS ${PKG_VERSION}
GLOBAL_TARGETS faiss
GLOBAL_TARGETS faiss FAISS::FAISS
CPM_ARGS
GIT_REPOSITORY https://github.com/facebookresearch/faiss.git
GIT_TAG ${PKG_PINNED_TAG}
Expand Down
27 changes: 4 additions & 23 deletions cpp/cmake/thirdparty/get_gtest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,11 @@
# limitations under the License.
#=============================================================================

function(find_and_configure_gtest VERSION)
function(find_and_configure_gtest)

if(TARGET GTest::gtest)
return()
endif()

rapids_cpm_find(GTest ${VERSION}
GLOBAL_TARGETS gmock gmock_main gtest gtest_main GTest::gmock GTest::gtest GTest::gtest_main
CPM_ARGS
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-${VERSION}
GIT_SHALLOW TRUE
OPTIONS "INSTALL_GTEST ON"
# googletest >= 1.10.0 provides a cmake config file -- use it if it exists
FIND_PACKAGE_ARGUMENTS "CONFIG"
)

if(NOT TARGET GTest::gtest)
add_library(GTest::gmock ALIAS gmock)
add_library(GTest::gmock_main ALIAS gmock_main)
add_library(GTest::gtest ALIAS gtest)
add_library(GTest::gtest_main ALIAS gtest_main)
endif()
include(${rapids-cmake-dir}/cpm/gtest.cmake)
rapids_cpm_gtest()

endfunction()

find_and_configure_gtest(1.10.0)
find_and_configure_gtest()
4 changes: 0 additions & 4 deletions cpp/cmake/thirdparty/get_nccl.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ function(find_and_configure_nccl)
return()
endif()

set(oneValueArgs VERSION PINNED_TAG)
cmake_parse_arguments(PKG "${options}" "${oneValueArgs}"
"${multiValueArgs}" ${ARGN} )

rapids_find_generate_module(NCCL
HEADER_NAMES nccl.h
LIBRARY_NAMES nccl
Expand Down
28 changes: 4 additions & 24 deletions cpp/cmake/thirdparty/get_rmm.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,14 @@
# limitations under the License.
#=============================================================================

function(find_and_configure_rmm VERSION)
function(find_and_configure_rmm)

if(${VERSION} MATCHES [=[([0-9]+)\.([0-9]+)\.([0-9]+)]=])
set(MAJOR_AND_MINOR "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}")
else()
set(MAJOR_AND_MINOR "${VERSION}")
endif()

if(TARGET rmm::rmm)
return()
endif()

rapids_cpm_find(rmm ${VERSION}
GLOBAL_TARGETS rmm::rmm
include(${rapids-cmake-dir}/cpm/rmm.cmake)
rapids_cpm_rmm(
BUILD_EXPORT_SET cugraph-exports
INSTALL_EXPORT_SET cugraph-exports
CPM_ARGS
GIT_REPOSITORY https://github.com/rapidsai/rmm.git
GIT_TAG branch-${MAJOR_AND_MINOR}
GIT_SHALLOW TRUE
OPTIONS "BUILD_TESTS OFF"
"BUILD_BENCHMARKS OFF"
"CUDA_STATIC_RUNTIME ${CUDA_STATIC_RUNTIME}"
"DISABLE_DEPRECATION_WARNING ${DISABLE_DEPRECATION_WARNING}"
)

endfunction()

set(CUGRAPH_MIN_VERSION_rmm "${CUGRAPH_VERSION_MAJOR}.${CUGRAPH_VERSION_MINOR}.00")

find_and_configure_rmm(${CUGRAPH_MIN_VERSION_rmm})
find_and_configure_rmm()
17 changes: 8 additions & 9 deletions cpp/cmake/thirdparty/get_thrust.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,15 @@
# limitations under the License.
#=============================================================================

function(find_and_configure_thrust VERSION)
function(find_and_configure_thrust)
include(${rapids-cmake-dir}/cpm/thrust.cmake)

rapids_cpm_find(Thrust ${VERSION}
CPM_ARGS
GIT_REPOSITORY https://github.com/thrust/thrust.git
GIT_TAG ${VERSION}
)

thrust_create_target(cugraph::Thrust FROM_OPTIONS)
rapids_cpm_thrust(
NAMESPACE cugraph
BUILD_EXPORT_SET raft-exports
INSTALL_EXPORT_SET raft-exports
)

endfunction()

find_and_configure_thrust(1.12.0)
find_and_configure_thrust()
20 changes: 0 additions & 20 deletions cpp/cmake/version_config.hpp.in

This file was deleted.

32 changes: 6 additions & 26 deletions cpp/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ target_link_libraries(cugraphtestutil


add_library(cugraphmgtestutil STATIC
"${CMAKE_CURRENT_SOURCE_DIR}/utilities/device_comm_wrapper.cu")
utilities/device_comm_wrapper.cu)

set_property(TARGET cugraphmgtestutil PROPERTY POSITION_INDEPENDENT_CODE ON)

Expand Down Expand Up @@ -241,19 +241,11 @@ endif(RAPIDS_DATASET_ROOT_DIR)

###################################################################################################
# - graph generator tests -------------------------------------------------------------------------

set(GRAPH_GENERATORS_TEST_SRC
"${CMAKE_CURRENT_SOURCE_DIR}/generators/generators_test.cpp")

ConfigureTest(GRAPH_GENERATORS_TEST "${GRAPH_GENERATORS_TEST_SRC}")
ConfigureTest(GRAPH_GENERATORS_TEST generators/generators_test.cpp)

###################################################################################################
# - erdos renyi graph generator tests -------------------------------------------------------------

set(ERDOS_RENYI_GENERATOR_TEST_SRC
"${CMAKE_CURRENT_SOURCE_DIR}/generators/erdos_renyi_test.cpp")

ConfigureTest(ERDOS_RENYI_GENERATOR_TEST "${ERDOS_RENYI_GENERATOR_TEST_SRC}")
ConfigureTest(ERDOS_RENYI_GENERATOR_TEST generators/erdos_renyi_test.cpp)

###################################################################################################
# - katz centrality tests -------------------------------------------------------------------------
Expand Down Expand Up @@ -374,11 +366,7 @@ ConfigureTest(KATZ_CENTRALITY_TEST centrality/katz_centrality_test.cpp)

###################################################################################################
# - WEAKLY CONNECTED COMPONENTS tests -------------------------------------------------------------

set(WEAKLY_CONNECTED_COMPONENTS_TEST_SRCS
"${CMAKE_CURRENT_SOURCE_DIR}/components/weakly_connected_components_test.cpp")

ConfigureTest(WEAKLY_CONNECTED_COMPONENTS_TEST "${WEAKLY_CONNECTED_COMPONENTS_TEST_SRCS}")
ConfigureTest(WEAKLY_CONNECTED_COMPONENTS_TEST components/weakly_connected_components_test.cpp)

###################################################################################################
# - Experimental RANDOM_WALKS tests ---------------------------------------------------------------
Expand All @@ -399,20 +387,12 @@ ConfigureTest(RANDOM_WALKS_PROFILING sampling/random_walks_profiling.cu)

###################################################################################################
# - Serialization tests ---------------------------------------------------------------------------

set(SERIALIZATION_TEST_SRCS
"${CMAKE_CURRENT_SOURCE_DIR}/serialization/un_serialize_test.cpp")

ConfigureTest(SERIALIZATION_TEST "${SERIALIZATION_TEST_SRCS}")
ConfigureTest(SERIALIZATION_TEST serialization/un_serialize_test.cpp)


###################################################################################################
# - BFS Visitor tests -----------------------------------------------------------------------------

set(BFS_VISITOR_TEST_SRCS
"${CMAKE_CURRENT_SOURCE_DIR}/visitors/bfs_test.cpp")

ConfigureTest(BFS_VISITOR_TEST "${BFS_VISITOR_TEST_SRCS}")
ConfigureTest(BFS_VISITOR_TEST visitors/bfs_test.cpp)

###################################################################################################
# - MG tests --------------------------------------------------------------------------------------
Expand Down

0 comments on commit 6f5803c

Please sign in to comment.