Skip to content

Commit

Permalink
[CI] Add Windows GPU to Jenkins CI pipeline (#4463)
Browse files Browse the repository at this point in the history
* Fix #4462: Use /MT flag consistently for MSVC target

* First attempt at Windows CI

* Distinguish stages in Linux and Windows pipelines

* Try running CMake in Windows pipeline

* Add build step
  • Loading branch information
hcho3 authored May 14, 2019
1 parent e7d17ec commit c6f2a7e
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 6 deletions.
9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ if (MSVC)
endif (MSVC)

set_default_configuration_release()
msvc_use_static_runtime()

#-- Options
option(BUILD_C_DOC "Build documentation for C APIs using Doxygen." OFF)
Expand Down Expand Up @@ -67,6 +66,7 @@ if (USE_CUDA)
endif (USE_CUDA)

# dmlc-core
msvc_use_static_runtime()
add_subdirectory(${PROJECT_SOURCE_DIR}/dmlc-core)
set_target_properties(dmlc PROPERTIES
CXX_STANDARD 11
Expand Down Expand Up @@ -139,6 +139,8 @@ set_target_properties(

set_output_directory(runxgboost ${PROJECT_SOURCE_DIR})
set_output_directory(xgboost ${PROJECT_SOURCE_DIR}/lib)
# Ensure these two targets do not build simultaneously, as they produce outputs with conflicting names
add_dependencies(xgboost runxgboost)

#-- Installing XGBoost
if (R_LIB)
Expand Down Expand Up @@ -214,3 +216,8 @@ if (GOOGLE_TEST)
PROPERTIES
PASS_REGULAR_EXPRESSION ".*test-rmse:0.087.*")
endif (GOOGLE_TEST)

# For MSVC: Call msvc_use_static_runtime() once again to completely
# replace /MD with /MT. See https://github.com/dmlc/xgboost/issues/4462
# for issues caused by mixing of /MD and /MT flags
msvc_use_static_runtime()
8 changes: 4 additions & 4 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pipeline {

// Build stages
stages {
stage('Get sources') {
stage('Jenkins Linux: Get sources') {
agent { label 'linux && cpu' }
steps {
script {
Expand All @@ -35,7 +35,7 @@ pipeline {
milestone ordinal: 1
}
}
stage('Formatting Check') {
stage('Jenkins Linux: Formatting Check') {
agent none
steps {
script {
Expand All @@ -49,7 +49,7 @@ pipeline {
milestone ordinal: 2
}
}
stage('Build') {
stage('Jenkins Linux: Build') {
agent none
steps {
script {
Expand All @@ -65,7 +65,7 @@ pipeline {
milestone ordinal: 3
}
}
stage('Test') {
stage('Jenkins Linux: Test') {
agent none
steps {
script {
Expand Down
70 changes: 70 additions & 0 deletions Jenkinsfile-win64
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/usr/bin/groovy
// -*- mode: groovy -*-

/* Jenkins pipeline for Windows AMD64 target */

pipeline {
agent none
// Build stages
stages {
stage('Jenkins Win64: Get sources') {
agent { label 'win64' }
steps {
script {
checkoutSrcs()
}
stash name: 'srcs'
milestone ordinal: 1
}
}
stage('Jenkins Win64: Build') {
agent none
steps {
script {
parallel ([
'build-win64': { BuildWin64() }
])
}
milestone ordinal: 2
}
}
}
}

// check out source code from git
def checkoutSrcs() {
retry(5) {
try {
timeout(time: 2, unit: 'MINUTES') {
checkout scm
sh 'git submodule update --init'
}
} catch (exc) {
deleteDir()
error "Failed to fetch source codes"
}
}
}

def BuildWin64() {
node('win64') {
unstash name: 'srcs'
echo "Building XGBoost for Windows AMD64 target..."
bat """
mkdir build
cd build
cmake .. -G"Visual Studio 15 2017 Win64" -DUSE_CUDA=ON -DCMAKE_VERBOSE_MAKEFILE=ON
"""
bat """
cd build
"C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\MSBuild\\15.0\\Bin\\MSBuild.exe" xgboost.sln /m /p:Configuration=Release
"""
bat """
cd python-package
conda activate && python setup.py bdist_wheel --universal
"""
stash name: 'xgboost_win_whl', includes: 'python-package/dist/*.whl'
archiveArtifacts artifacts: "python-package/dist/*.whl", allowEmptyArchive: true
deleteDir()
}
}
9 changes: 9 additions & 0 deletions cmake/Utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ endfunction(auto_source_group)
function(msvc_use_static_runtime)
if(MSVC)
set(variables
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_MINSIZEREL
CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_RELWITHDEBINFO
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_MINSIZEREL
CMAKE_CXX_FLAGS_RELEASE
Expand All @@ -29,6 +33,7 @@ function(msvc_use_static_runtime)
endif()
endforeach()
set(variables
CMAKE_CUDA_FLAGS
CMAKE_CUDA_FLAGS_DEBUG
CMAKE_CUDA_FLAGS_MINSIZEREL
CMAKE_CUDA_FLAGS_RELEASE
Expand All @@ -39,6 +44,10 @@ function(msvc_use_static_runtime)
string(REGEX REPLACE "-MD" "-MT" ${variable} "${${variable}}")
set(${variable} "${${variable}}" PARENT_SCOPE)
endif()
if(${variable} MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" ${variable} "${${variable}}")
set(${variable} "${${variable}}" PARENT_SCOPE)
endif()
endforeach()
endif()
endfunction(msvc_use_static_runtime)
Expand Down
8 changes: 7 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ if (USE_CUDA)
$<$<COMPILE_LANGUAGE:CUDA>:--expt-extended-lambda>
$<$<COMPILE_LANGUAGE:CUDA>:--expt-relaxed-constexpr>
$<$<COMPILE_LANGUAGE:CUDA>:-lineinfo>
$<$<COMPILE_LANGUAGE:CUDA>:--std=c++11>
$<$<AND:$<NOT:$<CXX_COMPILER_ID:MSVC>>,$<COMPILE_LANGUAGE:CUDA>>:--std=c++11>
$<$<COMPILE_LANGUAGE:CUDA>:${GEN_CODE}>)

if (USE_NCCL)
Expand Down Expand Up @@ -113,4 +113,10 @@ if (USE_OPENMP)
set(LINKED_LIBRARIES_PRIVATE "${LINKED_LIBRARIES_PRIVATE};${SRC_LIBS}" PARENT_SCOPE)
endif (OpenMP_CXX_FOUND OR OPENMP_FOUND)
endif (USE_OPENMP)

# For MSVC: Call msvc_use_static_runtime() once again to completely
# replace /MD with /MT. See https://github.com/dmlc/xgboost/issues/4462
# for issues caused by mixing of /MD and /MT flags
msvc_use_static_runtime()

#-- End object library

0 comments on commit c6f2a7e

Please sign in to comment.