minor cleanup.

This commit is contained in:
Srinivasan Narayanamoorthy 2020-04-16 12:08:58 -07:00
parent aae350dbb5
commit 3b972aa3de
2 changed files with 6 additions and 12 deletions

View File

@ -101,8 +101,7 @@ int32 NumIntraOpThreadsFromEnvironment() {
const char* val = std::getenv("TF_NUM_INTRAOP_THREADS");
return (val && strings::safe_strto32(val, &num)) ? num : 0;
}
#ifndef ENABLE_MKLDNN_THREADPOOL
#ifdef INTEL_MKL
#if !defined(ENABLE_MKLDNN_THREADPOOL) && defined(INTEL_MKL)
int32 OMPThreadsFromEnvironment() {
// 1) std::getenv is thread-safe (as long as no other function modifies the
// host env) from C++11 onward. 2) Most of TF code (except tests and
@ -122,16 +121,14 @@ int32 DefaultNumIntraOpThreads() {
// Default to the maximum parallelism for the current process.
return port::MaxParallelism();
}
#endif // INTEL_MKL
#endif // ENABLE_MKLDNN_THREADPOOL
#endif // !defined(ENABLE_MKLDNN_THREADPOOL) && defined(INTEL_MKL)
int32 NumInterOpThreadsFromSessionOptions(const SessionOptions& options) {
const int32 inter_op = options.config.inter_op_parallelism_threads();
if (inter_op > 0) return inter_op;
const int32 env_inter_op = GetEnvNumInterOpThreads();
if (env_inter_op > 0) return env_inter_op;
#ifndef ENABLE_MKLDNN_THREADPOOL
#ifdef INTEL_MKL
#if !defined(ENABLE_MKLDNN_THREADPOOL) && defined(INTEL_MKL)
if (!DisableMKL()) {
// MKL library executes ops in parallel using OMP threads.
// Setting inter_op conservatively to avoid thread oversubscription that
@ -152,8 +149,7 @@ int32 NumInterOpThreadsFromSessionOptions(const SessionOptions& options) {
<< ". Tune using inter_op_parallelism_threads for best performance.";
return mkl_inter_op;
}
#endif // INTEL_MKL
#endif // ENABLE_MKLDNN_THREADPOOL
#endif // !defined(ENABLE_MKLDNN_THREADPOOL) && defined(INTEL_MKL)
return DefaultNumInterOpThreads();
}

View File

@ -50,8 +50,7 @@ ThreadPoolDevice::ThreadPoolDevice(const SessionOptions& options,
name, DEVICE_CPU, memory_limit, locality)),
allocator_(allocator),
scoped_allocator_mgr_(new ScopedAllocatorMgr(name)) {
#ifndef ENABLE_MKLDNN_THREADPOOL
#ifdef INTEL_MKL
#if !defined(ENABLE_MKLDNN_THREADPOOL) && defined(INTEL_MKL)
// Early return when MKL is disabled
if (DisableMKL()) return;
#ifdef _OPENMP
@ -70,8 +69,7 @@ ThreadPoolDevice::ThreadPoolDevice(const SessionOptions& options,
}
}
#endif // _OPENMP
#endif // INTEL_MKL
#endif // ENABLE_MKLDNN_THREADPOOL
#endif // !defined(ENABLE_MKLDNN_THREADPOOL) && defined(INTEL_MKL)
}
ThreadPoolDevice::~ThreadPoolDevice() {}