From 3b972aa3de4971037e4f40f17f31dfda963f5ffc Mon Sep 17 00:00:00 2001 From: Srinivasan Narayanamoorthy Date: Thu, 16 Apr 2020 12:08:58 -0700 Subject: [PATCH] minor cleanup. --- tensorflow/core/common_runtime/process_util.cc | 12 ++++-------- tensorflow/core/common_runtime/threadpool_device.cc | 6 ++---- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/tensorflow/core/common_runtime/process_util.cc b/tensorflow/core/common_runtime/process_util.cc index f7d5a0ff920..8f87873a5bd 100644 --- a/tensorflow/core/common_runtime/process_util.cc +++ b/tensorflow/core/common_runtime/process_util.cc @@ -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(); } diff --git a/tensorflow/core/common_runtime/threadpool_device.cc b/tensorflow/core/common_runtime/threadpool_device.cc index 22a83608a6e..44fa5bf2d3a 100644 --- a/tensorflow/core/common_runtime/threadpool_device.cc +++ b/tensorflow/core/common_runtime/threadpool_device.cc @@ -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() {}