Skip to content

Commit d748f89

Browse files
authored
Revert "Disable thread pool creation when enabled OpenMP (#2485)" (#2535)
This reverts commit 7c7d5a1.
1 parent 5c2e474 commit d748f89

File tree

5 files changed

+3
-15
lines changed

5 files changed

+3
-15
lines changed

onnxruntime/core/framework/session_options.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ struct SessionOptions {
5555
TransformerLevel graph_optimization_level = TransformerLevel::Level1;
5656

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

6160
// controls the size of the thread pool used to parallelize the execution of nodes (ops)

onnxruntime/core/session/inference_session.cc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,9 @@ void InferenceSession::ConstructorCommon(const SessionOptions& session_options,
173173
graph_transformation_mgr_ = onnxruntime::make_unique<GraphTransformerManager>(
174174
session_options_.max_num_graph_transformation_steps);
175175
logging_manager_ = logging_manager;
176-
#ifndef USE_OPENMP
176+
177177
thread_pool_ = concurrency::CreateThreadPool("intra_op_thread_pool",
178178
session_options_.intra_op_num_threads);
179-
#else
180-
thread_pool_ = nullptr;
181-
#endif
182179

183180
inter_op_thread_pool_ = session_options_.execution_mode == ExecutionMode::ORT_PARALLEL
184181
? concurrency::CreateThreadPool("inter_op_thread_pool",

onnxruntime/test/perftest/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Options:
3232
3333
-v: Show verbose information.
3434
35-
-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.
35+
-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.
3636

3737
-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.
3838

onnxruntime/test/perftest/command_args_parser.cc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,10 @@ namespace perftest {
123123
test_config.run_config.f_verbose = true;
124124
break;
125125
case 'x':
126-
#ifdef USE_OPENMP
127-
fprintf(stderr, "cannot use argument '-x' when OpenMP is enabled.\n");
128-
return false;
129-
#else
130126
test_config.run_config.intra_op_num_threads = static_cast<int>(OrtStrtol<PATH_CHAR_TYPE>(optarg, nullptr));
131127
if (test_config.run_config.intra_op_num_threads < 0) {
132128
return false;
133129
}
134-
#endif
135130
break;
136131
case 'y':
137132
test_config.run_config.inter_op_num_threads = static_cast<int>(OrtStrtol<PATH_CHAR_TYPE>(optarg, nullptr));

onnxruntime/test/perftest/ort_test_session.cc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ OnnxRuntimeTestSession::OnnxRuntimeTestSession(Ort::Env& env, std::random_device
8282
} else if (provider_name == onnxruntime::kAclExecutionProvider) {
8383
#ifdef USE_ACL
8484
Ort::ThrowOnError(OrtSessionOptionsAppendExecutionProvider_ACL(session_options,
85-
performance_test_config.run_config.enable_cpu_mem_arena ? 1 : 0));
85+
performance_test_config.run_config.enable_cpu_mem_arena ? 1 : 0));
8686
#else
8787
ORT_THROW("Acl is not supported in this build\n");
8888
#endif
@@ -100,11 +100,8 @@ OnnxRuntimeTestSession::OnnxRuntimeTestSession(Ort::Env& env, std::random_device
100100
else
101101
session_options.DisableMemPattern();
102102
session_options.SetExecutionMode(performance_test_config.run_config.execution_mode);
103-
104-
#ifndef USE_OPENMP
105103
fprintf(stdout, "Setting intra_op_num_threads to %d\n", performance_test_config.run_config.intra_op_num_threads);
106104
session_options.SetIntraOpNumThreads(performance_test_config.run_config.intra_op_num_threads);
107-
#endif
108105

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

0 commit comments

Comments
 (0)