32 using std::atomic_uint;
33 using std::this_thread::sleep_for;
42 const uint NUM_THREADS = 256;
44 atomic_uint stage1{0};
45 atomic_uint stage2{0};
46 atomic_uint finish{0};
66 localSum = ran.i(1000);
67 stage1.fetch_add (localSum);
72 localSum += ran.i(1000);
73 stage2.fetch_add (localSum+sync);
90 .reduce ([&](
TestThread const& t){
return t.localSum; });
114 array<TestThread,NUM_THREADS> threads;
117 CHECK (
explore(threads).and_all());
122 CHECK (NUM_THREADS == finish);
124 CHECK (stage1 < stage2);
126 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.
SeedNucleus & seedFromDefaultGen()
draw seed another Generator from the default RandomSequencer
Abstract Base Class for all testcases.
Simplistic 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.