11 #define EIGEN_USE_THREADS 13 #include "Eigen/CXX11/ThreadPool" 14 #include "Eigen/CXX11/Tensor" 20 for (
int i = 0;
i < 16; ++
i) {
29 const int kThreads = 16;
34 std::atomic<int> running(0);
35 std::atomic<int> done(0);
36 std::atomic<int> phase(0);
38 for (
int i = 0;
i < kThreads; ++
i) {
49 while (running != kThreads) {
55 for (
int i = 0;
i < kThreads; ++
i) {
65 if (
i < kThreads / 2) {
66 }
else if (
i < 3 * kThreads / 4) {
72 for (
int j = 0;
j < 2; ++
j) {
84 while (running != kThreads) {
88 for (
int i = 0;
i < kThreads / 4; ++
i) {
96 while (running != kThreads) {
99 while (done != 3 * kThreads) {
111 for (
int i = 0;
i < 1000; ++
i) {
113 std::this_thread::sleep_for(std::chrono::milliseconds(2000));
122 const int kThreads = 2;
127 std::vector<std::pair<unsigned, unsigned>> steal_partitions(kThreads);
128 for (
int i = 0;
i < kThreads; ++
i) {
129 steal_partitions[
i] = std::make_pair(
i,
i + 1);
133 std::atomic<int> running(0);
134 std::atomic<int> done(0);
135 std::atomic<int> phase(0);
138 for (
int i = 0;
i < kThreads; ++
i) {
149 while (running != kThreads) {
152 for (
int i = 0;
i < kThreads; ++
i) {
166 while (running != kThreads) {
void ScheduleWithHint(std::function< void()> fn, int start, int limit) override
void Cancel() EIGEN_OVERRIDE
static void test_pool_partitions()
static void test_cancel()
iterator iter(handle obj)
int CurrentThreadId() const EIGEN_FINAL
#define VERIFY_IS_EQUAL(a, b)
int NumThreads() const EIGEN_FINAL
static void test_parallelism(bool allow_spinning)
void SetStealPartitions(const std::vector< std::pair< unsigned, unsigned >> &partitions)
void Schedule(std::function< void()> fn) EIGEN_OVERRIDE
#define CALL_SUBTEST(FUNC)
static void test_create_destroy_empty_pool()
EIGEN_DECLARE_TEST(cxx11_non_blocking_thread_pool)