41 using std::atomic_uint;
42 using std::this_thread::sleep_for;
51 const uint NUM_THREADS = 256;
53 atomic_uint stage1{0};
54 atomic_uint stage2{0};
55 atomic_uint finish{0};
74 localSum = rand() % 1000;
75 stage1.fetch_add (localSum);
80 localSum += rand() % 1000;
81 stage2.fetch_add (localSum+sync);
98 .reduce ([&](
TestThread const& t){
return t.localSum; });
120 array<TestThread,NUM_THREADS> threads;
123 CHECK (
explore(threads).and_all());
128 CHECK (NUM_THREADS == finish);
130 CHECK (stage1 < stage2);
132 CHECK (stage2 ==
sumLocals(threads) + NUM_THREADS*stage1);
A test thread to perform a summation protocol including synchronisation points.
auto explore(IT &&srcSeq)
start building a IterExplorer by suitably wrapping the given iterable source.
uint sumLocals(CON const &threads)
sum up all localSum fields from all TestThread instances in a container
Implementation namespace for support and library code.
Abstract Base Class for all testcases.
Simple test class runner.
Convenience front-end to simplify and codify basic thread handling.
A one time N-fold mutual synchronisation barrier.
A thin convenience wrapper to simplify thread-handling.
Building tree expanding and backtracking evaluations within hierarchical scopes.
A N-fold synchronisation latch using yield-wait until fulfilment.