From e35e860ae3fbdecee8cdc24bfd700427a450e093 Mon Sep 17 00:00:00 2001 From: "Quan (Andy) Gan" Date: Sat, 8 Jun 2019 02:00:34 +0800 Subject: [PATCH] [Build] Support older CMake & OpenMP toggle (#619) * cmake fixes for older systems * allow specification of cuda path * test script fixes to enable openmp & test * update minigun; disable minigun partial frontier compile --- CMakeLists.txt | 12 +++++++++--- cmake/config.cmake | 3 +++ cmake/util/FindCUDA.cmake | 19 +++---------------- tests/scripts/build_dgl.bat | 2 +- tests/scripts/build_dgl.sh | 7 ++++--- third_party/minigun | 2 +- 6 files changed, 21 insertions(+), 24 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f4339e121689..715d2ab9cb2e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.9) +cmake_minimum_required(VERSION 3.5) ######################################## # Borrowed and adapted from TVM project ######################################## @@ -27,7 +27,7 @@ dgl_option(BUILD_CPP_TEST "Build cpp unittest executables" OFF) if(USE_CUDA) message(STATUS "Build with CUDA support") - project(dgl C CXX CUDA) + project(dgl C CXX) include(cmake/modules/CUDA.cmake) endif(USE_CUDA) @@ -70,13 +70,18 @@ else(MSVC) check_cxx_compiler_flag("-std=c++11" SUPPORT_CXX11) set(CMAKE_C_FLAGS "-O2 -Wall -fPIC ${CMAKE_C_FLAGS}") set(CMAKE_CXX_FLAGS "-O2 -Wall -fPIC -std=c++11 ${CMAKE_CXX_FLAGS}") +endif(MSVC) +if(USE_OPENMP) include(FindOpenMP) if(OPENMP_FOUND) set(CMAKE_C_FLAGS "${OpenMP_C_FLAGS} ${CMAKE_C_FLAGS}") set(CMAKE_CXX_FLAGS "${OpenMP_CXX_FLAGS} ${CMAKE_CXX_FLAGS}") endif(OPENMP_FOUND) -endif(MSVC) +endif(USE_OPENMP) + +# configure minigun +add_definitions(-DENABLE_PARTIAL_FRONTIER=0) # disable minigun partial frontier compile # Source file lists file(GLOB DGL_SRC @@ -93,6 +98,7 @@ file(GLOB_RECURSE DGL_SRC_1 list(APPEND DGL_SRC ${DGL_SRC_1}) +# Configure cuda if(USE_CUDA) dgl_config_cuda(DGL_CUDA_SRC) list(APPEND DGL_SRC ${DGL_CUDA_SRC}) diff --git a/cmake/config.cmake b/cmake/config.cmake index a604e7e2ab4b..e4a922e4c9a8 100644 --- a/cmake/config.cmake +++ b/cmake/config.cmake @@ -36,3 +36,6 @@ set(USE_CUDA OFF) #--------------------------------------------- # Whether to build cpp unittest executables set(BUILD_CPP_TEST OFF) + +# Whether to enable OpenMP +set(USE_OPENMP ON) diff --git a/cmake/util/FindCUDA.cmake b/cmake/util/FindCUDA.cmake index 3a99551358f6..ec9b41e3c352 100644 --- a/cmake/util/FindCUDA.cmake +++ b/cmake/util/FindCUDA.cmake @@ -5,7 +5,8 @@ # find_cuda(${USE_CUDA}) # # - When USE_CUDA=ON, use auto search -# - When USE_CUDA=/path/to/cuda-path, use the cuda path +# +# Please use the CMAKE variable CUDA_TOOLKIT_ROOT_DIR to set CUDA directory # # Provide variables: # @@ -21,21 +22,7 @@ macro(find_cuda use_cuda) set(__use_cuda ${use_cuda}) if(__use_cuda STREQUAL "ON") - find_package(CUDA QUIET) - elseif(IS_DIRECTORY ${__use_cuda}) - set(CUDA_TOOLKIT_ROOT_DIR ${__use_cuda}) - message(STATUS "Custom CUDA_PATH=" ${CUDA_TOOLKIT_ROOT_DIR}) - set(CUDA_INCLUDE_DIRS ${CUDA_TOOLKIT_ROOT_DIR}/include) - set(CUDA_FOUND TRUE) - if(MSVC) - find_library(CUDA_CUDART_LIBRARY cudart - ${CUDA_TOOLKIT_ROOT_DIR}/lib/x64 - ${CUDA_TOOLKIT_ROOT_DIR}/lib/Win32) - else(MSVC) - find_library(CUDA_CUDART_LIBRARY cudart - ${CUDA_TOOLKIT_ROOT_DIR}/lib64 - ${CUDA_TOOLKIT_ROOT_DIR}/lib) - endif(MSVC) + include(FindCUDA) endif() # additional libraries diff --git a/tests/scripts/build_dgl.bat b/tests/scripts/build_dgl.bat index 8d4eb1d466b7..f6d9ab79c151 100644 --- a/tests/scripts/build_dgl.bat +++ b/tests/scripts/build_dgl.bat @@ -7,7 +7,7 @@ MD build PUSHD build CALL "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvars64.bat" -cmake -DCMAKE_CXX_FLAGS="/DDGL_EXPORTS" -Dgtest_force_shared_crt=ON -DBUILD_CPP_TEST=1 -DCMAKE_CONFIGURATION_TYPES="Release" .. -G "Visual Studio 15 2017 Win64" || EXIT /B 1 +cmake -DCMAKE_CXX_FLAGS="/DDGL_EXPORTS" -DUSE_OPENMP=ON -Dgtest_force_shared_crt=ON -DBUILD_CPP_TEST=1 -DCMAKE_CONFIGURATION_TYPES="Release" .. -G "Visual Studio 15 2017 Win64" || EXIT /B 1 msbuild dgl.sln || EXIT /B 1 COPY Release\dgl.dll . COPY Release\runUnitTests.exe . diff --git a/tests/scripts/build_dgl.sh b/tests/scripts/build_dgl.sh index 4ce1d5d5c28f..3026ef9583b6 100644 --- a/tests/scripts/build_dgl.sh +++ b/tests/scripts/build_dgl.sh @@ -6,9 +6,10 @@ if [ $# -ne 1 ]; then exit -1 fi +CMAKE_VARS="-DBUILD_CPP_TEST=ON -DUSE_OPENMP=ON" + if [ "$1" == "gpu" ]; then - cp cmake/config.cmake config.cmake - sed -i -e 's/USE_CUDA OFF/USE_CUDA ON/g' config.cmake + CMAKE_VARS="-DUSE_CUDA=ON $CMAKE_VARS" fi if [ -d build ]; then @@ -19,7 +20,7 @@ mkdir build rm -rf _download pushd build -cmake .. -DBUILD_CPP_TEST=1 +cmake $CMAKE_VARS .. make -j4 popd diff --git a/third_party/minigun b/third_party/minigun index bcf5f041dde6..e77ce9496015 160000 --- a/third_party/minigun +++ b/third_party/minigun @@ -1 +1 @@ -Subproject commit bcf5f041dde6ce43264dd10159677eb81bd2eed9 +Subproject commit e77ce949601570980f76630862ee838cf8bbc96a