Skip to content

Revert "Disable thread pool creation when enabled OpenMP" #2535

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

Merged
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
1 change: 0 additions & 1 deletion onnxruntime/core/framework/session_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ struct SessionOptions {
TransformerLevel graph_optimization_level = TransformerLevel::Level1;

// controls the size of the thread pool used to parallelize the execution of tasks within individual nodes (ops)
// if OpenMP is enabled, this configuration will be ignored
int intra_op_num_threads = 0;

// controls the size of the thread pool used to parallelize the execution of nodes (ops)
Expand Down
5 changes: 1 addition & 4 deletions onnxruntime/core/session/inference_session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,9 @@ void InferenceSession::ConstructorCommon(const SessionOptions& session_options,
graph_transformation_mgr_ = onnxruntime::make_unique<GraphTransformerManager>(
session_options_.max_num_graph_transformation_steps);
logging_manager_ = logging_manager;
#ifndef USE_OPENMP

thread_pool_ = concurrency::CreateThreadPool("intra_op_thread_pool",
session_options_.intra_op_num_threads);
#else
thread_pool_ = nullptr;
#endif

inter_op_thread_pool_ = session_options_.execution_mode == ExecutionMode::ORT_PARALLEL
? concurrency::CreateThreadPool("inter_op_thread_pool",
Expand Down
2 changes: 1 addition & 1 deletion onnxruntime/test/perftest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Options:

-v: Show verbose information.

-x: [intra_op_num_threads]: Sets the number of threads used to parallelize the execution within nodes. A value of 0 means the test will auto-select a default. Must >=0. If OpenMP is enabled, this configuration will be ignored.
-x: [intra_op_num_threads]: Sets the number of threads used to parallelize the execution within nodes. A value of 0 means the test will auto-select a default. Must >=0.

-y: [inter_op_num_threads]: Sets the number of threads used to parallelize the execution of the graph (across nodes), A value of 0 means the test will auto-select a default. Must >=0.

Expand Down
5 changes: 0 additions & 5 deletions onnxruntime/test/perftest/command_args_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,10 @@ namespace perftest {
test_config.run_config.f_verbose = true;
break;
case 'x':
#ifdef USE_OPENMP
fprintf(stderr, "cannot use argument '-x' when OpenMP is enabled.\n");
return false;
#else
test_config.run_config.intra_op_num_threads = static_cast<int>(OrtStrtol<PATH_CHAR_TYPE>(optarg, nullptr));
if (test_config.run_config.intra_op_num_threads < 0) {
return false;
}
#endif
break;
case 'y':
test_config.run_config.inter_op_num_threads = static_cast<int>(OrtStrtol<PATH_CHAR_TYPE>(optarg, nullptr));
Expand Down
5 changes: 1 addition & 4 deletions onnxruntime/test/perftest/ort_test_session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ OnnxRuntimeTestSession::OnnxRuntimeTestSession(Ort::Env& env, std::random_device
} else if (provider_name == onnxruntime::kAclExecutionProvider) {
#ifdef USE_ACL
Ort::ThrowOnError(OrtSessionOptionsAppendExecutionProvider_ACL(session_options,
performance_test_config.run_config.enable_cpu_mem_arena ? 1 : 0));
performance_test_config.run_config.enable_cpu_mem_arena ? 1 : 0));
#else
ORT_THROW("Acl is not supported in this build\n");
#endif
Expand All @@ -100,11 +100,8 @@ OnnxRuntimeTestSession::OnnxRuntimeTestSession(Ort::Env& env, std::random_device
else
session_options.DisableMemPattern();
session_options.SetExecutionMode(performance_test_config.run_config.execution_mode);

#ifndef USE_OPENMP
fprintf(stdout, "Setting intra_op_num_threads to %d\n", performance_test_config.run_config.intra_op_num_threads);
session_options.SetIntraOpNumThreads(performance_test_config.run_config.intra_op_num_threads);
#endif

if (performance_test_config.run_config.execution_mode == ExecutionMode::ORT_PARALLEL) {
fprintf(stdout, "Setting inter_op_num_threads to %d\n", performance_test_config.run_config.inter_op_num_threads);
Expand Down