Changeset 26fd986 for benchmark


Ignore:
Timestamp:
Jan 21, 2020, 6:14:34 PM (5 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
5518719
Parents:
c12869e
Message:

update benchmarks for concurrency paper

Location:
benchmark
Files:
2 added
14 edited

Legend:

Unmodified
Added
Removed
  • benchmark/Makefile.am

    rc12869e r26fd986  
    1111## Created On       : Sun May 31 09:08:15 2015
    1212## Last Modified By : Peter A. Buhr
    13 ## Last Modified On : Mon Jan 20 11:50:13 2020
    14 ## Update Count     : 244
     13## Last Modified On : Tue Jan 21 17:56:31 2020
     14## Update Count     : 250
    1515###############################################################################
    1616
     
    7575.ONESHELL:              # use one shell to execute recipe
    7676.NOTPARALLEL:
    77 .PHONY: compile.csv basic.csv ctxswitch.csv mutex.csv signal.csv
    78 
    79 ## =========================================================================================================
    80 
    81 all : basic$(EXEEXT) ctxswitch$(EXEEXT) mutex$(EXEEXT) signal$(EXEEXT) waitfor$(EXEEXT) creation$(EXEEXT)
     77.PHONY: compile.csv basic.csv ctxswitch.csv mutex.csv schedint.csv
     78
     79## =========================================================================================================
     80
     81all : basic$(EXEEXT) ctxswitch$(EXEEXT) mutex$(EXEEXT) schedint$(EXEEXT) schedext$(EXEEXT) creation$(EXEEXT)
    8282
    8383basic_loop_DURATION = 15000000000
     
    9191ctxswitch_DURATION = 100000000
    9292
    93 mutex_java_DURATION = 10000000
     93#mutex_java_DURATION = 10000000
    9494mutex_DURATION = 50000000
    9595
    96 signal_pthread_DURATION = 1000000
    97 signal_java_DURATION = $(signal_pthread_DURATION)
    98 signal_rust_DURATION = $(signal_pthread_DURATION)
    99 signal_DURATION = 10000000
    100 
    101 waitfor_DURATION = 10000000
     96schedint_pthread_DURATION = 1000000
     97schedint_java_DURATION = $(schedint_pthread_DURATION)
     98schedint_rust_DURATION = $(schedint_pthread_DURATION)
     99schedint_DURATION = 10000000
     100
     101schedext_DURATION = 10000000
    102102
    103103creation_pthread_DURATION = 250000
    104 creation_rust_DURATION = ${creation_pthread_DURATION}
     104creation_rust_thread_DURATION = ${creation_pthread_DURATION}
     105creation_java_thread_DURATION = ${creation_pthread_DURATION}
    105106creation_cfa_coroutine_DURATION = 100000000
    106107creation_cfa_coroutine_eager_DURATION = 10000000
     
    151152        +make mutex.csv
    152153        -+make mutex.diff.csv
    153         +make signal.csv
    154         -+make signal.diff.csv
     154        +make schedint.csv
     155        -+make schedint.diff.csv
    155156@DOifskipcompile@
    156157        cat compile.csv
     
    163164        cat mutex.csv
    164165        -cat mutex.diff.csv
    165         cat signal.csv
    166         -cat signal.diff.csv
     166        cat schedint.csv
     167        -cat schedint.diff.csv
    167168
    168169compile.csv:
     
    198199        $(srcdir)/fixcsv.sh $@
    199200
    200 signal.csv:
    201         echo "signal-1,signal-2,waitfor-1,waitfor-2" > $@
    202         +make signal-cfa1.runquiet >> $@ && echo -n ',' >> $@
    203         +make signal-cfa2.runquiet >> $@ && echo -n ',' >> $@
    204         +make waitfor-cfa1.runquiet >> $@ && echo -n ',' >> $@
    205         +make waitfor-cfa2.runquiet >> $@
     201schedint.csv:
     202        echo "schedint-1,schedint-2,schedext-1,schedext-2" > $@
     203        +make schedint-cfa1.runquiet >> $@ && echo -n ',' >> $@
     204        +make schedint-cfa2.runquiet >> $@ && echo -n ',' >> $@
     205        +make schedext-cfa1.runquiet >> $@ && echo -n ',' >> $@
     206        +make schedext-cfa2.runquiet >> $@
    206207        $(srcdir)/fixcsv.sh $@
    207208
     
    351352## =========================================================================================================
    352353
    353 signal$(EXEEXT) :               \
    354         signal-cfa1.run         \
    355         signal-cfa2.run         \
    356         signal-cfa4.run         \
    357         signal-upp.run          \
    358         signal-rust.run         \
    359         signal-java.run         \
    360         signal-pthread.run
    361 
    362 signal-pthread$(EXEEXT):
     354schedint$(EXEEXT) :             \
     355        schedint-cfa1.run       \
     356        schedint-cfa2.run       \
     357        schedint-cfa4.run       \
     358        schedint-upp.run        \
     359        schedint-rust.run       \
     360        schedint-java.run       \
     361        schedint-pthread.run
     362
     363schedint-cfa1$(EXEEXT):
     364        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedint/cfa1.cfa
     365
     366schedint-cfa2$(EXEEXT):
     367        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedint/cfa2.cfa
     368
     369schedint-cfa4$(EXEEXT):
     370        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedint/cfa4.cfa
     371
     372schedint-upp$(EXEEXT):
     373        $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/schedint/upp.cc
     374
     375schedint-rust$(EXEEXT):
     376        $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/schedint/rust.rs
     377
     378schedint-java$(EXEEXT):
     379        $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/schedint/JavaThread.java
     380        echo "#!/bin/sh" > a.out
     381        echo "java JavaThread" >> a.out
     382        chmod a+x a.out
     383
     384schedint-pthread$(EXEEXT):
    363385        $(BENCH_V_CC)$(COMPILE) $(srcdir)/schedint/pthreads.c
    364386
    365 signal-upp$(EXEEXT):
    366         $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/schedint/upp.cc
    367 
    368 signal-cfa1$(EXEEXT):
    369         $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedint/cfa1.cfa
    370 
    371 signal-cfa2$(EXEEXT):
    372         $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedint/cfa2.cfa
    373 
    374 signal-cfa4$(EXEEXT):
    375         $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedint/cfa4.cfa
    376 
    377 signal-rust$(EXEEXT):
    378         $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/schedint/rust.rs
    379 
    380 signal-java$(EXEEXT):
    381         $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/schedint/JavaThread.java
    382         echo "#!/bin/sh" > a.out
    383         echo "java JavaThread" >> a.out
    384         chmod a+x a.out
    385 
    386 ## =========================================================================================================
    387 
    388 waitfor$(EXEEXT) :              \
    389         waitfor-cfa1.run        \
    390         waitfor-cfa2.run        \
    391         waitfor-cfa4.run        \
    392         waitfor-upp.run
    393 
    394 waitfor-upp$(EXEEXT):
     387## =========================================================================================================
     388
     389schedext$(EXEEXT) :             \
     390        schedext-cfa1.run       \
     391        schedext-cfa2.run       \
     392        schedext-cfa4.run       \
     393        schedext-upp.run        \
     394        schedext-goroutine.run
     395
     396schedext-cfa1$(EXEEXT):
     397        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedext/cfa1.cfa
     398
     399schedext-cfa2$(EXEEXT):
     400        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedext/cfa2.cfa
     401
     402schedext-cfa4$(EXEEXT):
     403        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedext/cfa4.cfa
     404
     405schedext-upp$(EXEEXT):
    395406        $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/schedext/upp.cc
    396407
    397 waitfor-cfa1$(EXEEXT):
    398         $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedext/cfa1.cfa
    399 
    400 waitfor-cfa2$(EXEEXT):
    401         $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedext/cfa2.cfa
    402 
    403 waitfor-cfa4$(EXEEXT):
    404         $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedext/cfa4.cfa
     408schedext-goroutine$(EXEEXT):
     409        $(BENCH_V_GOC)go build -o a.out $(srcdir)/schedext/goroutine.go
     410
    405411
    406412## =========================================================================================================
    407413
    408414creation$(EXEEXT) :                             \
     415        creation-cfa_generator.run              \
    409416        creation-cfa_coroutine.run              \
    410417        creation-cfa_coroutine_eager.run        \
     
    419426        creation-pthread.run
    420427
     428creation-cfa_generator$(EXEEXT):
     429        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_gen.cfa
     430
    421431creation-cfa_coroutine$(EXEEXT):
    422432        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_cor.cfa
     
    450460        $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/creation/rust_thrd.rs
    451461
    452 creation-java$(EXEEXT):
     462creation-java_thread$(EXEEXT):
    453463        $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/creation/JavaThread.java
    454464        echo "#!/bin/sh" > a.out
  • benchmark/Makefile.in

    rc12869e r26fd986  
    427427ctxswitch_cfa_generator_DURATION = 5000000000
    428428ctxswitch_DURATION = 100000000
    429 mutex_java_DURATION = 10000000
     429
     430#mutex_java_DURATION = 10000000
    430431mutex_DURATION = 50000000
    431 signal_pthread_DURATION = 1000000
    432 signal_java_DURATION = $(signal_pthread_DURATION)
    433 signal_rust_DURATION = $(signal_pthread_DURATION)
    434 signal_DURATION = 10000000
    435 waitfor_DURATION = 10000000
     432schedint_pthread_DURATION = 1000000
     433schedint_java_DURATION = $(schedint_pthread_DURATION)
     434schedint_rust_DURATION = $(schedint_pthread_DURATION)
     435schedint_DURATION = 10000000
     436schedext_DURATION = 10000000
    436437creation_pthread_DURATION = 250000
    437 creation_rust_DURATION = ${creation_pthread_DURATION}
     438creation_rust_thread_DURATION = ${creation_pthread_DURATION}
     439creation_java_thread_DURATION = ${creation_pthread_DURATION}
    438440creation_cfa_coroutine_DURATION = 100000000
    439441creation_cfa_coroutine_eager_DURATION = 10000000
     
    784786.ONESHELL:              # use one shell to execute recipe
    785787.NOTPARALLEL:
    786 .PHONY: compile.csv basic.csv ctxswitch.csv mutex.csv signal.csv
    787 
    788 all : basic$(EXEEXT) ctxswitch$(EXEEXT) mutex$(EXEEXT) signal$(EXEEXT) waitfor$(EXEEXT) creation$(EXEEXT)
     788.PHONY: compile.csv basic.csv ctxswitch.csv mutex.csv schedint.csv
     789
     790all : basic$(EXEEXT) ctxswitch$(EXEEXT) mutex$(EXEEXT) schedint$(EXEEXT) schedext$(EXEEXT) creation$(EXEEXT)
    789791
    790792%.run : %$(EXEEXT) ${REPEAT}
     
    825827        +make mutex.csv
    826828        -+make mutex.diff.csv
    827         +make signal.csv
    828         -+make signal.diff.csv
     829        +make schedint.csv
     830        -+make schedint.diff.csv
    829831@DOifskipcompile@
    830832        cat compile.csv
     
    837839        cat mutex.csv
    838840        -cat mutex.diff.csv
    839         cat signal.csv
    840         -cat signal.diff.csv
     841        cat schedint.csv
     842        -cat schedint.diff.csv
    841843
    842844compile.csv:
     
    872874        $(srcdir)/fixcsv.sh $@
    873875
    874 signal.csv:
    875         echo "signal-1,signal-2,waitfor-1,waitfor-2" > $@
    876         +make signal-cfa1.runquiet >> $@ && echo -n ',' >> $@
    877         +make signal-cfa2.runquiet >> $@ && echo -n ',' >> $@
    878         +make waitfor-cfa1.runquiet >> $@ && echo -n ',' >> $@
    879         +make waitfor-cfa2.runquiet >> $@
     876schedint.csv:
     877        echo "schedint-1,schedint-2,schedext-1,schedext-2" > $@
     878        +make schedint-cfa1.runquiet >> $@ && echo -n ',' >> $@
     879        +make schedint-cfa2.runquiet >> $@ && echo -n ',' >> $@
     880        +make schedext-cfa1.runquiet >> $@ && echo -n ',' >> $@
     881        +make schedext-cfa2.runquiet >> $@
    880882        $(srcdir)/fixcsv.sh $@
    881883
     
    989991        chmod a+x a.out
    990992
    991 signal$(EXEEXT) :               \
    992         signal-cfa1.run         \
    993         signal-cfa2.run         \
    994         signal-cfa4.run         \
    995         signal-upp.run          \
    996         signal-rust.run         \
    997         signal-java.run         \
    998         signal-pthread.run
    999 
    1000 signal-pthread$(EXEEXT):
    1001         $(BENCH_V_CC)$(COMPILE) $(srcdir)/schedint/pthreads.c
    1002 
    1003 signal-upp$(EXEEXT):
     993schedint$(EXEEXT) :             \
     994        schedint-cfa1.run       \
     995        schedint-cfa2.run       \
     996        schedint-cfa4.run       \
     997        schedint-upp.run        \
     998        schedint-rust.run       \
     999        schedint-java.run       \
     1000        schedint-pthread.run
     1001
     1002schedint-cfa1$(EXEEXT):
     1003        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedint/cfa1.cfa
     1004
     1005schedint-cfa2$(EXEEXT):
     1006        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedint/cfa2.cfa
     1007
     1008schedint-cfa4$(EXEEXT):
     1009        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedint/cfa4.cfa
     1010
     1011schedint-upp$(EXEEXT):
    10041012        $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/schedint/upp.cc
    10051013
    1006 signal-cfa1$(EXEEXT):
    1007         $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedint/cfa1.cfa
    1008 
    1009 signal-cfa2$(EXEEXT):
    1010         $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedint/cfa2.cfa
    1011 
    1012 signal-cfa4$(EXEEXT):
    1013         $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedint/cfa4.cfa
    1014 
    1015 signal-rust$(EXEEXT):
     1014schedint-rust$(EXEEXT):
    10161015        $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/schedint/rust.rs
    10171016
    1018 signal-java$(EXEEXT):
     1017schedint-java$(EXEEXT):
    10191018        $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/schedint/JavaThread.java
    10201019        echo "#!/bin/sh" > a.out
     
    10221021        chmod a+x a.out
    10231022
    1024 waitfor$(EXEEXT) :              \
    1025         waitfor-cfa1.run        \
    1026         waitfor-cfa2.run        \
    1027         waitfor-cfa4.run        \
    1028         waitfor-upp.run
    1029 
    1030 waitfor-upp$(EXEEXT):
     1023schedint-pthread$(EXEEXT):
     1024        $(BENCH_V_CC)$(COMPILE) $(srcdir)/schedint/pthreads.c
     1025
     1026schedext$(EXEEXT) :             \
     1027        schedext-cfa1.run       \
     1028        schedext-cfa2.run       \
     1029        schedext-cfa4.run       \
     1030        schedext-upp.run        \
     1031        schedext-goroutine.run
     1032
     1033schedext-cfa1$(EXEEXT):
     1034        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedext/cfa1.cfa
     1035
     1036schedext-cfa2$(EXEEXT):
     1037        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedext/cfa2.cfa
     1038
     1039schedext-cfa4$(EXEEXT):
     1040        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedext/cfa4.cfa
     1041
     1042schedext-upp$(EXEEXT):
    10311043        $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/schedext/upp.cc
    10321044
    1033 waitfor-cfa1$(EXEEXT):
    1034         $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedext/cfa1.cfa
    1035 
    1036 waitfor-cfa2$(EXEEXT):
    1037         $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedext/cfa2.cfa
    1038 
    1039 waitfor-cfa4$(EXEEXT):
    1040         $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedext/cfa4.cfa
     1045schedext-goroutine$(EXEEXT):
     1046        $(BENCH_V_GOC)go build -o a.out $(srcdir)/schedext/goroutine.go
    10411047
    10421048creation$(EXEEXT) :                             \
     1049        creation-cfa_generator.run              \
    10431050        creation-cfa_coroutine.run              \
    10441051        creation-cfa_coroutine_eager.run        \
     
    10531060        creation-pthread.run
    10541061
     1062creation-cfa_generator$(EXEEXT):
     1063        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_gen.cfa
     1064
    10551065creation-cfa_coroutine$(EXEEXT):
    10561066        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_cor.cfa
     
    10841094        $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/creation/rust_thrd.rs
    10851095
    1086 creation-java$(EXEEXT):
     1096creation-java_thread$(EXEEXT):
    10871097        $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/creation/JavaThread.java
    10881098        echo "#!/bin/sh" > a.out
  • benchmark/creation/cfa_cor.cfa

    rc12869e r26fd986  
    1 #include <stdio.h>
    2 #include <coroutine.hfa>
    3 
    41#include "bench.h"
    52
    6 coroutine MyCoroutine {};
    7 void ?{}( MyCoroutine & this ) {
    8 #ifdef EAGER
    9         resume( this );
    10 #endif
    11 }
    12 void main( MyCoroutine & ) {}
     3typedef struct {
     4        void * next;
     5} C;
    136
    147int main( int argc, char * argv[] ) {
     
    169        BENCH(
    1710                for ( times ) {
    18                         MyCoroutine c;
     11                        C c;
    1912                },
    2013                result
  • benchmark/schedext/cfa1.cfa

    rc12869e r26fd986  
    66#include "../bench.h"
    77
    8 volatile int go = 0;
    9 
    108monitor M {} m1;
    119
    1210void __attribute__((noinline)) call( M & mutex p1 ) {}
    13 
    1411void __attribute__((noinline)) wait( M & mutex p1 ) {
    15         go = 1;
    1612        for ( times ) {
    1713                waitfor( call : p1 );
    1814        }
    19         go = 0;
    2015}
    2116
    2217thread T {};
    2318void main( T & ) {
    24         while ( go == 0 ) { yield(); }
    2519        BENCH(
    26                 while ( go == 1 ) { call( m1 ); },
     20                for ( times ) { call( m1 ); },
    2721                result
    2822        )
  • benchmark/schedext/cfa2.cfa

    rc12869e r26fd986  
    44#include <stdio.h>
    55
    6 #include "bench.h"
    7 
    8 volatile int go = 0;
     6#include "../bench.h"
    97
    108monitor M {} m1, m2;
    119
    1210void __attribute__((noinline)) call( M & mutex p1, M & mutex p2 ) {}
    13 
    1411void __attribute__((noinline)) wait( M & mutex p1, M & mutex p2 ) {
    15         go = 1;
    1612        for ( times ) {
    1713                waitfor( call : p1, p2 );
    1814        }
    19         go = 0;
    2015}
    21 
    2216thread T {};
    2317void main( T & ) {
    24         while( go == 0 ) { yield(); }
    2518        BENCH(
    26                 while ( go == 1 ) { call( m1, m2 ); },
     19                for ( times ) {
     20                        call( m1, m2 );
     21                },
    2722                result
    2823        )
  • benchmark/schedext/cfa4.cfa

    rc12869e r26fd986  
    44#include <stdio.h>
    55
    6 #include "bench.h"
    7 
    8 volatile int go = 0;
     6#include "../bench.h"
    97
    108monitor M {} m1, m2, m3, m4;
    119
    1210void __attribute__((noinline)) call( M & mutex p1, M & mutex p2, M & mutex p3, M & mutex p4 ) {}
    13 
    1411void __attribute__((noinline)) wait( M & mutex p1, M & mutex p2, M & mutex p3, M & mutex p4 ) {
    15         go = 1;
    1612        for ( times ) {
    1713                waitfor( call : p1, p2, p3, p4 );
    1814        }
    19         go = 0;
    2015}
    21 
    2216thread T {};
    2317void main( T & ) {
    24         while( go == 0 ) { yield(); }
    2518        BENCH(
    26                 while( go == 1 ) { call( m1, m2, m3, m4 ); },
     19                for ( times ) {
     20                        call( m1, m2, m3, m4 );
     21                },
    2722                result
    2823        )
  • benchmark/schedext/upp.cc

    rc12869e r26fd986  
    33#include "bench.h"
    44
    5 volatile int go = 0;
    6 
    75_Monitor M {
    86public:
    97        void __attribute__((noinline)) call() {}
    10 
    11         int __attribute__((noinline)) wait() {
    12                 go = 1;
     8        void __attribute__((noinline)) wait() {
    139                for ( size_t i = 0; i < times; i++ ) {
    1410                        _Accept(call);
    1511                }
    16                 go = 0;
    17                 return 0;
    1812        }
    1913} m;
     
    2115_Task T {
    2216        void main() {
    23                 while ( go == 0 ) { yield(); }
    2417                BENCH(
    25                         while ( go == 1 ) { m.call(); },
     18                        for ( size_t i = 0; i < times; i++ ) {
     19                                m.call();
     20                        },
    2621                        result
    2722                )
     
    3328        BENCH_START()
    3429        T t;
    35         return m.wait();
     30        m.wait();
    3631}
    3732
  • benchmark/schedint/JavaThread.java

    rc12869e r26fd986  
    6363                synchronized(m) {
    6464                        s.start();
    65                         while( !Monitor.go ) {
     65                        while( ! Monitor.go ) { // waiter must start first
    6666                                Thread.yield();
    6767                        }
  • benchmark/schedint/cfa1.cfa

    rc12869e r26fd986  
    77
    88volatile int go = 0;
     9
    910condition c;
    1011monitor M {} m1;
     
    1314        signal( c );
    1415}
    15 
    1616void __attribute__((noinline)) wait( M & mutex p1 ) {
    1717        go = 1;
     
    1919                wait( c );
    2020        }
    21         go = 0;
    2221}
    2322
    2423thread T {};
    2524void main( T & ) {
    26         while ( go == 0 ) { yield(); }
     25        while ( go == 0 ) { yield(); } // waiter must start first
    2726        BENCH(
    28                 while ( go == 1 ) { call( m1 ); },
     27                for ( times ) { call( m1 ); },
    2928                result
    3029        )
  • benchmark/schedint/cfa2.cfa

    rc12869e r26fd986  
    77
    88volatile int go = 0;
     9
    910condition c;
    1011monitor M {} m1, m2;
     
    1314        signal( c );
    1415}
    15 
    1616void __attribute__((noinline)) wait( M & mutex p1, M & mutex p2 ) {
    1717        go = 1;
     
    1919                wait( c );
    2020        }
    21         go = 0;
    2221}
    2322
    2423thread T {};
    2524void main( T & ) {
    26         while ( go == 0 ) { yield(); }
     25        while ( go == 0 ) { yield(); } // waiter must start first
    2726        BENCH(
    28                 while ( go == 1 ) { call( m1, m2 ); },
     27                for ( times ) { call( m1, m2 ); },
    2928                result
    3029        )
  • benchmark/schedint/cfa4.cfa

    rc12869e r26fd986  
    44#include <stdio.h>
    55
    6 #include "bench.h"
     6#include "../bench.h"
    77
    88volatile int go = 0;
     9
    910condition c;
    1011monitor M {} m1, m2, m3, m4;
     
    1314        signal( c );
    1415}
    15 
    1616void __attribute__((noinline)) wait( M & mutex p1, M & mutex p2, M & mutex p3, M & mutex p4 ) {
    1717        go = 1;
     
    1919                wait( c );
    2020        }
    21         go = 0;
    2221}
    2322
    2423thread T {};
    2524void main( T & ) {
    26         while ( go == 0 ) { yield(); }
     25        while ( go == 0 ) { yield(); } // waiter must start first
    2726        BENCH(
    28                 while ( go == 1 ) { call( m1, m2, m3, m4 ); },
     27                for ( times ) { call( m1, m2, m3, m4 ); },
    2928                result
    3029        )
  • benchmark/schedint/pthreads.c

    rc12869e r26fd986  
    66volatile int go = 0;
    77
     8pthread_mutex_t m;
    89pthread_cond_t c;
    9 pthread_mutex_t m;
    1010
    1111void __attribute__((noinline)) call() {
    12         pthread_mutex_lock(&m);
    13         pthread_cond_signal(&c);
    14         pthread_mutex_unlock(&m);
     12        pthread_mutex_lock( &m );
     13        pthread_cond_signal( &c );
     14        pthread_mutex_unlock( &m );
    1515}
    1616
    17 int __attribute__((noinline)) wait() {
     17void __attribute__((noinline)) wait() {
    1818        pthread_mutex_lock(&m);
    1919        go = 1;
     20        for ( size_t i = 0; i < times; i++ ) {
     21                pthread_cond_wait( &c, &m );
     22        }
     23        go = 0;
     24        pthread_mutex_unlock( &m );
     25}
     26
     27void * thread_main( __attribute__((unused)) void * arg ) {
     28        while ( go == 0 ) { sched_yield(); } // waiter must start first
     29        // barging for lock acquire => may not execute N times
    2030        BENCH(
    21                 for (size_t i = 0; i < times; i++) {
    22                         pthread_cond_wait(&c, &m);
    23                 },
     31                while ( go == 1 ) { call(); },
    2432                result
    2533        )
    2634        printf( "%g\n", result );
    27         go = 0;
    28         pthread_mutex_unlock(&m);
    29         return 0;
    30 }
    31 
    32 void* thread_main(__attribute__((unused)) void * arg ) {
    33         while(go == 0) { sched_yield(); }
    34         while(go == 1) { call(); }
    3535        return NULL;
    3636}
     
    3939        BENCH_START()
    4040        pthread_t thread;
    41         if (pthread_create(&thread, NULL, thread_main, NULL) < 0) {
     41        if ( pthread_create( &thread, NULL, thread_main, NULL ) < 0 ) {
    4242                perror( "failure" );
    4343                return 1;
    4444        }
    4545        wait();
    46         if (pthread_join( thread, NULL) < 0) {
     46        if ( pthread_join( thread, NULL ) < 0 ) {
    4747                perror( "failure" );
    4848                return 1;
  • benchmark/schedint/rust.rs

    rc12869e r26fd986  
    1818
    1919        let th = thread::spawn( move || {
    20                 while *m2.lock().unwrap() == 0 {
     20                while *m2.lock().unwrap() == 0 { // waiter must start first
    2121                        thread::yield_now();
    2222                }
  • benchmark/schedint/upp.cc

    rc12869e r26fd986  
    1111                cond.signal();
    1212        }
     13        void __attribute__((noinline)) wait() {
     14                go = 1;
     15                for ( size_t i = 0; i < times; i++ ) {
     16                        cond.wait();
     17                }
     18        }
     19} m;
    1320
    14         int __attribute__((noinline)) wait() {
    15                 go = 1;
     21_Task T {
     22        void main() {
     23                while ( go == 0 ) { yield(); } // waiter must start first
    1624                BENCH(
    17                         for (size_t i = 0; i < times; i++) {
    18                                 cond.wait();
     25                        for ( size_t i = 0; i < times; i++ ) {
     26                                m.call();
    1927                        },
    2028                        result
    2129                )
    2230                printf( "%g\n", result );
    23                 go = 0;
    24                 return 0;
    25         }
    26 };
    27 
    28 M m;
    29 
    30 _Task T {
    31         void main() {
    32                 while(go == 0) { yield(); }
    33                 while(go == 1) { m.call(); }
    34 
    3531        }
    3632};
     
    3935        BENCH_START()
    4036        T t;
    41         return m.wait();
     37        m.wait();
    4238}
    4339
Note: See TracChangeset for help on using the changeset viewer.