@@ -89,22 +89,6 @@ struct CPUStreamsExecutor::Impl {
89
89
});
90
90
}
91
91
}
92
- #elif OV_THREAD == OV_THREAD_SEQ
93
- auto proc_type_table = get_org_proc_type_table ();
94
- if (get_num_numa_nodes () > 1 ) {
95
- pin_current_thread_to_socket (_numaNodeId);
96
- } else if (proc_type_table.size () == 1 && proc_type_table[0 ][EFFICIENT_CORE_PROC] == 0 &&
97
- _impl->_config .get_cpu_pinning ()) {
98
- CpuSet processMask;
99
- int ncpus = 0 ;
100
- std::tie (processMask, ncpus) = get_process_mask ();
101
- if (nullptr != processMask) {
102
- pin_thread_to_vacant_core (_streamId + _impl->_config .get_thread_binding_offset (),
103
- _impl->_config .get_thread_binding_step (),
104
- ncpus,
105
- processMask);
106
- }
107
- }
108
92
#endif
109
93
}
110
94
~Stream () {
@@ -226,6 +210,9 @@ struct CPUStreamsExecutor::Impl {
226
210
std::unique_ptr<custom::task_arena> _taskArena;
227
211
std::unique_ptr<Observer> _observer;
228
212
std::vector<int > _cpu_ids;
213
+ #elif OV_THREAD == OV_THREAD_SEQ
214
+ CpuSet _mask = nullptr ;
215
+ int _ncpus = 0 ;
229
216
#endif
230
217
};
231
218
// if the thread is created by CPUStreamsExecutor, the Impl::Stream of the thread is stored by tbb Class
@@ -429,7 +416,38 @@ struct CPUStreamsExecutor::Impl {
429
416
task ();
430
417
}
431
418
#else
419
+ pin_stream_to_cpus ();
432
420
task ();
421
+ unpin_stream_to_cpus ();
422
+ #endif
423
+ }
424
+
425
+ void pin_stream_to_cpus () {
426
+ #if OV_THREAD == OV_THREAD_SEQ
427
+ if (_config.get_cpu_pinning ()) {
428
+ auto stream = _streams.local ();
429
+ auto proc_type_table = get_org_proc_type_table ();
430
+ std::tie (stream->_mask , stream->_ncpus ) = get_process_mask ();
431
+ if (get_num_numa_nodes () > 1 ) {
432
+ pin_current_thread_to_socket (stream->_numaNodeId );
433
+ } else if (proc_type_table.size () == 1 && proc_type_table[0 ][EFFICIENT_CORE_PROC] == 0 ) {
434
+ if (nullptr != stream->_mask ) {
435
+ pin_thread_to_vacant_core (stream->_streamId + _config.get_thread_binding_offset (),
436
+ _config.get_thread_binding_step (),
437
+ stream->_ncpus ,
438
+ stream->_mask );
439
+ }
440
+ }
441
+ }
442
+ #endif
443
+ }
444
+
445
+ void unpin_stream_to_cpus () {
446
+ #if OV_THREAD == OV_THREAD_SEQ
447
+ auto stream = _streams.local ();
448
+ if (stream->_mask ) {
449
+ pin_current_thread_by_mask (stream->_ncpus , stream->_mask );
450
+ }
433
451
#endif
434
452
}
435
453
0 commit comments