diff --git a/CMakeLists.txt b/CMakeLists.txt index a543566e8289..a65779bb4c2d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,21 +13,106 @@ include(cmake/util/Util.cmake) include(cmake/util/MshadowUtil.cmake) include(cmake/util/FindCUDA.cmake) -# NOTE: do not modify this file to change option values. -# Use bash script/build_dgl.sh -e '-DOPTION=VALUE' through command-line. -dgl_option(USE_CUDA "Build with CUDA" OFF) -dgl_option(USE_OPENMP "Build with OpenMP" ON) -dgl_option(USE_LIBXSMM "Build with LIBXSMM library optimization" ON) -dgl_option(BUILD_CPP_TEST "Build cpp unittest executables" OFF) -dgl_option(LIBCXX_ENABLE_PARALLEL_ALGORITHMS "Enable the parallel algorithms library. This requires the PSTL to be available." OFF) -dgl_option(USE_S3 "Build with S3 support" OFF) -dgl_option(USE_HDFS "Build with HDFS support" OFF) # Set env HADOOP_HDFS_HOME if needed -dgl_option(REBUILD_LIBXSMM "Clean LIBXSMM build cache at every build" OFF) # Set env HADOOP_HDFS_HOME if needed -dgl_option(USE_EPOLL "Build with epoll for socket communicator" ON) -dgl_option(TP_BUILD_LIBUV "Build libuv together with tensorpipe (only impacts Linux)" ON) -dgl_option(BUILD_TORCH "Build the PyTorch plugin" OFF) -dgl_option(BUILD_SPARSE "Build DGL sparse library" ON) -dgl_option(TORCH_PYTHON_INTERPS "Python interpreter used to build tensoradapter and DGL sparse library" python3) +# TODO(#5475): Clean up the old flags after CI and regression framework adopt to the new setup. +if (NOT DEFINED BUILD_TYPE) + dgl_option(USE_CUDA "Build with CUDA" OFF) + dgl_option(USE_OPENMP "Build with OpenMP" ON) + dgl_option(USE_LIBXSMM "Build with LIBXSMM library optimization" ON) + dgl_option(BUILD_CPP_TEST "Build cpp unittest executables" OFF) + dgl_option(LIBCXX_ENABLE_PARALLEL_ALGORITHMS "Enable the parallel algorithms library. This requires the PSTL to be available." OFF) + dgl_option(USE_S3 "Build with S3 support" OFF) + dgl_option(USE_HDFS "Build with HDFS support" OFF) # Set env HADOOP_HDFS_HOME if needed + dgl_option(REBUILD_LIBXSMM "Clean LIBXSMM build cache at every build" OFF) # Set env HADOOP_HDFS_HOME if needed + dgl_option(USE_EPOLL "Build with epoll for socket communicator" ON) + dgl_option(BUILD_TORCH "Build the PyTorch plugin" OFF) + dgl_option(BUILD_SPARSE "Build DGL sparse library" ON) + dgl_option(BUILD_GRAPHBOLT "Build Graphbolt library" OFF) + dgl_option(TORCH_PYTHON_INTERPS "Python interpreter used to build tensoradapter and DGL sparse library" python3) +else() + # Options for building DGL. + # NOTE: do not modify this file to change option values. + # Use bash script/build_dgl.sh -e '-DOPTION=VALUE' through command-line. + dgl_option( + BUILD_TYPE + "Type of the build: dev, test or release" + "dev" + ) + message(STATUS "Build for ${BUILD_TYPE}") + + dgl_option( + USE_CUDA + "Build with CUDA" + OFF + ) + dgl_option( + TORCH_PYTHON_INTERPS + "Python interpreter used to build tensoradapter and DGL sparse library" + python3 + ) + + # Options for building DGL features, supported: "none", "dev", "test", "release", "all". + # NOTE: do not modify this file to change option values. + # Use bash script/build_dgl.sh -e '-DFEATURE_NAME=ON/OFF' through command-line. + dgl_feature_option( + BUILD_SPARSE + "Build DGL sparse library" + "all" + ) + dgl_feature_option( + BUILD_TORCH + "Build the PyTorch plugin" + "all" + ) + dgl_feature_option( + USE_EPOLL + "Build with epoll for socket communicator" + "all" + ) + dgl_feature_option( + USE_LIBXSMM + "Build with LIBXSMM library optimization" + "all" + ) + dgl_feature_option( + USE_OPENMP + "Build with OpenMP" + "all" + ) + + dgl_feature_option( + BUILD_GRAPHBOLT + "Build Graphbolt library" + "dev" "test" + ) + + dgl_feature_option( + LIBCXX_ENABLE_PARALLEL_ALGORITHMS + "Enable the parallel algorithms library. This requires the PSTL to be available." + "none" + ) + dgl_feature_option( + REBUILD_LIBXSMM + "Clean LIBXSMM build cache at every build" + "none" + ) + dgl_feature_option( + USE_HDFS + "Build with HDFS support" + "none" + ) # Set env HADOOP_HDFS_HOME if needed + dgl_feature_option( + USE_S3 + "Build with S3 support" + "none" + ) + + # Build cpp test only in test build. + dgl_feature_option( + BUILD_CPP_TEST + "Build cpp unittest executables" + "test" + ) +endif() # Set debug compile option for gdb, only happens when -DCMAKE_BUILD_TYPE=DEBUG if (NOT MSVC) diff --git a/cmake/util/Util.cmake b/cmake/util/Util.cmake index c6570246f834..26c92ef5450d 100644 --- a/cmake/util/Util.cmake +++ b/cmake/util/Util.cmake @@ -4,6 +4,27 @@ macro(__dgl_option variable description value) endif() endmacro() +####################################################### +# An option to specify the build type for a feature. +# Usage: +# dgl_feature_option( "doc string" "dev" "release") +macro(dgl_feature_option variable description) + set(__value "") + foreach(arg ${ARGN}) + if(arg STREQUAL "all") + __dgl_option(${variable} "${description}" ON) + elseif(arg STREQUAL "dev" OR arg STREQUAL "test" OR arg STREQUAL "release") + list(APPEND __value ${arg}) + endif() + endforeach() + + if(${BUILD_TYPE} IN_LIST __value) + __dgl_option(${variable} "${description}" ON) + else() + __dgl_option(${variable} "${description}" OFF) + endif() +endmacro() + ####################################################### # An option that the user can select. Can accept condition to control when option is available for user. # Usage: diff --git a/script/build_dgl.sh b/script/build_dgl.sh index 85f156727969..b1fa375e1695 100644 --- a/script/build_dgl.sh +++ b/script/build_dgl.sh @@ -69,7 +69,7 @@ if [[ -z ${cuda} ]]; then else mkdir -p build cd build - cmake -DUSE_CUDA=${cuda} ${extra_args} .. + cmake -DBUILD_TYPE=dev -DUSE_CUDA=${cuda} ${extra_args} .. fi if [[ ${PWD} == "${DGL_HOME}/build" ]]; then diff --git a/tests/README.md b/tests/README.md index bcb87e865c6c..26f60ba581a6 100644 --- a/tests/README.md +++ b/tests/README.md @@ -21,9 +21,6 @@ The code organization goes as follows: Compile with unittest by executing the command below ``` # Assume current directory is the root directory of dgl, and googletest submodule is initialized -mkdir build -cd build -cmake .. -DBUILD_CPP_TEST=1 -make -j${nproc} +bash script/build_dgl.sh -c -r -e '-DBUILD_TYPE=test' ./runUnitTests ``` diff --git a/tests/scripts/build_dgl.bat b/tests/scripts/build_dgl.bat index 0bc4353c5fdd..ef79220b65fe 100644 --- a/tests/scripts/build_dgl.bat +++ b/tests/scripts/build_dgl.bat @@ -13,7 +13,7 @@ SET TEMP=%WORKSPACE%\tmp SET TMPDIR=%WORKSPACE%\tmp PUSHD build -cmake -DCMAKE_CXX_FLAGS="/DDGL_EXPORTS" -DUSE_OPENMP=ON -DBUILD_TORCH=ON -Dgtest_force_shared_crt=ON -DDMLC_FORCE_SHARED_CRT=ON -DBUILD_CPP_TEST=1 -DCMAKE_CONFIGURATION_TYPES="Release" -DTORCH_PYTHON_INTERPS=python -DBUILD_SPARSE=ON .. -G "Visual Studio 16 2019" || EXIT /B 1 +cmake -DBUILD_TYPE=test -DCMAKE_CXX_FLAGS="/DDGL_EXPORTS" -Dgtest_force_shared_crt=ON -DDMLC_FORCE_SHARED_CRT=ON -DCMAKE_CONFIGURATION_TYPES="Release" -DTORCH_PYTHON_INTERPS=python .. -G "Visual Studio 16 2019" || EXIT /B 1 msbuild dgl.sln /m /nr:false || EXIT /B 1 COPY /Y Release\runUnitTests.exe . POPD diff --git a/tests/scripts/build_dgl.sh b/tests/scripts/build_dgl.sh index 0f894f89d298..792268f95969 100644 --- a/tests/scripts/build_dgl.sh +++ b/tests/scripts/build_dgl.sh @@ -7,7 +7,13 @@ if [ $# -ne 1 ]; then exit -1 fi -CMAKE_VARS="-DBUILD_CPP_TEST=ON -DUSE_OPENMP=ON" +# Build for testing. +CMAKE_VARS="-DBUILD_TYPE=test" + +if [[ $1 != "cpu" ]]; then + CMAKE_VARS="$CMAKE_VARS -DUSE_CUDA=ON" +fi + # This is a semicolon-separated list of Python interpreters containing PyTorch. # The value here is for CI. Replace it with your own or comment this whole # statement for default Python interpreter. @@ -15,16 +21,12 @@ if [ "$1" != "cugraph" ]; then # We do not build pytorch for cugraph because currently building # pytorch against all the supported cugraph versions is not supported # See issue: https://github.com/rapidsai/cudf/issues/8510 - CMAKE_VARS="$CMAKE_VARS -DBUILD_TORCH=ON -DTORCH_PYTHON_INTERPS=/opt/conda/envs/pytorch-ci/bin/python" + CMAKE_VARS="$CMAKE_VARS -DTORCH_PYTHON_INTERPS=/opt/conda/envs/pytorch-ci/bin/python" else # Disable sparse build as cugraph docker image lacks cuDNN. CMAKE_VARS="$CMAKE_VARS -DBUILD_TORCH=OFF -DBUILD_SPARSE=OFF" fi -if [[ $1 != "cpu" ]]; then - CMAKE_VARS="-DUSE_CUDA=ON $CMAKE_VARS" -fi - if [ -d build ]; then rm -rf build fi