Skip to content

Commit

Permalink
Fix compilation on Mac OSX High Sierra (10.13) (#5597)
Browse files Browse the repository at this point in the history
* Fix compilation on Mac OSX High Sierra

* [CI] Build Mac OSX binary wheel using Travis CI
  • Loading branch information
hcho3 committed May 4, 2020
1 parent 844d7c1 commit 02faddc
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 9 deletions.
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ os:
- linux
- osx

osx_image: xcode10.3
osx_image: xcode10.1
dist: bionic

# Use Build Matrix to do lint and build seperately
Expand All @@ -21,6 +21,10 @@ env:
# cmake test
- TASK=cmake_test

global:
- secure: "PR16i9F8QtNwn99C5NDp8nptAS+97xwDtXEJJfEiEVhxPaaRkOp0MPWhogCaK0Eclxk1TqkgWbdXFknwGycX620AzZWa/A1K3gAs+GrpzqhnPMuoBJ0Z9qxXTbSJvCyvMbYwVrjaxc/zWqdMU8waWz8A7iqKGKs/SqbQ3rO6v7c="
- secure: "dAGAjBokqm/0nVoLMofQni/fWIBcYSmdq4XvCBX1ZAMDsWnuOfz/4XCY6h2lEI1rVHZQ+UdZkc9PioOHGPZh5BnvE49/xVVWr9c4/61lrDOlkD01ZjSAeoV0fAZq+93V/wPl4QV+MM+Sem9hNNzFSbN5VsQLAiWCSapWsLdKzqA="

matrix:
exclude:
- os: linux
Expand Down
3 changes: 1 addition & 2 deletions src/metric/survival_metric.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ struct EvalAFT : public Metric {

double nloglik_sum = 0.0;
double weight_sum = 0.0;
#pragma omp parallel for default(none) \
firstprivate(nsize, is_null_weight, aft_loss_distribution_scale) \
#pragma omp parallel for \
shared(weights, y_lower, y_upper, yhat) reduction(+:nloglik_sum, weight_sum)
for (omp_ulong i = 0; i < nsize; ++i) {
// If weights are empty, data is unweighted so we use 1.0 everywhere
Expand Down
5 changes: 2 additions & 3 deletions src/objective/aft_obj.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ class AFTObj : public ObjFunction {
const omp_ulong nsize = static_cast<omp_ulong>(yhat.size());
const float aft_loss_distribution_scale = param_.aft_loss_distribution_scale;

#pragma omp parallel for default(none) \
firstprivate(nsize, is_null_weight, aft_loss_distribution_scale) \
#pragma omp parallel for \
shared(weights, y_lower, y_upper, yhat, gpair)
for (omp_ulong i = 0; i < nsize; ++i) {
// If weights are empty, data is unweighted so we use 1.0 everywhere
Expand All @@ -74,7 +73,7 @@ class AFTObj : public ObjFunction {
// Trees give us a prediction in log scale, so exponentiate
std::vector<bst_float> &preds = io_preds->HostVector();
const long ndata = static_cast<long>(preds.size()); // NOLINT(*)
#pragma omp parallel for default(none) firstprivate(ndata) shared(preds)
#pragma omp parallel for shared(preds)
for (long j = 0; j < ndata; ++j) { // NOLINT(*)
preds[j] = std::exp(preds[j]);
}
Expand Down
2 changes: 0 additions & 2 deletions tests/ci_build/rename_whl.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ def cd(path):
commit_id = sys.argv[2]
platform_tag = sys.argv[3]

assert platform_tag in ['manylinux1_x86_64', 'manylinux2010_x86_64', 'win_amd64']

dirname, basename = os.path.dirname(whl_path), os.path.basename(whl_path)

with cd(dirname):
Expand Down
26 changes: 25 additions & 1 deletion tests/travis/run_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,42 @@ if [ ${TASK} == "python_test" ]; then
mkdir build && cd build
cmake .. -DUSE_OPENMP=ON -DCMAKE_VERBOSE_MAKEFILE=ON
make -j$(nproc)
cd ..

echo "-------------------------------"
conda activate python3
conda --version
python --version

# Build binary wheel
cd ../python-package
python setup.py bdist_wheel
TAG=macosx_10_13_x86_64.macosx_10_14_x86_64.macosx_10_15_x86_64
python ../tests/ci_build/rename_whl.py dist/*.whl ${TRAVIS_COMMIT} ${TAG}
python -m pip install ./dist/xgboost-*-py3-none-${TAG}.whl

# Run unit tests
cd ..
python -m pip install graphviz pytest pytest-cov codecov
python -m pip install datatable
python -m pip install numpy scipy pandas matplotlib scikit-learn dask[complete]
python -m pytest -v --fulltrace -s tests/python --cov=python-package/xgboost || exit -1
codecov

# Deploy binary wheel to S3
python -m pip install awscli
if [ "${TRAVIS_PULL_REQUEST}" != "false" ]
then
S3_DEST="s3://xgboost-nightly-builds/PR-${TRAVIS_PULL_REQUEST}/"
else
if [ "${TRAVIS_BRANCH}" == "master" ]
then
S3_DEST="s3://xgboost-nightly-builds/"
elif [ -z "${TRAVIS_TAG}" ]
then
S3_DEST="s3://xgboost-nightly-builds/${TRAVIS_BRANCH}/"
fi
fi
python -m awscli s3 cp python-package/dist/*.whl "${S3_DEST}" || true
fi

if [ ${TASK} == "java_test" ]; then
Expand Down

0 comments on commit 02faddc

Please sign in to comment.