Skip to content

Commit

Permalink
Work around a compiler bug in MacOS AppleClang 11 (#6103)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
hcho3 authored Sep 10, 2020
1 parent 9338582 commit d0ccb13
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 32 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
7 changes: 3 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
sudo: required

osx_image: xcode10.1
dist: bionic

env:
Expand All @@ -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
Expand Down
7 changes: 6 additions & 1 deletion plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
7 changes: 4 additions & 3 deletions src/common/threading_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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);
Expand All @@ -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();
}
Expand Down
26 changes: 6 additions & 20 deletions tests/travis/run_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
4 changes: 0 additions & 4 deletions tests/travis/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit d0ccb13

Please sign in to comment.