[CI] Add Windows GPU to Jenkins CI pipeline (#4463)

* 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
This commit is contained in:
Philip Hyunsu Cho 2019-05-14 04:45:06 +00:00 committed by GitHub
parent e7d17ec4f4
commit c6f2a7e186
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 98 additions and 6 deletions

View File

@ -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)
@ -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
@ -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)
@ -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
Jenkinsfile vendored
View File

@ -25,7 +25,7 @@ pipeline {
// Build stages
stages {
stage('Get sources') {
stage('Jenkins Linux: Get sources') {
agent { label 'linux && cpu' }
steps {
script {
@ -35,7 +35,7 @@ pipeline {
milestone ordinal: 1
}
}
stage('Formatting Check') {
stage('Jenkins Linux: Formatting Check') {
agent none
steps {
script {
@ -49,7 +49,7 @@ pipeline {
milestone ordinal: 2
}
}
stage('Build') {
stage('Jenkins Linux: Build') {
agent none
steps {
script {
@ -65,7 +65,7 @@ pipeline {
milestone ordinal: 3
}
}
stage('Test') {
stage('Jenkins Linux: Test') {
agent none
steps {
script {

70
Jenkinsfile-win64 Normal file
View File

@ -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()
}
}

View File

@ -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
@ -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
@ -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)

View File

@ -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)
@ -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