MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / Init

Method Init

tensorflow/core/common_runtime/threadpool_device.cc:71–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69}
70
71void 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
94ThreadPoolDevice::~ThreadPoolDevice() {}
95

Callers

nothing calls this directly

Calls 4

safe_strtou64Function · 0.85
DisableMKLFunction · 0.50
NumSchedulableCPUsFunction · 0.50
NumHyperthreadsPerCoreFunction · 0.50

Tested by

no test coverage detected