From 76308e7fd277ad962a87724040670da827a27db4 Mon Sep 17 00:00:00 2001 From: Rasmus Munk Larsen Date: Fri, 3 Jun 2016 16:28:58 -0700 Subject: Add CurrentThreadId and NumThreads methods to Eigen threadpools and TensorDeviceThreadPool. --- unsupported/test/cxx11_non_blocking_thread_pool.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'unsupported/test/cxx11_non_blocking_thread_pool.cpp') diff --git a/unsupported/test/cxx11_non_blocking_thread_pool.cpp b/unsupported/test/cxx11_non_blocking_thread_pool.cpp index 6569218c4..844a1fbf4 100644 --- a/unsupported/test/cxx11_non_blocking_thread_pool.cpp +++ b/unsupported/test/cxx11_non_blocking_thread_pool.cpp @@ -27,6 +27,8 @@ static void test_parallelism() // Test we never-ever fail to match available tasks with idle threads. const int kThreads = 16; // code below expects that this is a multiple of 4 NonBlockingThreadPool tp(kThreads); + VERIFY_IS_EQUAL(tp.NumThreads(), kThreads); + VERIFY_IS_EQUAL(tp.CurrentThreadId(), kThreads); for (int iter = 0; iter < 100; ++iter) { std::atomic running(0); std::atomic done(0); @@ -34,6 +36,9 @@ 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(); + VERIFY_GE(thread_id, 0); + VERIFY_LE(thread_id, kThreads - 1); running++; while (phase < 1) { } -- cgit v1.2.3