Improve OpenMP exception handling (#6680)
This commit is contained in:
@@ -290,15 +290,19 @@ class SparsePage {
|
||||
|
||||
void SortRows() {
|
||||
auto ncol = static_cast<bst_omp_uint>(this->Size());
|
||||
#pragma omp parallel for default(none) shared(ncol) schedule(dynamic, 1)
|
||||
dmlc::OMPException exc;
|
||||
#pragma omp parallel for schedule(dynamic, 1)
|
||||
for (bst_omp_uint i = 0; i < ncol; ++i) {
|
||||
if (this->offset.HostVector()[i] < this->offset.HostVector()[i + 1]) {
|
||||
std::sort(
|
||||
this->data.HostVector().begin() + this->offset.HostVector()[i],
|
||||
this->data.HostVector().begin() + this->offset.HostVector()[i + 1],
|
||||
Entry::CmpValue);
|
||||
}
|
||||
exc.Run([&]() {
|
||||
if (this->offset.HostVector()[i] < this->offset.HostVector()[i + 1]) {
|
||||
std::sort(
|
||||
this->data.HostVector().begin() + this->offset.HostVector()[i],
|
||||
this->data.HostVector().begin() + this->offset.HostVector()[i + 1],
|
||||
Entry::CmpValue);
|
||||
}
|
||||
});
|
||||
}
|
||||
exc.Rethrow();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user