From cb3a652f55918481a1e5017549d45a5c694d870f Mon Sep 17 00:00:00 2001 From: byron jaeger Date: Mon, 23 Oct 2023 15:03:13 -0400 Subject: [PATCH] more intentional thread management --- src/Forest.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Forest.cpp b/src/Forest.cpp index 54c5d49d..5f6e0d57 100644 --- a/src/Forest.cpp +++ b/src/Forest.cpp @@ -231,6 +231,8 @@ void Forest::grow() { thread.join(); } + threads.clear(); + if (aborted_threads > 0) { throw std::runtime_error("User interrupt."); } @@ -242,6 +244,9 @@ void Forest::grow() { vi_denom += vi_denom_threads[i]; } + vi_numer_threads.clear(); + vi_denom_threads.clear(); + } } @@ -370,6 +375,8 @@ void Forest::compute_oobag_vi() { thread.join(); } + threads.clear(); + if (aborted_threads > 0) { throw std::runtime_error("User interrupt."); } @@ -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) { @@ -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]; @@ -623,6 +634,9 @@ mat Forest::predict(bool oobag) { } + result_threads.clear(); + oobag_denom_threads.clear(); + } if(pred_type == PRED_TERMINAL_NODES || !pred_aggregate){