44 const uint NUM_STAGES = 1024;
63 :
public Sync<NonrecursiveLock_Waitable>
67 bool allPassed() {
return latch_ <= 0; }
79 sync.wait ([
this]{
return allPassed(); });
102 template<
class BAR,
size_t nThreads>
106 BAR barrier[NUM_STAGES];
107 for (uint i=0; i<NUM_STAGES; ++i)
108 new(&barrier[i]) BAR{nThreads};
110 auto testSubject = [&](
size_t i) ->
size_t 116 auto [micros, cnt] = threadBenchmark<nThreads> (testSubject, NUM_STAGES);
117 CHECK (cnt == nThreads * NUM_STAGES*(NUM_STAGES-1)/2);
148 cout<<
"\n\n■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■"<<endl;
150 double time_yieldWait_80 = performanceTest<SyncBarrier, 80>();
151 double time_yieldWait_64 = performanceTest<SyncBarrier, 64>();
152 double time_yieldWait_48 = performanceTest<SyncBarrier, 48>();
153 double time_yieldWait_32 = performanceTest<SyncBarrier, 32>();
154 double time_yieldWait_16 = performanceTest<SyncBarrier, 16>();
155 double time_yieldWait_8 = performanceTest<SyncBarrier, 8>();
156 double time_yieldWait_4 = performanceTest<SyncBarrier, 4>();
157 double time_yieldWait_2 = performanceTest<SyncBarrier, 2>();
159 double time_emptySetup = performanceTest<FakeBarrier, 5>();
161 double time_sleepWait_16 = performanceTest<MonitorSync, 16>();
162 double time_sleepWait_8 = performanceTest<MonitorSync, 8>();
163 double time_sleepWait_4 = performanceTest<MonitorSync, 4>();
164 double time_sleepWait_2 = performanceTest<MonitorSync, 2>();
166 cout<<
"\n___Microbenchmark_______ (µs)" 167 <<
"\nemptySetup : "<<time_emptySetup
169 <<
"\nSyncBarrier (2 Thr) : "<<time_yieldWait_2
170 <<
"\nSyncBarrier (4 Thr) : "<<time_yieldWait_4
171 <<
"\nSyncBarrier (8 Thr) : "<<time_yieldWait_8
172 <<
"\nSyncBarrier (16 Thr) : "<<time_yieldWait_16
173 <<
"\nSyncBarrier (32 Thr) : "<<time_yieldWait_32
174 <<
"\nSyncBarrier (48 Thr) : "<<time_yieldWait_48
175 <<
"\nSyncBarrier (64 Thr) : "<<time_yieldWait_64
176 <<
"\nSyncBarrier (80 Thr) : "<<time_yieldWait_80
178 <<
"\nMonitorWait (2 Thr) : "<<time_sleepWait_2
179 <<
"\nMonitorWait (4 Thr) : "<<time_sleepWait_4
180 <<
"\nMonitorWait (8 Thr) : "<<time_sleepWait_8
181 <<
"\nMonitorWait (16 Thr) : "<<time_sleepWait_16
182 <<
"\n________________________\n" 183 <<
"\nbarriers..... "<<NUM_STAGES
187 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.
Simple test class runner.
A N-fold synchronisation latch using yield-wait until fulfilment.