diff --git a/.ci/test.sh b/.ci/test.sh index b2bd43570..1bc9124fc 100755 --- a/.ci/test.sh +++ b/.ci/test.sh @@ -138,7 +138,7 @@ elif [[ $TASK == "mpi" ]]; then pytest $BUILD_DIRECTORY/tests/python_package_test || exit -1 exit 0 fi - cmake -DUSE_MPI=ON .. + cmake -DUSE_MPI=ON -DUSE_DEBUG=ON .. else cmake .. fi diff --git a/CMakeLists.txt b/CMakeLists.txt index 070b709c4..9627927dc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,8 @@ OPTION(USE_GPU "Enable GPU-accelerated training" OFF) OPTION(USE_SWIG "Enable SWIG to generate Java API" OFF) OPTION(USE_HDFS "Enable HDFS support (EXPERIMENTAL)" OFF) OPTION(USE_R35 "Set to ON if your R version is not earlier than 3.5" OFF) +OPTION(USE_TIMETAG "Set to ON to output time costs" OFF) +OPTION(USE_DEBUG "Set to ON for Debug mode" OFF) if(APPLE) OPTION(APPLE_OUTPUT_DYLIB "Output dylib shared library" OFF) @@ -72,6 +74,10 @@ if(USE_TIMETAG) ADD_DEFINITIONS(-DTIMETAG) endif(USE_TIMETAG) +if(USE_DEBUG) + ADD_DEFINITIONS(-DDEBUG) +endif(USE_DEBUG) + if(USE_MPI) find_package(MPI REQUIRED) ADD_DEFINITIONS(-DUSE_MPI) @@ -150,7 +156,12 @@ if(${MM_MALLOC}) endif() if(UNIX OR MINGW OR CYGWIN) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pthread -O3 -Wextra -Wall -Wno-ignored-attributes -Wno-unknown-pragmas -Wno-return-type") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pthread -Wextra -Wall -Wno-ignored-attributes -Wno-unknown-pragmas -Wno-return-type") + if(USE_DEBUG) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0") + else() + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3") + endif() if(USE_SWIG) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing") endif() @@ -171,10 +182,16 @@ if(MSVC) CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELWITHDEBINFO ) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /O2 /Ob2 /Oi /Ot /Oy /MP") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /MP") + if(USE_DEBUG) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Od") + else() + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /O2 /Ob2 /Oi /Ot /Oy") + endif() else() - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -funroll-loops") + if(NOT USE_DEBUG) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -funroll-loops") + endif() endif(MSVC) SET(LightGBM_HEADER_DIR ${PROJECT_SOURCE_DIR}/include) diff --git a/docs/Installation-Guide.rst b/docs/Installation-Guide.rst index 261625727..6dcdb4080 100644 --- a/docs/Installation-Guide.rst +++ b/docs/Installation-Guide.rst @@ -7,6 +7,10 @@ All instructions below are aimed to compile 64-bit version of LightGBM. It is worth to compile 32-bit version only in very rare special cases of environmental limitations. 32-bit version is slow and untested, so use it on your own risk and don't forget to adjust some commands in this guide. +Users who want to perform benchmarking can make LightGBM output time costs for different internal routines via adding ``-DUSE_TIMETAG=ON`` to CMake flags. + +It is possible to build LightGBM in a debug mode. In this mode all compiler optimizations are disabled and LightGBM performs more checks internally. To enable debug mode you can add ``-DUSE_DEBUG=ON`` to CMake flags or choose ``Debug_*`` configuration (e.g. ``Debug_DLL``, ``Debug_mpi``) in Visual Studio depending on how you are building LightGBM. + For the build of Python-package and R-package, please refer to `Python-package`_ and `R-package`_ folders respectively. Also you can download artifacts of the latest successful build in master branch (nightly builds): |download artifacts|. diff --git a/windows/LightGBM.sln b/windows/LightGBM.sln index 189d7d4e7..42b090bec 100644 --- a/windows/LightGBM.sln +++ b/windows/LightGBM.sln @@ -1,4 +1,3 @@ - Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 VisualStudioVersion = 14.0.25420.1 @@ -7,6 +6,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LightGBM", "LightGBM.vcxpro EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug_DLL|x64 = Debug_DLL|x64 Debug_mpi|x64 = Debug_mpi|x64 Debug|x64 = Debug|x64 DLL|x64 = DLL|x64 @@ -14,6 +14,8 @@ Global Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F31C0B5D-715E-4953-AA1B-8D2AEEE4344C}.Debug_DLL|x64.ActiveCfg = Debug_DLL|x64 + {F31C0B5D-715E-4953-AA1B-8D2AEEE4344C}.Debug_DLL|x64.Build.0 = Debug_DLL|x64 {F31C0B5D-715E-4953-AA1B-8D2AEEE4344C}.Debug_mpi|x64.ActiveCfg = Debug_mpi|x64 {F31C0B5D-715E-4953-AA1B-8D2AEEE4344C}.Debug_mpi|x64.Build.0 = Debug_mpi|x64 {F31C0B5D-715E-4953-AA1B-8D2AEEE4344C}.Debug|x64.ActiveCfg = Debug|x64 diff --git a/windows/LightGBM.vcxproj b/windows/LightGBM.vcxproj index e664b9ae5..acb14cee5 100644 --- a/windows/LightGBM.vcxproj +++ b/windows/LightGBM.vcxproj @@ -1,6 +1,10 @@ + + Debug_DLL + x64 + Debug_mpi x64 @@ -46,6 +50,10 @@ v140 + + v140 + DynamicLibrary + v140 @@ -55,6 +63,9 @@ + + + @@ -64,6 +75,11 @@ $(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64); lightgbm + + ..\include;$(VC_IncludePath);$(WindowsSDK_IncludePath); + $(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64); + lib_lightgbm + $(MSMPI_INC);..\include;$(VC_IncludePath);$(WindowsSDK_IncludePath); $(MSMPI_LIB64);$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64); @@ -124,6 +140,25 @@ + + + USE_SOCKET + Level4 + true + Neither + Default + false + false + false + Disabled + MultiThreadedDebugDLL + true + + + + + + Level4