diff options
Diffstat (limited to 'unsupported')
5 files changed, 21 insertions, 21 deletions
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceThreadPool.h b/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceThreadPool.h index 90fded8ad..9073c611a 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceThreadPool.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceThreadPool.h @@ -172,7 +172,7 @@ struct ThreadPoolDevice { pool_->Schedule(func); } - EIGEN_STRONG_INLINE size_t currentThreadId() const { + EIGEN_STRONG_INLINE int currentThreadId() const { return pool_->CurrentThreadId(); } diff --git a/unsupported/Eigen/CXX11/src/ThreadPool/NonBlockingThreadPool.h b/unsupported/Eigen/CXX11/src/ThreadPool/NonBlockingThreadPool.h index 1465878b7..8bc986c84 100644 --- a/unsupported/Eigen/CXX11/src/ThreadPool/NonBlockingThreadPool.h +++ b/unsupported/Eigen/CXX11/src/ThreadPool/NonBlockingThreadPool.h @@ -95,17 +95,17 @@ class NonBlockingThreadPoolTempl : public Eigen::ThreadPoolInterface { env_.ExecuteTask(t); // Push failed, execute directly. } - size_t NumThreads() const final { - return threads_.size(); + int NumThreads() const final { + return static_cast<int>(threads_.size()); } - size_t CurrentThreadId() const { + int CurrentThreadId() const { const PerThread* pt = const_cast<NonBlockingThreadPoolTempl*>(this)->GetPerThread(); if (pt->pool == this) { - return static_cast<size_t>(pt->thread_id); + return pt->thread_id; } else { - return threads_.size(); + return NumThreads(); } } @@ -114,9 +114,9 @@ class NonBlockingThreadPoolTempl : public Eigen::ThreadPoolInterface { struct PerThread { bool inited; - NonBlockingThreadPoolTempl* pool; // Parent pool, or null for normal threads. - unsigned thread_id; // Worker thread index in pool. - unsigned rand; // Random generator state. + NonBlockingThreadPoolTempl* pool; // Parent pool, or null for normal threads. + int thread_id; // Worker thread index in pool. + unsigned rand; // Random generator state. }; Environment env_; @@ -130,7 +130,7 @@ class NonBlockingThreadPoolTempl : public Eigen::ThreadPoolInterface { EventCount ec_; // Main worker thread loop. - void WorkerLoop(unsigned thread_id) { + void WorkerLoop(int thread_id) { PerThread* pt = GetPerThread(); pt->pool = this; pt->thread_id = thread_id; diff --git a/unsupported/Eigen/CXX11/src/ThreadPool/SimpleThreadPool.h b/unsupported/Eigen/CXX11/src/ThreadPool/SimpleThreadPool.h index fde80afdf..36eb6950f 100644 --- a/unsupported/Eigen/CXX11/src/ThreadPool/SimpleThreadPool.h +++ b/unsupported/Eigen/CXX11/src/ThreadPool/SimpleThreadPool.h @@ -69,21 +69,21 @@ class SimpleThreadPoolTempl : public ThreadPoolInterface { } } - size_t NumThreads() const final { - return threads_.size(); + int NumThreads() const final { + return static_cast<int>(threads_.size()); } - size_t CurrentThreadId() const final { + int CurrentThreadId() const final { const PerThread* pt = this->GetPerThread(); if (pt->pool == this) { return pt->thread_id; } else { - return threads_.size(); + return NumThreads(); } } protected: - void WorkerLoop(size_t thread_id) { + void WorkerLoop(int thread_id) { std::unique_lock<std::mutex> l(mu_); PerThread* pt = GetPerThread(); pt->pool = this; @@ -129,15 +129,15 @@ class SimpleThreadPoolTempl : public ThreadPoolInterface { struct PerThread { ThreadPoolTempl* pool; // Parent pool, or null for normal threads. - size_t thread_id; // Worker thread index in pool. + int thread_id; // Worker thread index in pool. }; Environment env_; std::mutex mu_; MaxSizeVector<Thread*> threads_; // All threads MaxSizeVector<Waiter*> waiters_; // Stack of waiting threads. - std::deque<Task> pending_; // Queue of pending work - std::condition_variable empty_; // Signaled on pending_.empty() + std::deque<Task> pending_; // Queue of pending work + std::condition_variable empty_; // Signaled on pending_.empty() bool exiting_ = false; PerThread* GetPerThread() const { diff --git a/unsupported/Eigen/CXX11/src/ThreadPool/ThreadPoolInterface.h b/unsupported/Eigen/CXX11/src/ThreadPool/ThreadPoolInterface.h index b1beccdde..569cd4bc8 100644 --- a/unsupported/Eigen/CXX11/src/ThreadPool/ThreadPoolInterface.h +++ b/unsupported/Eigen/CXX11/src/ThreadPool/ThreadPoolInterface.h @@ -19,11 +19,11 @@ class ThreadPoolInterface { virtual void Schedule(std::function<void()> fn) = 0; // Returns the number of threads in the pool. - virtual size_t NumThreads() const = 0; + virtual int NumThreads() const = 0; // Returns a logical thread index between 0 and NumThreads() - 1 if called // from one of the threads in the pool. Returns NumThreads() otherwise. - virtual size_t CurrentThreadId() const = 0; + virtual int CurrentThreadId() const = 0; virtual ~ThreadPoolInterface() {} }; diff --git a/unsupported/test/cxx11_non_blocking_thread_pool.cpp b/unsupported/test/cxx11_non_blocking_thread_pool.cpp index 844a1fbf4..6e4e5cbab 100644 --- a/unsupported/test/cxx11_non_blocking_thread_pool.cpp +++ b/unsupported/test/cxx11_non_blocking_thread_pool.cpp @@ -36,7 +36,7 @@ static void test_parallelism() // Schedule kThreads tasks and ensure that they all are running. for (int i = 0; i < kThreads; ++i) { tp.Schedule([&]() { - const size_t thread_id = tp.CurrentThreadId(); + const int thread_id = tp.CurrentThreadId(); VERIFY_GE(thread_id, 0); VERIFY_LE(thread_id, kThreads - 1); running++; |