Skip to content

Commit

Permalink
[onert] Introduce NUM_THREADS config (Samsung#13929)
Browse files Browse the repository at this point in the history
This commit introduces `NUM_THREADS`.
`NUM_THREADS` replaces `RUY_THREADS` and `XNNPACK_THREADS`.

ONE-DCO-1.0-Signed-off-by: Hyeongseok Oh <[email protected]>
  • Loading branch information
hseok-oh authored Sep 5, 2024
1 parent 67df4c5 commit 72349cc
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion runtime/onert/backend/cpu/ExternalContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class ExternalContext
public:
ExternalContext() : _ruy_context(new ruy::Context)
{
setMaxNumThreads(onert::util::getConfigInt(onert::util::config::RUY_THREADS));
setMaxNumThreads(onert::util::getConfigInt(onert::util::config::NUM_THREADS));
}

void setMaxNumThreads(int max_num_threads)
Expand Down
2 changes: 1 addition & 1 deletion runtime/onert/backend/ruy/ExternalContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class ExternalContext
public:
ExternalContext() : _ruy_context(new ::ruy::Context)
{
setMaxNumThreads(onert::util::getConfigInt(onert::util::config::RUY_THREADS));
setMaxNumThreads(onert::util::getConfigInt(onert::util::config::NUM_THREADS));
}

void setMaxNumThreads(int max_num_threads)
Expand Down
2 changes: 1 addition & 1 deletion runtime/onert/backend/xnnpack/BackendContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class BackendContext : public onert::backend::BackendContext
: onert::backend::BackendContext(backend, std::move(data), tensor_registry),
tensor_builder{tensor_builder}, kernel_gen{kernel_gen}, _external_context(nullptr)
{
int num_threads = util::getConfigInt(util::config::XNNPACK_THREADS);
int num_threads = util::getConfigInt(util::config::NUM_THREADS);
if (num_threads < 1)
num_threads = kDefaultNumThreadpoolThreads; // default num of threads
_external_context.reset(new ExternalContext(static_cast<size_t>(num_threads)));
Expand Down
3 changes: 1 addition & 2 deletions runtime/onert/core/include/util/Config.lst
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ CONFIG(USE_SCHEDULER , bool , "0")
CONFIG(TRACING_MODE , bool , "0")
CONFIG(MINMAX_DUMP , bool , "0")
CONFIG(FP16_ENABLE , bool , "0")
CONFIG(RUY_THREADS , int , "-1")
CONFIG(XNNPACK_THREADS , int , "-1")
CONFIG(NUM_THREADS , int , "-1")
CONFIG(USE_MMAPED_DATA , bool , "0")
CONFIG(WORKSPACE_DIR , std::string , ".")

Expand Down
2 changes: 1 addition & 1 deletion runtime/onert/core/src/backend/builtin/ExternalContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class ExternalContext
public:
ExternalContext() : _ruy_context(std::make_unique<ruy::Context>())
{
setMaxNumThreads(onert::util::getConfigInt(onert::util::config::RUY_THREADS));
setMaxNumThreads(onert::util::getConfigInt(onert::util::config::NUM_THREADS));
initPerThreadState();
}

Expand Down
3 changes: 1 addition & 2 deletions tools/stab/backend_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,7 @@ def schedule(self):
for op in op_list:
cmd += [f"OP_BACKEND_{op}={default_backend}"]
cmd += [f"BACKENDS={';'.join(backend_list)}"]
cmd += [f"RUY_THREADS={self.num_threads}"]
cmd += [f"XNNPACK_THREADS={self.num_threads}"]
cmd += [f"NUM_THREADS={self.num_threads}"]
logging.info(' '.join(cmd))

# Create nnpackage with backend mapping
Expand Down
3 changes: 1 addition & 2 deletions tools/stab/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ def profile_backend(self, backend, backend_op_list):
if backend == target_backend:
for op in op_list:
cmd += [f"OP_BACKEND_{op}={backend}"]
cmd += [f"XNNPACK_THREADS={self.num_threads}"]
cmd += [f"RUY_THREADS={self.num_threads}"]
cmd += [f"NUM_THREADS={self.num_threads}"]
cmd += [f"BACKENDS=\'{';'.join(['cpu', backend])}\'"]
cmd += [f"{nnpkg_run_path}"]
cmd += [f"-w5 -r50"]
Expand Down

0 comments on commit 72349cc

Please sign in to comment.