35 const uint NUM_STAGES = 1024;
54 :
public Sync<NonrecursiveLock_Waitable>
58 bool allPassed() {
return latch_ <= 0; }
70 sync.wait ([
this]{
return allPassed(); });
93 template<
class BAR,
size_t nThreads>
97 BAR barrier[NUM_STAGES];
98 for (uint i=0; i<NUM_STAGES; ++i)
99 new(&barrier[i]) BAR{nThreads};
101 auto testSubject = [&](
size_t i) ->
size_t 107 auto [micros, cnt] = threadBenchmark<nThreads> (testSubject, NUM_STAGES);
108 CHECK (cnt == nThreads * NUM_STAGES*(NUM_STAGES-1)/2);
139 cout<<
"\n\n■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■"<<endl;
141 double time_yieldWait_80 = performanceTest<SyncBarrier, 80>();
142 double time_yieldWait_64 = performanceTest<SyncBarrier, 64>();
143 double time_yieldWait_48 = performanceTest<SyncBarrier, 48>();
144 double time_yieldWait_32 = performanceTest<SyncBarrier, 32>();
145 double time_yieldWait_16 = performanceTest<SyncBarrier, 16>();
146 double time_yieldWait_8 = performanceTest<SyncBarrier, 8>();
147 double time_yieldWait_4 = performanceTest<SyncBarrier, 4>();
148 double time_yieldWait_2 = performanceTest<SyncBarrier, 2>();
150 double time_emptySetup = performanceTest<FakeBarrier, 5>();
152 double time_sleepWait_16 = performanceTest<MonitorSync, 16>();
153 double time_sleepWait_8 = performanceTest<MonitorSync, 8>();
154 double time_sleepWait_4 = performanceTest<MonitorSync, 4>();
155 double time_sleepWait_2 = performanceTest<MonitorSync, 2>();
157 cout<<
"\n___Microbenchmark_______ (µs)" 158 <<
"\nemptySetup : "<<time_emptySetup
160 <<
"\nSyncBarrier (2 Thr) : "<<time_yieldWait_2
161 <<
"\nSyncBarrier (4 Thr) : "<<time_yieldWait_4
162 <<
"\nSyncBarrier (8 Thr) : "<<time_yieldWait_8
163 <<
"\nSyncBarrier (16 Thr) : "<<time_yieldWait_16
164 <<
"\nSyncBarrier (32 Thr) : "<<time_yieldWait_32
165 <<
"\nSyncBarrier (48 Thr) : "<<time_yieldWait_48
166 <<
"\nSyncBarrier (64 Thr) : "<<time_yieldWait_64
167 <<
"\nSyncBarrier (80 Thr) : "<<time_yieldWait_80
169 <<
"\nMonitorWait (2 Thr) : "<<time_sleepWait_2
170 <<
"\nMonitorWait (4 Thr) : "<<time_sleepWait_4
171 <<
"\nMonitorWait (8 Thr) : "<<time_sleepWait_8
172 <<
"\nMonitorWait (16 Thr) : "<<time_sleepWait_16
173 <<
"\n________________________\n" 174 <<
"\nbarriers..... "<<NUM_STAGES
178 CHECK (time_emptySetup < time_yieldWait_4);
Facility for monitor object based locking.
scoped guard to control the actual locking.
Functions to perform (multithreaded) timing measurement on a given functor.
Implementation namespace for support and library code.
Object Monitor based synchronisation.
Abstract Base Class for all testcases.
Simplistic test class runner.
A N-fold synchronisation latch using yield-wait until fulfilment.