-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
variable 'aft_loss_distribution_scale' must have explicitly specified data sharing attributes #5595
Comments
I have no idea if this changes correctness or not (please advise), but I get a clean build when I remove the 'const' attribute from 6 variables across src/metric/survival_metric.cc and src/objective/aft_obj.cc diff --git a/src/metric/survival_metric.cc b/src/metric/survival_metric.cc
index 58518f00..ae299338 100644
--- a/src/metric/survival_metric.cc
+++ b/src/metric/survival_metric.cc
@@ -62,11 +62,11 @@ struct EvalAFT : public Metric {
const auto& y_lower = info.labels_lower_bound_.HostVector();
const auto& y_upper = info.labels_upper_bound_.HostVector();
const auto& weights = info.weights_.HostVector();
- const bool is_null_weight = weights.empty();
- const float aft_loss_distribution_scale = param_.aft_loss_distribution_scale;
+ bool is_null_weight = weights.empty();
+ float aft_loss_distribution_scale = param_.aft_loss_distribution_scale;
CHECK_LE(yhat.size(), static_cast<size_t>(std::numeric_limits<omp_ulong>::max()))
<< "yhat is too big";
- const omp_ulong nsize = static_cast<omp_ulong>(yhat.size());
+ omp_ulong nsize = static_cast<omp_ulong>(yhat.size());
double nloglik_sum = 0.0;
double weight_sum = 0.0;
diff --git a/src/objective/aft_obj.cc b/src/objective/aft_obj.cc
index 0a5df139..7e65a1a7 100644
--- a/src/objective/aft_obj.cc
+++ b/src/objective/aft_obj.cc
@@ -47,14 +47,14 @@ class AFTObj : public ObjFunction {
const auto& y_lower = info.labels_lower_bound_.HostVector();
const auto& y_upper = info.labels_upper_bound_.HostVector();
const auto& weights = info.weights_.HostVector();
- const bool is_null_weight = weights.empty();
+ bool is_null_weight = weights.empty();
out_gpair->Resize(yhat.size());
std::vector<GradientPair>& gpair = out_gpair->HostVector();
CHECK_LE(yhat.size(), static_cast<size_t>(std::numeric_limits<omp_ulong>::max()))
<< "yhat is too big";
- const omp_ulong nsize = static_cast<omp_ulong>(yhat.size());
- const float aft_loss_distribution_scale = param_.aft_loss_distribution_scale;
+ omp_ulong nsize = static_cast<omp_ulong>(yhat.size());
+ 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) \
@@ -73,7 +73,7 @@ class AFTObj : public ObjFunction {
void PredTransform(HostDeviceVector<bst_float> *io_preds) override {
// 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(*)
+ long ndata = static_cast<long>(preds.size()); // NOLINT(*)
#pragma omp parallel for default(none) firstprivate(ndata) shared(preds)
for (long j = 0; j < ndata; ++j) { // NOLINT(*)
preds[j] = std::exp(preds[j]); |
@glycerine Thanks for letting us know. The code compiles fine on my Macbook Pro (2019, Catalina 10.15.4), I'll look into why it is not working on High Sierra. FYI, we currently test XGBoost using MacOS Mojave (10.14.4): Line 9 in ef26bc4
|
@glycerine I reproduced the error by running tests inside High Sierra environment: https://travis-ci.org/github/hcho3/xgboost/jobs/679300820#L1262 |
Related: darktable-org/darktable#2189, darktable-org/darktable#3977, https://redmine.darktable.org/issues/12568#note-13 According to http://jakascorner.com/blog/2016/07/omp-default-none-and-const.html, we should not list any diff --git a/src/metric/survival_metric.cc b/src/metric/survival_metric.cc
index 58518f00..87e4f5ee 100644
--- a/src/metric/survival_metric.cc
+++ b/src/metric/survival_metric.cc
@@ -71,7 +71,6 @@ 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) \
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
diff --git a/src/objective/aft_obj.cc b/src/objective/aft_obj.cc
index 0a5df139..92705415 100644
--- a/src/objective/aft_obj.cc
+++ b/src/objective/aft_obj.cc
@@ -57,7 +57,6 @@ class AFTObj : public ObjFunction {
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) \
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
@@ -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 default(none) shared(preds)
for (long j = 0; j < ndata; ++j) { // NOLINT(*)
preds[j] = std::exp(preds[j]);
} This patch will fix compilation on High Sierra. |
@hcho3 Your patch failed clang++-10 compilation on Linux:
I would just remove the scope constraints. |
@trivialfis It looks like |
@glycerine Fix available at #5597. |
re #5593 v1.1.0rc1, when trying to build from source on OSX 10.13.16 High Sierra, I get compilation failure:
using libomp-10.0.0.high_sierra.bottle.tar.gz from homebrew
The text was updated successfully, but these errors were encountered: