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

[onert] Introduce NUM_THREADS config #13929

Merged
merged 1 commit into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
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
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