"include/vscode:/vscode.git/clone" did not exist on "3b1619195e61e562435262e3ec5386f8e9b6dc9b"
Commit 14195876 authored by Guolin Ke's avatar Guolin Ke
Browse files

support multi-threading exceptions.

parent 6ed335df
...@@ -282,10 +282,11 @@ void VotingParallelTreeLearner::FindBestThresholds() { ...@@ -282,10 +282,11 @@ void VotingParallelTreeLearner::FindBestThresholds() {
std::vector<SplitInfo> smaller_bestsplit_per_features(num_features_); std::vector<SplitInfo> smaller_bestsplit_per_features(num_features_);
std::vector<SplitInfo> larger_bestsplit_per_features(num_features_); std::vector<SplitInfo> larger_bestsplit_per_features(num_features_);
OMP_INIT_EX();
// find splits // find splits
#pragma omp parallel for schedule(static) #pragma omp parallel for schedule(static)
for (int feature_index = 0; feature_index < num_features_; ++feature_index) { for (int feature_index = 0; feature_index < num_features_; ++feature_index) {
OMP_LOOP_EX_BEGIN();
if (!is_feature_used[feature_index]) { continue; } if (!is_feature_used[feature_index]) { continue; }
const int real_feature_index = train_data_->RealFeatureIndex(feature_index); const int real_feature_index = train_data_->RealFeatureIndex(feature_index);
train_data_->FixHistogram(feature_index, train_data_->FixHistogram(feature_index,
...@@ -316,7 +317,9 @@ void VotingParallelTreeLearner::FindBestThresholds() { ...@@ -316,7 +317,9 @@ void VotingParallelTreeLearner::FindBestThresholds() {
larger_leaf_splits_->num_data_in_leaf(), larger_leaf_splits_->num_data_in_leaf(),
&larger_bestsplit_per_features[feature_index]); &larger_bestsplit_per_features[feature_index]);
larger_bestsplit_per_features[feature_index].feature = real_feature_index; larger_bestsplit_per_features[feature_index].feature = real_feature_index;
OMP_LOOP_EX_END();
} }
OMP_THROW_EX();
std::vector<SplitInfo> smaller_top_k_splits, larger_top_k_splits; std::vector<SplitInfo> smaller_top_k_splits, larger_top_k_splits;
// local voting // local voting
...@@ -361,6 +364,7 @@ void VotingParallelTreeLearner::FindBestThresholds() { ...@@ -361,6 +364,7 @@ void VotingParallelTreeLearner::FindBestThresholds() {
// find best split from local aggregated histograms // find best split from local aggregated histograms
#pragma omp parallel for schedule(static) #pragma omp parallel for schedule(static)
for (int feature_index = 0; feature_index < num_features_; ++feature_index) { for (int feature_index = 0; feature_index < num_features_; ++feature_index) {
OMP_LOOP_EX_BEGIN();
const int tid = omp_get_thread_num(); const int tid = omp_get_thread_num();
if (smaller_is_feature_aggregated_[feature_index]) { if (smaller_is_feature_aggregated_[feature_index]) {
SplitInfo smaller_split; SplitInfo smaller_split;
...@@ -406,7 +410,9 @@ void VotingParallelTreeLearner::FindBestThresholds() { ...@@ -406,7 +410,9 @@ void VotingParallelTreeLearner::FindBestThresholds() {
larger_best[tid].feature = train_data_->RealFeatureIndex(feature_index); larger_best[tid].feature = train_data_->RealFeatureIndex(feature_index);
} }
} }
OMP_LOOP_EX_END();
} }
OMP_THROW_EX();
auto smaller_best_idx = ArrayArgs<SplitInfo>::ArgMax(smaller_best); auto smaller_best_idx = ArrayArgs<SplitInfo>::ArgMax(smaller_best);
int leaf = smaller_leaf_splits_->LeafIndex(); int leaf = smaller_leaf_splits_->LeafIndex();
best_split_per_leaf_[leaf] = smaller_best[smaller_best_idx]; best_split_per_leaf_[leaf] = smaller_best[smaller_best_idx];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment