Avoid std::terminate for R package. (#7661)

This is part of CRAN policies.
This commit is contained in:
Jiaming Yuan 2022-02-17 01:27:20 +08:00 committed by GitHub
parent 12949c6b31
commit 711f7f3851
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 6 deletions

View File

@ -102,13 +102,27 @@ namespace common {
#define SPAN_CHECK KERNEL_CHECK
#else // not CUDA
#else // ------------------------------ not CUDA ----------------------------
#define KERNEL_CHECK(cond) \
(XGBOOST_EXPECT((cond), true) ? static_cast<void>(0) : std::terminate())
#if defined(XGBOOST_STRICT_R_MODE) && XGBOOST_STRICT_R_MODE == 1
#define KERNEL_CHECK(cond) \
do { \
if (XGBOOST_EXPECT(!(cond), false)) { \
printf("[xgboost] fatal error.\n"); \
} \
} while (0)
#define SPAN_CHECK(cond) KERNEL_CHECK(cond)
#else
#define KERNEL_CHECK(cond) (XGBOOST_EXPECT((cond), true) ? static_cast<void>(0) : std::terminate())
#define SPAN_CHECK(cond) KERNEL_CHECK(cond)
#endif // defined(XGBOOST_STRICT_R_MODE)
#endif // __CUDA_ARCH__
#if defined(__CUDA_ARCH__)

View File

@ -114,9 +114,6 @@ template <typename GradientSumT, typename ExpandEntry> class HistEvaluator {
left_sum.SetSubstract(parent.stats, right_sum);
break;
}
default: {
std::terminate();
}
}
};