Work around a compiler bug in MacOS AppleClang 11 (#6103)

* Workaround a compiler bug in MacOS AppleClang

* [CI] Run C++ test with MacOS Catalina + AppleClang 11.0.3

* [CI] Migrate cmake_test on MacOS from Travis CI to GitHub Actions

* Install OpenMP runtime

* [CI] Use CMake to locate lz4 lib
This commit is contained in:
Philip Hyunsu Cho 2020-09-09 21:21:55 -07:00 committed by GitHub
parent 9338582d79
commit d0ccb13d09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 43 additions and 32 deletions

View File

@ -11,6 +11,30 @@ env:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
gtest-cpu:
name: Test Google C++ test (CPU)
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-10.15]
steps:
- uses: actions/checkout@v2
with:
submodules: 'true'
- name: Install system packages
run: |
brew install lz4 ninja libomp
- name: Build gtest binary
run: |
mkdir build
cd build
cmake .. -DGOOGLE_TEST=ON -DUSE_OPENMP=ON -DUSE_DMLC_GTEST=ON -DPLUGIN_LZ4=ON -DPLUGIN_DENSE_PARSER=ON -GNinja
ninja -v
- name: Run gtest binary
run: |
cd build
ctest --extra-verbose
test-with-jvm:
name: Test JVM on OS ${{ matrix.os }}
runs-on: ${{ matrix.os }}

View File

@ -1,6 +1,5 @@
sudo: required
osx_image: xcode10.1
dist: bionic
env:
@ -15,16 +14,16 @@ jobs:
env: TASK=python_sdist_test
- os: osx
arch: amd64
osx_image: xcode10.1
env: TASK=python_test
- os: osx
arch: amd64
osx_image: xcode10.1
env: TASK=python_sdist_test
- os: osx
arch: amd64
osx_image: xcode10.1
env: TASK=java_test
- os: osx
arch: amd64
env: TASK=cmake_test
- os: linux
arch: s390x
env: TASK=s390x_test

View File

@ -1,6 +1,11 @@
if (PLUGIN_LZ4)
target_sources(objxgboost PRIVATE ${xgboost_SOURCE_DIR}/plugin/lz4/sparse_page_lz4_format.cc)
target_link_libraries(objxgboost PUBLIC lz4)
find_path(LIBLZ4_INCLUDE_DIR lz4.h)
find_library(LIBLZ4_LIBRARY NAMES lz4)
message(STATUS "LIBLZ4_INCLUDE_DIR = ${LIBLZ4_INCLUDE_DIR}")
message(STATUS "LIBLZ4_LIBRARY = ${LIBLZ4_LIBRARY}")
target_include_directories(objxgboost PUBLIC ${LIBLZ4_INCLUDE_DIR})
target_link_libraries(objxgboost PUBLIC ${LIBLZ4_LIBRARY})
endif (PLUGIN_LZ4)
if (PLUGIN_DENSE_PARSER)

View File

@ -109,7 +109,7 @@ class BlockedSpace2d {
// Wrapper to implement nested parallelism with simple omp parallel for
template<typename Func>
template <typename Func>
void ParallelFor2d(const BlockedSpace2d& space, int nthreads, Func func) {
const size_t num_blocks_in_space = space.Size();
nthreads = std::min(nthreads, omp_get_max_threads());
@ -118,7 +118,8 @@ void ParallelFor2d(const BlockedSpace2d& space, int nthreads, Func func) {
dmlc::OMPException omp_exc;
#pragma omp parallel num_threads(nthreads)
{
omp_exc.Run([&]() {
omp_exc.Run(
[](size_t num_blocks_in_space, const BlockedSpace2d& space, int nthreads, Func func) {
size_t tid = omp_get_thread_num();
size_t chunck_size =
num_blocks_in_space / nthreads + !!(num_blocks_in_space % nthreads);
@ -128,7 +129,7 @@ void ParallelFor2d(const BlockedSpace2d& space, int nthreads, Func func) {
for (auto i = begin; i < end; i++) {
func(space.GetFirstDimension(i), space.GetRange(i));
}
});
}, num_blocks_in_space, space, nthreads, func);
}
omp_exc.Rethrow();
}

View File

@ -17,6 +17,12 @@ if [ ${TASK} == "python_sdist_test" ]; then
fi
if [ ${TASK} == "python_test" ]; then
if grep -n -R '<<<.*>>>\(.*\)' src include | grep --invert "NOLINT"; then
echo 'Do not use raw CUDA execution configuration syntax with <<<blocks, threads>>>.' \
'try `dh::LaunchKernel`'
exit -1
fi
set -e
# Build/test
rm -rf build
@ -69,26 +75,6 @@ if [ ${TASK} == "java_test" ]; then
mvn -q test
fi
if [ ${TASK} == "cmake_test" ]; then
set -e
if grep -n -R '<<<.*>>>\(.*\)' src include | grep --invert "NOLINT"; then
echo 'Do not use raw CUDA execution configuration syntax with <<<blocks, threads>>>.' \
'try `dh::LaunchKernel`'
exit -1
fi
# Build/test
rm -rf build
mkdir build && cd build
PLUGINS="-DPLUGIN_LZ4=ON -DPLUGIN_DENSE_PARSER=ON"
cmake .. -DCMAKE_VERBOSE_MAKEFILE=ON -DGOOGLE_TEST=ON -DUSE_OPENMP=ON -DUSE_DMLC_GTEST=ON ${PLUGINS}
make -j$(nproc)
./testxgboost
cd ..
rm -rf build
fi
if [ ${TASK} == "s390x_test" ]; then
set -e

View File

@ -16,10 +16,6 @@ if [ ${TASK} == "python_test" ] || [ ${TASK} == "python_sdist_test" ]; then
conda create -n python3 python=3.7
fi
if [ ${TASK} == "cmake_test" ] && [ ${TRAVIS_OS_NAME} == "osx" ]; then
sudo softwareupdate -i "Command Line Tools (macOS High Sierra version 10.13) for Xcode-9.3"
fi
if [ ${TASK} == "s390x_test" ] && [ ${TRAVIS_CPU_ARCH} == "s390x" ]; then
sudo snap install cmake --channel=3.17/beta --classic
export PATH=/snap/bin:${PATH}