Skip to content

Commit

Permalink
threadpool: work around an issue of zero threads identified on AMD
Browse files Browse the repository at this point in the history
XByak can't identify threads on AMD due to implementation limitation. To
work around it, we use a method from std if XByak returned zero threads.
It may happen that Intel HW not supported via XByak may result in same
issue but the chance is pretty low.
  • Loading branch information
dzarukin committed Oct 12, 2021
1 parent 849fa34 commit ad901e5
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/cpu/platform.cpp
Expand Up @@ -160,6 +160,13 @@ unsigned get_num_cores() {
// function supports process affinity.
unsigned get_max_threads_to_use() {
int num_cores_per_socket = (int)dnnl::impl::cpu::platform::get_num_cores();
// It may happen that XByak doesn't get num of threads identified, e.g. for
// AMD. In order to make threadpool working, we supply an additional
// condition to have some reasonable number of threads available at
// primitive descriptor creation time.
if (num_cores_per_socket == 0)
num_cores_per_socket = std::thread::hardware_concurrency();

#if defined(_WIN32)
DWORD_PTR proc_affinity_mask;
DWORD_PTR sys_affinity_mask;
Expand Down

0 comments on commit ad901e5

Please sign in to comment.