| 69 | } |
| 70 | |
| 71 | void ThreadPoolDevice::Init() { |
| 72 | #if !defined(ENABLE_DNNL_THREADPOOL) && defined(INTEL_MKL) |
| 73 | // Early return when OneDNN is disabled |
| 74 | if (DisableMKL()) return; |
| 75 | #ifdef _OPENMP |
| 76 | const char* user_omp_threads = getenv("OMP_NUM_THREADS"); |
| 77 | if (user_omp_threads == nullptr) { |
| 78 | // OMP_NUM_THREADS controls OneDNN's intra-op parallelization |
| 79 | // Default to available physical cores |
| 80 | const int mkl_intra_op = port::NumSchedulableCPUs(); |
| 81 | const int ht = port::NumHyperthreadsPerCore(); |
| 82 | omp_set_num_threads((mkl_intra_op + ht - 1) / ht); |
| 83 | } else { |
| 84 | uint64 user_val = 0; |
| 85 | if (strings::safe_strtou64(user_omp_threads, &user_val)) { |
| 86 | // Superflous but triggers OpenMP loading |
| 87 | omp_set_num_threads(user_val); |
| 88 | } |
| 89 | } |
| 90 | #endif // _OPENMP |
| 91 | #endif // !defined(ENABLE_DNNL_THREADPOOL) && defined(INTEL_MKL) |
| 92 | } |
| 93 | |
| 94 | ThreadPoolDevice::~ThreadPoolDevice() {} |
| 95 |
nothing calls this directly
no test coverage detected