source: doc/theses/colby_parsons_MMAth/benchmarks/mutex_stmt/cfa/order-basic.cfa @ 6bc70a38

ADTast-experimental
Last change on this file since 6bc70a38 was 6bc70a38, checked in by caparsons <caparson@…>, 14 months ago

added baseline mutex stmt and scoped lock benchmarks

  • Property mode set to 100644
File size: 1.4 KB
Line 
1#include <locks.hfa>
2#include <mutex_stmt.hfa>
3#include <stdio.h>
4
5#include "../bench.h"
6
7test_spinlock LOCKS;
8
9inline void lock( test_spinlock &a, test_spinlock &b ) {
10    lock(a); lock(b);
11}
12inline void lock( test_spinlock &a, test_spinlock &b, test_spinlock &c, test_spinlock &d ) {
13    lock(a); lock(b); lock(c); lock(d);
14}
15inline void lock( test_spinlock &a, test_spinlock &b, test_spinlock &c, test_spinlock &d, test_spinlock &e, test_spinlock &f, test_spinlock &g, test_spinlock &h ) {
16    lock(a); lock(b); lock(c); lock(d); lock(e); lock(f); lock(g); lock(h);
17}
18inline void unlock( test_spinlock &a, test_spinlock &b ) {
19    unlock(a); unlock(b);
20}
21inline void unlock( test_spinlock &a, test_spinlock &b, test_spinlock &c, test_spinlock &d ) {
22    unlock(a); unlock(b); unlock(c); unlock(d);
23}
24inline void unlock( test_spinlock &a, test_spinlock &b, test_spinlock &c, test_spinlock &d, test_spinlock &e, test_spinlock &f, test_spinlock &g, test_spinlock &h ) {
25    unlock(a); unlock(b); unlock(c); unlock(d); unlock(e); unlock(f); unlock(g); unlock(h);
26}
27
28bool done = false;
29uint64_t total = 0;
30thread worker {};
31void main( worker & w ) {
32    BENCH( lock( LOCKS ); unlock( LOCKS );, total, done )
33}
34
35int main( int argc, char * argv[] ) {
36        BENCH_START()
37    processor p[threads]; // one extra for main thread
38    {
39        worker w[threads];
40        sleep( 10`s );
41        done = true;
42    }
43        printf( "%lu\n", total );
44}
45
46// Local Variables: //
47// tab-width: 4 //
48// End: //
Note: See TracBrowser for help on using the repository browser.