Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UTIL] fix the bug in nntr parallel run @open sesame 12/02 17:11 #2802

Merged
merged 1 commit into from
Dec 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
static const unsigned int nntr_num_threads = NNTR_NUM_THREADS;
#else
static const unsigned int nntr_num_threads = 1;
#endif

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd recomment to constify and make it static with the current usage to avoid future misuse.

static const unsigned int nntr_num_threads = ...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Thanks.

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