From 03dae45e476d86b1ba8c7bc6baa39603bb13d6aa Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Mon, 24 May 2021 20:52:19 -0400 Subject: [PATCH] Update `cugraph` to with newest CMake features, including CPM for dependencies (#1585) This allows the `cugraph` to be used via `CPM` either from a system installed version or from a build-directory. Authors: - Robert Maynard (https://github.com/robertmaynard) - Paul Taylor (https://github.com/trxcllnt) - Dante Gama Dessavre (https://github.com/dantegd) Approvers: - AJ Schmidt (https://github.com/ajschmidt8) - Rick Ratzel (https://github.com/rlratzel) URL: https://github.com/rapidsai/cugraph/pull/1585 --- build.sh | 10 +- ci/release/update-version.sh | 2 +- conda/environments/cugraph_dev_cuda11.0.yml | 2 +- conda/environments/cugraph_dev_cuda11.1.yml | 2 +- conda/environments/cugraph_dev_cuda11.2.yml | 2 +- conda/recipes/libcugraph/meta.yaml | 2 +- cpp/CMakeLists.txt | 528 ++++++-------------- cpp/cmake/EvalGpuArchs.cmake | 68 --- cpp/cmake/Modules/FindFAISS.cmake | 98 ---- cpp/cmake/Modules/FindNCCL.cmake | 116 ----- cpp/cmake/faiss_cuda11.patch | 40 -- cpp/cmake/thirdparty/get_cuco.cmake | 35 ++ cpp/cmake/thirdparty/get_cuhornet.cmake | 45 ++ cpp/cmake/thirdparty/get_faiss.cmake | 50 ++ cpp/cmake/thirdparty/get_gtest.cmake | 43 ++ cpp/cmake/thirdparty/get_gunrock.cmake | 64 +++ cpp/cmake/thirdparty/get_nccl.cmake | 42 ++ cpp/cmake/thirdparty/get_raft.cmake | 48 ++ cpp/cmake/thirdparty/get_rmm.cmake | 47 ++ cpp/cmake/thirdparty/get_thrust.cmake | 29 ++ cpp/tests/CMakeLists.txt | 430 ++++------------ python/setup.py | 5 +- python/setuputils.py | 67 +-- 23 files changed, 716 insertions(+), 1059 deletions(-) delete mode 100644 cpp/cmake/EvalGpuArchs.cmake delete mode 100644 cpp/cmake/Modules/FindFAISS.cmake delete mode 100644 cpp/cmake/Modules/FindNCCL.cmake delete mode 100644 cpp/cmake/faiss_cuda11.patch create mode 100644 cpp/cmake/thirdparty/get_cuco.cmake create mode 100644 cpp/cmake/thirdparty/get_cuhornet.cmake create mode 100644 cpp/cmake/thirdparty/get_faiss.cmake create mode 100644 cpp/cmake/thirdparty/get_gtest.cmake create mode 100644 cpp/cmake/thirdparty/get_gunrock.cmake create mode 100644 cpp/cmake/thirdparty/get_nccl.cmake create mode 100644 cpp/cmake/thirdparty/get_raft.cmake create mode 100644 cpp/cmake/thirdparty/get_rmm.cmake create mode 100644 cpp/cmake/thirdparty/get_thrust.cmake diff --git a/build.sh b/build.sh index 682e9b5ed33..8437a32bf94 100755 --- a/build.sh +++ b/build.sh @@ -53,7 +53,7 @@ INSTALL_TARGET=install BUILD_DISABLE_DEPRECATION_WARNING=ON BUILD_CPP_MG_TESTS=OFF BUILD_STATIC_FAISS=OFF -GPU_ARCH="" +BUILD_ALL_GPU_ARCH=0 # Set defaults for vars that may not have been defined externally # FIXME: if PREFIX is not set, check CONDA_PREFIX, but there is no fallback @@ -96,7 +96,7 @@ if hasArg -n; then INSTALL_TARGET="" fi if hasArg --allgpuarch; then - GPU_ARCH="-DGPU_ARCHS=ALL" + BUILD_ALL_GPU_ARCH=1 fi if hasArg --buildfaiss; then BUILD_STATIC_FAISS=ON @@ -154,15 +154,17 @@ fi ################################################################################ # Configure, build, and install libcugraph if buildAll || hasArg libcugraph; then - if [[ ${GPU_ARCH} == "" ]]; then + if (( ${BUILD_ALL_GPU_ARCH} == 0 )); then + CUGRAPH_CMAKE_CUDA_ARCHITECTURES="NATIVE" echo "Building for the architecture of the GPU in the system..." else + CUGRAPH_CMAKE_CUDA_ARCHITECTURES="ALL" echo "Building for *ALL* supported GPU architectures..." fi mkdir -p ${LIBCUGRAPH_BUILD_DIR} cd ${LIBCUGRAPH_BUILD_DIR} cmake -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \ - ${GPU_ARCH} \ + -DCMAKE_CUDA_ARCHITECTURES=${CUGRAPH_CMAKE_CUDA_ARCHITECTURES} \ -DDISABLE_DEPRECATION_WARNING=${BUILD_DISABLE_DEPRECATION_WARNING} \ -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ -DBUILD_STATIC_FAISS=${BUILD_STATIC_FAISS} \ diff --git a/ci/release/update-version.sh b/ci/release/update-version.sh index f381ed7f6fb..0629f19d3b8 100755 --- a/ci/release/update-version.sh +++ b/ci/release/update-version.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2018-2020, NVIDIA CORPORATION. +# Copyright (c) 2018-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 diff --git a/conda/environments/cugraph_dev_cuda11.0.yml b/conda/environments/cugraph_dev_cuda11.0.yml index 20d56b281d2..e12b6143e69 100644 --- a/conda/environments/cugraph_dev_cuda11.0.yml +++ b/conda/environments/cugraph_dev_cuda11.0.yml @@ -21,7 +21,7 @@ dependencies: - networkx>=2.5.1 - clang=8.0.1 - clang-tools=8.0.1 -- cmake>=3.18 +- cmake>=3.20.1 - python>=3.6,<3.9 - notebook>=0.5.0 - boost diff --git a/conda/environments/cugraph_dev_cuda11.1.yml b/conda/environments/cugraph_dev_cuda11.1.yml index 0eba2baccaa..3fd7013f475 100644 --- a/conda/environments/cugraph_dev_cuda11.1.yml +++ b/conda/environments/cugraph_dev_cuda11.1.yml @@ -21,7 +21,7 @@ dependencies: - networkx>=2.5.1 - clang=8.0.1 - clang-tools=8.0.1 -- cmake>=3.18 +- cmake>=3.20.1 - python>=3.6,<3.9 - notebook>=0.5.0 - boost diff --git a/conda/environments/cugraph_dev_cuda11.2.yml b/conda/environments/cugraph_dev_cuda11.2.yml index 55f6ad75cec..978cbf4dd5f 100644 --- a/conda/environments/cugraph_dev_cuda11.2.yml +++ b/conda/environments/cugraph_dev_cuda11.2.yml @@ -21,7 +21,7 @@ dependencies: - networkx>=2.5.1 - clang=8.0.1 - clang-tools=8.0.1 -- cmake>=3.18 +- cmake>=3.20.1 - python>=3.6,<3.9 - notebook>=0.5.0 - boost diff --git a/conda/recipes/libcugraph/meta.yaml b/conda/recipes/libcugraph/meta.yaml index 71b22c8cf1b..afab0d01dba 100644 --- a/conda/recipes/libcugraph/meta.yaml +++ b/conda/recipes/libcugraph/meta.yaml @@ -31,7 +31,7 @@ build: requirements: build: - - cmake>=3.12.4 + - cmake>=3.20.1 - cudatoolkit {{ cuda_version }}.* - librmm {{ minor_version }}.* - boost-cpp>=1.66 diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 978ec93cc2e..b0e52ba73b6 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -14,10 +14,47 @@ # limitations under the License. #============================================================================= -cmake_minimum_required(VERSION 3.18...3.18 FATAL_ERROR) +cmake_minimum_required(VERSION 3.20.1 FATAL_ERROR) +include(FetchContent) +FetchContent_Declare( + rapids-cmake + GIT_REPOSITORY https://github.com/rapidsai/rapids-cmake.git + GIT_TAG origin/branch-21.06 + ) +FetchContent_MakeAvailable(rapids-cmake) + +include(rapids-cmake) +include(rapids-cpm) +include(rapids-cuda) +include(rapids-export) +include(rapids-find) + +rapids_cuda_init_architectures(CUGRAPH) project(CUGRAPH VERSION 21.06.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) + string(REPLACE "-real" "" arch ${arch}) + if( arch IN_LIST supported_archs ) + list(APPEND usable_arch_values ${arch}) + endif() +endforeach() +# Make sure everything but the 'newest' arch +# is marked as `-real` so we only generate PTX for +# arch > 80 +list(POP_BACK usable_arch_values latest_arch) +list(TRANSFORM usable_arch_values APPEND "-real") +list(APPEND usable_arch_values ${latest_arch}) + +set(CMAKE_CUDA_ARCHITECTURES ${usable_arch_values}) + + # Write the version header include(cmake/Modules/Version.cmake) write_version() @@ -26,147 +63,59 @@ write_version() # - build type ------------------------------------------------------------------------------------ # Set a default build type if none was specified -set(DEFAULT_BUILD_TYPE "Release") - -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() +rapids_cmake_build_type(Release) ############################################################################## # - User Options ------------------------------------------------------------ option(BUILD_CUGRAPH_MG_TESTS "Build cuGraph multigpu algorithm tests" OFF) - -################################################################################################### -# - user options ------------------------------------------------------------------------------ - -set(BLAS_LIBRARIES "" CACHE STRING - "Location of BLAS library for FAISS build.") +set(BLAS_LIBRARIES "" CACHE STRING "Location of BLAS library for FAISS build.") option(BUILD_STATIC_FAISS "Build the FAISS library for nearest neighbors search on GPU" OFF) +option(CMAKE_CUDA_LINEINFO "Enable the -lineinfo option for nvcc (useful for cuda-memcheck / profiler" OFF) +option(BUILD_TESTS "Configure CMake to build tests" ON) ################################################################################################### # - compiler options ------------------------------------------------------------------------------ -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_C_COMPILER $ENV{CC}) -set(CMAKE_CXX_COMPILER $ENV{CXX}) -set(CMAKE_CXX_STANDARD_REQUIRED ON) +rapids_find_package(CUDAToolkit REQUIRED + BUILD_EXPORT_SET cugraph-exports + INSTALL_EXPORT_SET cugraph-exports + ) -set(CMAKE_CUDA_STANDARD 17) -set(CMAKE_CUDA_STANDARD_REQUIRED ON) +set(CUGRAPH_CXX_FLAGS "") +set(CUGRAPH_CUDA_FLAGS "") if(CMAKE_COMPILER_IS_GNUCXX) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wno-error=deprecated-declarations") + list(APPEND CUGRAPH_CXX_FLAGS -Werror -Wno-error=deprecated-declarations) endif(CMAKE_COMPILER_IS_GNUCXX) -find_package(CUDA) - -# Configure GPU arch to build -set(GUNROCK_GENCODE_SM60 "OFF") -set(GUNROCK_GENCODE_SM61 "OFF") -set(GUNROCK_GENCODE_SM70 "OFF") -set(GUNROCK_GENCODE_SM72 "OFF") -set(GUNROCK_GENCODE_SM75 "OFF") -set(GUNROCK_GENCODE_SM80 "OFF") - -# ARCHS handling: -# -if("${GPU_ARCHS}" STREQUAL "") - include(cmake/EvalGpuArchs.cmake) - evaluate_gpu_archs(GPU_ARCHS) -endif() - -# CUDA 11 onwards cub ships with CTK -if((CUDA_VERSION_MAJOR EQUAL 11) OR (CUDA_VERSION_MAJOR GREATER 11)) - set(CUB_IS_PART_OF_CTK ON) -else() - set(CUB_IS_PART_OF_CTK OFF) -endif() +message("-- Building for GPU_ARCHS = ${CMAKE_CUDA_ARCHITECTURES}") -if("${GPU_ARCHS}" STREQUAL "ALL") - set(GPU_ARCHS "60") - if((CUDA_VERSION_MAJOR EQUAL 9) OR (CUDA_VERSION_MAJOR GREATER 9)) - set(GPU_ARCHS "${GPU_ARCHS};70") - endif() - if((CUDA_VERSION_MAJOR EQUAL 10) OR (CUDA_VERSION_MAJOR GREATER 10)) - set(GPU_ARCHS "${GPU_ARCHS};75") - endif() - if((CUDA_VERSION_MAJOR EQUAL 11) OR (CUDA_VERSION_MAJOR GREATER 11)) - set(GPU_ARCHS "${GPU_ARCHS};80") - endif() -endif() - -message("-- Building for GPU_ARCHS = ${GPU_ARCHS}") -foreach(arch ${GPU_ARCHS}) - set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -gencode arch=compute_${arch},code=sm_${arch}") - set(GUNROCK_GENCODE_SM${arch} "ON") - set(FAISS_GPU_ARCHS "${FAISS_GPU_ARCHS} -gencode arch=compute_${arch},code=sm_${arch}") -endforeach() - -list(GET GPU_ARCHS -1 ptx) -set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -gencode arch=compute_${ptx},code=compute_${ptx}") -set(FAISS_GPU_ARCHS "${FAISS_GPU_ARCHS} -gencode arch=compute_${ptx},code=compute_${ptx}") - -set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --expt-extended-lambda --expt-relaxed-constexpr") -set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Werror=cross-execution-space-call -Wno-deprecated-declarations -Xptxas --disable-warnings") -set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler -Wall,-Wno-error=sign-compare,-Wno-error=unused-but-set-variable") -set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xfatbin=-compress-all") +list(APPEND CUGRAPH_CUDA_FLAGS --expt-extended-lambda --expt-relaxed-constexpr) +list(APPEND CUGRAPH_CUDA_FLAGS -Werror=cross-execution-space-call -Wno-deprecated-declarations -Xptxas=--disable-warnings) +list(APPEND CUGRAPH_CUDA_FLAGS -Xcompiler=-Wall,-Wno-error=sign-compare,-Wno-error=unused-but-set-variable) +list(APPEND CUGRAPH_CUDA_FLAGS -Xfatbin=-compress-all) # Option to enable line info in CUDA device compilation to allow introspection when profiling / # memchecking -option(CMAKE_CUDA_LINEINFO "Enable the -lineinfo option for nvcc (useful for cuda-memcheck / profiler" OFF) if (CMAKE_CUDA_LINEINFO) - set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -lineinfo") + list(APPEND CUGRAPH_CUDA_FLAGS -lineinfo) endif(CMAKE_CUDA_LINEINFO) # Debug options if(CMAKE_BUILD_TYPE MATCHES Debug) message(STATUS "Building with debugging flags") - set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -G -Xcompiler -rdynamic") + list(APPEND CUGRAPH_CUDA_FLAGS -G -Xcompiler=-rdynamic) endif(CMAKE_BUILD_TYPE MATCHES Debug) -# 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") - -option(BUILD_TESTS "Configure CMake to build tests" - ON) - -################################################################################################### -# - cmake modules --------------------------------------------------------------------------------- - -set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/" ${CMAKE_MODULE_PATH}) - -include(FeatureSummary) -include(CheckIncludeFiles) -include(CheckLibraryExists) -if(BUILD_TESTS) - include(CTest) -endif(BUILD_TESTS) - -################################################################################################### -# - find boost ------------------------------------------------------------------------------------ - -find_package(Boost REQUIRED) -if(Boost_FOUND) - message(STATUS "Boost found in ${Boost_INCLUDE_DIRS}") -else() - message(FATAL_ERROR "Boost not found, please check your settings.") -endif(Boost_FOUND) - ################################################################################################### # - find openmp ----------------------------------------------------------------------------------- find_package(OpenMP) if(OpenMP_FOUND) # find_package(OPenMP) does not automatically add OpenMP flags to CUDA - set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler=${OpenMP_CXX_FLAGS}") + list(APPEND CUGRAPH_CUDA_FLAGS -Xcompiler=${OpenMP_CXX_FLAGS}) endif(OpenMP_FOUND) @@ -180,218 +129,28 @@ else() endif() ################################################################################################### -# - find gtest ------------------------------------------------------------------------------------ - -if(BUILD_TESTS) - find_package(GTest REQUIRED) -endif(BUILD_TESTS) - -################################################################################################### -# - find RMM -------------------------------------------------------------------------------------- - -find_path(RMM_INCLUDE "rmm" - HINTS - "$ENV{RMM_ROOT}/include" - "$ENV{CONDA_PREFIX}/include/rmm" - "$ENV{CONDA_PREFIX}/include") - -message(STATUS "RMM: RMM_INCLUDE set to ${RMM_INCLUDE}") - -################################################################################################### -# - find NCCL ------------------------------------------------------------------------------------- - -if(NOT NCCL_PATH) - find_package(NCCL REQUIRED) -else() - message("-- Manually set NCCL PATH to ${NCCL_PATH}") - set(NCCL_INCLUDE_DIRS ${NCCL_PATH}/include) - set(NCCL_LIBRARIES ${NCCL_PATH}/lib/libnccl.so) -endif(NOT NCCL_PATH) - -################################################################################################### -# - find MPI - only enabled if MG tests are to be built - -if(BUILD_CUGRAPH_MG_TESTS) - find_package(MPI REQUIRED) -endif(BUILD_CUGRAPH_MG_TESTS) - -################################################################################################### -# - Fetch Content --------------------------------------------------------------------------------- -include(FetchContent) - -# - THRUST/CUB -message("Fetching Thrust") - -FetchContent_Declare( - thrust - GIT_REPOSITORY https://github.com/thrust/thrust.git - GIT_TAG 1.12.0 -) - -FetchContent_GetProperties(thrust) -if(NOT thrust_POPULATED) - FetchContent_Populate(thrust) - # We are not using the thrust CMake targets, so no need to call `add_subdirectory()`. -endif() -set(THRUST_INCLUDE_DIR "${thrust_SOURCE_DIR}") +# - find CPM based dependencies ------------------------------------------------------------------ -# - cuco -message("Fetching cuco") -FetchContent_Declare( - cuco - GIT_REPOSITORY https://github.com/NVIDIA/cuCollections.git - GIT_TAG 7678a5ecaa192b8983b02a0191a140097171713e -) +rapids_cpm_init() -FetchContent_GetProperties(cuco) -if(NOT cuco_POPULATED) - FetchContent_Populate(cuco) -endif() -set(CUCO_INCLUDE_DIR "${cuco_SOURCE_DIR}/include") -# - libcudacxx -# NOTE: This is necessary because libcudacxx is not supported in -# debian cuda 10.2 packages. Once 10.2 is deprecated -# we should not need this any longer. -message("Fetching libcudacxx") +include(cmake/thirdparty/get_thrust.cmake) +include(cmake/thirdparty/get_faiss.cmake) +include(cmake/thirdparty/get_nccl.cmake) +include(cmake/thirdparty/get_rmm.cmake) -FetchContent_Declare( - libcudacxx - GIT_REPOSITORY https://github.com/NVIDIA/libcudacxx.git - GIT_TAG 1.3.0 - GIT_SHALLOW true -) +include(cmake/thirdparty/get_raft.cmake) -FetchContent_GetProperties(libcudacxx) -if(NOT libcudacxx_POPULATED) - message("populating libcudacxx") - FetchContent_Populate(libcudacxx) -endif() -set(LIBCUDACXX_INCLUDE_DIR "${libcudacxx_SOURCE_DIR}/include") -message("set LIBCUDACXX_INCLUDE_DIR to: ${LIBCUDACXX_INCLUDE_DIR}") +include(cmake/thirdparty/get_cuco.cmake) +include(cmake/thirdparty/get_cuhornet.cmake) -# - CUHORNET -FetchContent_Declare( - cuhornet - GIT_REPOSITORY https://github.com/rapidsai/cuhornet.git - GIT_TAG 261399356e62bd76fa7628880f1a847aee713eed - SOURCE_SUBDIR hornet -) +include(cmake/thirdparty/get_gunrock.cmake) -FetchContent_GetProperties(cuhornet) -if(NOT cuhornet_POPULATED) - message("populating cuhornet") - FetchContent_Populate(cuhornet) - # We are not using the cuhornet CMake targets, so no need to call `add_subdirectory()`. +if(BUILD_TESTS) + include(cmake/thirdparty/get_gtest.cmake) endif() -set(CUHORNET_INCLUDE_DIR ${cuhornet_SOURCE_DIR} CACHE STRING "Path to cuhornet includes") - -# - raft - (header only) -# Only cloned if RAFT_PATH env variable is not defined -if(DEFINED ENV{RAFT_PATH}) - message(STATUS "RAFT_PATH environment variable detected.") - message(STATUS "RAFT_DIR set to $ENV{RAFT_PATH}") - set(RAFT_DIR "$ENV{RAFT_PATH}") - -else(DEFINED ENV{RAFT_PATH}) - message(STATUS "RAFT_PATH environment variable NOT detected, cloning RAFT") - - FetchContent_Declare( - raft - GIT_REPOSITORY https://github.com/rapidsai/raft.git - GIT_TAG 66f82b4e79a3e268d0da3cc864ec7ce4ad065296 - SOURCE_SUBDIR raft - ) - - FetchContent_GetProperties(raft) - if(NOT raft_POPULATED) - message("populating raft") - FetchContent_Populate(raft) - # We are not using any raft CMake targets, so no need to call `add_subdirectory()`. - endif() - - set(RAFT_DIR "${raft_SOURCE_DIR}") -endif(DEFINED ENV{RAFT_PATH}) - -################################################################################################### -# - External Projects ----------------------------------------------------------------------------- - -# https://cmake.org/cmake/help/v3.0/module/ExternalProject.html - -# FIXME: gunrock is still using ExternalProject instead of -# FetchContent. Consider migrating to FetchContent soon (this may require -# updates to the gunrock cmake files to support this). - -include(ExternalProject) - -# - GUNROCK -set(GUNROCK_DIR ${CMAKE_CURRENT_BINARY_DIR}/gunrock CACHE STRING "Path to gunrock repo") -set(GUNROCK_INCLUDE_DIR ${GUNROCK_DIR}/src/gunrock_ext CACHE STRING "Path to gunrock includes") - -ExternalProject_Add(gunrock_ext - GIT_REPOSITORY https://github.com/gunrock/gunrock.git - GIT_TAG v1.2 - PREFIX ${GUNROCK_DIR} - CMAKE_ARGS -DCMAKE_INSTALL_PREFIX= - -DGUNROCK_BUILD_SHARED_LIBS=OFF - -DGUNROCK_BUILD_TESTS=OFF - -DCUDA_AUTODETECT_GENCODE=OFF - -DGUNROCK_GENCODE_SM60=${GUNROCK_GENCODE_SM60} - -DGUNROCK_GENCODE_SM61=${GUNROCK_GENCODE_SM61} - -DGUNROCK_GENCODE_SM70=${GUNROCK_GENCODE_SM70} - -DGUNROCK_GENCODE_SM72=${GUNROCK_GENCODE_SM72} - -DGUNROCK_GENCODE_SM75=${GUNROCK_GENCODE_SM75} - -DGUNROCK_GENCODE_SM80=${GUNROCK_GENCODE_SM80} - ${GUNROCK_GENCODE} - BUILD_BYPRODUCTS ${GUNROCK_DIR}/src/gunrock_ext-build/lib/libgunrock.a - INSTALL_COMMAND "" -) -add_library(gunrock STATIC IMPORTED) -add_dependencies(gunrock gunrock_ext) -set_property(TARGET gunrock PROPERTY IMPORTED_LOCATION ${GUNROCK_DIR}/src/gunrock_ext-build/lib/libgunrock.a) - -# - FAISS -# FIXME: The commit currently being fetched from faiss is using autotools which -# is more convenient to build with ExternalProjectAdd. -# Consider migrating to FetchContent once the tagged commit is changed. - -if(BUILD_STATIC_FAISS) - set(FAISS_DIR ${CMAKE_CURRENT_BINARY_DIR}/faiss CACHE STRING - "Path to FAISS source directory") - ExternalProject_Add(faiss - GIT_REPOSITORY https://github.com/facebookresearch/faiss.git - GIT_TAG 7c2d2388a492d65fdda934c7e74ae87acaeed066 - CONFIGURE_COMMAND LIBS=-pthread - CPPFLAGS=-w - LDFLAGS=-L${CMAKE_INSTALL_PREFIX}/lib - cmake -B build . - -DCMAKE_BUILD_TYPE=Release - -DBUILD_TESTING=OFF - -DFAISS_ENABLE_PYTHON=OFF - -DBUILD_SHARED_LIBS=OFF - -DFAISS_ENABLE_GPU=ON - -DCUDAToolkit_ROOT=${CUDA_TOOLKIT_ROOT_DIR} - -DCUDA_ARCHITECTURES=${FAISS_GPU_ARCHS} - -DBLAS_LIBRARIES=${BLAS_LIBRARIES} - PREFIX ${FAISS_DIR} - BUILD_COMMAND make -C build -j${PARALLEL_LEVEL} VERBOSE=1 - BUILD_BYPRODUCTS ${FAISS_DIR}/src/faiss/build/faiss/libfaiss.a - BUILD_ALWAYS 1 - INSTALL_COMMAND "" - UPDATE_COMMAND "" - BUILD_IN_SOURCE 1) - - ExternalProject_Get_Property(faiss install_dir) - add_library(FAISS::FAISS STATIC IMPORTED) - set_property(TARGET FAISS::FAISS PROPERTY - IMPORTED_LOCATION ${FAISS_DIR}/src/faiss/build/faiss/libfaiss.a) - set(FAISS_INCLUDE_DIRS "${FAISS_DIR}/src/faiss") -else() - set(FAISS_INSTALL_DIR ENV{FAISS_ROOT}) - find_package(FAISS REQUIRED) -endif(BUILD_STATIC_FAISS) ################################################################################################### # - library targets ------------------------------------------------------------------------------- @@ -443,50 +202,68 @@ add_library(cugraph SHARED src/utilities/host_barrier.cpp ) -target_link_directories(cugraph - PRIVATE - # CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES is an undocumented/unsupported variable containing the - # link directories for nvcc. - "${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}") +set_target_properties(cugraph + PROPERTIES BUILD_RPATH "\$ORIGIN" + INSTALL_RPATH "\$ORIGIN" + # set target compile options + CXX_STANDARD 17 + CXX_STANDARD_REQUIRED ON + CUDA_STANDARD 17 + CUDA_STANDARD_REQUIRED ON + INTERFACE_POSITION_INDEPENDENT_CODE ON +) -# -# NOTE: This dependency will force the building of cugraph to -# wait until after cugunrock is constructed. -# -add_dependencies(cugraph gunrock_ext) +target_compile_options(cugraph + PRIVATE "$<$:${CUGRAPH_CXX_FLAGS}>" + "$<$:${CUGRAPH_CUDA_FLAGS}>" +) # Per-thread default stream option see https://docs.nvidia.com/cuda/cuda-runtime-api/stream-sync-behavior.html # The per-thread default stream does not synchronize with other streams target_compile_definitions(cugraph PUBLIC CUDA_API_PER_THREAD_DEFAULT_STREAM) +file(WRITE "${CUGRAPH_BINARY_DIR}/fatbin.ld" +[=[ +SECTIONS +{ + .nvFatBinSegment : { *(.nvFatBinSegment) } + .nv_fatbin : { *(.nv_fatbin) } +} +]=]) +target_link_options(cugraph PRIVATE "${CUGRAPH_BINARY_DIR}/fatbin.ld") + +add_library(cugraph::cugraph ALIAS cugraph) + ################################################################################################### # - include paths --------------------------------------------------------------------------------- target_include_directories(cugraph PRIVATE - "${THRUST_INCLUDE_DIR}" - "${CUCO_INCLUDE_DIR}" - "${LIBCUDACXX_INCLUDE_DIR}" - "${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}" - "${Boost_INCLUDE_DIRS}" - "${RMM_INCLUDE}" - "${CMAKE_CURRENT_SOURCE_DIR}/../thirdparty" - "${CUHORNET_INCLUDE_DIR}/hornet/include" - "${CUHORNET_INCLUDE_DIR}/hornetsnest/include" - "${CUHORNET_INCLUDE_DIR}/xlib/include" - "${CUHORNET_INCLUDE_DIR}/primitives" - "${CMAKE_CURRENT_SOURCE_DIR}/src" - "${GUNROCK_INCLUDE_DIR}" - "${NCCL_INCLUDE_DIRS}" - "${RAFT_DIR}/cpp/include" + "${CMAKE_CURRENT_SOURCE_DIR}/../thirdparty" + "${CMAKE_CURRENT_SOURCE_DIR}/src" + "${NCCL_INCLUDE_DIRS}" PUBLIC - "${CMAKE_CURRENT_SOURCE_DIR}/include" + "$" + "$" ) ################################################################################################### # - link libraries -------------------------------------------------------------------------------- - -target_link_libraries(cugraph PRIVATE - gunrock cublas cusparse curand cusolver cudart cuda FAISS::FAISS ${NCCL_LIBRARIES}) +target_link_libraries(cugraph + PUBLIC + rmm::rmm + cugraph::Thrust + raft::raft + PRIVATE + cuco::cuco + CUDA::cublas + CUDA::curand + CUDA::cusolver + CUDA::cusparse + cugraph::cuHornet + FAISS::FAISS + gunrock + NCCL::NCCL +) if(OpenMP_CXX_FOUND) target_link_libraries(cugraph PRIVATE @@ -539,49 +316,74 @@ target_link_libraries(cugraph PRIVATE ${OpenMP_CXX_LIB_NAMES}) endif(OpenMP_CXX_FOUND) -# CUDA_ARCHITECTURES=OFF implies cmake will not pass arch flags to the -# compiler. CUDA_ARCHITECTURES must be set to a non-empty value to prevent cmake -# warnings about policy CMP0104. With this setting, arch flags must be manually -# set! ("evaluate_gpu_archs(GPU_ARCHS)" is the current mechanism used in -# cpp/CMakeLists.txt for setting arch options). Run "cmake --help-policy -# CMP0104" for policy details. -# NOTE: the CUDA_ARCHITECTURES=OFF setting may be removed after migrating to the -# findcudatoolkit features in cmake 3.17+ -set_target_properties(cugraph PROPERTIES - CUDA_ARCHITECTURES OFF) ################################################################################################### # - generate tests -------------------------------------------------------------------------------- if(BUILD_TESTS) - if(GTEST_FOUND) - add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tests) - endif(GTEST_FOUND) + include(CTest) + add_subdirectory(tests) endif(BUILD_TESTS) ################################################################################################### # - install targets ------------------------------------------------------------------------------- -install(TARGETS cugraph LIBRARY - DESTINATION lib) +install(TARGETS cugraph + DESTINATION lib + EXPORT cugraph-exports) install(DIRECTORY include/ - DESTINATION include/cugraph) + DESTINATION include/cugraph) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/include/cugraph/version_config.hpp DESTINATION include/cugraph) -install(DIRECTORY ${RAFT_DIR}/cpp/include/raft/ - DESTINATION include/cugraph/raft) +################################################################################################ +# - install export ------------------------------------------------------------------------------- +set(doc_string +[=[ +Provide targets for cuGraph. + +cuGraph library is a collection of GPU accelerated graph algorithms that process data found in +[GPU DataFrames](https://github.com/rapidsai/cudf). + +]=]) + +set(code_string +[=[ +thrust_create_target(cugraph::Thrust FROM_OPTIONS) +]=]) + + rapids_export(INSTALL cugraph + EXPORT_SET cugraph-exports + GLOBAL_TARGETS cugraph + NAMESPACE cugraph:: + DOCUMENTATION doc_string + FINAL_CODE_BLOCK code_string + ) + +################################################################################################ +# - build export ------------------------------------------------------------------------------- +rapids_export(BUILD cugraph + EXPORT_SET cugraph-exports + GLOBAL_TARGETS cugraph + NAMESPACE cugraph:: + DOCUMENTATION doc_string + FINAL_CODE_BLOCK code_string + ) + ################################################################################################### # - make documentation ---------------------------------------------------------------------------- # requires doxygen and graphviz to be installed # from build directory, run make docs_cugraph -# doc targets for cuGraph -add_custom_command(OUTPUT CUGRAPH_DOXYGEN - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/doxygen - COMMAND doxygen Doxyfile - VERBATIM) +# doc targets for cugraph +find_package(Doxygen 1.8.11) +if(Doxygen_FOUND) + add_custom_command(OUTPUT CUGRAPH_DOXYGEN + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/doxygen + COMMAND doxygen Doxyfile + VERBATIM) -add_custom_target(docs_cugraph DEPENDS CUGRAPH_DOXYGEN) + add_custom_target(docs_cugraph DEPENDS CUGRAPH_DOXYGEN) +endif() diff --git a/cpp/cmake/EvalGpuArchs.cmake b/cpp/cmake/EvalGpuArchs.cmake deleted file mode 100644 index f3918542db9..00000000000 --- a/cpp/cmake/EvalGpuArchs.cmake +++ /dev/null @@ -1,68 +0,0 @@ -# Copyright (c) 2019-2020, 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(evaluate_gpu_archs gpu_archs) - set(eval_file ${PROJECT_BINARY_DIR}/eval_gpu_archs.cu) - set(eval_exe ${PROJECT_BINARY_DIR}/eval_gpu_archs) - file(WRITE ${eval_file} - " -#include -#include -#include -using namespace std; -int main(int argc, char** argv) { - set archs; - int nDevices; - if((cudaGetDeviceCount(&nDevices) == cudaSuccess) && (nDevices > 0)) { - for(int dev=0;dev::const_iterator itr=archs.begin();itr!=archs.end();++itr) { - printf(first? \"%s\" : \";%s\", itr->c_str()); - first = false; - } - } - printf(\"\\n\"); - return 0; -} -") - execute_process( - COMMAND ${CUDA_NVCC_EXECUTABLE} - -o ${eval_exe} - --run - ${eval_file} - OUTPUT_VARIABLE __gpu_archs - OUTPUT_STRIP_TRAILING_WHITESPACE) - set(__gpu_archs_filtered "${__gpu_archs}") - foreach(arch ${__gpu_archs}) - if (arch VERSION_LESS 60) - list(REMOVE_ITEM __gpu_archs_filtered ${arch}) - endif() - endforeach() - if (NOT __gpu_archs_filtered) - message(FATAL_ERROR "No supported GPU arch found on this system") - endif() - message("Auto detection of gpu-archs: ${__gpu_archs_filtered}") - set(${gpu_archs} ${__gpu_archs_filtered} PARENT_SCOPE) -endfunction(evaluate_gpu_archs) diff --git a/cpp/cmake/Modules/FindFAISS.cmake b/cpp/cmake/Modules/FindFAISS.cmake deleted file mode 100644 index 7c456edfeef..00000000000 --- a/cpp/cmake/Modules/FindFAISS.cmake +++ /dev/null @@ -1,98 +0,0 @@ -# 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. -# - -# Based on FindPNG.cmake from cmake 3.14.3 - -#[=======================================================================[.rst: -FindFAISS --------- - -Template to generate FindPKG_NAME.cmake CMake modules - -Find FAISS - -Imported targets -^^^^^^^^^^^^^^^^ - -This module defines the following :prop_tgt:`IMPORTED` target: - -``FAISS::FAISS`` - The libFAISS library, if found. - -Result variables -^^^^^^^^^^^^^^^^ - -This module will set the following variables in your project: - -``FAISS_INCLUDE_DIRS`` - where to find FAISS.hpp , etc. -``FAISS_LIBRARIES`` - the libraries to link against to use libFAISS. -``FAISS_FOUND`` - If false, do not try to use FAISS. -``FAISS_VERSION_STRING`` - the version of the FAISS library found - -#]=======================================================================] - -find_path(FAISS_LOCATION faiss/IndexFlat.h - HINTS ${FAISS_INSTALL_DIR} - PATH_SUFFIXES include include/) - -list(APPEND FAISS_NAMES faiss libfaiss) -set(_FAISS_VERSION_SUFFIXES ) - -foreach(v IN LISTS _FAISS_VERSION_SUFFIXES) - list(APPEND FAISS_NAMES faiss${v} libfaiss${v}) - list(APPEND FAISS_NAMES faiss.${v} libfaiss.${v}) -endforeach() -unset(_FAISS_VERSION_SUFFIXES) - -find_library(FAISS_LIBRARY_RELEASE NAMES ${FAISS_NAMES} - HINTS ${FAISS_INSTALL_DIR} - PATH_SUFFIXES lib) - -include(${CMAKE_ROOT}/Modules/SelectLibraryConfigurations.cmake) -select_library_configurations(FAISS) -mark_as_advanced(FAISS_LIBRARY_RELEASE) -unset(FAISS_NAMES) - -# Set by select_library_configurations(), but we want the one from -# find_package_handle_standard_args() below. -unset(FAISS_FOUND) - -if (FAISS_LIBRARY AND FAISS_LOCATION) - set(FAISS_INCLUDE_DIRS ${FAISS_LOCATION} ) - set(FAISS_LIBRARY ${FAISS_LIBRARY}) - - if(NOT TARGET FAISS::FAISS) - add_library(FAISS::FAISS UNKNOWN IMPORTED) - set_target_properties(FAISS::FAISS PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${FAISS_INCLUDE_DIRS}") - if(EXISTS "${FAISS_LIBRARY}") - set_target_properties(FAISS::FAISS PROPERTIES - IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" - IMPORTED_LOCATION "${FAISS_LIBRARY}") - endif() - endif() -endif () - - -include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake) -find_package_handle_standard_args(FAISS - REQUIRED_VARS FAISS_LIBRARY FAISS_LOCATION - VERSION_VAR FAISS_VERSION_STRING) - -mark_as_advanced(FAISS_LOCATION FAISS_LIBRARY) diff --git a/cpp/cmake/Modules/FindNCCL.cmake b/cpp/cmake/Modules/FindNCCL.cmake deleted file mode 100644 index 0f673707444..00000000000 --- a/cpp/cmake/Modules/FindNCCL.cmake +++ /dev/null @@ -1,116 +0,0 @@ -# Copyright (c) 2019-2020, 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. -# - -# Based on FindPNG.cmake from cmake 3.14.3 - -#[=======================================================================[.rst: -FindNCCL --------- - -Find libnccl, the NVIDIA Collective Communication Library. A hint to find NCCL -can be provided by setting NCCL_INSTALL_DIR. - -Imported targets -^^^^^^^^^^^^^^^^ - -This module defines the following :prop_tgt:`IMPORTED` target: - -``NCCL::NCCL`` - The libnccl library, if found. - -Result variables -^^^^^^^^^^^^^^^^ - -This module will set the following variables in your project: - -``NCCL_INCLUDE_DIRS`` - where to find nccl.h , etc. -``NCCL_LIBRARIES`` - the libraries to link against to use NCCL. -``NCCL_FOUND`` - If false, do not try to use NCCL. -``NCCL_VERSION_STRING`` - the version of the NCCL library found - -#]=======================================================================] - -find_path(NCCL_NCCL_INCLUDE_DIR nccl.h HINTS ${NCCL_INSTALL_DIR} PATH_SUFFIXES include) - -#TODO: Does this need to support finding the static library? - -list(APPEND NCCL_NAMES nccl libnccl) -set(_NCCL_VERSION_SUFFIXES 2) - -foreach(v IN LISTS _NCCL_VERSION_SUFFIXES) - list(APPEND NCCL_NAMES nccl${v} libnccl${v}) -endforeach() -unset(_NCCL_VERSION_SUFFIXES) -# For compatibility with versions prior to this multi-config search, honor -# any NCCL_LIBRARY that is already specified and skip the search. -if(NOT NCCL_LIBRARY) - find_library(NCCL_LIBRARY_RELEASE NAMES ${NCCL_NAMES} HINTS ${NCCL_INSTALL_DIR} PATH_SUFFIXES lib) - include(${CMAKE_ROOT}/Modules/SelectLibraryConfigurations.cmake) - select_library_configurations(NCCL) - mark_as_advanced(NCCL_LIBRARY_RELEASE) -endif() -unset(NCCL_NAMES) - -# Set by select_library_configurations(), but we want the one from -# find_package_handle_standard_args() below. -unset(NCCL_FOUND) - -if (NCCL_LIBRARY AND NCCL_NCCL_INCLUDE_DIR) - set(NCCL_INCLUDE_DIRS ${NCCL_NCCL_INCLUDE_DIR} ) - set(NCCL_LIBRARY ${NCCL_LIBRARY}) - - if(NOT TARGET NCCL::NCCL) - add_library(NCCL::NCCL UNKNOWN IMPORTED) - set_target_properties(NCCL::NCCL PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${NCCL_INCLUDE_DIRS}") - if(EXISTS "${NCCL_LIBRARY}") - set_target_properties(NCCL::NCCL PROPERTIES - IMPORTED_LINK_INTERFACE_LANGUAGES "C" - IMPORTED_LOCATION "${NCCL_LIBRARY}") - endif() - endif() -endif () - -if (NCCL_NCCL_INCLUDE_DIR AND EXISTS "${NCCL_NCCL_INCLUDE_DIR}/nccl.h") - file(STRINGS "${NCCL_NCCL_INCLUDE_DIR}/nccl.h" nccl_major_version_str REGEX "^#define[ \t]+NCCL_MAJOR[ \t]+[0-9]+") - string(REGEX REPLACE "^#define[ \t]+NCCL_MAJOR[ \t]+([0-9]+)" "\\1" nccl_major_version_str "${nccl_major_version_str}") - - file(STRINGS "${NCCL_NCCL_INCLUDE_DIR}/nccl.h" nccl_minor_version_str REGEX "^#define[ \t]+NCCL_MINOR[ \t]+[0-9]+") - string(REGEX REPLACE "^#define[ \t]+NCCL_MINOR[ \t]+([0-9]+)" "\\1" nccl_minor_version_str "${nccl_minor_version_str}") - - file(STRINGS "${NCCL_NCCL_INCLUDE_DIR}/nccl.h" nccl_patch_version_str REGEX "^#define[ \t]+NCCL_PATCH[ \t]+[0-9]+") - string(REGEX REPLACE "^#define[ \t]+NCCL_PATCH[ \t]+([0-9]+)" "\\1" nccl_patch_version_str "${nccl_patch_version_str}") - - file(STRINGS "${NCCL_NCCL_INCLUDE_DIR}/nccl.h" nccl_suffix_version_str REGEX "^#define[ \t]+NCCL_SUFFIX[ \t]+\".*\"") - string(REGEX REPLACE "^#define[ \t]+NCCL_SUFFIX[ \t]+\"(.*)\"" "\\1" nccl_suffix_version_str "${nccl_suffix_version_str}") - - set(NCCL_VERSION_STRING "${nccl_major_version_str}.${nccl_minor_version_str}.${nccl_patch_version_str}${nccl_suffix_version_str}") - - unset(nccl_major_version_str) - unset(nccl_minor_version_str) - unset(nccl_patch_version_str) - unset(nccl_suffix_version_str) -endif () - -include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake) -find_package_handle_standard_args(NCCL - REQUIRED_VARS NCCL_LIBRARY NCCL_NCCL_INCLUDE_DIR - VERSION_VAR NCCL_VERSION_STRING) - -mark_as_advanced(NCCL_NCCL_INCLUDE_DIR NCCL_LIBRARY) diff --git a/cpp/cmake/faiss_cuda11.patch b/cpp/cmake/faiss_cuda11.patch deleted file mode 100644 index 496ca0e7b23..00000000000 --- a/cpp/cmake/faiss_cuda11.patch +++ /dev/null @@ -1,40 +0,0 @@ -diff --git a/configure b/configure -index ed40dae..f88ed0a 100755 ---- a/configure -+++ b/configure -@@ -2970,7 +2970,7 @@ ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ex - ac_compiler_gnu=$ac_cv_cxx_compiler_gnu - - -- ax_cxx_compile_alternatives="11 0x" ax_cxx_compile_cxx11_required=true -+ ax_cxx_compile_alternatives="14 11 0x" ax_cxx_compile_cxx11_required=true - ac_ext=cpp - ac_cpp='$CXXCPP $CPPFLAGS' - ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -diff --git a/gpu/utils/DeviceDefs.cuh b/gpu/utils/DeviceDefs.cuh -index 89d3dda..bc0f9b5 100644 ---- a/gpu/utils/DeviceDefs.cuh -+++ b/gpu/utils/DeviceDefs.cuh -@@ -13,7 +13,7 @@ - namespace faiss { namespace gpu { - - #ifdef __CUDA_ARCH__ --#if __CUDA_ARCH__ <= 750 -+#if __CUDA_ARCH__ <= 800 - constexpr int kWarpSize = 32; - #else - #error Unknown __CUDA_ARCH__; please define parameters for compute capability -diff --git a/gpu/utils/MatrixMult-inl.cuh b/gpu/utils/MatrixMult-inl.cuh -index ede225e..4f7eb44 100644 ---- a/gpu/utils/MatrixMult-inl.cuh -+++ b/gpu/utils/MatrixMult-inl.cuh -@@ -51,6 +51,9 @@ rawGemm(cublasHandle_t handle, - auto cBT = GetCudaType::Type; - - // Always accumulate in f32 -+# if __CUDACC_VER_MAJOR__ >= 11 -+ cublasSetMathMode(handle, CUBLAS_MATH_DISALLOW_REDUCED_PRECISION_REDUCTION); -+# endif - return cublasSgemmEx(handle, transa, transb, m, n, k, - &fAlpha, A, cAT, lda, - B, cBT, ldb, diff --git a/cpp/cmake/thirdparty/get_cuco.cmake b/cpp/cmake/thirdparty/get_cuco.cmake new file mode 100644 index 00000000000..a255793285f --- /dev/null +++ b/cpp/cmake/thirdparty/get_cuco.cmake @@ -0,0 +1,35 @@ +#============================================================================= +# 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(find_and_configure_cuco VERSION) + + rapids_cpm_find(cuco ${VERSION} + GLOBAL_TARGETS cuco cuco::cuco + CPM_ARGS + GIT_REPOSITORY https://github.com/NVIDIA/cuCollections.git + GIT_TAG 7678a5ecaa192b8983b02a0191a140097171713e + OPTIONS "BUILD_TESTS OFF" + "BUILD_BENCHMARKS OFF" + "BUILD_EXAMPLES OFF" + ) + + if(NOT TARGET cuco::cuco) + add_library(cuco::cuco ALIAS cuco) + endif() + +endfunction() + +find_and_configure_cuco(0.0.1) diff --git a/cpp/cmake/thirdparty/get_cuhornet.cmake b/cpp/cmake/thirdparty/get_cuhornet.cmake new file mode 100644 index 00000000000..28c83161ff4 --- /dev/null +++ b/cpp/cmake/thirdparty/get_cuhornet.cmake @@ -0,0 +1,45 @@ +#============================================================================= +# 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(find_and_configure_cuhornet) + + # We are not using the cuhornet CMake targets, so no need to call `add_subdirectory()`, + # or to use CPM + FetchContent_Declare( + cuhornet + GIT_REPOSITORY https://github.com/rapidsai/cuhornet.git + GIT_TAG 261399356e62bd76fa7628880f1a847aee713eed + SOURCE_SUBDIR hornet + ) + FetchContent_GetProperties(cuhornet) + + if(NOT cuhornet_POPULATED) + FetchContent_Populate(cuhornet) + endif() + + if(NOT TARGET cugraph::cuHornet) + add_library(cugraph::cuHornet IMPORTED INTERFACE GLOBAL) + target_include_directories(cugraph::cuHornet INTERFACE + "${cuhornet_SOURCE_DIR}/hornet/include" + "${cuhornet_SOURCE_DIR}/hornetsnest/include" + "${cuhornet_SOURCE_DIR}/xlib/include" + "${cuhornet_SOURCE_DIR}/primitives" + ) + endif() +endfunction() + + +find_and_configure_cuhornet() diff --git a/cpp/cmake/thirdparty/get_faiss.cmake b/cpp/cmake/thirdparty/get_faiss.cmake new file mode 100644 index 00000000000..4991990e379 --- /dev/null +++ b/cpp/cmake/thirdparty/get_faiss.cmake @@ -0,0 +1,50 @@ +#============================================================================= +# 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(find_and_configure_faiss) + set(oneValueArgs VERSION PINNED_TAG) + cmake_parse_arguments(PKG "${options}" "${oneValueArgs}" + "${multiValueArgs}" ${ARGN} ) + + rapids_find_generate_module(FAISS + HEADER_NAMES faiss/IndexFlat.h + LIBRARY_NAMES faiss + ) + + rapids_cpm_find(FAISS ${PKG_VERSION} + GLOBAL_TARGETS faiss + CPM_ARGS + GIT_REPOSITORY https://github.com/facebookresearch/faiss.git + GIT_TAG ${PKG_PINNED_TAG} + OPTIONS + "FAISS_ENABLE_PYTHON OFF" + "BUILD_SHARED_LIBS OFF" + "CUDAToolkit_ROOT ${CUDAToolkit_LIBRARY_DIR}" + "FAISS_ENABLE_GPU ON" + "BUILD_TESTING OFF" + "CMAKE_MESSAGE_LOG_LEVEL VERBOSE" + ) + + if(FAISS_ADDED) + set(FAISS_GPU_HEADERS ${FAISS_SOURCE_DIR} PARENT_SCOPE) + add_library(FAISS::FAISS ALIAS faiss) + endif() + +endfunction() + +find_and_configure_faiss(VERSION 1.7.0 + PINNED_TAG bde7c0027191f29c9dadafe4f6e68ca0ee31fb30 + ) diff --git a/cpp/cmake/thirdparty/get_gtest.cmake b/cpp/cmake/thirdparty/get_gtest.cmake new file mode 100644 index 00000000000..e413cad7601 --- /dev/null +++ b/cpp/cmake/thirdparty/get_gtest.cmake @@ -0,0 +1,43 @@ +#============================================================================= +# 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(find_and_configure_gtest VERSION) + + 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() + +endfunction() + +find_and_configure_gtest(1.10.0) diff --git a/cpp/cmake/thirdparty/get_gunrock.cmake b/cpp/cmake/thirdparty/get_gunrock.cmake new file mode 100644 index 00000000000..056cd4bd5ea --- /dev/null +++ b/cpp/cmake/thirdparty/get_gunrock.cmake @@ -0,0 +1,64 @@ +#============================================================================= +# 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(find_and_configure_gunrock VERSION) + + if(NOT TARGET gunrock) + set(GUNROCK_GENCODE_SM60 OFF) + set(GUNROCK_GENCODE_SM61 OFF) + set(GUNROCK_GENCODE_SM70 OFF) + set(GUNROCK_GENCODE_SM72 OFF) + set(GUNROCK_GENCODE_SM75 OFF) + set(GUNROCK_GENCODE_SM80 OFF) + + foreach(arch IN LISTS CMAKE_CUDA_ARCHITECTURES) + string(REPLACE "-real" "" arch ${arch}) + set(GUNROCK_GENCODE_SM${arch} "ON") + endforeach() + + # FIXME: gunrock is still using ExternalProject instead of CPM, as version 1.2 + # doesn't work with CPM + + include(ExternalProject) + + set(GUNROCK_DIR ${CMAKE_CURRENT_BINARY_DIR}/gunrock) + ExternalProject_Add(gunrock_ext + GIT_REPOSITORY https://github.com/gunrock/gunrock.git + GIT_TAG v${VERSION} + PREFIX ${GUNROCK_DIR} + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX= + -DGUNROCK_BUILD_SHARED_LIBS=OFF + -DGUNROCK_BUILD_TESTS=OFF + -DCUDA_AUTODETECT_GENCODE=OFF + -DGUNROCK_GENCODE_SM60=${GUNROCK_GENCODE_SM60} + -DGUNROCK_GENCODE_SM61=${GUNROCK_GENCODE_SM61} + -DGUNROCK_GENCODE_SM70=${GUNROCK_GENCODE_SM70} + -DGUNROCK_GENCODE_SM72=${GUNROCK_GENCODE_SM72} + -DGUNROCK_GENCODE_SM75=${GUNROCK_GENCODE_SM75} + -DGUNROCK_GENCODE_SM80=${GUNROCK_GENCODE_SM80} + BUILD_BYPRODUCTS ${GUNROCK_DIR}/src/gunrock_ext-build/lib/libgunrock.a + INSTALL_COMMAND "" + ) + + add_library(gunrock STATIC IMPORTED) + add_dependencies(gunrock gunrock_ext) + set_property(TARGET gunrock PROPERTY IMPORTED_LOCATION "${GUNROCK_DIR}/src/gunrock_ext-build/lib/libgunrock.a") + target_include_directories(gunrock INTERFACE "${GUNROCK_DIR}/src/gunrock_ext") + endif() +endfunction() + + +find_and_configure_gunrock(1.2) diff --git a/cpp/cmake/thirdparty/get_nccl.cmake b/cpp/cmake/thirdparty/get_nccl.cmake new file mode 100644 index 00000000000..30ec976f27c --- /dev/null +++ b/cpp/cmake/thirdparty/get_nccl.cmake @@ -0,0 +1,42 @@ +#============================================================================= +# 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(find_and_configure_nccl) + + if(TARGET NCCL::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 + ) + + # Currently NCCL has no CMake build-system so we require + # it built and installed on the machine already + rapids_find_package(NCCL REQUIRED) + +endfunction() + +find_and_configure_nccl() + + + + diff --git a/cpp/cmake/thirdparty/get_raft.cmake b/cpp/cmake/thirdparty/get_raft.cmake new file mode 100644 index 00000000000..d8c9358e023 --- /dev/null +++ b/cpp/cmake/thirdparty/get_raft.cmake @@ -0,0 +1,48 @@ +#============================================================================= +# 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(find_and_configure_raft) + + set(oneValueArgs VERSION FORK PINNED_TAG) + cmake_parse_arguments(PKG "" "${oneValueArgs}" "" ${ARGN} ) + + rapids_cpm_find(raft ${PKG_VERSION} + GLOBAL_TARGETS raft::raft + BUILD_EXPORT_SET cugraph-exports + INSTALL_EXPORT_SET cugraph-exports + CPM_ARGS + GIT_REPOSITORY https://github.com/${PKG_FORK}/raft.git + GIT_TAG ${PKG_PINNED_TAG} + SOURCE_SUBDIR cpp + OPTIONS "BUILD_TESTS OFF" + ) + + message(VERBOSE "CUML: Using RAFT located in ${raft_SOURCE_DIR}") + +endfunction() + +set(CUGRAPH_MIN_VERSION_raft "${CUGRAPH_VERSION_MAJOR}.${CUGRAPH_VERSION_MINOR}.00") +set(CUGRAPH_BRANCH_VERSION_raft "${CUGRAPH_VERSION_MAJOR}.${CUGRAPH_VERSION_MINOR}") + + +# Change pinned tag and fork here to test a commit in CI +# To use a different RAFT locally, set the CMake variable +# RPM_raft_SOURCE=/path/to/local/raft +find_and_configure_raft(VERSION ${CUGRAPH_MIN_VERSION_raft} + FORK rapidsai + PINNED_TAG branch-${CUGRAPH_BRANCH_VERSION_raft} + ) + diff --git a/cpp/cmake/thirdparty/get_rmm.cmake b/cpp/cmake/thirdparty/get_rmm.cmake new file mode 100644 index 00000000000..aecb6489f92 --- /dev/null +++ b/cpp/cmake/thirdparty/get_rmm.cmake @@ -0,0 +1,47 @@ +#============================================================================= +# 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(find_and_configure_rmm VERSION) + + 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 + 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}) diff --git a/cpp/cmake/thirdparty/get_thrust.cmake b/cpp/cmake/thirdparty/get_thrust.cmake new file mode 100644 index 00000000000..86fcffed5d2 --- /dev/null +++ b/cpp/cmake/thirdparty/get_thrust.cmake @@ -0,0 +1,29 @@ +#============================================================================= +# 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(find_and_configure_thrust VERSION) + + 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) + +endfunction() + +find_and_configure_thrust(1.12.0) diff --git a/cpp/tests/CMakeLists.txt b/cpp/tests/CMakeLists.txt index 768f441a881..cb7eca3ed11 100644 --- a/cpp/tests/CMakeLists.txt +++ b/cpp/tests/CMakeLists.txt @@ -20,42 +20,34 @@ # - common test utils ----------------------------------------------------------------------------- add_library(cugraphtestutil STATIC - "${CMAKE_CURRENT_SOURCE_DIR}/utilities/matrix_market_file_utilities.cu" - "${CMAKE_CURRENT_SOURCE_DIR}/utilities/rmat_utilities.cu" - "${CMAKE_CURRENT_SOURCE_DIR}/utilities/thrust_wrapper.cu" - "${CMAKE_CURRENT_SOURCE_DIR}/utilities/misc_utilities.cpp" - "${CMAKE_CURRENT_SOURCE_DIR}/components/wcc_graphs.cu" - "${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/mmio/mmio.c") + utilities/matrix_market_file_utilities.cu + utilities/rmat_utilities.cu + utilities/thrust_wrapper.cu + utilities/misc_utilities.cpp + components/wcc_graphs.cu + ../../thirdparty/mmio/mmio.c) + +target_compile_options(cugraphtestutil + PUBLIC "$<$:${CUGRAPH_CXX_FLAGS}>" + "$:${CUGRAPH_CUDA_FLAGS}>>" +) set_property(TARGET cugraphtestutil PROPERTY POSITION_INDEPENDENT_CODE ON) target_include_directories(cugraphtestutil - PRIVATE - "${CUB_INCLUDE_DIR}" - "${THRUST_INCLUDE_DIR}" - "${CUCO_INCLUDE_DIR}" - "${LIBCUDACXX_INCLUDE_DIR}" - "${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}" - "${RMM_INCLUDE}" - "${NCCL_INCLUDE_DIRS}" - "${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/mmio" - "${CMAKE_CURRENT_SOURCE_DIR}/../include" - "${CMAKE_CURRENT_SOURCE_DIR}" - "${RAFT_DIR}/cpp/include" + PUBLIC + "${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/mmio" + "${CMAKE_CURRENT_SOURCE_DIR}" + "${CUGRAPH_SOURCE_DIR}/src" ) -target_link_libraries(cugraphtestutil cugraph) +target_link_libraries(cugraphtestutil + PUBLIC + cugraph + cuco::cuco + NCCL::NCCL +) -# CUDA_ARCHITECTURES=OFF implies cmake will not pass arch flags to the -# compiler. CUDA_ARCHITECTURES must be set to a non-empty value to prevent -# cmake warnings about policy CMP0104. With this setting, arch flags must be -# manually set! ("evaluate_gpu_archs(GPU_ARCHS)" is the current mechanism -# used in cpp/CMakeLists.txt for setting arch options). -# Run "cmake --help-policy CMP0104" for policy details. -# NOTE: the CUDA_ARCHITECTURES=OFF setting may be removed after migrating to -# the findcudatoolkit features in cmake 3.17+ -set_target_properties(cugraphtestutil PROPERTIES - CUDA_ARCHITECTURES OFF) add_library(cugraphmgtestutil STATIC "${CMAKE_CURRENT_SOURCE_DIR}/utilities/device_comm_wrapper.cu") @@ -93,45 +85,23 @@ set_target_properties(cugraphmgtestutil PROPERTIES ################################################################################################### # - compiler function ----------------------------------------------------------------------------- -function(ConfigureTest CMAKE_TEST_NAME CMAKE_TEST_SRC) - add_executable(${CMAKE_TEST_NAME} - ${CMAKE_TEST_SRC}) - - target_include_directories(${CMAKE_TEST_NAME} - PRIVATE - "${CUB_INCLUDE_DIR}" - "${THRUST_INCLUDE_DIR}" - "${CUCO_INCLUDE_DIR}" - "${LIBCUDACXX_INCLUDE_DIR}" - "${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}" - "${RMM_INCLUDE}" - "${NCCL_INCLUDE_DIRS}" - "${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/mmio" - "${CMAKE_CURRENT_SOURCE_DIR}/../include" - "${CMAKE_CURRENT_SOURCE_DIR}/../src" - "${CMAKE_CURRENT_SOURCE_DIR}" - "${RAFT_DIR}/cpp/include" - ) - - target_link_directories(${CMAKE_TEST_NAME} - PRIVATE - # CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES is an undocumented/unsupported - # variable containing the link directories for nvcc. - "${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}") +function(ConfigureTest CMAKE_TEST_NAME) + add_executable(${CMAKE_TEST_NAME} ${ARGN}) target_link_libraries(${CMAKE_TEST_NAME} PRIVATE - cugraphtestutil - cugraph - GTest::GTest - GTest::Main - ${NCCL_LIBRARIES} - cudart - cuda - cublas - cusparse - cusolver - curand) + cugraphtestutil + cugraph + GTest::gmock + GTest::gmock_main + GTest::gtest + GTest::gtest_main + NCCL::NCCL + CUDA::cublas + CUDA::cusparse + CUDA::cusolver + CUDA::curand + ) if(OpenMP_CXX_FOUND) target_link_libraries(${CMAKE_TEST_NAME} PRIVATE @@ -184,60 +154,28 @@ function(ConfigureTest CMAKE_TEST_NAME CMAKE_TEST_SRC) ${OpenMP_CXX_LIB_NAMES}) endif(OpenMP_CXX_FOUND) - # CUDA_ARCHITECTURES=OFF implies cmake will not pass arch flags to the - # compiler. CUDA_ARCHITECTURES must be set to a non-empty value to prevent - # cmake warnings about policy CMP0104. With this setting, arch flags must be - # manually set! ("evaluate_gpu_archs(GPU_ARCHS)" is the current mechanism - # used in cpp/CMakeLists.txt for setting arch options). - # Run "cmake --help-policy CMP0104" for policy details. - # NOTE: the CUDA_ARCHITECTURES=OFF setting may be removed after migrating to - # the findcudatoolkit features in cmake 3.17+ - set_target_properties(${CMAKE_TEST_NAME} PROPERTIES - CUDA_ARCHITECTURES OFF) - add_test(NAME ${CMAKE_TEST_NAME} COMMAND ${CMAKE_TEST_NAME}) endfunction() -function(ConfigureTestMG CMAKE_TEST_NAME CMAKE_TEST_SRC) - add_executable(${CMAKE_TEST_NAME} - ${CMAKE_TEST_SRC}) - - target_include_directories(${CMAKE_TEST_NAME} - PRIVATE - "${CUB_INCLUDE_DIR}" - "${THRUST_INCLUDE_DIR}" - "${CUCO_INCLUDE_DIR}" - "${LIBCUDACXX_INCLUDE_DIR}" - "${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}" - "${RMM_INCLUDE}" - "${NCCL_INCLUDE_DIRS}" - "${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/mmio" - "${CMAKE_CURRENT_SOURCE_DIR}/../include" - "${CMAKE_CURRENT_SOURCE_DIR}/../src" - "${CMAKE_CURRENT_SOURCE_DIR}" - "${RAFT_DIR}/cpp/include" - ) - - target_link_directories(${CMAKE_TEST_NAME} - PRIVATE - # CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES is an undocumented/unsupported - # variable containing the link directories for nvcc. - "${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}") +function(ConfigureTestMG CMAKE_TEST_NAME) + add_executable(${CMAKE_TEST_NAME} ${ARGN}) target_link_libraries(${CMAKE_TEST_NAME} PRIVATE cugraphmgtestutil cugraphtestutil cugraph - GTest::GTest - GTest::Main - ${NCCL_LIBRARIES} - cudart - cuda - cublas - cusparse - cusolver - curand) + GTest::gmock + GTest::gmock_main + GTest::gtest + GTest::gtest_main + NCCL::NCCL + CUDA::cublas + CUDA::cusparse + CUDA::cusolver + CUDA::curand + MPI::MPI_CXX + ) if(OpenMP_CXX_FOUND) target_link_libraries(${CMAKE_TEST_NAME} PRIVATE @@ -290,17 +228,6 @@ function(ConfigureTestMG CMAKE_TEST_NAME CMAKE_TEST_SRC) ${OpenMP_CXX_LIB_NAMES}) endif(OpenMP_CXX_FOUND) - # CUDA_ARCHITECTURES=OFF implies cmake will not pass arch flags to the - # compiler. CUDA_ARCHITECTURES must be set to a non-empty value to prevent - # cmake warnings about policy CMP0104. With this setting, arch flags must be - # manually set! ("evaluate_gpu_archs(GPU_ARCHS)" is the current mechanism - # used in cpp/CMakeLists.txt for setting arch options). - # Run "cmake --help-policy CMP0104" for policy details. - # NOTE: the CUDA_ARCHITECTURES=OFF setting may be removed after migrating to - # the findcudatoolkit features in cmake 3.17+ - set_target_properties(${CMAKE_TEST_NAME} PROPERTIES - CUDA_ARCHITECTURES OFF) - add_test(NAME ${CMAKE_TEST_NAME} COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} @@ -326,248 +253,124 @@ endif(RAPIDS_DATASET_ROOT_DIR) ################################################################################################### # - katz centrality tests ------------------------------------------------------------------------- - -set(KATZ_TEST_SRC - "${CMAKE_CURRENT_SOURCE_DIR}/centrality/katz_centrality_test.cu") - - ConfigureTest(KATZ_TEST "${KATZ_TEST_SRC}") +ConfigureTest(KATZ_TEST centrality/katz_centrality_test.cu) ################################################################################################### # - betweenness centrality tests ------------------------------------------------------------------ - -set(BETWEENNESS_TEST_SRC - "${CMAKE_CURRENT_SOURCE_DIR}/centrality/betweenness_centrality_test.cu") - - ConfigureTest(BETWEENNESS_TEST "${BETWEENNESS_TEST_SRC}") - -set(EDGE_BETWEENNESS_TEST_SRC - "${CMAKE_CURRENT_SOURCE_DIR}/centrality/edge_betweenness_centrality_test.cu") - - ConfigureTest(EDGE_BETWEENNESS_TEST "${EDGE_BETWEENNESS_TEST_SRC}") +ConfigureTest(BETWEENNESS_TEST centrality/betweenness_centrality_test.cu) +ConfigureTest(EDGE_BETWEENNESS_TEST centrality/edge_betweenness_centrality_test.cu) ################################################################################################### # - SSSP tests ------------------------------------------------------------------------------------ - -set(SSSP_TEST_SRCS - "${CMAKE_CURRENT_SOURCE_DIR}/traversal/sssp_test.cu") - -ConfigureTest(SSSP_TEST "${SSSP_TEST_SRCS}") +ConfigureTest(SSSP_TEST traversal/sssp_test.cu) ################################################################################################### # - BFS tests ------------------------------------------------------------------------------------- - -set(BFS_TEST_SRCS - "${CMAKE_CURRENT_SOURCE_DIR}/traversal/bfs_test.cu") - -ConfigureTest(BFS_TEST "${BFS_TEST_SRCS}") +ConfigureTest(BFS_TEST traversal/bfs_test.cu) ################################################################################################### # - LOUVAIN tests --------------------------------------------------------------------------------- - -set(LOUVAIN_TEST_SRC - "${CMAKE_CURRENT_SOURCE_DIR}/community/louvain_test.cpp") - -ConfigureTest(LOUVAIN_TEST "${LOUVAIN_TEST_SRC}") +ConfigureTest(LOUVAIN_TEST community/louvain_test.cpp) ################################################################################################### # - LEIDEN tests --------------------------------------------------------------------------------- - -set(LEIDEN_TEST_SRC - "${CMAKE_CURRENT_SOURCE_DIR}/community/leiden_test.cpp") - -ConfigureTest(LEIDEN_TEST "${LEIDEN_TEST_SRC}") +ConfigureTest(LEIDEN_TEST community/leiden_test.cpp) ################################################################################################### # - ECG tests --------------------------------------------------------------------------------- - -set(ECG_TEST_SRC - "${CMAKE_CURRENT_SOURCE_DIR}/community/ecg_test.cpp") - -ConfigureTest(ECG_TEST "${ECG_TEST_SRC}") +ConfigureTest(ECG_TEST community/ecg_test.cpp) ################################################################################################### # - Balanced cut clustering tests ----------------------------------------------------------------- - -set(BALANCED_TEST_SRC - "${CMAKE_CURRENT_SOURCE_DIR}/community/balanced_edge_test.cpp") - -ConfigureTest(BALANCED_TEST "${BALANCED_TEST_SRC}") +ConfigureTest(BALANCED_TEST community/balanced_edge_test.cpp) ################################################################################################### # - TRIANGLE tests -------------------------------------------------------------------------------- - -set(TRIANGLE_TEST_SRC - "${CMAKE_CURRENT_SOURCE_DIR}/community/triangle_test.cu") - -ConfigureTest(TRIANGLE_TEST "${TRIANGLE_TEST_SRC}") +ConfigureTest(TRIANGLE_TEST community/triangle_test.cu) ################################################################################################### # - EGO tests -------------------------------------------------------------------------------- +ConfigureTest(EGO_TEST community/egonet_test.cu) -set(EGO_TEST_SRC - "${CMAKE_CURRENT_SOURCE_DIR}/community/egonet_test.cu") - -ConfigureTest(EGO_TEST "${EGO_TEST_SRC}" "") ################################################################################################### # - RENUMBERING tests ----------------------------------------------------------------------------- - -set(RENUMBERING_TEST_SRC - "${CMAKE_CURRENT_SOURCE_DIR}/renumber/renumber_test.cu") - -ConfigureTest(RENUMBERING_TEST "${RENUMBERING_TEST_SRC}") +ConfigureTest(RENUMBERING_TEST renumber/renumber_test.cu) ################################################################################################### # - FORCE ATLAS 2 tests -------------------------------------------------------------------------- - -set(FA2_TEST_SRC - "${CMAKE_CURRENT_SOURCE_DIR}/layout/force_atlas2_test.cu") - -ConfigureTest(FA2_TEST "${FA2_TEST_SRC}") +ConfigureTest(FA2_TEST layout/force_atlas2_test.cu) ################################################################################################### # - TSP tests -------------------------------------------------------------------------- - -set(TSP_TEST_SRC - "${CMAKE_CURRENT_SOURCE_DIR}/traversal/tsp_test.cu") - - ConfigureTest(TSP_TEST "${TSP_TEST_SRC}" "") +ConfigureTest(TSP_TEST traversal/tsp_test.cu) ################################################################################################### # - CONNECTED COMPONENTS tests ------------------------------------------------------------------- - -set(CONNECT_TEST_SRC - "${CMAKE_CURRENT_SOURCE_DIR}/components/con_comp_test.cu") - -ConfigureTest(CONNECT_TEST "${CONNECT_TEST_SRC}") +ConfigureTest(CONNECT_TEST components/con_comp_test.cu) ################################################################################################### # - STRONGLY CONNECTED COMPONENTS tests ---------------------------------------------------------- - -set(SCC_TEST_SRC - "${CMAKE_CURRENT_SOURCE_DIR}/components/scc_test.cu") - -ConfigureTest(SCC_TEST "${SCC_TEST_SRC}") +ConfigureTest(SCC_TEST components/scc_test.cu) ################################################################################################### # - WEAKLY CONNECTED COMPONENTS tests ---------------------------------------------------------- - -set(WCC_TEST_SRC - "${CMAKE_CURRENT_SOURCE_DIR}/components/wcc_test.cpp") - -ConfigureTest(WCC_TEST "${WCC_TEST_SRC}") +ConfigureTest(WCC_TEST components/wcc_test.cpp) ################################################################################################### -#-Hungarian (Linear Assignment Problem) tests --------------------------------------------------------------------- - -set(HUNGARIAN_TEST_SRC - "${CMAKE_CURRENT_SOURCE_DIR}/linear_assignment/hungarian_test.cu") - -ConfigureTest(HUNGARIAN_TEST "${HUNGARIAN_TEST_SRC}") +#-Hungarian (Linear Assignment Problem) tests ---------------------------------------------------- +ConfigureTest(HUNGARIAN_TEST linear_assignment/hungarian_test.cu) ################################################################################################### # - MST tests ---------------------------------------------------------------------------- - -set(MST_TEST_SRC - "${CMAKE_CURRENT_SOURCE_DIR}/tree/mst_test.cu") - -ConfigureTest(MST_TEST "${MST_TEST_SRC}") +ConfigureTest(MST_TEST tree/mst_test.cu) ################################################################################################### # - Experimental stream tests ----------------------------------------------------- - -set(EXPERIMENTAL_STREAM_SRCS - "${CMAKE_CURRENT_SOURCE_DIR}/experimental/streams.cu") - -ConfigureTest(EXPERIMENTAL_STREAM "${EXPERIMENTAL_STREAM_SRCS}" "") +ConfigureTest(EXPERIMENTAL_STREAM experimental/streams.cu) ################################################################################################### # - Experimental R-mat graph generation tests ----------------------------------------------------- - -set(EXPERIMENTAL_GENERATE_RMAT_TEST_SRCS - "${CMAKE_CURRENT_SOURCE_DIR}/experimental/generate_rmat_test.cpp") - -ConfigureTest(EXPERIMENTAL_GENERATE_RMAT_TEST "${EXPERIMENTAL_GENERATE_RMAT_TEST_SRCS}" "") +ConfigureTest(EXPERIMENTAL_GENERATE_RMAT_TEST experimental/generate_rmat_test.cpp) ################################################################################################### # - Experimental Graph tests ---------------------------------------------------------------------- - -set(EXPERIMENTAL_GRAPH_TEST_SRCS - "${CMAKE_CURRENT_SOURCE_DIR}/experimental/graph_test.cpp") - -ConfigureTest(EXPERIMENTAL_GRAPH_TEST "${EXPERIMENTAL_GRAPH_TEST_SRCS}") +ConfigureTest(EXPERIMENTAL_GRAPH_TEST experimental/graph_test.cpp) ################################################################################################### # - Experimental weight-sum tests ----------------------------------------------------------------- - -set(EXPERIMENTAL_WEIGHT_SUM_TEST_SRCS - "${CMAKE_CURRENT_SOURCE_DIR}/experimental/weight_sum_test.cpp") - -ConfigureTest(EXPERIMENTAL_WEIGHT_SUM_TEST "${EXPERIMENTAL_WEIGHT_SUM_TEST_SRCS}") +ConfigureTest(EXPERIMENTAL_WEIGHT_SUM_TEST experimental/weight_sum_test.cpp) ################################################################################################### # - Experimental degree tests --------------------------------------------------------------------- - -set(EXPERIMENTAL_DEGREE_TEST_SRCS - "${CMAKE_CURRENT_SOURCE_DIR}/experimental/degree_test.cpp") - -ConfigureTest(EXPERIMENTAL_DEGREE_TEST "${EXPERIMENTAL_DEGREE_TEST_SRCS}") +ConfigureTest(EXPERIMENTAL_DEGREE_TEST experimental/degree_test.cpp) ################################################################################################### # - Experimental coarsening tests ----------------------------------------------------------------- - -set(EXPERIMENTAL_COARSEN_GRAPH_TEST_SRCS - "${CMAKE_CURRENT_SOURCE_DIR}/experimental/coarsen_graph_test.cpp") - -ConfigureTest(EXPERIMENTAL_COARSEN_GRAPH_TEST "${EXPERIMENTAL_COARSEN_GRAPH_TEST_SRCS}") +ConfigureTest(EXPERIMENTAL_COARSEN_GRAPH_TEST experimental/coarsen_graph_test.cpp) ################################################################################################### # - Experimental induced subgraph tests ----------------------------------------------------------- - -set(EXPERIMENTAL_INDUCED_SUBGRAPH_TEST_SRCS - "${CMAKE_CURRENT_SOURCE_DIR}/experimental/induced_subgraph_test.cpp") - -ConfigureTest(EXPERIMENTAL_INDUCED_SUBGRAPH_TEST "${EXPERIMENTAL_INDUCED_SUBGRAPH_TEST_SRCS}") +ConfigureTest(EXPERIMENTAL_INDUCED_SUBGRAPH_TEST experimental/induced_subgraph_test.cpp) ################################################################################################### # - Experimental BFS tests ------------------------------------------------------------------------ - -set(EXPERIMENTAL_BFS_TEST_SRCS - "${CMAKE_CURRENT_SOURCE_DIR}/experimental/bfs_test.cpp") - -ConfigureTest(EXPERIMENTAL_BFS_TEST "${EXPERIMENTAL_BFS_TEST_SRCS}") +ConfigureTest(EXPERIMENTAL_BFS_TEST experimental/bfs_test.cpp) ################################################################################################### # - Experimental Multi-source BFS tests ----------------------------------------------------------- - -set(EXPERIMENTAL_MSBFS_TEST_SRCS - "${CMAKE_CURRENT_SOURCE_DIR}/experimental/ms_bfs_test.cpp") - -ConfigureTest(EXPERIMENTAL_MSBFS_TEST "${EXPERIMENTAL_MSBFS_TEST_SRCS}") - +ConfigureTest(EXPERIMENTAL_MSBFS_TEST experimental/ms_bfs_test.cpp) ################################################################################################### # - Experimental SSSP tests ----------------------------------------------------------------------- - -set(EXPERIMENTAL_SSSP_TEST_SRCS - "${CMAKE_CURRENT_SOURCE_DIR}/experimental/sssp_test.cpp") - -ConfigureTest(EXPERIMENTAL_SSSP_TEST "${EXPERIMENTAL_SSSP_TEST_SRCS}") +ConfigureTest(EXPERIMENTAL_SSSP_TEST experimental/sssp_test.cpp) ################################################################################################### # - Experimental PAGERANK tests ------------------------------------------------------------------- - -set(EXPERIMENTAL_PAGERANK_TEST_SRCS - "${CMAKE_CURRENT_SOURCE_DIR}/experimental/pagerank_test.cpp") - -ConfigureTest(EXPERIMENTAL_PAGERANK_TEST "${EXPERIMENTAL_PAGERANK_TEST_SRCS}") +ConfigureTest(EXPERIMENTAL_PAGERANK_TEST experimental/pagerank_test.cpp) ################################################################################################### # - Experimental KATZ_CENTRALITY tests ------------------------------------------------------------ - -set(EXPERIMENTAL_KATZ_CENTRALITY_TEST_SRCS - "${CMAKE_CURRENT_SOURCE_DIR}/experimental/katz_centrality_test.cpp") - -ConfigureTest(EXPERIMENTAL_KATZ_CENTRALITY_TEST "${EXPERIMENTAL_KATZ_CENTRALITY_TEST_SRCS}") +ConfigureTest(EXPERIMENTAL_KATZ_CENTRALITY_TEST experimental/katz_centrality_test.cpp) ################################################################################################### # - WEAKLY CONNECTED COMPONENTS tests ------------------------------------------------------------- @@ -579,32 +382,27 @@ ConfigureTest(WEAKLY_CONNECTED_COMPONENTS_TEST "${WEAKLY_CONNECTED_COMPONENTS_TE ################################################################################################### # - Experimental RANDOM_WALKS tests ------------------------------------------------------------ - -set(RANDOM_WALKS_TEST_SRCS - "${CMAKE_CURRENT_SOURCE_DIR}/sampling/random_walks_test.cu") - -ConfigureTest(RANDOM_WALKS_TEST "${RANDOM_WALKS_TEST_SRCS}") +ConfigureTest(RANDOM_WALKS_TEST sampling/random_walks_test.cu) ################################################################################################### -set(RANDOM_WALKS_LOW_LEVEL_SRCS - "${CMAKE_CURRENT_SOURCE_DIR}/sampling/rw_low_level_test.cu") - -ConfigureTest(RANDOM_WALKS_LOW_LEVEL_TEST "${RANDOM_WALKS_LOW_LEVEL_SRCS}") +ConfigureTest(RANDOM_WALKS_LOW_LEVEL_TEST sampling/rw_low_level_test.cu) ################################################################################################### -set(RANDOM_WALKS_PROFILING_SRCS - "${CMAKE_CURRENT_SOURCE_DIR}/sampling/random_walks_profiling.cu") - # FIXME: since this is technically not a test, consider refactoring the the # ConfigureTest function to share common code with a new ConfigureBenchmark # function (which would not link gtest, etc.) -ConfigureTest(RANDOM_WALKS_PROFILING "${RANDOM_WALKS_PROFILING_SRCS}") +ConfigureTest(RANDOM_WALKS_PROFILING sampling/random_walks_profiling.cu) ################################################################################################### # - MG tests -------------------------------------------------------------------------------------- if(BUILD_CUGRAPH_MG_TESTS) + + ############################################################################################### + # - find MPI - only enabled if MG tests are to be built + find_package(MPI REQUIRED) + execute_process( COMMAND nvidia-smi -L COMMAND wc -l @@ -616,64 +414,34 @@ if(BUILD_CUGRAPH_MG_TESTS) if(MPI_CXX_FOUND) ########################################################################################### # - MG PAGERANK tests --------------------------------------------------------------------- - - set(MG_PAGERANK_TEST_SRCS - "${CMAKE_CURRENT_SOURCE_DIR}/pagerank/mg_pagerank_test.cpp") - - ConfigureTestMG(MG_PAGERANK_TEST "${MG_PAGERANK_TEST_SRCS}") - target_link_libraries(MG_PAGERANK_TEST PRIVATE MPI::MPI_C MPI::MPI_CXX) + ConfigureTestMG(MG_PAGERANK_TEST pagerank/mg_pagerank_test.cpp) ########################################################################################### # - MG KATZ CENTRALITY tests -------------------------------------------------------------- - - set(MG_KATZ_CENTRALITY_TEST_SRCS - "${CMAKE_CURRENT_SOURCE_DIR}/experimental/mg_katz_centrality_test.cpp") - - ConfigureTestMG(MG_KATZ_CENTRALITY_TEST "${MG_KATZ_CENTRALITY_TEST_SRCS}") - target_link_libraries(MG_KATZ_CENTRALITY_TEST PRIVATE MPI::MPI_C MPI::MPI_CXX) + ConfigureTestMG(MG_KATZ_CENTRALITY_TEST experimental/mg_katz_centrality_test.cpp) ########################################################################################### # - MG BFS tests -------------------------------------------------------------------------- - - set(MG_BFS_TEST_SRCS - "${CMAKE_CURRENT_SOURCE_DIR}/experimental/mg_bfs_test.cpp") - - ConfigureTestMG(MG_BFS_TEST "${MG_BFS_TEST_SRCS}") - target_link_libraries(MG_BFS_TEST PRIVATE MPI::MPI_C MPI::MPI_CXX) + ConfigureTestMG(MG_BFS_TEST experimental/mg_bfs_test.cpp) ########################################################################################### # - MG SSSP tests ------------------------------------------------------------------------- - - set(MG_SSSP_TEST_SRCS - "${CMAKE_CURRENT_SOURCE_DIR}/experimental/mg_sssp_test.cpp") - - ConfigureTestMG(MG_SSSP_TEST "${MG_SSSP_TEST_SRCS}") - target_link_libraries(MG_SSSP_TEST PRIVATE MPI::MPI_C MPI::MPI_CXX) + ConfigureTestMG(MG_SSSP_TEST experimental/mg_sssp_test.cpp) ########################################################################################### # - MG LOUVAIN tests ---------------------------------------------------------------------- - - set(MG_LOUVAIN_TEST_SRCS - "${CMAKE_CURRENT_SOURCE_DIR}/community/mg_louvain_helper.cu" - "${CMAKE_CURRENT_SOURCE_DIR}/community/mg_louvain_test.cpp") - - ConfigureTestMG(MG_LOUVAIN_TEST "${MG_LOUVAIN_TEST_SRCS}") - target_link_libraries(MG_LOUVAIN_TEST PRIVATE MPI::MPI_C MPI::MPI_CXX) + ConfigureTestMG(MG_LOUVAIN_TEST + community/mg_louvain_helper.cu + community/mg_louvain_test.cpp) ########################################################################################### # - MG WEAKLY CONNECTED COMPONENTS tests -------------------------------------------------- - - set(MG_WEAKLY_CONNECTED_COMPONENTS_TEST_SRCS - "${CMAKE_CURRENT_SOURCE_DIR}/components/mg_weakly_connected_components_test.cpp") - ConfigureTestMG(MG_WEAKLY_CONNECTED_COMPONENTS_TEST - "${MG_WEAKLY_CONNECTED_COMPONENTS_TEST_SRCS}") - target_link_libraries(MG_WEAKLY_CONNECTED_COMPONENTS_TEST PRIVATE MPI::MPI_C MPI::MPI_CXX) - - else(MPI_CXX_FOUND) + components/mg_weakly_connected_components_test.cpp) + else() message(FATAL_ERROR "OpenMPI NOT found, cannot build MG tests.") - endif(MPI_CXX_FOUND) -endif(BUILD_CUGRAPH_MG_TESTS) + endif() +endif() ################################################################################################### ### enable testing ################################################################################ diff --git a/python/setup.py b/python/setup.py index 799cb805afa..d614eef24d6 100644 --- a/python/setup.py +++ b/python/setup.py @@ -65,8 +65,9 @@ raft_path = get_environment_option('RAFT_PATH') # FIXME: This could clone RAFT, even if it's not needed (eg. running --clean). -raft_include_dir = use_raft_package(raft_path, libcugraph_path, - git_info_file='../cpp/CMakeLists.txt') +# deprecated: This functionality will go away after +# https://github.com/rapidsai/raft/issues/83 +raft_include_dir = use_raft_package(raft_path, libcugraph_path) class CleanCommand(Command): diff --git a/python/setuputils.py b/python/setuputils.py index d93051d05ef..a64e60e1c32 100644 --- a/python/setuputils.py +++ b/python/setuputils.py @@ -20,7 +20,6 @@ import shutil import subprocess import sys -import warnings from pathlib import Path @@ -71,7 +70,7 @@ def clean_folder(path): def use_raft_package(raft_path, cpp_build_path, - git_info_file='../cpp/cmake/Dependencies.cmake'): + git_info_file=None): """ Function to use the python code in RAFT in package.raft @@ -139,10 +138,13 @@ def use_raft_package(raft_path, cpp_build_path, def clone_repo_if_needed(name, cpp_build_path=None, git_info_file=None): if git_info_file is None: - git_info_file = _get_repo_path() + '/cpp/CMakeLists.txt' + git_info_file = \ + _get_repo_path() + '/cpp/cmake/thirdparty/get_{}.cmake'.format( + name + ) if cpp_build_path is None or cpp_build_path is False: - cpp_build_path = _get_repo_path() + '/cpp/build/' + cpp_build_path = _get_repo_path() + '/cpp/build/_deps/' repo_cloned = get_submodule_dependency(name, cpp_build_path=cpp_build_path, @@ -152,7 +154,7 @@ def clone_repo_if_needed(name, cpp_build_path=None, repo_path = ( _get_repo_path() + '/python/_external_repositories/' + name + '/') else: - repo_path = os.path.join(cpp_build_path, '_deps', name + '-src') + repo_path = os.path.join(cpp_build_path, name + '-src/') return repo_path, repo_cloned @@ -192,7 +194,7 @@ def get_submodule_dependency(repo, repo_info = get_repo_cmake_info(repos, git_info_file) - if os.path.exists(cpp_build_path): + if os.path.exists(os.path.join(cpp_build_path, repos[0] + '-src/')): print("-- Third party modules found succesfully in the libcugraph++ " "build folder.") @@ -200,11 +202,11 @@ def get_submodule_dependency(repo, else: - warnings.warn("-- Third party repositories have not been found so they" - "will be cloned. To avoid this set the environment " - "variable CUGRAPH_BUILD_PATH, containing the relative " - "path of the root of the repository to the folder " - "where libcugraph++ was built.") + print("-- Third party repositories have not been found so they" + "will be cloned. To avoid this set the environment " + "variable CUGRAPH_BUILD_PATH, containing the relative " + "path of the root of the repository to the folder " + "where libcugraph++ was built.") for repo in repos: clone_repo(repo, repo_info[repo][0], repo_info[repo][1]) @@ -262,8 +264,8 @@ def get_repo_cmake_info(names, file_path): `ExternalProject_Add(name` file_path : String Relative path of the location of the CMakeLists.txt (or the cmake - module which contains FetchContent_Declare or ExternalProject_Add - definitions) to extract the information. + module which contains ExternalProject_Add definitions) to extract + the information. Returns ------- @@ -272,31 +274,32 @@ def get_repo_cmake_info(names, file_path): where results[name][0] is the url of the repo and repo_info[repo][1] is the tag/commit hash to be cloned as specified by cmake. + """ - with open(file_path, encoding='utf-8') as f: + with open(file_path) as f: s = f.read() results = {} - cmake_ext_proj_decls = ["FetchContent_Declare", "ExternalProject_Add"] - for name in names: - res = None - for decl in cmake_ext_proj_decls: - res = re.search(f'{decl}\(\s*' # noqa: W605 - + '(' + re.escape(name) + ')' - + '\s+.*GIT_REPOSITORY\s+(\S+)\s+.+' # noqa: W605 - + '\s+.*GIT_TAG\s+(\S+)', # noqa: W605 - s) - if res: - break - if res is None: - raise RuntimeError('Could not find any of the following ' - f'statements: {cmake_ext_proj_decls}, for ' - f'module "{name}" in file "{file_path}" with ' - 'GIT_REPOSITORY and GIT_TAG settings') - - results[res.group(1)] = [res.group(2), res.group(3)] + repo = re.findall(r'\s.*GIT_REPOSITORY.*', s) + repo = repo[-1].split()[-1] + fork = re.findall(r'\s.*FORK.*', s) + fork = fork[-1].split()[-1] + repo = repo.replace("${PKG_FORK}", fork) + tag = re.findall(r'\s.*PINNED_TAG.*', s) + tag = tag[-1].split()[-1] + results[name] = [repo, tag] + if tag == 'branch-${CUGRAPH_BRANCH_VERSION_raft}': + loc = _get_repo_path() + '/cpp/CMakeLists.txt' + with open(loc) as f: + cmakelists = f.read() + tag = re.findall(r'\s.*project\(CUGRAPH VERSION.*', cmakelists) + print(tag) + tag = tag[-1].split()[2].split('.') + tag = 'branch-{}.{}'.format(tag[0], tag[1]) + + results[name] = [repo, tag] return results