From b31665420d2bd0c76463dd43f58b002ec92164b4 Mon Sep 17 00:00:00 2001 From: "jijoong.moon" Date: Fri, 22 Nov 2024 15:53:15 +0900 Subject: [PATCH] [UTIL] fix the bug in nntr parallel run This PR fix the nntr prarallel run. Previously it is not set properly according to NNTR-NUM-THREADS options in meson_options.txt **Self evaluation:** 1. Build test: [X]Passed [ ]Failed [ ]Skipped 2. Run test: [X]Passed [ ]Failed [ ]Skipped Signed-off-by: jijoong.moon --- nntrainer/utils/nntr_threads.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/nntrainer/utils/nntr_threads.cpp b/nntrainer/utils/nntr_threads.cpp index 4ac9259e03..954f0f1183 100644 --- a/nntrainer/utils/nntr_threads.cpp +++ b/nntrainer/utils/nntr_threads.cpp @@ -13,19 +13,25 @@ #include #include +#ifdef NNTR_NUM_THREADS +static const unsigned int nntr_num_threads = NNTR_NUM_THREADS; +#else +static const unsigned int nntr_num_threads = 1; +#endif + namespace nntrainer { ParallelBatch::ParallelBatch(unsigned int batch_size) : cb(nullptr), batch(batch_size), - num_workers(NNTR_NUM_THREADS > batch ? 1 : NNTR_NUM_THREADS), + num_workers(nntr_num_threads > batch ? 1 : nntr_num_threads), user_data_prop(new props::PropsUserData(nullptr)){}; ParallelBatch::ParallelBatch(threaded_cb threaded_cb_, unsigned int batch_size, void *user_data_) : cb(threaded_cb_), batch(batch_size), - num_workers(NNTR_NUM_THREADS > batch ? 1 : NNTR_NUM_THREADS), + num_workers(nntr_num_threads > batch ? 1 : nntr_num_threads), user_data_prop(new props::PropsUserData(user_data_)) {} ParallelBatch::~ParallelBatch() {}