Skip to content

Commit

Permalink
more intentional thread management
Browse files Browse the repository at this point in the history
  • Loading branch information
bcjaeger committed Oct 23, 2023
1 parent 56944e0 commit cb3a652
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Forest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@ void Forest::grow() {
thread.join();
}

threads.clear();

if (aborted_threads > 0) {
throw std::runtime_error("User interrupt.");
}
Expand All @@ -242,6 +244,9 @@ void Forest::grow() {
vi_denom += vi_denom_threads[i];
}

vi_numer_threads.clear();
vi_denom_threads.clear();

}

}
Expand Down Expand Up @@ -370,6 +375,8 @@ void Forest::compute_oobag_vi() {
thread.join();
}

threads.clear();

if (aborted_threads > 0) {
throw std::runtime_error("User interrupt.");
}
Expand All @@ -378,6 +385,8 @@ void Forest::compute_oobag_vi() {
vi_numer += vi_numer_threads[i];
}

vi_numer_threads.clear();

}

void Forest::compute_oobag_vi_single_thread(vec* vi_numer_ptr) {
Expand Down Expand Up @@ -598,6 +607,8 @@ mat Forest::predict(bool oobag) {
thread.join();
}

threads.clear();

for(uint i = 0; i < n_thread; ++i){

result += result_threads[i];
Expand All @@ -623,6 +634,9 @@ mat Forest::predict(bool oobag) {

}

result_threads.clear();
oobag_denom_threads.clear();

}

if(pred_type == PRED_TERMINAL_NODES || !pred_aggregate){
Expand Down

0 comments on commit cb3a652

Please sign in to comment.