Skip to content

Commit

Permalink
[UTIL] fix the bug in nntr parallel run
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
jijoongmoon committed Nov 22, 2024
1 parent b193afd commit f87ba97
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions nntrainer/utils/nntr_threads.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,25 @@
#include <algorithm>
#include <nntr_threads.h>

#ifdef NNTR_NUM_THREADS
unsigned int nntr_num_threads = NNTR_NUM_THREADS;
#else
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() {}
Expand Down

0 comments on commit f87ba97

Please sign in to comment.