From cc8fbc9d086ffe7ba0c8db8aa5fb197ad17a28a5 Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Tue, 12 Jun 2018 11:51:32 -0400 Subject: [PATCH] Revert "Name the thread pools (#8137)" (#8379) This reverts commit 96876d9e7ef6baf9d11541454b5f4d22b092de77. --- caffe2/utils/thread_name.cc | 24 ------------------------ caffe2/utils/thread_name.h | 9 --------- caffe2/utils/thread_pool.h | 2 -- caffe2/utils/threadpool/ThreadPool.h | 4 ++-- caffe2/utils/threadpool/WorkersPool.h | 8 +++----- 5 files changed, 5 insertions(+), 42 deletions(-) delete mode 100644 caffe2/utils/thread_name.cc delete mode 100644 caffe2/utils/thread_name.h diff --git a/caffe2/utils/thread_name.cc b/caffe2/utils/thread_name.cc deleted file mode 100644 index 5fdcc2256775..000000000000 --- a/caffe2/utils/thread_name.cc +++ /dev/null @@ -1,24 +0,0 @@ -#include "caffe2/utils/thread_name.h" - -#include - -#if defined(__GLIBC__) && !defined(__APPLE__) && !defined(__ANDROID__) -#define CAFFE2_HAS_PTHREAD_SETNAME_NP -#endif - -#ifdef CAFFE2_HAS_PTHREAD_SETNAME_NP -#include -#endif - -namespace caffe2 { - -void setThreadName(std::string name) { -#ifdef CAFFE2_HAS_PTHREAD_SETNAME_NP - constexpr size_t kMaxThreadName = 15; - name.resize(std::min(name.size(), kMaxThreadName)); - - pthread_setname_np(pthread_self(), name.c_str()); -#endif -} - -} // namespace caffe2 diff --git a/caffe2/utils/thread_name.h b/caffe2/utils/thread_name.h deleted file mode 100644 index aece335c23db..000000000000 --- a/caffe2/utils/thread_name.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once - -#include - -namespace caffe2 { - -void setThreadName(std::string name); - -} // namespace caffe2 diff --git a/caffe2/utils/thread_pool.h b/caffe2/utils/thread_pool.h index 3c10dd769e8e..db25d7c30dfc 100644 --- a/caffe2/utils/thread_pool.h +++ b/caffe2/utils/thread_pool.h @@ -9,7 +9,6 @@ #include #include "caffe2/core/numa.h" -#include "caffe2/utils/thread_name.h" namespace caffe2 { @@ -116,7 +115,6 @@ class TaskThreadPool { private: /// @brief Entry point for pool threads. void main_loop(std::size_t index) { - setThreadName("CaffeTaskThread"); NUMABind(numa_node_id_); while (running_) { diff --git a/caffe2/utils/threadpool/ThreadPool.h b/caffe2/utils/threadpool/ThreadPool.h index aa6c44ac7984..8c111d0ac044 100644 --- a/caffe2/utils/threadpool/ThreadPool.h +++ b/caffe2/utils/threadpool/ThreadPool.h @@ -19,12 +19,12 @@ class WorkersPool; constexpr size_t kCacheLineSize = 64; -// A threadpool with the given number of threads. +// A work-stealing threadpool with the given number of threads. // NOTE: the kCacheLineSize alignment is present only for cache // performance, and is not strictly enforced (for example, when // the object is created on the heap). Thus, in order to avoid // misaligned intrinsics, no SSE instructions shall be involved in -// the ThreadPool implementation. +// the ThreadPool implemetation. class alignas(kCacheLineSize) ThreadPool { public: static std::unique_ptr defaultThreadPool(); diff --git a/caffe2/utils/threadpool/WorkersPool.h b/caffe2/utils/threadpool/WorkersPool.h index 0c621d53854d..9d2ffd57864b 100644 --- a/caffe2/utils/threadpool/WorkersPool.h +++ b/caffe2/utils/threadpool/WorkersPool.h @@ -1,11 +1,10 @@ #pragma once -#include -#include -#include #include "caffe2/core/common.h" #include "caffe2/core/logging.h" -#include "caffe2/utils/thread_name.h" +#include +#include +#include #if defined(_MSC_VER) #include @@ -263,7 +262,6 @@ class alignas(kGEMMLOWPCacheLineSize) Worker { // Thread entry point. void ThreadFunc() { - setThreadName("CaffeWorkersPool"); ChangeState(State::Ready); // Thread main loop