11 #define EIGEN_USE_THREADS 13 #include "Eigen/CXX11/ThreadPool" 19 for (
int i = 0; i < 16; ++i) {
28 const int kThreads = 16;
30 VERIFY_IS_EQUAL(tp.NumThreads(), kThreads);
31 VERIFY_IS_EQUAL(tp.CurrentThreadId(), -1);
32 for (
int iter = 0; iter < 100; ++iter) {
33 std::atomic<int> running(0);
34 std::atomic<int> done(0);
35 std::atomic<int> phase(0);
37 for (
int i = 0; i < kThreads; ++i) {
39 const int thread_id = tp.CurrentThreadId();
40 VERIFY_GE(thread_id, 0);
41 VERIFY_LE(thread_id, kThreads - 1);
48 while (running != kThreads) {
54 for (
int i = 0; i < kThreads; ++i) {
55 tp.Schedule([&, i]() {
64 if (i < kThreads / 2) {
65 }
else if (i < 3 * kThreads / 4) {
71 for (
int j = 0; j < 2; ++j) {
83 while (running != kThreads) {
87 for (
int i = 0; i < kThreads / 4; ++i) {
95 while (running != kThreads) {
98 while (done != 3 * kThreads) {
static void test_parallelism()
void test_cxx11_non_blocking_thread_pool()
static void test_create_destroy_empty_pool()
NonBlockingThreadPoolTempl< StlThreadEnvironment > NonBlockingThreadPool