8 #define EIGEN_USE_THREADS 11 #include <unordered_set> 14 #include <Eigen/CXX11/ThreadPool> 32 counter.created_by = std::this_thread::get_id();
37 int num_threads = internal::random<int>(4, 32);
41 int num_tasks = 3 * num_threads;
44 for (
int i = 0;
i < num_tasks; ++
i) {
45 thread_pool.Schedule([&counter, &barrier]() {
49 std::this_thread::sleep_for(std::chrono::milliseconds(100));
77 int num_threads = internal::random<int>(4, 32);
81 int num_tasks = 10000;
84 for (
int i = 0;
i < num_tasks; ++
i) {
85 thread_pool.Schedule([&counter, &barrier]() {
95 std::unordered_set<std::thread::id> unique_threads;
99 unique_threads.insert(
id);
106 unique_threads.size() <= (
static_cast<size_t>(num_threads + 1)),
true);
112 int num_threads = internal::random<int>(4, 32);
116 int num_tasks = 10000;
119 for (
int i = 0;
i < num_tasks; ++
i) {
120 thread_pool.Schedule([&counter, &barrier]() {
130 std::unordered_set<std::thread::id> unique_threads;
133 total += cnt.value();
134 unique_threads.insert(
id);
141 unique_threads.size() <= (
static_cast<size_t>(num_threads + 1)),
true);
void operator()(Counter &counter)
void test_large_number_of_tasks_no_spill()
void ForEach(std::function< void(std::thread::id, T &)> f)
static const Similarity3 id
#define VERIFY_IS_EQUAL(a, b)
EIGEN_DECLARE_TEST(cxx11_tensor_thread_local)
#define CALL_SUBTEST(FUNC)
void test_large_number_of_tasks_with_spill()
std::thread::id created_by
void test_simple_thread_local()
void test_zero_sized_thread_local()