11 #define EIGEN_USE_THREADS 14 #include <Eigen/CXX11/ThreadPool> 20 #ifdef EIGEN_COMP_MSVC_STRICT 35 std::vector<int> stolen;
124 std::atomic<bool> done(
false);
125 std::thread mutator([&q, &done]() {
127 std::vector<int> stolen;
128 for (
int i = 0;
i < 1 << 18;
i++) {
162 static const int kEvents = 1 << 18;
164 std::atomic<int> total(0);
165 std::vector<std::unique_ptr<std::thread>> threads;
166 threads.emplace_back(
new std::thread([&q, &total]() {
170 while (pushed < kEvents || popped < kEvents) {
171 if (pushed < kEvents) {
177 if (popped < kEvents) {
187 for (
int i = 0;
i < 2;
i++) {
188 threads.emplace_back(
new std::thread([&q, &total]() {
190 for (
int j = 1;
j < kEvents;
j++) {
200 threads.emplace_back(
new std::thread([&q, &total]() {
202 std::vector<int> stolen;
203 for (
int j = 1;
j < kEvents;) {
208 while (stolen.size() &&
j < kEvents) {
209 int v = stolen.back();
216 while (stolen.size()) {
217 int v = stolen.back();
225 for (
size_t i = 0;
i < threads.size();
i++) threads[
i]->join();
227 VERIFY(total.load() == 0);
#define VERIFY_IS_NOT_EQUAL(a, b)
void test_basic_runqueue()
#define CALL_SUBTEST_3(FUNC)
int rand_reentrant(unsigned int *s)
#define VERIFY_IS_EQUAL(a, b)
#define CALL_SUBTEST_1(FUNC)
Array< int, Dynamic, 1 > v
#define EIGEN_THREAD_YIELD()
EIGEN_DEVICE_FUNC const Scalar & q
void test_stress_runqueue()
EIGEN_DECLARE_TEST(cxx11_runqueue)
unsigned PopBackHalf(std::vector< Work > *result)
#define CALL_SUBTEST_2(FUNC)
void test_empty_runqueue()
#define EIGEN_UNUSED_VARIABLE(var)