Skip to content

Commit

Permalink
[Build] Support older CMake & OpenMP toggle (dmlc#619)
Browse files Browse the repository at this point in the history
* cmake fixes for older systems

* allow specification of cuda path

* test script fixes to enable openmp & test

* update minigun; disable minigun partial frontier compile
  • Loading branch information
BarclayII authored and jermainewang committed Jun 7, 2019
1 parent 34dfaf7 commit e35e860
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 24 deletions.
12 changes: 9 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.9)
cmake_minimum_required(VERSION 3.5)
########################################
# Borrowed and adapted from TVM project
########################################
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand All @@ -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})
Expand Down
3 changes: 3 additions & 0 deletions cmake/config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
19 changes: 3 additions & 16 deletions cmake/util/FindCUDA.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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:
#
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/scripts/build_dgl.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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 .
Expand Down
7 changes: 4 additions & 3 deletions tests/scripts/build_dgl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -19,7 +20,7 @@ mkdir build
rm -rf _download

pushd build
cmake .. -DBUILD_CPP_TEST=1
cmake $CMAKE_VARS ..
make -j4
popd

Expand Down
2 changes: 1 addition & 1 deletion third_party/minigun

0 comments on commit e35e860

Please sign in to comment.