diff options
author | Rasmus Munk Larsen <rmlarsen@google.com> | 2016-06-03 16:28:58 -0700 |
---|---|---|
committer | Rasmus Munk Larsen <rmlarsen@google.com> | 2016-06-03 16:28:58 -0700 |
commit | 76308e7fd277ad962a87724040670da827a27db4 (patch) | |
tree | a4b431787f1b826e3660c85eb4b8b1e044a9d750 /unsupported/test | |
parent | 8d97ba6b2251aabf325ff74f24959ceaa85cf11e (diff) |
Add CurrentThreadId and NumThreads methods to Eigen threadpools and TensorDeviceThreadPool.
Diffstat (limited to 'unsupported/test')
-rw-r--r-- | unsupported/test/cxx11_non_blocking_thread_pool.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
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<int> running(0); std::atomic<int> 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) { } |