Changes in / [aefb247:bdfc032]


Ignore:
Files:
32 added
10 deleted
95 edited

Legend:

Unmodified
Added
Removed
  • benchmark/Makefile.am

    raefb247 rbdfc032  
    1111## Created On       : Sun May 31 09:08:15 2015
    1212## Last Modified By : Peter A. Buhr
    13 ## Last Modified On : Mon Jul 29 18:02:19 2019
    14 ## Update Count     : 54
     13## Last Modified On : Sat Jan 25 09:20:44 2020
     14## Update Count     : 255
    1515###############################################################################
    1616
     
    2828BENCH_V_CFA = $(__bench_v_CFA_$(__quiet))
    2929BENCH_V_CXX = $(__bench_v_CXX_$(__quiet))
     30BENCH_V_UPP = $(__bench_v_UPP_$(__quiet))
    3031BENCH_V_GOC = $(__bench_v_GOC_$(__quiet))
     32BENCH_V_RUSTC = $(__bench_v_RUSTC_$(__quiet))
     33BENCH_V_NODEJS = $(__bench_v_NODEJS_$(__quiet))
    3134BENCH_V_JAVAC = $(__bench_v_JAVAC_$(__quiet))
    32 BENCH_V_UPP = $(__bench_v_UPP_$(__quiet))
    3335
    3436__quiet = verbose
     
    3638__bench_v_CFA_quiet = @
    3739__bench_v_CXX_quiet = @
     40__bench_v_UPP_quiet = @
    3841__bench_v_GOC_quiet = @
     42__bench_v_RUSTC_quiet = @
    3943__bench_v_JAVAC_quiet = @
    40 __bench_v_UPP_quiet = @
    4144__bench_v_CC_verbose = $(AM_V_CC)
    4245__bench_v_CFA_verbose = $(AM_V_CFA)
    4346__bench_v_CXX_verbose = $(AM_V_CXX)
     47__bench_v_UPP_verbose = $(AM_V_UPP)
    4448__bench_v_GOC_verbose = $(AM_V_GOC)
     49__bench_v_RUSTC_verbose = $(AM_V_RUSTC)
     50__bench_v_NODEJS_verbose = $(AM_V_NODEJS)
    4551__bench_v_JAVAC_verbose = $(AM_V_JAVAC)
    46 __bench_v_UPP_verbose = $(AM_V_UPP)
    4752
    4853
     
    5156STATS    = ${abs_top_srcdir}/tools/stat.py
    5257# NEED AT LEAST 4 DATA VALUES FOR BENCHMARKS BECAUSE THE MAX AND MIN VALUES ARE REMOVED
    53 repeats  = 5 # 31 for benchmarks
     58repeats  = 13 # 31 for benchmarks
    5459arch     = x64
    5560skipcompile = no
     
    6267
    6368dummyC.c:
    64         @echo "int main() { return 0; }" > ${@}
     69        echo "int main() { return 0; }" > ${@}
    6570
    6671dummyCXX.cpp:
    67         @echo "int main() { return 0; }" > ${@}
    68 
     72        echo "int main() { return 0; }" > ${@}
     73
     74#.SILENT:               # do not print recipe
     75.ONESHELL:              # use one shell to execute recipe
    6976.NOTPARALLEL:
    70 .PHONY: compile.csv ctxswitch.csv mutex.csv signal.csv
    71 
    72 ## =========================================================================================================
    73 all : 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)
     82
     83basic_loop_DURATION = 15000000000
     84basic_function_DURATION = 10000000000
     85basic_tls_fetch_add_DURATION = 10000000000
     86basic_DURATION = 250000000
     87
     88ctxswitch_pthread_DURATION = 25000000
     89ctxswitch_rust_thread_DURATION = $(ctxswitch_pthread_DURATION)
     90ctxswitch_cfa_generator_DURATION = 5000000000
     91ctxswitch_nodejs_await_DURATION = 5000000
     92ctxswitch_DURATION = 100000000
     93
     94#mutex_java_DURATION = 10000000
     95mutex_DURATION = 50000000
     96
     97schedint_pthread_DURATION = 1000000
     98schedint_java_DURATION = $(schedint_pthread_DURATION)
     99schedint_rust_DURATION = $(schedint_pthread_DURATION)
     100schedint_DURATION = 10000000
     101
     102schedext_DURATION = 10000000
     103
     104creation_pthread_DURATION = 250000
     105creation_rust_thread_DURATION = ${creation_pthread_DURATION}
     106creation_java_thread_DURATION = ${creation_pthread_DURATION}
     107creation_cfa_coroutine_DURATION = 100000000
     108creation_cfa_coroutine_eager_DURATION = 10000000
     109creation_upp_coroutine_DURATION = ${creation_cfa_coroutine_eager_DURATION}
     110creation_cfa_thread_DURATION = 10000000
     111creation_upp_thread_DURATION = ${creation_cfa_thread_DURATION}
     112creation_DURATION = 10000000
    74113
    75114%.run : %$(EXEEXT) ${REPEAT}
    76         @rm -f .result.log
    77         @echo "------------------------------------------------------"
    78         @echo $<
    79         @${REPEAT} ${repeats} ./a.out | tee -a .result.log
    80         @${STATS} .result.log
    81         @echo "------------------------------------------------------"
    82         @rm -f a.out .result.log *.class
     115        rm -f .result.log
     116        echo "------------------------------------------------------"
     117        echo $<
     118        ${REPEAT} ${repeats} -- ./a.out\
     119                $(if ${$(subst -,_,$(basename $@))_DURATION},\
     120                        ${$(subst -,_,$(basename $@))_DURATION},\
     121                        ${$(firstword $(subst -, ,$(basename $@)))_DURATION}) | tee -a .result.log
     122        ${STATS} .result.log
     123        echo "------------------------------------------------------"
     124        rm -f a.out .result.log *.class
     125
     126#       ${REPEAT} ${repeats} -- /usr/bin/time -f "%Uu %Ss %Er %Mkb" ./a.out
    83127
    84128%.runquiet :
    85         @+make $(basename $@) CFLAGS="-w" __quiet=quiet
    86         @taskset -c 1 ./a.out
    87         @rm -f a.out
     129        +make $(basename $@) CFLAGS="-w" __quiet=quiet
     130        taskset -c 1 ./a.out
     131        rm -f a.out
    88132
    89133%.make :
    90         @printf "${PRINT_FORMAT}" $(basename $(subst compile-,,$@))
    91         @+/usr/bin/time -f ${TIME_FORMAT} make $(basename $@) 2>&1
     134        printf "${PRINT_FORMAT}" $(basename $(subst compile-,,$@))
     135        +/usr/bin/time -f ${TIME_FORMAT} make $(basename $@) 2>&1
    92136
    93137${REPEAT} :
    94         @+make -C ${abs_top_builddir}/tools repeat
     138        +make -C ${abs_top_builddir}/tools repeat
    95139
    96140## =========================================================================================================
     
    100144jenkins$(EXEEXT):
    101145@DOifskipcompile@
    102         @+make compile.csv
    103         @-+make compile.diff.csv
     146        +make compile.csv
     147        -+make compile.diff.csv
    104148@DOendif@
    105         @+make ctxswitch.csv
    106         @-+make ctxswitch.diff.csv
    107         @+make mutex.csv
    108         @-+make mutex.diff.csv
    109         @+make signal.csv
    110         @-+make signal.diff.csv
     149        +make basic.csv
     150        -+make basic.diff.csv
     151        +make ctxswitch.csv
     152        -+make ctxswitch.diff.csv
     153        +make mutex.csv
     154        -+make mutex.diff.csv
     155        +make schedint.csv
     156        -+make schedint.diff.csv
    111157@DOifskipcompile@
    112158        cat compile.csv
    113159        -cat compile.diff.csv
    114160@DOendif@
     161        cat basic.csv
     162        -cat basic.diff.csv
    115163        cat ctxswitch.csv
    116164        -cat ctxswitch.diff.csv
    117165        cat mutex.csv
    118166        -cat mutex.diff.csv
    119         cat signal.csv
    120         -cat signal.diff.csv
     167        cat schedint.csv
     168        -cat schedint.diff.csv
    121169
    122170compile.csv:
    123         @echo "array,attributes,empty,expression,io,monitor,operators,typeof" > $@
    124         @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-array.make >> $@
    125         @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-attributes.make >> $@
    126         @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-empty.make >> $@
    127         @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-expression.make >> $@
    128         @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-io.make >> $@
    129         @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-monitor.make >> $@
    130         @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-operators.make >> $@
    131         @+make TIME_FORMAT='%e' PRINT_FORMAT='' compile-typeof.make >> $@
    132         @$(srcdir)/fixcsv.sh $@
     171        echo "array,attributes,empty,expression,io,monitor,operators,typeof" > $@
     172        +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-array.make >> $@
     173        +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-attributes.make >> $@
     174        +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-empty.make >> $@
     175        +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-expression.make >> $@
     176        +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-io.make >> $@
     177        +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-monitor.make >> $@
     178        +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-operators.make >> $@
     179        +make TIME_FORMAT='%e' PRINT_FORMAT='' compile-typeof.make >> $@
     180        $(srcdir)/fixcsv.sh $@
     181
     182basic.csv:
     183        echo "generator,coroutine,thread" > $@
     184        +make basic-cfa_generator.runquiet >> $@ && echo -n ',' >> $@
     185        +make basic-cfa_coroutine.runquiet >> $@ && echo -n ',' >> $@
     186        +make basic-cfa_thread.runquiet >> $@
     187        $(srcdir)/fixcsv.sh $@
    133188
    134189ctxswitch.csv:
    135         @echo "generator,coroutine,thread" > $@
    136         @+make ctxswitch-cfa_generator.runquiet >> $@ && echo -n ',' >> $@
    137         @+make ctxswitch-cfa_coroutine.runquiet >> $@ && echo -n ',' >> $@
    138         @+make ctxswitch-cfa_thread.runquiet >> $@
    139         @$(srcdir)/fixcsv.sh $@
     190        echo "generator,coroutine,thread" > $@
     191        +make ctxswitch-cfa_generator.runquiet >> $@ && echo -n ',' >> $@
     192        +make ctxswitch-cfa_coroutine.runquiet >> $@ && echo -n ',' >> $@
     193        +make ctxswitch-cfa_thread.runquiet >> $@
     194        $(srcdir)/fixcsv.sh $@
    140195
    141196mutex.csv:
    142         @echo "1-monitor,2-monitor" > $@
    143         @+make mutex-cfa1.runquiet >> $@ && echo -n ',' >> $@
    144         @+make mutex-cfa2.runquiet >> $@
    145         @$(srcdir)/fixcsv.sh $@
    146 
    147 signal.csv:
    148         @echo "signal-1,signal-2,waitfor-1,waitfor-2" > $@
    149         @+make signal-cfa1.runquiet >> $@ && echo -n ',' >> $@
    150         @+make signal-cfa2.runquiet >> $@ && echo -n ',' >> $@
    151         @+make waitfor-cfa1.runquiet >> $@ && echo -n ',' >> $@
    152         @+make waitfor-cfa2.runquiet >> $@
    153         @$(srcdir)/fixcsv.sh $@
     197        echo "1-monitor,2-monitor" > $@
     198        +make mutex-cfa1.runquiet >> $@ && echo -n ',' >> $@
     199        +make mutex-cfa2.runquiet >> $@
     200        $(srcdir)/fixcsv.sh $@
     201
     202schedint.csv:
     203        echo "schedint-1,schedint-2,schedext-1,schedext-2" > $@
     204        +make schedint-cfa1.runquiet >> $@ && echo -n ',' >> $@
     205        +make schedint-cfa2.runquiet >> $@ && echo -n ',' >> $@
     206        +make schedext-cfa1.runquiet >> $@ && echo -n ',' >> $@
     207        +make schedext-cfa2.runquiet >> $@
     208        $(srcdir)/fixcsv.sh $@
    154209
    155210%.diff.csv: %.csv
    156         @test -e $(srcdir)/baselines/$(arch)/$< || (echo "Error : Missing baseline for ${<}" && false)
    157         @$(srcdir)/baselines/calc.py $(srcdir)/baselines/$(arch)/$(<) $(<) > $@
    158 
    159 
    160 ## =========================================================================================================
    161 loop$(EXEEXT):
    162         $(BENCH_V_CC)$(COMPILE) -DBENCH_N=5000000000 $(srcdir)/loop.c
    163 
    164 function$(EXEEXT):
    165         $(BENCH_V_CC)$(COMPILE) -DBENCH_N=5000000000 $(srcdir)/function.c
    166 
    167 fetch_add$(EXEEXT):
    168         $(BENCH_V_CC)$(COMPILE) -DBENCH_N=500000000  $(srcdir)/fetch_add.c
    169 
    170 ttst_lock$(EXEEXT):
    171         $(BENCH_V_CC)$(COMPILE) -DBENCH_N=500000000  $(srcdir)/ttst_lock.c
    172 
    173 tls-fetch_add$(EXEEXT):
    174         $(BENCH_V_CC)$(COMPILE) -DBENCH_N=500000000  $(srcdir)/tls-fetch_add.c
    175 
    176 ## =========================================================================================================
    177 CTXSWITCH_DEPEND  =                 \
    178         loop.run                                \
    179         function.run                    \
    180         fetch_add.run                   \
    181         ttst_lock.run                   \
    182         tls-fetch_add.run                       \
    183         ctxswitch-pthread.run           \
     211        test -e $(srcdir)/baselines/$(arch)/$< || (echo "Error : Missing baseline for ${<}" && false)
     212        $(srcdir)/baselines/calc.py $(srcdir)/baselines/$(arch)/$(<) $(<) > $@
     213
     214## =========================================================================================================
     215
     216BASIC_DEPEND  =                                 \
     217        basic-loop.run                          \
     218        basic-function.run                      \
     219        basic-fetch_add.run                     \
     220        basic-ttst_lock.run                     \
     221        basic-tls-fetch_add.run
     222
     223basic-loop$(EXEEXT):
     224        $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/loop.c
     225
     226basic-function$(EXEEXT):
     227        $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/function.c
     228
     229basic-fetch_add$(EXEEXT):
     230        $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/fetch_add.c
     231
     232basic-ttst_lock$(EXEEXT):
     233        $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/ttst_lock.c
     234
     235basic-tls-fetch_add$(EXEEXT):
     236        $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/tls_fetch_add.c
     237
     238basic$(EXEEXT): $(BASIC_DEPEND)
     239
     240## =========================================================================================================
     241
     242CTXSWITCH_DEPEND  =                     \
    184243        ctxswitch-cfa_generator.run     \
    185244        ctxswitch-cfa_coroutine.run     \
     
    188247        ctxswitch-upp_coroutine.run     \
    189248        ctxswitch-upp_thread.run        \
    190         ctxswitch-goroutine.run         \
    191         ctxswitch-java_thread.run
    192 
     249        ctxswitch-python_coroutine.run  \
     250        ctxswitch-nodejs_coroutine.run  \
     251        ctxswitch-nodejs_await.run      \
     252        ctxswitch-goroutine_thread.run  \
     253        ctxswitch-rust_thread.run       \
     254        ctxswitch-nodejs_coroutine.run  \
     255        ctxswitch-java_thread.run       \
     256        ctxswitch-pthread.run
    193257
    194258if WITH_LIBFIBRE
    195 CTXSWITCH_DEPEND  +=           \
    196         ctxswitch-kos_fibre.run  \
     259CTXSWITCH_DEPEND  +=                    \
     260        ctxswitch-kos_fibre.run         \
    197261        ctxswitch-kos_fibre2.run
    198 
    199262
    200263ctxswitch-kos_fibre$(EXEEXT):
     
    207270ctxswitch$(EXEEXT): $(CTXSWITCH_DEPEND)
    208271
    209 ctxswitch-pthread$(EXEEXT):
    210         $(BENCH_V_CC)$(COMPILE)    -DBENCH_N=50000000 $(srcdir)/ctxswitch/pthreads.c
    211 
    212272ctxswitch-cfa_generator$(EXEEXT):
    213         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/cfa_gen.cfa
     273        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/ctxswitch/cfa_gen.cfa
    214274
    215275ctxswitch-cfa_coroutine$(EXEEXT):
    216         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/cfa_cor.cfa
     276        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/ctxswitch/cfa_cor.cfa
    217277
    218278ctxswitch-cfa_thread$(EXEEXT):
    219         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/cfa_thrd.cfa
     279        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/ctxswitch/cfa_thrd.cfa
    220280
    221281ctxswitch-cfa_thread2$(EXEEXT):
    222         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/cfa_thrd2.cfa
     282        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/ctxswitch/cfa_thrd2.cfa
    223283
    224284ctxswitch-upp_coroutine$(EXEEXT):
    225         $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/upp_cor.cc
     285        $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/ctxswitch/upp_cor.cc
    226286
    227287ctxswitch-upp_thread$(EXEEXT):
    228         $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/upp_thrd.cc
    229 
    230 ctxswitch-goroutine$(EXEEXT):
     288        $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/ctxswitch/upp_thrd.cc
     289
     290ctxswitch-python_coroutine$(EXEEXT):
     291        echo "#!/bin/sh" > a.out
     292        echo "python3.7 $(srcdir)/ctxswitch/python_cor.py" >> a.out
     293        chmod a+x a.out
     294
     295ctxswitch-nodejs_coroutine$(EXEEXT):
     296        echo "#!/bin/sh" > a.out
     297        echo "nodejs $(srcdir)/ctxswitch/node_cor.js" >> a.out
     298        chmod a+x a.out
     299
     300ctxswitch-nodejs_await$(EXEEXT):
     301        echo "#!/bin/sh" > a.out
     302        echo "nodejs $(srcdir)/ctxswitch/node_await.js" >> a.out
     303        chmod a+x a.out
     304
     305ctxswitch-goroutine_thread$(EXEEXT):
    231306        $(BENCH_V_GOC)go build -o a.out $(srcdir)/ctxswitch/goroutine.go
     307
     308ctxswitch-rust_thread$(EXEEXT):
     309        $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/ctxswitch/rust_thrd.rs
    232310
    233311ctxswitch-java_thread$(EXEEXT):
    234312        $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/ctxswitch/JavaThread.java
    235         @echo "#!/bin/sh" > a.out
    236         @echo "java JavaThread" >> a.out
    237         @chmod a+x a.out
    238 
    239 ## =========================================================================================================
    240 mutex$(EXEEXT) :\
    241         loop.run                        \
    242         function.run            \
    243         fetch_add.run           \
    244         mutex-pthread_lock.run  \
    245         mutex-upp.run           \
     313        echo "#!/bin/sh" > a.out
     314        echo "java JavaThread" >> a.out
     315        chmod a+x a.out
     316
     317ctxswitch-pthread$(EXEEXT):
     318        $(BENCH_V_CC)$(COMPILE) $(srcdir)/ctxswitch/pthreads.c
     319
     320## =========================================================================================================
     321
     322mutex$(EXEEXT) :                \
    246323        mutex-cfa1.run          \
    247324        mutex-cfa2.run          \
    248325        mutex-cfa4.run          \
    249         mutex-java_thread.run
    250 
    251 mutex-pthread_lock$(EXEEXT):
    252         $(BENCH_V_CC)$(COMPILE)    -DBENCH_N=50000000 $(srcdir)/mutex/pthreads.c
     326        mutex-upp.run           \
     327        mutex-go.run            \
     328        mutex-rust.run          \
     329        mutex-java.run          \
     330        mutex-pthread.run
     331
     332mutex-pthread$(EXEEXT):
     333        $(BENCH_V_CC)$(COMPILE) $(srcdir)/mutex/pthreads.c
     334
     335mutex-cfa1$(EXEEXT):
     336        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutex/cfa1.cfa
     337
     338mutex-cfa2$(EXEEXT):
     339        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutex/cfa2.cfa
     340
     341mutex-cfa4$(EXEEXT):
     342        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutex/cfa4.cfa
    253343
    254344mutex-upp$(EXEEXT):
    255         $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/mutex/upp.cc
    256 
    257 mutex-cfa1$(EXEEXT):
    258         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=5000000  $(srcdir)/mutex/cfa1.cfa
    259 
    260 mutex-cfa2$(EXEEXT):
    261         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=5000000  $(srcdir)/mutex/cfa2.cfa
    262 
    263 mutex-cfa4$(EXEEXT):
    264         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=5000000  $(srcdir)/mutex/cfa4.cfa
    265 
    266 mutex-java_thread$(EXEEXT):
     345        $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/mutex/upp.cc
     346
     347mutex-go$(EXEEXT):
     348        $(BENCH_V_GOC)go build -o a.out $(srcdir)/mutex/goroutine.go
     349
     350mutex-rust$(EXEEXT):
     351        $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/mutex/rust.rs
     352
     353mutex-java$(EXEEXT):
    267354        $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/mutex/JavaThread.java
    268         @echo "#!/bin/sh" > a.out
    269         @echo "java JavaThread" >> a.out
    270         @chmod a+x a.out
    271 
    272 ## =========================================================================================================
    273 signal$(EXEEXT) :\
    274         signal-pthread_cond.run \
    275         signal-upp.run          \
    276         signal-cfa1.run         \
    277         signal-cfa2.run         \
    278         signal-cfa4.run         \
    279         signal-java_thread.run
    280 
    281 signal-pthread_cond$(EXEEXT):
    282         $(BENCH_V_CC)$(COMPILE)    -DBENCH_N=500000  $(srcdir)/schedint/pthreads.c
    283 
    284 signal-upp$(EXEEXT):
    285         $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=5000000 $(srcdir)/schedint/upp.cc
    286 
    287 signal-cfa1$(EXEEXT):
    288         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000  $(srcdir)/schedint/cfa1.cfa
    289 
    290 signal-cfa2$(EXEEXT):
    291         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000  $(srcdir)/schedint/cfa2.cfa
    292 
    293 signal-cfa4$(EXEEXT):
    294         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000  $(srcdir)/schedint/cfa4.cfa
    295 
    296 signal-java_thread$(EXEEXT):
     355        echo "#!/bin/sh" > a.out
     356        echo "java JavaThread" >> a.out
     357        chmod a+x a.out
     358
     359## =========================================================================================================
     360
     361schedint$(EXEEXT) :             \
     362        schedint-cfa1.run       \
     363        schedint-cfa2.run       \
     364        schedint-cfa4.run       \
     365        schedint-upp.run        \
     366        schedint-rust.run       \
     367        schedint-java.run       \
     368        schedint-pthread.run
     369
     370schedint-cfa1$(EXEEXT):
     371        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedint/cfa1.cfa
     372
     373schedint-cfa2$(EXEEXT):
     374        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedint/cfa2.cfa
     375
     376schedint-cfa4$(EXEEXT):
     377        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedint/cfa4.cfa
     378
     379schedint-upp$(EXEEXT):
     380        $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/schedint/upp.cc
     381
     382schedint-rust$(EXEEXT):
     383        $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/schedint/rust.rs
     384
     385schedint-java$(EXEEXT):
    297386        $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/schedint/JavaThread.java
    298         @echo "#!/bin/sh" > a.out
    299         @echo "java JavaThread" >> a.out
    300         @chmod a+x a.out
    301 
    302 
    303 ## =========================================================================================================
    304 waitfor$(EXEEXT) :\
    305         waitfor-upp.run         \
    306         waitfor-cfa1.run                \
    307         waitfor-cfa2.run                \
    308         waitfor-cfa4.run
    309 
    310 waitfor-upp$(EXEEXT):
    311         $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=5000000 $(srcdir)/schedext/upp.cc
    312 
    313 waitfor-cfa1$(EXEEXT):
    314         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000  $(srcdir)/schedext/cfa1.cfa
    315 
    316 waitfor-cfa2$(EXEEXT):
    317         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000  $(srcdir)/schedext/cfa2.cfa
    318 
    319 waitfor-cfa4$(EXEEXT):
    320         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000  $(srcdir)/schedext/cfa4.cfa
    321 
    322 ## =========================================================================================================
    323 creation$(EXEEXT) :\
    324         creation-pthread.run                    \
     387        echo "#!/bin/sh" > a.out
     388        echo "java JavaThread" >> a.out
     389        chmod a+x a.out
     390
     391schedint-pthread$(EXEEXT):
     392        $(BENCH_V_CC)$(COMPILE) $(srcdir)/schedint/pthreads.c
     393
     394## =========================================================================================================
     395
     396schedext$(EXEEXT) :             \
     397        schedext-cfa1.run       \
     398        schedext-cfa2.run       \
     399        schedext-cfa4.run       \
     400        schedext-upp.run        \
     401        schedext-goroutine.run
     402
     403schedext-cfa1$(EXEEXT):
     404        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedext/cfa1.cfa
     405
     406schedext-cfa2$(EXEEXT):
     407        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedext/cfa2.cfa
     408
     409schedext-cfa4$(EXEEXT):
     410        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedext/cfa4.cfa
     411
     412schedext-upp$(EXEEXT):
     413        $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/schedext/upp.cc
     414
     415schedext-goroutine$(EXEEXT):
     416        $(BENCH_V_GOC)go build -o a.out $(srcdir)/schedext/goroutine.go
     417
     418
     419## =========================================================================================================
     420
     421creation$(EXEEXT) :                             \
     422        creation-cfa_generator.run              \
    325423        creation-cfa_coroutine.run              \
    326424        creation-cfa_coroutine_eager.run        \
     
    328426        creation-upp_coroutine.run              \
    329427        creation-upp_thread.run                 \
    330         creation-goroutine.run                  \
    331         creation-java_thread.run
     428        creation-python_coroutine.run           \
     429        creation-nodejs_coroutine.run           \
     430        creation-goroutine_thread.run           \
     431        creation-rust_thread.run                \
     432        creation-java_thread.run                \
     433        creation-pthread.run
     434
     435creation-cfa_generator$(EXEEXT):
     436        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_gen.cfa
    332437
    333438creation-cfa_coroutine$(EXEEXT):
    334         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=10000000 $(srcdir)/creation/cfa_cor.cfa
     439        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_cor.cfa
    335440
    336441creation-cfa_coroutine_eager$(EXEEXT):
    337         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=10000000 $(srcdir)/creation/cfa_cor.cfa  -DEAGER
     442        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_cor.cfa  -DEAGER
    338443
    339444creation-cfa_thread$(EXEEXT):
    340         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=10000000 $(srcdir)/creation/cfa_thrd.cfa
     445        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_thrd.cfa
    341446
    342447creation-upp_coroutine$(EXEEXT):
    343         $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/creation/upp_cor.cc
     448        $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/creation/upp_cor.cc
    344449
    345450creation-upp_thread$(EXEEXT):
    346         $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/creation/upp_thrd.cc
    347 
    348 creation-pthread$(EXEEXT):
    349         $(BENCH_V_CC)$(COMPILE)    -DBENCH_N=250000   $(srcdir)/creation/pthreads.c
    350 
    351 creation-goroutine$(EXEEXT):
     451        $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/creation/upp_thrd.cc
     452
     453creation-python_coroutine$(EXEEXT):
     454        echo "#!/bin/sh" > a.out
     455        echo "python3.7 $(srcdir)/creation/python_cor.py" >> a.out
     456        chmod a+x a.out
     457
     458creation-nodejs_coroutine$(EXEEXT):
     459        echo "#!/bin/sh" > a.out
     460        echo "nodejs $(srcdir)/creation/node_cor.js" >> a.out
     461        chmod a+x a.out
     462
     463creation-goroutine_thread$(EXEEXT):
    352464        $(BENCH_V_GOC)go build -o a.out $(srcdir)/creation/goroutine.go
     465
     466creation-rust_thread$(EXEEXT):
     467        $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/creation/rust_thrd.rs
    353468
    354469creation-java_thread$(EXEEXT):
    355470        $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/creation/JavaThread.java
    356         @echo "#!/bin/sh" > a.out
    357         @echo "java JavaThread" >> a.out
    358         @chmod a+x a.out
    359 
    360 ## =========================================================================================================
    361 
    362 compile$(EXEEXT) :\
     471        echo "#!/bin/sh" > a.out
     472        echo "java JavaThread" >> a.out
     473        chmod a+x a.out
     474
     475creation-pthread$(EXEEXT):
     476        $(BENCH_V_CC)$(COMPILE) $(srcdir)/creation/pthreads.c
     477
     478## =========================================================================================================
     479
     480compile$(EXEEXT) :              \
    363481        compile-array.make      \
    364482        compile-attributes.make \
     
    370488        compile-typeof.make
    371489
    372 
    373490testdir = $(top_srcdir)/tests
    374491
    375492compile-array$(EXEEXT):
    376         @$(CFACOMPILE) -fsyntax-only -w $(testdir)/array.cfa
     493        $(CFACOMPILE) -fsyntax-only -w $(testdir)/array.cfa
    377494
    378495compile-attributes$(EXEEXT):
    379         @$(CFACOMPILE) -fsyntax-only -w $(testdir)/attributes.cfa
     496        $(CFACOMPILE) -fsyntax-only -w $(testdir)/attributes.cfa
    380497
    381498compile-empty$(EXEEXT):
    382         @$(CFACOMPILE) -fsyntax-only -w $(srcdir)/compile/empty.cfa
     499        $(CFACOMPILE) -fsyntax-only -w $(srcdir)/compile/empty.cfa
    383500
    384501compile-expression$(EXEEXT):
    385         @$(CFACOMPILE) -fsyntax-only -w $(testdir)/expression.cfa
     502        $(CFACOMPILE) -fsyntax-only -w $(testdir)/expression.cfa
    386503
    387504compile-io$(EXEEXT):
    388         @$(CFACOMPILE) -fsyntax-only -w $(testdir)/io1.cfa
     505        $(CFACOMPILE) -fsyntax-only -w $(testdir)/io1.cfa
    389506
    390507compile-monitor$(EXEEXT):
    391         @$(CFACOMPILE) -fsyntax-only -w $(testdir)/concurrent/monitor.cfa
     508        $(CFACOMPILE) -fsyntax-only -w $(testdir)/concurrent/monitor.cfa
    392509
    393510compile-operators$(EXEEXT):
    394         @$(CFACOMPILE) -fsyntax-only -w $(testdir)/operators.cfa
     511        $(CFACOMPILE) -fsyntax-only -w $(testdir)/operators.cfa
    395512
    396513compile-thread$(EXEEXT):
    397         @$(CFACOMPILE) -fsyntax-only -w $(testdir)/concurrent/thread.cfa
     514        $(CFACOMPILE) -fsyntax-only -w $(testdir)/concurrent/thread.cfa
    398515
    399516compile-typeof$(EXEEXT):
    400         @$(CFACOMPILE) -fsyntax-only -w $(testdir)/typeof.cfa
     517        $(CFACOMPILE) -fsyntax-only -w $(testdir)/typeof.cfa
  • benchmark/Makefile.in

    raefb247 rbdfc032  
    9393EXTRA_PROGRAMS = dummy$(EXEEXT)
    9494@WITH_LIBFIBRE_TRUE@am__append_1 = \
    95 @WITH_LIBFIBRE_TRUE@    ctxswitch-kos_fibre.run  \
     95@WITH_LIBFIBRE_TRUE@    ctxswitch-kos_fibre.run         \
    9696@WITH_LIBFIBRE_TRUE@    ctxswitch-kos_fibre2.run
    9797
     
    358358am__v_CFA_0 = @echo "  CFA     " $@;
    359359am__v_CFA_1 =
    360 AM_V_JAVAC = $(am__v_JAVAC_@AM_V@)
    361 am__v_JAVAC_ = $(am__v_JAVAC_@AM_DEFAULT_V@)
    362 am__v_JAVAC_0 = @echo "  JAVAC   " $@;
    363 am__v_JAVAC_1 =
    364 AM_V_GOC = $(am__v_GOC_@AM_V@)
    365 am__v_GOC_ = $(am__v_GOC_@AM_DEFAULT_V@)
    366 am__v_GOC_0 = @echo "  GOC     " $@;
    367 am__v_GOC_1 =
    368360UPPCC = u++
    369361UPPCOMPILE = $(UPPCC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_UPPFLAGS) $(UPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_CFLAGS) $(CFLAGS)
     
    372364am__v_UPP_0 = @echo "  UPP     " $@;
    373365am__v_UPP_1 =
     366AM_V_GOC = $(am__v_GOC_@AM_V@)
     367am__v_GOC_ = $(am__v_GOC_@AM_DEFAULT_V@)
     368am__v_GOC_0 = @echo "  GOC     " $@;
     369am__v_GOC_1 =
     370AM_V_RUST = $(am__v_RUST_@AM_V@)
     371am__v_RUST_ = $(am__v_RUST_@AM_DEFAULT_V@)
     372am__v_RUST_0 = @echo "  RUST     " $@;
     373am__v_RUST_1 =
     374AM_V_NODEJS = $(am__v_NODEJS_@AM_V@)
     375am__v_NODEJS_ = $(am__v_NODEJS_@AM_DEFAULT_V@)
     376am__v_NODEJS_0 = @echo "  NODEJS     " $@;
     377am__v_NODEJS_1 =
     378AM_V_JAVAC = $(am__v_JAVAC_@AM_V@)
     379am__v_JAVAC_ = $(am__v_JAVAC_@AM_DEFAULT_V@)
     380am__v_JAVAC_0 = @echo "  JAVAC   " $@;
     381am__v_JAVAC_1 =
    374382
    375383# applies to both programs
     
    380388BENCH_V_CFA = $(__bench_v_CFA_$(__quiet))
    381389BENCH_V_CXX = $(__bench_v_CXX_$(__quiet))
     390BENCH_V_UPP = $(__bench_v_UPP_$(__quiet))
    382391BENCH_V_GOC = $(__bench_v_GOC_$(__quiet))
     392BENCH_V_RUSTC = $(__bench_v_RUSTC_$(__quiet))
     393BENCH_V_NODEJS = $(__bench_v_NODEJS_$(__quiet))
    383394BENCH_V_JAVAC = $(__bench_v_JAVAC_$(__quiet))
    384 BENCH_V_UPP = $(__bench_v_UPP_$(__quiet))
    385395__quiet = verbose
    386396__bench_v_CC_quiet = @
    387397__bench_v_CFA_quiet = @
    388398__bench_v_CXX_quiet = @
     399__bench_v_UPP_quiet = @
    389400__bench_v_GOC_quiet = @
     401__bench_v_RUSTC_quiet = @
    390402__bench_v_JAVAC_quiet = @
    391 __bench_v_UPP_quiet = @
    392403__bench_v_CC_verbose = $(AM_V_CC)
    393404__bench_v_CFA_verbose = $(AM_V_CFA)
    394405__bench_v_CXX_verbose = $(AM_V_CXX)
     406__bench_v_UPP_verbose = $(AM_V_UPP)
    395407__bench_v_GOC_verbose = $(AM_V_GOC)
     408__bench_v_RUSTC_verbose = $(AM_V_RUSTC)
     409__bench_v_NODEJS_verbose = $(AM_V_NODEJS)
    396410__bench_v_JAVAC_verbose = $(AM_V_JAVAC)
    397 __bench_v_UPP_verbose = $(AM_V_UPP)
    398411TOOLSDIR = ${abs_top_builddir}/tools/
    399412REPEAT = ${abs_top_builddir}/tools/repeat
    400413STATS = ${abs_top_srcdir}/tools/stat.py
    401414# NEED AT LEAST 4 DATA VALUES FOR BENCHMARKS BECAUSE THE MAX AND MIN VALUES ARE REMOVED
    402 repeats = 5 # 31 for benchmarks
     415repeats = 13 # 31 for benchmarks
    403416arch = x64
    404417skipcompile = no
     
    406419PRINT_FORMAT = %20s: #Comments needed for spacing
    407420dummy_SOURCES = dummyC.c dummyCXX.cpp
     421basic_loop_DURATION = 15000000000
     422basic_function_DURATION = 10000000000
     423basic_tls_fetch_add_DURATION = 10000000000
     424basic_DURATION = 250000000
     425ctxswitch_pthread_DURATION = 25000000
     426ctxswitch_rust_thread_DURATION = $(ctxswitch_pthread_DURATION)
     427ctxswitch_cfa_generator_DURATION = 5000000000
     428ctxswitch_nodejs_await_DURATION = 5000000
     429ctxswitch_DURATION = 100000000
     430
     431#mutex_java_DURATION = 10000000
     432mutex_DURATION = 50000000
     433schedint_pthread_DURATION = 1000000
     434schedint_java_DURATION = $(schedint_pthread_DURATION)
     435schedint_rust_DURATION = $(schedint_pthread_DURATION)
     436schedint_DURATION = 10000000
     437schedext_DURATION = 10000000
     438creation_pthread_DURATION = 250000
     439creation_rust_thread_DURATION = ${creation_pthread_DURATION}
     440creation_java_thread_DURATION = ${creation_pthread_DURATION}
     441creation_cfa_coroutine_DURATION = 100000000
     442creation_cfa_coroutine_eager_DURATION = 10000000
     443creation_upp_coroutine_DURATION = ${creation_cfa_coroutine_eager_DURATION}
     444creation_cfa_thread_DURATION = 10000000
     445creation_upp_thread_DURATION = ${creation_cfa_thread_DURATION}
     446creation_DURATION = 10000000
    408447FIX_NEW_LINES = cat $@ | tr "\n" "\t" | sed -r 's/\t,/,/' | tr "\t" "\n" > $@
    409 CTXSWITCH_DEPEND = loop.run function.run fetch_add.run ttst_lock.run \
    410         tls-fetch_add.run ctxswitch-pthread.run \
    411         ctxswitch-cfa_generator.run ctxswitch-cfa_coroutine.run \
    412         ctxswitch-cfa_thread.run ctxswitch-cfa_thread2.run \
    413         ctxswitch-upp_coroutine.run ctxswitch-upp_thread.run \
    414         ctxswitch-goroutine.run ctxswitch-java_thread.run \
    415         $(am__append_1)
     448BASIC_DEPEND = \
     449        basic-loop.run                          \
     450        basic-function.run                      \
     451        basic-fetch_add.run                     \
     452        basic-ttst_lock.run                     \
     453        basic-tls-fetch_add.run
     454
     455CTXSWITCH_DEPEND = ctxswitch-cfa_generator.run \
     456        ctxswitch-cfa_coroutine.run ctxswitch-cfa_thread.run \
     457        ctxswitch-cfa_thread2.run ctxswitch-upp_coroutine.run \
     458        ctxswitch-upp_thread.run ctxswitch-python_coroutine.run \
     459        ctxswitch-nodejs_coroutine.run ctxswitch-nodejs_await.run \
     460        ctxswitch-goroutine_thread.run ctxswitch-rust_thread.run \
     461        ctxswitch-nodejs_coroutine.run ctxswitch-java_thread.run \
     462        ctxswitch-pthread.run $(am__append_1)
    416463testdir = $(top_srcdir)/tests
    417464all: all-am
     
    732779
    733780dummyC.c:
    734         @echo "int main() { return 0; }" > ${@}
     781        echo "int main() { return 0; }" > ${@}
    735782
    736783dummyCXX.cpp:
    737         @echo "int main() { return 0; }" > ${@}
    738 
     784        echo "int main() { return 0; }" > ${@}
     785
     786#.SILENT:               # do not print recipe
     787.ONESHELL:              # use one shell to execute recipe
    739788.NOTPARALLEL:
    740 .PHONY: compile.csv ctxswitch.csv mutex.csv signal.csv
    741 
    742 all : ctxswitch$(EXEEXT) mutex$(EXEEXT) signal$(EXEEXT) waitfor$(EXEEXT) creation$(EXEEXT)
     789.PHONY: compile.csv basic.csv ctxswitch.csv mutex.csv schedint.csv
     790
     791all : basic$(EXEEXT) ctxswitch$(EXEEXT) mutex$(EXEEXT) schedint$(EXEEXT) schedext$(EXEEXT) creation$(EXEEXT)
    743792
    744793%.run : %$(EXEEXT) ${REPEAT}
    745         @rm -f .result.log
    746         @echo "------------------------------------------------------"
    747         @echo $<
    748         @${REPEAT} ${repeats} ./a.out | tee -a .result.log
    749         @${STATS} .result.log
    750         @echo "------------------------------------------------------"
    751         @rm -f a.out .result.log *.class
     794        rm -f .result.log
     795        echo "------------------------------------------------------"
     796        echo $<
     797        ${REPEAT} ${repeats} -- ./a.out\
     798                $(if ${$(subst -,_,$(basename $@))_DURATION},\
     799                        ${$(subst -,_,$(basename $@))_DURATION},\
     800                        ${$(firstword $(subst -, ,$(basename $@)))_DURATION}) | tee -a .result.log
     801        ${STATS} .result.log
     802        echo "------------------------------------------------------"
     803        rm -f a.out .result.log *.class
     804
     805#       ${REPEAT} ${repeats} -- /usr/bin/time -f "%Uu %Ss %Er %Mkb" ./a.out
    752806
    753807%.runquiet :
    754         @+make $(basename $@) CFLAGS="-w" __quiet=quiet
    755         @taskset -c 1 ./a.out
    756         @rm -f a.out
     808        +make $(basename $@) CFLAGS="-w" __quiet=quiet
     809        taskset -c 1 ./a.out
     810        rm -f a.out
    757811
    758812%.make :
    759         @printf "${PRINT_FORMAT}" $(basename $(subst compile-,,$@))
    760         @+/usr/bin/time -f ${TIME_FORMAT} make $(basename $@) 2>&1
     813        printf "${PRINT_FORMAT}" $(basename $(subst compile-,,$@))
     814        +/usr/bin/time -f ${TIME_FORMAT} make $(basename $@) 2>&1
    761815
    762816${REPEAT} :
    763         @+make -C ${abs_top_builddir}/tools repeat
     817        +make -C ${abs_top_builddir}/tools repeat
    764818
    765819jenkins$(EXEEXT):
    766820@DOifskipcompile@
    767         @+make compile.csv
    768         @-+make compile.diff.csv
     821        +make compile.csv
     822        -+make compile.diff.csv
    769823@DOendif@
    770         @+make ctxswitch.csv
    771         @-+make ctxswitch.diff.csv
    772         @+make mutex.csv
    773         @-+make mutex.diff.csv
    774         @+make signal.csv
    775         @-+make signal.diff.csv
     824        +make basic.csv
     825        -+make basic.diff.csv
     826        +make ctxswitch.csv
     827        -+make ctxswitch.diff.csv
     828        +make mutex.csv
     829        -+make mutex.diff.csv
     830        +make schedint.csv
     831        -+make schedint.diff.csv
    776832@DOifskipcompile@
    777833        cat compile.csv
    778834        -cat compile.diff.csv
    779835@DOendif@
     836        cat basic.csv
     837        -cat basic.diff.csv
    780838        cat ctxswitch.csv
    781839        -cat ctxswitch.diff.csv
    782840        cat mutex.csv
    783841        -cat mutex.diff.csv
    784         cat signal.csv
    785         -cat signal.diff.csv
     842        cat schedint.csv
     843        -cat schedint.diff.csv
    786844
    787845compile.csv:
    788         @echo "array,attributes,empty,expression,io,monitor,operators,typeof" > $@
    789         @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-array.make >> $@
    790         @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-attributes.make >> $@
    791         @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-empty.make >> $@
    792         @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-expression.make >> $@
    793         @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-io.make >> $@
    794         @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-monitor.make >> $@
    795         @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-operators.make >> $@
    796         @+make TIME_FORMAT='%e' PRINT_FORMAT='' compile-typeof.make >> $@
    797         @$(srcdir)/fixcsv.sh $@
     846        echo "array,attributes,empty,expression,io,monitor,operators,typeof" > $@
     847        +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-array.make >> $@
     848        +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-attributes.make >> $@
     849        +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-empty.make >> $@
     850        +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-expression.make >> $@
     851        +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-io.make >> $@
     852        +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-monitor.make >> $@
     853        +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-operators.make >> $@
     854        +make TIME_FORMAT='%e' PRINT_FORMAT='' compile-typeof.make >> $@
     855        $(srcdir)/fixcsv.sh $@
     856
     857basic.csv:
     858        echo "generator,coroutine,thread" > $@
     859        +make basic-cfa_generator.runquiet >> $@ && echo -n ',' >> $@
     860        +make basic-cfa_coroutine.runquiet >> $@ && echo -n ',' >> $@
     861        +make basic-cfa_thread.runquiet >> $@
     862        $(srcdir)/fixcsv.sh $@
    798863
    799864ctxswitch.csv:
    800         @echo "generator,coroutine,thread" > $@
    801         @+make ctxswitch-cfa_generator.runquiet >> $@ && echo -n ',' >> $@
    802         @+make ctxswitch-cfa_coroutine.runquiet >> $@ && echo -n ',' >> $@
    803         @+make ctxswitch-cfa_thread.runquiet >> $@
    804         @$(srcdir)/fixcsv.sh $@
     865        echo "generator,coroutine,thread" > $@
     866        +make ctxswitch-cfa_generator.runquiet >> $@ && echo -n ',' >> $@
     867        +make ctxswitch-cfa_coroutine.runquiet >> $@ && echo -n ',' >> $@
     868        +make ctxswitch-cfa_thread.runquiet >> $@
     869        $(srcdir)/fixcsv.sh $@
    805870
    806871mutex.csv:
    807         @echo "1-monitor,2-monitor" > $@
    808         @+make mutex-cfa1.runquiet >> $@ && echo -n ',' >> $@
    809         @+make mutex-cfa2.runquiet >> $@
    810         @$(srcdir)/fixcsv.sh $@
    811 
    812 signal.csv:
    813         @echo "signal-1,signal-2,waitfor-1,waitfor-2" > $@
    814         @+make signal-cfa1.runquiet >> $@ && echo -n ',' >> $@
    815         @+make signal-cfa2.runquiet >> $@ && echo -n ',' >> $@
    816         @+make waitfor-cfa1.runquiet >> $@ && echo -n ',' >> $@
    817         @+make waitfor-cfa2.runquiet >> $@
    818         @$(srcdir)/fixcsv.sh $@
     872        echo "1-monitor,2-monitor" > $@
     873        +make mutex-cfa1.runquiet >> $@ && echo -n ',' >> $@
     874        +make mutex-cfa2.runquiet >> $@
     875        $(srcdir)/fixcsv.sh $@
     876
     877schedint.csv:
     878        echo "schedint-1,schedint-2,schedext-1,schedext-2" > $@
     879        +make schedint-cfa1.runquiet >> $@ && echo -n ',' >> $@
     880        +make schedint-cfa2.runquiet >> $@ && echo -n ',' >> $@
     881        +make schedext-cfa1.runquiet >> $@ && echo -n ',' >> $@
     882        +make schedext-cfa2.runquiet >> $@
     883        $(srcdir)/fixcsv.sh $@
    819884
    820885%.diff.csv: %.csv
    821         @test -e $(srcdir)/baselines/$(arch)/$< || (echo "Error : Missing baseline for ${<}" && false)
    822         @$(srcdir)/baselines/calc.py $(srcdir)/baselines/$(arch)/$(<) $(<) > $@
    823 
    824 loop$(EXEEXT):
    825         $(BENCH_V_CC)$(COMPILE) -DBENCH_N=5000000000 $(srcdir)/loop.c
    826 
    827 function$(EXEEXT):
    828         $(BENCH_V_CC)$(COMPILE) -DBENCH_N=5000000000 $(srcdir)/function.c
    829 
    830 fetch_add$(EXEEXT):
    831         $(BENCH_V_CC)$(COMPILE) -DBENCH_N=500000000  $(srcdir)/fetch_add.c
    832 
    833 ttst_lock$(EXEEXT):
    834         $(BENCH_V_CC)$(COMPILE) -DBENCH_N=500000000  $(srcdir)/ttst_lock.c
    835 
    836 tls-fetch_add$(EXEEXT):
    837         $(BENCH_V_CC)$(COMPILE) -DBENCH_N=500000000  $(srcdir)/tls-fetch_add.c
     886        test -e $(srcdir)/baselines/$(arch)/$< || (echo "Error : Missing baseline for ${<}" && false)
     887        $(srcdir)/baselines/calc.py $(srcdir)/baselines/$(arch)/$(<) $(<) > $@
     888
     889basic-loop$(EXEEXT):
     890        $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/loop.c
     891
     892basic-function$(EXEEXT):
     893        $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/function.c
     894
     895basic-fetch_add$(EXEEXT):
     896        $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/fetch_add.c
     897
     898basic-ttst_lock$(EXEEXT):
     899        $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/ttst_lock.c
     900
     901basic-tls-fetch_add$(EXEEXT):
     902        $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/tls_fetch_add.c
     903
     904basic$(EXEEXT): $(BASIC_DEPEND)
    838905
    839906@WITH_LIBFIBRE_TRUE@ctxswitch-kos_fibre$(EXEEXT):
     
    845912ctxswitch$(EXEEXT): $(CTXSWITCH_DEPEND)
    846913
    847 ctxswitch-pthread$(EXEEXT):
    848         $(BENCH_V_CC)$(COMPILE)    -DBENCH_N=50000000 $(srcdir)/ctxswitch/pthreads.c
    849 
    850914ctxswitch-cfa_generator$(EXEEXT):
    851         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/cfa_gen.cfa
     915        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/ctxswitch/cfa_gen.cfa
    852916
    853917ctxswitch-cfa_coroutine$(EXEEXT):
    854         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/cfa_cor.cfa
     918        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/ctxswitch/cfa_cor.cfa
    855919
    856920ctxswitch-cfa_thread$(EXEEXT):
    857         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/cfa_thrd.cfa
     921        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/ctxswitch/cfa_thrd.cfa
    858922
    859923ctxswitch-cfa_thread2$(EXEEXT):
    860         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/cfa_thrd2.cfa
     924        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/ctxswitch/cfa_thrd2.cfa
    861925
    862926ctxswitch-upp_coroutine$(EXEEXT):
    863         $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/upp_cor.cc
     927        $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/ctxswitch/upp_cor.cc
    864928
    865929ctxswitch-upp_thread$(EXEEXT):
    866         $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/upp_thrd.cc
    867 
    868 ctxswitch-goroutine$(EXEEXT):
     930        $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/ctxswitch/upp_thrd.cc
     931
     932ctxswitch-python_coroutine$(EXEEXT):
     933        echo "#!/bin/sh" > a.out
     934        echo "python3.7 $(srcdir)/ctxswitch/python_cor.py" >> a.out
     935        chmod a+x a.out
     936
     937ctxswitch-nodejs_coroutine$(EXEEXT):
     938        echo "#!/bin/sh" > a.out
     939        echo "nodejs $(srcdir)/ctxswitch/node_cor.js" >> a.out
     940        chmod a+x a.out
     941
     942ctxswitch-nodejs_await$(EXEEXT):
     943        echo "#!/bin/sh" > a.out
     944        echo "nodejs $(srcdir)/ctxswitch/node_await.js" >> a.out
     945        chmod a+x a.out
     946
     947ctxswitch-goroutine_thread$(EXEEXT):
    869948        $(BENCH_V_GOC)go build -o a.out $(srcdir)/ctxswitch/goroutine.go
     949
     950ctxswitch-rust_thread$(EXEEXT):
     951        $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/ctxswitch/rust_thrd.rs
    870952
    871953ctxswitch-java_thread$(EXEEXT):
    872954        $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/ctxswitch/JavaThread.java
    873         @echo "#!/bin/sh" > a.out
    874         @echo "java JavaThread" >> a.out
    875         @chmod a+x a.out
    876 
    877 mutex$(EXEEXT) :\
    878         loop.run                        \
    879         function.run            \
    880         fetch_add.run           \
    881         mutex-pthread_lock.run  \
    882         mutex-upp.run           \
     955        echo "#!/bin/sh" > a.out
     956        echo "java JavaThread" >> a.out
     957        chmod a+x a.out
     958
     959ctxswitch-pthread$(EXEEXT):
     960        $(BENCH_V_CC)$(COMPILE) $(srcdir)/ctxswitch/pthreads.c
     961
     962mutex$(EXEEXT) :                \
    883963        mutex-cfa1.run          \
    884964        mutex-cfa2.run          \
    885965        mutex-cfa4.run          \
    886         mutex-java_thread.run
    887 
    888 mutex-pthread_lock$(EXEEXT):
    889         $(BENCH_V_CC)$(COMPILE)    -DBENCH_N=50000000 $(srcdir)/mutex/pthreads.c
     966        mutex-upp.run           \
     967        mutex-go.run            \
     968        mutex-rust.run          \
     969        mutex-java.run          \
     970        mutex-pthread.run
     971
     972mutex-pthread$(EXEEXT):
     973        $(BENCH_V_CC)$(COMPILE) $(srcdir)/mutex/pthreads.c
     974
     975mutex-cfa1$(EXEEXT):
     976        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutex/cfa1.cfa
     977
     978mutex-cfa2$(EXEEXT):
     979        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutex/cfa2.cfa
     980
     981mutex-cfa4$(EXEEXT):
     982        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutex/cfa4.cfa
    890983
    891984mutex-upp$(EXEEXT):
    892         $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/mutex/upp.cc
    893 
    894 mutex-cfa1$(EXEEXT):
    895         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=5000000  $(srcdir)/mutex/cfa1.cfa
    896 
    897 mutex-cfa2$(EXEEXT):
    898         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=5000000  $(srcdir)/mutex/cfa2.cfa
    899 
    900 mutex-cfa4$(EXEEXT):
    901         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=5000000  $(srcdir)/mutex/cfa4.cfa
    902 
    903 mutex-java_thread$(EXEEXT):
     985        $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/mutex/upp.cc
     986
     987mutex-go$(EXEEXT):
     988        $(BENCH_V_GOC)go build -o a.out $(srcdir)/mutex/goroutine.go
     989
     990mutex-rust$(EXEEXT):
     991        $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/mutex/rust.rs
     992
     993mutex-java$(EXEEXT):
    904994        $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/mutex/JavaThread.java
    905         @echo "#!/bin/sh" > a.out
    906         @echo "java JavaThread" >> a.out
    907         @chmod a+x a.out
    908 
    909 signal$(EXEEXT) :\
    910         signal-pthread_cond.run \
    911         signal-upp.run          \
    912         signal-cfa1.run         \
    913         signal-cfa2.run         \
    914         signal-cfa4.run         \
    915         signal-java_thread.run
    916 
    917 signal-pthread_cond$(EXEEXT):
    918         $(BENCH_V_CC)$(COMPILE)    -DBENCH_N=500000  $(srcdir)/schedint/pthreads.c
    919 
    920 signal-upp$(EXEEXT):
    921         $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=5000000 $(srcdir)/schedint/upp.cc
    922 
    923 signal-cfa1$(EXEEXT):
    924         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000  $(srcdir)/schedint/cfa1.cfa
    925 
    926 signal-cfa2$(EXEEXT):
    927         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000  $(srcdir)/schedint/cfa2.cfa
    928 
    929 signal-cfa4$(EXEEXT):
    930         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000  $(srcdir)/schedint/cfa4.cfa
    931 
    932 signal-java_thread$(EXEEXT):
     995        echo "#!/bin/sh" > a.out
     996        echo "java JavaThread" >> a.out
     997        chmod a+x a.out
     998
     999schedint$(EXEEXT) :             \
     1000        schedint-cfa1.run       \
     1001        schedint-cfa2.run       \
     1002        schedint-cfa4.run       \
     1003        schedint-upp.run        \
     1004        schedint-rust.run       \
     1005        schedint-java.run       \
     1006        schedint-pthread.run
     1007
     1008schedint-cfa1$(EXEEXT):
     1009        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedint/cfa1.cfa
     1010
     1011schedint-cfa2$(EXEEXT):
     1012        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedint/cfa2.cfa
     1013
     1014schedint-cfa4$(EXEEXT):
     1015        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedint/cfa4.cfa
     1016
     1017schedint-upp$(EXEEXT):
     1018        $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/schedint/upp.cc
     1019
     1020schedint-rust$(EXEEXT):
     1021        $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/schedint/rust.rs
     1022
     1023schedint-java$(EXEEXT):
    9331024        $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/schedint/JavaThread.java
    934         @echo "#!/bin/sh" > a.out
    935         @echo "java JavaThread" >> a.out
    936         @chmod a+x a.out
    937 
    938 waitfor$(EXEEXT) :\
    939         waitfor-upp.run         \
    940         waitfor-cfa1.run                \
    941         waitfor-cfa2.run                \
    942         waitfor-cfa4.run
    943 
    944 waitfor-upp$(EXEEXT):
    945         $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=5000000 $(srcdir)/schedext/upp.cc
    946 
    947 waitfor-cfa1$(EXEEXT):
    948         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000  $(srcdir)/schedext/cfa1.cfa
    949 
    950 waitfor-cfa2$(EXEEXT):
    951         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000  $(srcdir)/schedext/cfa2.cfa
    952 
    953 waitfor-cfa4$(EXEEXT):
    954         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000  $(srcdir)/schedext/cfa4.cfa
    955 
    956 creation$(EXEEXT) :\
    957         creation-pthread.run                    \
     1025        echo "#!/bin/sh" > a.out
     1026        echo "java JavaThread" >> a.out
     1027        chmod a+x a.out
     1028
     1029schedint-pthread$(EXEEXT):
     1030        $(BENCH_V_CC)$(COMPILE) $(srcdir)/schedint/pthreads.c
     1031
     1032schedext$(EXEEXT) :             \
     1033        schedext-cfa1.run       \
     1034        schedext-cfa2.run       \
     1035        schedext-cfa4.run       \
     1036        schedext-upp.run        \
     1037        schedext-goroutine.run
     1038
     1039schedext-cfa1$(EXEEXT):
     1040        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedext/cfa1.cfa
     1041
     1042schedext-cfa2$(EXEEXT):
     1043        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedext/cfa2.cfa
     1044
     1045schedext-cfa4$(EXEEXT):
     1046        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedext/cfa4.cfa
     1047
     1048schedext-upp$(EXEEXT):
     1049        $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/schedext/upp.cc
     1050
     1051schedext-goroutine$(EXEEXT):
     1052        $(BENCH_V_GOC)go build -o a.out $(srcdir)/schedext/goroutine.go
     1053
     1054creation$(EXEEXT) :                             \
     1055        creation-cfa_generator.run              \
    9581056        creation-cfa_coroutine.run              \
    9591057        creation-cfa_coroutine_eager.run        \
     
    9611059        creation-upp_coroutine.run              \
    9621060        creation-upp_thread.run                 \
    963         creation-goroutine.run                  \
    964         creation-java_thread.run
     1061        creation-python_coroutine.run           \
     1062        creation-nodejs_coroutine.run           \
     1063        creation-goroutine_thread.run           \
     1064        creation-rust_thread.run                \
     1065        creation-java_thread.run                \
     1066        creation-pthread.run
     1067
     1068creation-cfa_generator$(EXEEXT):
     1069        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_gen.cfa
    9651070
    9661071creation-cfa_coroutine$(EXEEXT):
    967         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=10000000 $(srcdir)/creation/cfa_cor.cfa
     1072        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_cor.cfa
    9681073
    9691074creation-cfa_coroutine_eager$(EXEEXT):
    970         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=10000000 $(srcdir)/creation/cfa_cor.cfa  -DEAGER
     1075        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_cor.cfa  -DEAGER
    9711076
    9721077creation-cfa_thread$(EXEEXT):
    973         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=10000000 $(srcdir)/creation/cfa_thrd.cfa
     1078        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_thrd.cfa
    9741079
    9751080creation-upp_coroutine$(EXEEXT):
    976         $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/creation/upp_cor.cc
     1081        $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/creation/upp_cor.cc
    9771082
    9781083creation-upp_thread$(EXEEXT):
    979         $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/creation/upp_thrd.cc
    980 
    981 creation-pthread$(EXEEXT):
    982         $(BENCH_V_CC)$(COMPILE)    -DBENCH_N=250000   $(srcdir)/creation/pthreads.c
    983 
    984 creation-goroutine$(EXEEXT):
     1084        $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/creation/upp_thrd.cc
     1085
     1086creation-python_coroutine$(EXEEXT):
     1087        echo "#!/bin/sh" > a.out
     1088        echo "python3.7 $(srcdir)/creation/python_cor.py" >> a.out
     1089        chmod a+x a.out
     1090
     1091creation-nodejs_coroutine$(EXEEXT):
     1092        echo "#!/bin/sh" > a.out
     1093        echo "nodejs $(srcdir)/creation/node_cor.js" >> a.out
     1094        chmod a+x a.out
     1095
     1096creation-goroutine_thread$(EXEEXT):
    9851097        $(BENCH_V_GOC)go build -o a.out $(srcdir)/creation/goroutine.go
     1098
     1099creation-rust_thread$(EXEEXT):
     1100        $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/creation/rust_thrd.rs
    9861101
    9871102creation-java_thread$(EXEEXT):
    9881103        $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/creation/JavaThread.java
    989         @echo "#!/bin/sh" > a.out
    990         @echo "java JavaThread" >> a.out
    991         @chmod a+x a.out
    992 
    993 compile$(EXEEXT) :\
     1104        echo "#!/bin/sh" > a.out
     1105        echo "java JavaThread" >> a.out
     1106        chmod a+x a.out
     1107
     1108creation-pthread$(EXEEXT):
     1109        $(BENCH_V_CC)$(COMPILE) $(srcdir)/creation/pthreads.c
     1110
     1111compile$(EXEEXT) :              \
    9941112        compile-array.make      \
    9951113        compile-attributes.make \
     
    10021120
    10031121compile-array$(EXEEXT):
    1004         @$(CFACOMPILE) -fsyntax-only -w $(testdir)/array.cfa
     1122        $(CFACOMPILE) -fsyntax-only -w $(testdir)/array.cfa
    10051123
    10061124compile-attributes$(EXEEXT):
    1007         @$(CFACOMPILE) -fsyntax-only -w $(testdir)/attributes.cfa
     1125        $(CFACOMPILE) -fsyntax-only -w $(testdir)/attributes.cfa
    10081126
    10091127compile-empty$(EXEEXT):
    1010         @$(CFACOMPILE) -fsyntax-only -w $(srcdir)/compile/empty.cfa
     1128        $(CFACOMPILE) -fsyntax-only -w $(srcdir)/compile/empty.cfa
    10111129
    10121130compile-expression$(EXEEXT):
    1013         @$(CFACOMPILE) -fsyntax-only -w $(testdir)/expression.cfa
     1131        $(CFACOMPILE) -fsyntax-only -w $(testdir)/expression.cfa
    10141132
    10151133compile-io$(EXEEXT):
    1016         @$(CFACOMPILE) -fsyntax-only -w $(testdir)/io1.cfa
     1134        $(CFACOMPILE) -fsyntax-only -w $(testdir)/io1.cfa
    10171135
    10181136compile-monitor$(EXEEXT):
    1019         @$(CFACOMPILE) -fsyntax-only -w $(testdir)/concurrent/monitor.cfa
     1137        $(CFACOMPILE) -fsyntax-only -w $(testdir)/concurrent/monitor.cfa
    10201138
    10211139compile-operators$(EXEEXT):
    1022         @$(CFACOMPILE) -fsyntax-only -w $(testdir)/operators.cfa
     1140        $(CFACOMPILE) -fsyntax-only -w $(testdir)/operators.cfa
    10231141
    10241142compile-thread$(EXEEXT):
    1025         @$(CFACOMPILE) -fsyntax-only -w $(testdir)/concurrent/thread.cfa
     1143        $(CFACOMPILE) -fsyntax-only -w $(testdir)/concurrent/thread.cfa
    10261144
    10271145compile-typeof$(EXEEXT):
    1028         @$(CFACOMPILE) -fsyntax-only -w $(testdir)/typeof.cfa
     1146        $(CFACOMPILE) -fsyntax-only -w $(testdir)/typeof.cfa
    10291147
    10301148# Tell versions [3.59,3.63) of GNU make to not export all variables.
  • benchmark/bench.h

    raefb247 rbdfc032  
    55#endif
    66        #include <stdlib.h>
    7         #include <unistd.h>                                     // sysconf
     7        #include <stdint.h>                             // uint64_t
     8        #include <unistd.h>                             // sysconf
    89#if ! defined(__cforall)
    910        #include <time.h>
     
    1516
    1617
    17 static inline unsigned long long int bench_time() {
    18     struct timespec ts;
    19     clock_gettime(
    20 #if defined( __linux__ )
    21          CLOCK_THREAD_CPUTIME_ID,
    22 #elif defined( __freebsd__ )
    23          CLOCK_PROF,
    24 #elif defined( __solaris__ )
    25          CLOCK_HIGHRES,
    26 #else
    27     #error uC++ : internal error, unsupported architecture
    28 #endif
    29          &ts );
    30     return 1000000000LL * ts.tv_sec + ts.tv_nsec;
    31 } // Time
     18static inline uint64_t bench_time() {
     19        struct timespec ts;
     20        clock_gettime( CLOCK_THREAD_CPUTIME_ID, &ts );
     21        return 1000000000LL * ts.tv_sec + ts.tv_nsec;
     22} // bench_time
    3223
    3324#ifndef BENCH_N
    34 #define BENCH_N 500 //10000000
     25#define BENCH_N 10000000
    3526#endif
    3627
     28size_t times = BENCH_N;
     29
     30#define BENCH_START()                           \
     31        if ( argc > 2 ) exit( EXIT_FAILURE );   \
     32        if ( argc == 2 ) {                      \
     33                times = atoi( argv[1] );        \
     34        }
     35
    3736#define BENCH(statement, output)                \
    38         size_t n = BENCH_N;                     \
    39         if( argc > 2 ) return 1;                \
    40         if( argc == 2 ) {                               \
    41                 n = atoi(argv[1]);              \
    42         }                                               \
    43         long long int StartTime, EndTime;       \
     37        uint64_t StartTime, EndTime;            \
    4438        StartTime = bench_time();               \
    45         statement;                                      \
     39        statement;                              \
    4640        EndTime = bench_time();                 \
    47         double output =         \
    48             (double)( EndTime - StartTime ) / n;
     41        double output = (double)( EndTime - StartTime ) / times;
     42
    4943
    5044#if defined(__cforall)
     
    5347}
    5448#endif
     49#if defined(__U_CPLUSPLUS__)
     50unsigned int uDefaultPreemption() {
     51        return 0;
     52}
     53#endif
  • benchmark/creation/JavaThread.java

    raefb247 rbdfc032  
    2626        static int x = 2;
    2727
    28         static private final int NoOfTimes = Integer.parseInt("10000") ;
     28        static private int times = Integer.parseInt("10000") ;
    2929
    3030        public static class MyThread extends Thread {
     
    3333        }
    3434        public static void helper() throws InterruptedException {
    35                 for(int i = 1; i <= NoOfTimes; i += 1) {
     35                for(int i = 1; i <= times; i += 1) {
    3636                        MyThread m = new MyThread();
    3737                        x = nextRandom( x );
     
    4444                helper();
    4545                long end = System.nanoTime();
    46                 System.out.println( (end - start) / NoOfTimes );
     46                System.out.println( (end - start) / times );
    4747        }
    4848        public static void main(String[] args) throws InterruptedException {
    49                 for (int n = Integer.parseInt("5"); --n >= 0 ; ) {
     49                if ( args.length > 2 ) System.exit( 1 );
     50                if ( args.length == 2 ) { times = Integer.parseInt(args[1]); }
     51
     52                for (int i = Integer.parseInt("5"); --i >= 0 ; ) {
    5053                        InnerMain();
    51                         Thread.sleep(2000);     // 2 seconds
     54                        Thread.sleep(2000);             // 2 seconds
    5255                        x = nextRandom(x);
    5356                }
     
    5558        }
    5659}
     60
     61// Local Variables: //
     62// tab-width: 4 //
     63// End: //
  • benchmark/creation/cfa_cor.cfa

    raefb247 rbdfc032  
    55
    66coroutine MyCoroutine {};
    7 void ?{} (MyCoroutine & this) {
     7void ?{}( MyCoroutine & this ) {
    88#ifdef EAGER
    9         resume(this);
     9        resume( this );
    1010#endif
    1111}
    12 void main(MyCoroutine &) {}
     12void main( MyCoroutine & ) {}
    1313
    14 int main(int argc, char* argv[]) {
     14int main( int argc, char * argv[] ) {
     15        BENCH_START()
    1516        BENCH(
    16                 for ( i; n ) {
    17                         MyCoroutine m;
     17                for ( times ) {
     18                        MyCoroutine c;
    1819                },
    1920                result
    2021        )
     22        printf( "%g\n", result );
     23}
    2124
    22         printf("%g\n", result);
    23 }
     25// Local Variables: //
     26// tab-width: 4 //
     27// End: //
  • benchmark/creation/cfa_thrd.cfa

    raefb247 rbdfc032  
    77void main(MyThread &) {}
    88
    9 int main(int argc, char* argv[]) {
     9int main( int argc, char * argv[] ) {
     10        BENCH_START()
    1011        BENCH(
    11                 for ( i; n ) {
     12                for ( times ) {
    1213                        MyThread m;
    1314                },
    1415                result
    1516        )
     17        printf( "%g\n", result );
     18}
    1619
    17         printf("%g\n", result);
    18 }
     20// Local Variables: //
     21// tab-width: 4 //
     22// End: //
  • benchmark/creation/goroutine.go

    raefb247 rbdfc032  
    22
    33import (
    4     "fmt"
    5     "time"
     4        "fmt"
     5        "time"
     6        "os"
     7        "strconv"
    68)
    79
     
    1719
    1820func main() {
    19         const NoOfTimes = 500000
     21        var times int = 10000000
     22        if len( os.Args ) > 2 { os.Exit( 1 ) }
     23        if len( os.Args ) == 2 { times, _ = strconv.Atoi(os.Args[1]) }
     24
    2025        start := time.Now()
    21         for i := 1; i <= NoOfTimes; i += 1 {
     26        for i := 1; i <= times; i += 1 {
    2227                go noop()               // creation
     28                <- shake                // wait for completion
    2329        }
    2430        end := time.Now()
    25         fmt.Printf("%d\n", end.Sub(start) / time.Duration(NoOfTimes))
    26         <- shake
     31        fmt.Printf( "%d\n", end.Sub(start) / time.Duration(times) )
    2732}
     33
     34// Local Variables: //
     35// tab-width: 4 //
     36// End: //
  • benchmark/creation/pthreads.c

    raefb247 rbdfc032  
    44#include "bench.h"
    55
    6 static void *foo(void *arg) {
     6static void * foo(void *arg) {
    77    return arg;
    88}
    99
    10 int main(int argc, char* argv[]) {
     10int main( int argc, char * argv[] ) {
     11        BENCH_START()
    1112        BENCH(
    12                 for (size_t i = 0; i < n; i++) {
     13                for (size_t i = 0; i < times; i++) {
    1314                        pthread_t thread;
    1415                        if (pthread_create(&thread, NULL, foo, NULL) < 0) {
     
    1617                                return 1;
    1718                        }
    18 
    1919                        if (pthread_join( thread, NULL) < 0) {
    2020                                perror( "failure" );
     
    2424                result
    2525        )
     26        printf( "%g\n", result );
     27}
    2628
    27         printf("%g\n", result);
    28 }
     29// Local Variables: //
     30// tab-width: 4 //
     31// End: //
  • benchmark/creation/upp_cor.cc

    raefb247 rbdfc032  
    55_Coroutine MyCor {
    66        void main() {}
     7  public:
     8        MyCor() { resume(); }
    79};
    810
    9 int main(int argc, char* argv[]) {
     11int main( int argc, char * argv[] ) {
     12        BENCH_START()
    1013        BENCH(
    11                 for (size_t i = 0; i < n; i++) {
     14                for (size_t i = 0; i < times; i++) {
    1215                        MyCor m;
    1316                },
    1417                result
    1518        )
     19        printf( "%g\n", result );
     20}
    1621
    17         printf("%g\n", result);
    18 }
     22// Local Variables: //
     23// tab-width: 4 //
     24// End: //
  • benchmark/creation/upp_thrd.cc

    raefb247 rbdfc032  
    77};
    88
    9 int main(int argc, char* argv[]) {
     9int main( int argc, char * argv[] ) {
     10        BENCH_START()
    1011        BENCH(
    11                 for (size_t i = 0; i < n; i++) {
     12                for (size_t i = 0; i < times; i++) {
    1213                        MyThread m;
    1314                },
    1415                result
    1516        )
     17        printf( "%g\n", result );
     18}
    1619
    17         printf("%g\n", result);
    18 }
     20// Local Variables: //
     21// tab-width: 4 //
     22// End: //
  • benchmark/ctxswitch/JavaThread.java

    raefb247 rbdfc032  
    2626        static int x = 2;
    2727
    28         static private final int NoOfTimes = Integer.parseInt("1000000") ;
     28        static private int times = Integer.parseInt("100000");
    2929
    3030        public static void helper() {
    31                 for(int i = 1; i <= NoOfTimes; i += 1) {
     31                for(int i = 1; i <= times; i += 1) {
    3232                        Thread.yield();
    3333                }
     
    3737                helper();
    3838                long end = System.nanoTime();
    39                 System.out.println( (end - start) / NoOfTimes );
     39                System.out.println( (end - start) / times );
    4040        }
    4141        public static void main(String[] args) throws InterruptedException {
    42                 for (int n = Integer.parseInt("5"); --n >= 0 ; ) {
     42                if ( args.length > 2 ) System.exit( 1 );
     43                if ( args.length == 2 ) { times = Integer.parseInt(args[1]); }
     44
     45                for (int i = Integer.parseInt("5"); --i >= 0 ; ) {
    4346                        InnerMain();
    44                         Thread.sleep(2000);     // 2 seconds
     47                        Thread.sleep(2000);     // 2 seconds
    4548                        x = nextRandom(x);
    4649                }
     
    4851        }
    4952}
     53
     54// Local Variables: //
     55// tab-width: 4 //
     56// End: //
  • benchmark/ctxswitch/cfa_cor.cfa

    raefb247 rbdfc032  
    44#include "bench.h"
    55
    6 coroutine GreatSuspender {};
    7 
    8 void ?{}( GreatSuspender & this ) {
    9         prime(this);
    10 }
    11 
    12 void main( __attribute__((unused)) GreatSuspender & this ) {
    13         while( true ) {
     6coroutine C {} c;
     7void main( __attribute__((unused)) C & ) {
     8        while () {
    149                suspend();
    1510        }
    1611}
    17 
    18 int main(int argc, char* argv[]) {
    19         GreatSuspender s;
    20 
     12int main( int argc, char * argv[] ) {
     13        BENCH_START()
    2114        BENCH(
    22                 for ( i; n ) {
    23                         resume( s );
     15                for ( times ) {
     16                        resume( c );
    2417                },
    2518                result
    2619        )
     20        printf( "%g\n", result );
     21}
    2722
    28         printf("%g\n", result);
    29 }
     23// Local Variables: //
     24// tab-width: 4 //
     25// End: //
  • benchmark/ctxswitch/cfa_cor_then.cfa

    raefb247 rbdfc032  
    66void noOp(void) {}
    77
    8 coroutine GreatSuspender {};
     8coroutine C {} c;
    99
    10 void ?{}( GreatSuspender & this ) {
     10void ?{}( C & this ) {
    1111        prime(this);
    1212}
    1313
    14 void main( __attribute__((unused)) GreatSuspender & this ) {
    15         while( true ) {
     14void main( __attribute__((unused)) C & this ) {
     15        while () {
    1616                suspend_then(noOp);
    1717        }
    1818}
    1919
    20 int main(int argc, char* argv[]) {
    21         GreatSuspender s;
    22 
     20int main( int argc, char * argv[] ) {
     21        BENCH_START()
    2322        BENCH(
    24                 for ( i; n ) {
    25                         resume( s );
     23                for ( times ) {
     24                        resume( c );
    2625                },
    2726                result
    2827        )
     28        printf( "%g\n", result );
     29}
    2930
    30         printf("%g\n", result);
    31 }
     31// Local Variables: //
     32// tab-width: 4 //
     33// End: //
  • benchmark/ctxswitch/cfa_gen.cfa

    raefb247 rbdfc032  
    33typedef struct {
    44        void * next;
    5 } GreatSuspender;
     5} C;
    66
    7 void comain( GreatSuspender * this ) {
    8     if ( __builtin_expect(this->next != 0, 1) ) goto *(this->next);
    9     this->next = &&s1;
     7void comain( C * c ) {
     8        if ( __builtin_expect(c->next != 0, 1) ) goto *(c->next);
     9        c->next = &&s1;
    1010        for () {
    11             return;
     11                return;
    1212          s1: ;
    1313        }
    1414}
    1515
    16 int main(int argc, char* argv[]) {
    17     GreatSuspender s = { 0 };
    18 
     16int main( int argc, char * argv[] ) {
     17        BENCH_START()
     18        C c = { 0 };
    1919        BENCH(
    20                 for ( i; n ) {
    21                         comain( &s );
     20                for ( times ) {
     21                        comain( &c );
    2222                },
    2323                result
    2424        )
     25        printf( "%g\n", result );
     26}
    2527
    26         printf("%g\n", result);
    27 }
     28// Local Variables: //
     29// tab-width: 4 //
     30// End: //
  • benchmark/ctxswitch/cfa_thrd.cfa

    raefb247 rbdfc032  
    33#include "bench.h"
    44
    5 int main(int argc, char* argv[]) {
     5int main( int argc, char * argv[] ) {
     6        BENCH_START()
    67        BENCH(
    7                 for ( i; n ) {
     8                for ( times ) {
    89                        yield();
    910                },
    1011                result
    1112        )
     13        printf( "%g\n", result );
     14}
    1215
    13         printf("%g\n", result);
    14 }
     16// Local Variables: //
     17// tab-width: 4 //
     18// End: //
  • benchmark/ctxswitch/cfa_thrd2.cfa

    raefb247 rbdfc032  
    88
    99void main(__attribute__((unused)) Fibre & this) {
    10         while(!done) {
     10        while ( ! done ) {
    1111                yield();
    1212        }
    1313}
    1414
    15 int main(int argc, char* argv[]) {
     15int main( int argc, char * argv[] ) {
     16        BENCH_START()
    1617        Fibre f1;
    1718        BENCH(
    18                 for ( i; n ) {
     19                for ( times ) {
    1920                        yield();
    2021                },
    2122                result
    2223        )
     24        printf( "%g\n", result );
     25        done = true;
     26}
    2327
    24         printf("%g\n", result);
    25         done = true;
    26         return 0;
    27 }
     28// Local Variables: //
     29// tab-width: 4 //
     30// End: //
  • benchmark/ctxswitch/goroutine.go

    raefb247 rbdfc032  
    22
    33import (
    4     "fmt"
    5     "runtime"
    6     "time"
     4        "fmt"
     5        "time"
     6        "os"
     7        "strconv"
     8        "runtime"
    79)
    810
     
    2830
    2931func main() {
    30         const NoOfTimes = 10000000
    31         go ContextSwitch( NoOfTimes )           // context switch
     32        var times int = 10000000
     33        if len( os.Args ) > 2 { os.Exit( 1 ) }
     34        if len( os.Args ) == 2 { times, _ = strconv.Atoi(os.Args[1]) }
     35        go ContextSwitch( times )               // context switch
    3236        <- shake
    3337}
     38
     39// Local Variables: //
     40// tab-width: 4 //
     41// End: //
  • benchmark/ctxswitch/kos_fibre.cpp

    raefb247 rbdfc032  
    33#include "bench.h"
    44
    5 int main(int argc, char* argv[]) {
     5int main( int argc, char * argv[] ) {
     6        BENCH_START()
    67        BENCH(
    7                 for (size_t i = 0; i < n; i++) {
     8                for (size_t i = 0; i < times; i++) {
    89                        Fibre::yield();
    910                },
    1011                result
    1112        )
    12         printf("%g\n", result);
    13         return 0;
     13        printf( "%g\n", result );
    1414}
     15
     16// Local Variables: //
     17// tab-width: 4 //
     18// End: //
  • benchmark/ctxswitch/kos_fibre2.cpp

    raefb247 rbdfc032  
    1111}
    1212
    13 int main(int argc, char* argv[]) {
     13int main( int argc, char * argv[] ) {
     14        BENCH_START()
    1415        Fibre* f1 = (new Fibre)->run(f1main);
    1516        BENCH(
    16                 for (size_t i = 0; i < n; i++) {
     17                for (size_t i = 0; i < times; i++) {
    1718                        Fibre::yield();
    1819                },
    1920                result
    2021        )
    21         printf("%g\n", result);
     22        printf( "%g\n", result );
    2223        done = true;
    2324        Fibre::yield();
    2425        f1->join();
    25         return 0;
    2626}
     27
     28// Local Variables: //
     29// tab-width: 4 //
     30// End: //
  • benchmark/ctxswitch/pthreads.c

    raefb247 rbdfc032  
    66#include "bench.h"
    77
    8 int main(int argc, char* argv[]) {
     8int main( int argc, char * argv[] ) {
     9        BENCH_START()
    910        BENCH(
    10                 for (size_t i = 0; i < n; i++) {
     11                for (size_t i = 0; i < times; i++) {
    1112                        sched_yield();
    1213                },
    1314                result
    1415        )
    15 
    16         printf("%g\n", result);
     16        printf( "%g\n", result );
    1717}
  • benchmark/ctxswitch/upp_cor.cc

    raefb247 rbdfc032  
    33#include "bench.h"
    44
    5 _Coroutine GreatSuspender {
    6 public:
    7         GreatSuspender() {
    8                 resume();
    9         }
    10 
    11         void do_resume() {
    12                 resume();
    13         }
    14 private:
     5_Coroutine C {
    156        void main() {
    167                while( true ) {
     
    189                }
    1910        }
    20 };
    21 
    22 int main(int argc, char* argv[]) {
    23         GreatSuspender s;
    24 
     11  public:
     12        void do_resume() {
     13                resume();
     14        }
     15} c;
     16int main( int argc, char * argv[] ) {
     17        BENCH_START()
    2518        BENCH(
    26                 for (size_t i = 0; i < n; i++) {
    27                         s.do_resume();
     19                for (size_t i = 0; i < times; i++) {
     20                        c.do_resume();
    2821                },
    2922                result
    3023        )
     24        printf( "%g\n", result );
     25}
    3126
    32         printf("%g\n", result);
    33 }
     27// Local Variables: //
     28// tab-width: 4 //
     29// End: //
  • benchmark/ctxswitch/upp_thrd.cc

    raefb247 rbdfc032  
    33#include "bench.h"
    44
    5 int main(int argc, char* argv[]) {
     5int main( int argc, char * argv[] ) {
     6        BENCH_START()
    67        BENCH(
    7                 for (size_t i = 0; i < n; i++) {
     8                for (size_t i = 0; i < times; i++) {
    89                        uThisTask().yield();
    910                },
    1011                result
    1112        )
     13        printf( "%g\n", result );
     14}
    1215
    13         printf("%g\n", result);
    14 }
     16// Local Variables: //
     17// tab-width: 4 //
     18// End: //
  • benchmark/mutex/JavaThread.java

    raefb247 rbdfc032  
    2626        static int x = 2;
    2727
    28         static private final int NoOfTimes = Integer.parseInt("100000000") ;
     28        static private int times = Integer.parseInt("100000000");
    2929
    3030        public synchronized void noop() {
     
    3535                // Inhibit biased locking ...
    3636                x = (j.hashCode() ^ System.identityHashCode(j)) | 1 ;     
    37                 for(int i = 1; i <= NoOfTimes; i += 1) {
     37                for(int i = 1; i <= times; i += 1) {
    3838                        x = nextRandom(x);
    3939                        j.noop();
     
    4444                helper();
    4545                long end = System.nanoTime();
    46                 System.out.println( (end - start) / NoOfTimes );
     46                System.out.println( (end - start) / times );
    4747        }
    4848        public static void main(String[] args) throws InterruptedException {
     49                if ( args.length > 2 ) System.exit( 1 );
     50                if ( args.length == 2 ) { times = Integer.parseInt(args[1]); }
     51
    4952                for (int n = Integer.parseInt("5"); --n >= 0 ; ) {
    5053                        InnerMain();
     
    5558        }
    5659}
     60
     61// Local Variables: //
     62// tab-width: 4 //
     63// End: //
  • benchmark/mutex/cfa1.cfa

    raefb247 rbdfc032  
    44#include "bench.h"
    55
    6 monitor M {};
    7 void __attribute__((noinline)) call( M & mutex m ) {}
     6monitor M {} m1;
     7void __attribute__((noinline)) call( M & mutex p1 ) {}
    88
    9 int main(int argc, char* argv[]) {
    10         M m;
     9int main( int argc, char * argv[] ) {
     10        BENCH_START()
    1111        BENCH(
    12                 for ( i; n ) {
    13                         call(m);
     12                for ( times ) {
     13                        call( m1 );
    1414                },
    1515                result
    1616        )
     17        printf( "%g\n", result );
     18}
    1719
    18         printf("%g\n", result);
    19 }
     20// Local Variables: //
     21// tab-width: 4 //
     22// End: //
  • benchmark/mutex/cfa2.cfa

    raefb247 rbdfc032  
    44#include "bench.h"
    55
    6 monitor M {};
    7 void __attribute__((noinline)) call( M & mutex m1, M & mutex m2 ) {}
     6monitor M {} m1, m2;
    87
    9 int main(int argc, char* argv[]) {
    10         M m1, m2;
     8void __attribute__((noinline)) call( M & mutex p1, M & mutex p2 ) {}
     9
     10int main( int argc, char * argv[] ) {
     11        BENCH_START()
    1112        BENCH(
    12                 for ( i; n ) {
    13                         call(m1, m2);
     13                for ( times ) {
     14                        call( m1, m2 );
    1415                },
    1516                result
    1617        )
     18        printf( "%g\n", result );
     19}
    1720
    18         printf("%g\n", result);
    19 }
     21// Local Variables: //
     22// tab-width: 4 //
     23// End: //
  • benchmark/mutex/cfa4.cfa

    raefb247 rbdfc032  
    55
    66
    7 monitor M {};
    8 void __attribute__((noinline)) call( M & mutex m1, M & mutex m2, M & mutex m3, M & mutex m4 ) {}
     7monitor M {} m1, m2, m3, m4;
     8void __attribute__((noinline)) call( M & mutex p1, M & mutex p2, M & mutex p3, M & mutex p4 ) {}
    99
    10 int main(int argc, char* argv[]) {
    11         M m1, m2, m3, m4;
     10int main( int argc, char * argv[] ) {
     11        BENCH_START()
    1212        BENCH(
    13                 for ( i; n ) {
    14                         call(m1, m2, m3, m4);
     13                for ( times ) {
     14                        call( m1, m2, m3, m4 );
    1515                },
    1616                result
    1717        )
     18        printf( "%g\n", result );
     19}
    1820
    19         printf("%g\n", result);
    20 }
     21// Local Variables: //
     22// tab-width: 4 //
     23// End: //
  • benchmark/mutex/pthreads.c

    raefb247 rbdfc032  
    77
    88void __attribute__((noinline)) call() {
    9          pthread_mutex_lock  (&mutex);
    10          pthread_mutex_unlock(&mutex);
     9         pthread_mutex_lock( &mutex );
     10         pthread_mutex_unlock( &mutex );
    1111}
    12 
    13 int main(int argc, char* argv[]) {
     12int main( int argc, char * argv[] ) {
     13        BENCH_START()
    1414        BENCH(
    15                 for (size_t i = 0; i < n; i++) {
     15                for ( size_t i = 0; i < times; i++ ) {
    1616                        call();
    1717                },
    1818                result
    1919        )
     20        printf( "%g\n", result );
     21}
    2022
    21         printf("%g\n", result);
    22 }
     23// Local Variables: //
     24// tab-width: 4 //
     25// End: //
  • benchmark/mutex/upp.cc

    raefb247 rbdfc032  
    88};
    99
    10 int main(int argc, char* argv[]) {
     10int main( int argc, char * argv[] ) {
     11        BENCH_START()
    1112        MyMonitor m;
    1213        BENCH(
    13                 for (size_t i = 0; i < n; i++) {
     14                for ( size_t i = 0; i < times; i++ ) {
    1415                        m.call();
    1516                },
    1617                result
    1718        )
     19        printf( "%g\n", result );
     20}
    1821
    19         printf("%g\n", result);
    20 }
     22// Local Variables: //
     23// tab-width: 4 //
     24// End: //
  • benchmark/schedext/cfa1.cfa

    raefb247 rbdfc032  
    44#include <stdio.h>
    55
    6 #include "bench.h"
     6#include "../bench.h"
    77
    8 int argc;
    9 char** argv;
    10 volatile int go = 0;
     8monitor M {} m1;
    119
    12 monitor M {};
    13 M m1;
    14 
    15 void __attribute__((noinline)) call( M & mutex a1 ) {}
    16 
    17 int  __attribute__((noinline)) wait( M & mutex a1 ) {
    18         go = 1;
    19         BENCH(
    20                 for ( i; n ) {
    21                         waitfor(call, a1);
    22                 },
    23                 result
    24         )
    25 
    26         printf("%g\n", result);
    27         go = 0;
    28         return 0;
     10void __attribute__((noinline)) call( M & mutex p1 ) {}
     11void __attribute__((noinline)) wait( M & mutex p1 ) {
     12        for ( times ) {
     13                waitfor( call : p1 );
     14        }
    2915}
    3016
    3117thread T {};
    32 void ^?{}( T & mutex this ) {}
    3318void main( T & ) {
    34         while(go == 0) { yield(); }
    35         while(go == 1) { call(m1); }
    36 
     19        BENCH(
     20                for ( times ) { call( m1 ); },
     21                result
     22        )
     23        printf( "%g\n", result );
    3724}
    3825
    39 int main(__attribute__((unused)) int argc, __attribute__((unused)) char* argv[]) {
     26int main( int argc, char * argv[] ) {
     27        BENCH_START()
    4028        T t;
    41         return wait(m1);
     29        wait( m1 );
    4230}
     31
     32// Local Variables: //
     33// tab-width: 4 //
     34// End: //
  • benchmark/schedext/cfa2.cfa

    raefb247 rbdfc032  
    44#include <stdio.h>
    55
    6 #include "bench.h"
     6#include "../bench.h"
    77
    8 int argc;
    9 char** argv;
    10 volatile int go = 0;
     8monitor M {} m1, m2;
    119
    12 monitor M {};
    13 M m1, m2;
    14 
    15 void __attribute__((noinline)) call( M & mutex a1, M & mutex a2 ) {}
    16 
    17 int  __attribute__((noinline)) wait( M & mutex a1, M & mutex a2 ) {
    18         go = 1;
     10void __attribute__((noinline)) call( M & mutex p1, M & mutex p2 ) {}
     11void __attribute__((noinline)) wait( M & mutex p1, M & mutex p2 ) {
     12        for ( times ) {
     13                waitfor( call : p1, p2 );
     14        }
     15}
     16thread T {};
     17void main( T & ) {
    1918        BENCH(
    20                 for ( i; n ) {
    21                         waitfor(call, a1, a2);
     19                for ( times ) {
     20                        call( m1, m2 );
    2221                },
    2322                result
    2423        )
    25 
    26         printf("%g\n", result);
    27         go = 0;
    28         return 0;
     24        printf( "%g\n", result );
    2925}
    3026
    31 thread T {};
    32 void ^?{}( T & mutex this ) {}
    33 void main( T & ) {
    34         while(go == 0) { yield(); }
    35         while(go == 1) { call(m1, m2); }
    36 
     27int main( int argc, char * argv[] ) {
     28        BENCH_START()
     29        T t;
     30        wait( m1, m2 );
    3731}
    3832
    39 int main(__attribute__((unused)) int argc, __attribute__((unused)) char* argv[]) {
    40         T t;
    41         return wait(m1, m2);
    42 }
     33// Local Variables: //
     34// tab-width: 4 //
     35// End: //
  • benchmark/schedext/cfa4.cfa

    raefb247 rbdfc032  
    44#include <stdio.h>
    55
    6 #include "bench.h"
     6#include "../bench.h"
    77
    8 int argc;
    9 char** argv;
    10 volatile int go = 0;
     8monitor M {} m1, m2, m3, m4;
    119
    12 monitor M {};
    13 M m1, m2, m3, m4;
    14 
    15 void __attribute__((noinline)) call( M & mutex a1, M & mutex a2, M & mutex a3, M & mutex a4 ) {}
    16 
    17 int  __attribute__((noinline)) wait( M & mutex a1, M & mutex a2, M & mutex a3, M & mutex a4 ) {
    18         go = 1;
     10void __attribute__((noinline)) call( M & mutex p1, M & mutex p2, M & mutex p3, M & mutex p4 ) {}
     11void __attribute__((noinline)) wait( M & mutex p1, M & mutex p2, M & mutex p3, M & mutex p4 ) {
     12        for ( times ) {
     13                waitfor( call : p1, p2, p3, p4 );
     14        }
     15}
     16thread T {};
     17void main( T & ) {
    1918        BENCH(
    20                 for ( i; n ) {
    21                         waitfor(call, a1, a2, a3, a4);
     19                for ( times ) {
     20                        call( m1, m2, m3, m4 );
    2221                },
    2322                result
    2423        )
    25 
    26         printf("%g\n", result);
    27         go = 0;
    28         return 0;
     24        printf( "%g\n", result );
    2925}
    3026
    31 thread T {};
    32 void ^?{}( T & mutex this ) {}
    33 void main( T & ) {
    34         while(go == 0) { yield(); }
    35         while(go == 1) { call(m1, m2, m3, m4); }
    36 
     27int main( int argc, char * argv[] ) {
     28        BENCH_START()
     29        T t;
     30        wait( m1, m2, m3, m4 );
    3731}
    3832
    39 int main(__attribute__((unused)) int argc, __attribute__((unused)) char* argv[]) {
    40         T t;
    41         return wait(m1, m2, m3, m4);
    42 }
     33// Local Variables: //
     34// tab-width: 4 //
     35// End: //
  • benchmark/schedext/upp.cc

    raefb247 rbdfc032  
    33#include "bench.h"
    44
    5 int argc;
    6 char** argv;
    7 volatile int go = 0;
    8 
    95_Monitor M {
    106public:
    117        void __attribute__((noinline)) call() {}
     8        void __attribute__((noinline)) wait() {
     9                for ( size_t i = 0; i < times; i++ ) {
     10                        _Accept(call);
     11                }
     12        }
     13} m;
    1214
    13         int __attribute__((noinline)) wait() {
    14                 go = 1;
     15_Task T {
     16        void main() {
    1517                BENCH(
    16                         for (size_t i = 0; i < n; i++) {
    17                                 _Accept(call);
     18                        for ( size_t i = 0; i < times; i++ ) {
     19                                m.call();
    1820                        },
    1921                        result
    2022                )
    21 
    22                 printf("%g\n", result);
    23                 go = 0;
    24                 return 0;
     23                printf( "%g\n", result );
    2524        }
    2625};
    2726
    28 M m;
     27int main( int argc, char * argv[] ) {
     28        BENCH_START()
     29        T t;
     30        m.wait();
     31}
    2932
    30 _Task T {
    31         void main() {
    32                 while(go == 0) { yield(); }
    33                 while(go == 1) { m.call(); }
    34 
    35         }
    36 };
    37 
    38 int main(int margc, char* margv[]) {
    39         argc = margc;
    40         argv = margv;
    41         T t;
    42         return m.wait();
    43 }
     33// Local Variables: //
     34// tab-width: 4 //
     35// End: //
  • benchmark/schedint/JavaThread.java

    raefb247 rbdfc032  
    4949        static int x = 2;
    5050
    51         static private final int NoOfTimes = Integer.parseInt("1000000") ;
     51        static private int times = Integer.parseInt("1000000");
    5252
    5353        public static void helper( Monitor m ) throws InterruptedException {
    54                 for(int i = 1; i <= NoOfTimes; i += 1) {
     54                for(int i = 1; i <= times; i += 1) {
    5555                        m.wait();               // relase monitor lock
    5656                        m.next = true;
     
    6363                synchronized(m) {
    6464                        s.start();
    65                         while( !Monitor.go ) {
     65                        while( ! Monitor.go ) { // waiter must start first
    6666                                Thread.yield();
    6767                        }
     
    7272                Monitor.go = false;
    7373                s.join();
    74                 System.out.println( (end - start) / NoOfTimes);
     74                System.out.println( (end - start) / times);
    7575        }
    7676        public static void main(String[] args) throws InterruptedException {
     77                if ( args.length > 2 ) System.exit( 1 );
     78                if ( args.length == 2 ) { times = Integer.parseInt(args[1]); }
     79
    7780                for (int n = Integer.parseInt("5"); --n >= 0 ; ) {
    7881                        InnerMain();
     
    8386        }
    8487}
     88
     89// Local Variables: //
     90// tab-width: 4 //
     91// End: //
  • benchmark/schedint/cfa1.cfa

    raefb247 rbdfc032  
    44#include <stdio.h>
    55
    6 #include "bench.h"
     6#include "../bench.h"
    77
    8 int argc;
    9 char** argv;
    108volatile int go = 0;
    119
    1210condition c;
    13 monitor M {};
    14 M m1;
     11monitor M {} m1;
    1512
    16 void __attribute__((noinline)) call( M & mutex a1 ) {
    17         signal(c);
     13void __attribute__((noinline)) call( M & mutex p1 ) {
     14        signal( c );
    1815}
    19 
    20 int  __attribute__((noinline)) wait( M & mutex a1 ) {
     16void __attribute__((noinline)) wait( M & mutex p1 ) {
    2117        go = 1;
    22         BENCH(
    23                 for ( i; n ) {
    24                         wait(c);
    25                 },
    26                 result
    27         )
    28 
    29         printf("%g\n", result);
    30         go = 0;
    31         return 0;
     18        for ( times ) {
     19                wait( c );
     20        }
    3221}
    3322
    3423thread T {};
    35 void ^?{}( T & mutex ) {}
    3624void main( T & ) {
    37         while(go == 0) { yield(); }
    38         while(go == 1) { call(m1); }
    39 
     25        while ( go == 0 ) { yield(); } // waiter must start first
     26        BENCH(
     27                for ( times ) { call( m1 ); },
     28                result
     29        )
     30        printf( "%g\n", result );
    4031}
    4132
    42 int main(__attribute__((unused)) int argc, __attribute__((unused)) char* argv[]) {
     33int main( int argc, char * argv[] ) {
     34        BENCH_START()
    4335        T t;
    44         return wait(m1);
     36        wait( m1 );
    4537}
     38
     39// Local Variables: //
     40// tab-width: 4 //
     41// End: //
  • benchmark/schedint/cfa2.cfa

    raefb247 rbdfc032  
    44#include <stdio.h>
    55
    6 #include "bench.h"
     6#include "../bench.h"
    77
    8 int argc;
    9 char** argv;
    108volatile int go = 0;
    119
    1210condition c;
    13 monitor M {};
    14 M m1, m2;
     11monitor M {} m1, m2;
    1512
    16 void __attribute__((noinline)) call( M & mutex a1, M & mutex a2 ) {
    17         signal(c);
     13void __attribute__((noinline)) call( M & mutex p1, M & mutex p2 ) {
     14        signal( c );
    1815}
    19 
    20 int  __attribute__((noinline)) wait( M & mutex a1, M & mutex a2 ) {
     16void __attribute__((noinline)) wait( M & mutex p1, M & mutex p2 ) {
    2117        go = 1;
    22         BENCH(
    23                 for ( i; n ) {
    24                         wait(c);
    25                 },
    26                 result
    27         )
    28 
    29         printf("%g\n", result);
    30         go = 0;
    31         return 0;
     18        for ( times ) {
     19                wait( c );
     20        }
    3221}
    3322
    3423thread T {};
    35 void ^?{}( T & mutex this ) {}
    3624void main( T & ) {
    37         while(go == 0) { yield(); }
    38         while(go == 1) { call(m1, m2); }
    39 
     25        while ( go == 0 ) { yield(); } // waiter must start first
     26        BENCH(
     27                for ( times ) { call( m1, m2 ); },
     28                result
     29        )
     30        printf( "%g\n", result );
    4031}
    4132
    42 int main(__attribute__((unused)) int argc, __attribute__((unused)) char* argv[]) {
     33int main( int argc, char * argv[] ) {
     34        BENCH_START()
    4335        T t;
    44         return wait(m1, m2);
     36        wait( m1, m2 );
    4537}
     38
     39// Local Variables: //
     40// tab-width: 4 //
     41// End: //
  • benchmark/schedint/cfa4.cfa

    raefb247 rbdfc032  
    44#include <stdio.h>
    55
    6 #include "bench.h"
     6#include "../bench.h"
    77
    8 int argc;
    9 char** argv;
    108volatile int go = 0;
    119
    1210condition c;
    13 monitor M {};
    14 M m1, m2, m3, m4;
     11monitor M {} m1, m2, m3, m4;
    1512
    16 void __attribute__((noinline)) call( M & mutex a1, M & mutex a2, M & mutex a3, M & mutex a4 ) {
    17         signal(c);
     13void __attribute__((noinline)) call( M & mutex p1, M & mutex p2, M & mutex p3, M & mutex p4 ) {
     14        signal( c );
    1815}
    19 
    20 int  __attribute__((noinline)) wait( M & mutex a1, M & mutex a2, M & mutex a3, M & mutex a4 ) {
     16void __attribute__((noinline)) wait( M & mutex p1, M & mutex p2, M & mutex p3, M & mutex p4 ) {
    2117        go = 1;
    22         BENCH(
    23                 for ( i; n ) {
    24                         wait(c);
    25                 },
    26                 result
    27         )
    28 
    29         printf("%g\n", result);
    30         go = 0;
    31         return 0;
     18        for ( times ) {
     19                wait( c );
     20        }
    3221}
    3322
    3423thread T {};
    35 void ^?{}( T & mutex this ) {}
    3624void main( T & ) {
    37         while(go == 0) { yield(); }
    38         while(go == 1) { call(m1, m2, m3, m4); }
    39 
     25        while ( go == 0 ) { yield(); } // waiter must start first
     26        BENCH(
     27                for ( times ) { call( m1, m2, m3, m4 ); },
     28                result
     29        )
     30        printf( "%g\n", result );
    4031}
    4132
    42 int main(__attribute__((unused)) int argc, __attribute__((unused)) char* argv[]) {
     33int main( int argc, char * argv[] ) {
     34        BENCH_START()
    4335        T t;
    44         return wait(m1, m2, m3, m4);
     36        wait( m1, m2, m3, m4 );
    4537}
     38
     39// Local Variables: //
     40// tab-width: 4 //
     41// End: //
  • benchmark/schedint/pthreads.c

    raefb247 rbdfc032  
    44#include "bench.h"
    55
    6 int argc;
    7 char** argv;
    86volatile int go = 0;
    97
     8pthread_mutex_t m;
    109pthread_cond_t c;
    11 pthread_mutex_t m;
    1210
    1311void __attribute__((noinline)) call() {
    14         pthread_mutex_lock(&m);
    15         pthread_cond_signal(&c);
    16         pthread_mutex_unlock(&m);
     12        pthread_mutex_lock( &m );
     13        pthread_cond_signal( &c );
     14        pthread_mutex_unlock( &m );
    1715}
    1816
    19 int __attribute__((noinline)) wait() {
     17void __attribute__((noinline)) wait() {
    2018        pthread_mutex_lock(&m);
    2119        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
    2230        BENCH(
    23                 for (size_t i = 0; i < n; i++) {
    24                         pthread_cond_wait(&c, &m);
    25                 },
     31                while ( go == 1 ) { call(); },
    2632                result
    2733        )
    28 
    29         printf("%g\n", result);
    30         go = 0;
    31         pthread_mutex_unlock(&m);
    32         return 0;
    33 }
    34 
    35 void* thread_main(__attribute__((unused)) void * arg ) {
    36         while(go == 0) { sched_yield(); }
    37         while(go == 1) { call(); }
     34        printf( "%g\n", result );
    3835        return NULL;
    3936}
    4037
    41 int main(__attribute__((unused)) int argc, __attribute__((unused)) char* argv[]) {
     38int main( int argc, char * argv[] ) {
     39        BENCH_START()
    4240        pthread_t thread;
    43         if (pthread_create(&thread, NULL, thread_main, NULL) < 0) {
     41        if ( pthread_create( &thread, NULL, thread_main, NULL ) < 0 ) {
    4442                perror( "failure" );
    4543                return 1;
    4644        }
    4745        wait();
    48         if (pthread_join( thread, NULL) < 0) {
     46        if ( pthread_join( thread, NULL ) < 0 ) {
    4947                perror( "failure" );
    5048                return 1;
    5149        }
    52         return 0;
    5350}
     51
     52// Local Variables: //
     53// tab-width: 4 //
     54// End: //
  • benchmark/schedint/upp.cc

    raefb247 rbdfc032  
    33#include "bench.h"
    44
    5 int argc;
    6 char** argv;
    75volatile int go = 0;
    86
     
    1311                cond.signal();
    1412        }
     13        void __attribute__((noinline)) wait() {
     14                go = 1;
     15                for ( size_t i = 0; i < times; i++ ) {
     16                        cond.wait();
     17                }
     18        }
     19} m;
    1520
    16         int __attribute__((noinline)) wait() {
    17                 go = 1;
     21_Task T {
     22        void main() {
     23                while ( go == 0 ) { yield(); } // waiter must start first
    1824                BENCH(
    19                         for (size_t i = 0; i < n; i++) {
    20                                 cond.wait();
     25                        for ( size_t i = 0; i < times; i++ ) {
     26                                m.call();
    2127                        },
    2228                        result
    2329                )
    24 
    25                 printf("%g\n", result);
    26                 go = 0;
    27                 return 0;
     30                printf( "%g\n", result );
    2831        }
    2932};
    3033
    31 M m;
     34int main( int argc, char * argv[] ) {
     35        BENCH_START()
     36        T t;
     37        m.wait();
     38}
    3239
    33 _Task T {
    34         void main() {
    35                 while(go == 0) { yield(); }
    36                 while(go == 1) { m.call(); }
    37 
    38         }
    39 };
    40 
    41 int main(__attribute__((unused)) int argc, __attribute__((unused)) char* argv[]) {
    42         T t;
    43         return m.wait();
    44 }
     40// Local Variables: //
     41// tab-width: 4 //
     42// End: //
  • driver/cfa.cc

    raefb247 rbdfc032  
    1010// Created On       : Tue Aug 20 13:44:49 2002
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Sep 10 17:00:15 2019
    13 // Update Count     : 420
     12// Last Modified On : Fri Jan 31 16:48:03 2020
     13// Update Count     : 421
    1414//
    1515
     
    187187                        } else if ( arg == "-XCFA" ) {                          // CFA pass through
    188188                                i += 1;
     189                                if ( i == argc ) continue;                              // next argument available ?
    189190                                Putenv( argv, argv[i] );
    190191
  • libcfa/src/Makefile.in

    raefb247 rbdfc032  
    425425am__v_CFA_0 = @echo "  CFA     " $@;
    426426am__v_CFA_1 =
    427 AM_V_JAVAC = $(am__v_JAVAC_@AM_V@)
    428 am__v_JAVAC_ = $(am__v_JAVAC_@AM_DEFAULT_V@)
    429 am__v_JAVAC_0 = @echo "  JAVAC   " $@;
    430 am__v_JAVAC_1 =
    431 AM_V_GOC = $(am__v_GOC_@AM_V@)
    432 am__v_GOC_ = $(am__v_GOC_@AM_DEFAULT_V@)
    433 am__v_GOC_0 = @echo "  GOC     " $@;
    434 am__v_GOC_1 =
    435427UPPCC = u++
    436428UPPCOMPILE = $(UPPCC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_UPPFLAGS) $(UPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_CFLAGS) $(CFLAGS)
     
    439431am__v_UPP_0 = @echo "  UPP     " $@;
    440432am__v_UPP_1 =
     433AM_V_GOC = $(am__v_GOC_@AM_V@)
     434am__v_GOC_ = $(am__v_GOC_@AM_DEFAULT_V@)
     435am__v_GOC_0 = @echo "  GOC     " $@;
     436am__v_GOC_1 =
     437AM_V_RUST = $(am__v_RUST_@AM_V@)
     438am__v_RUST_ = $(am__v_RUST_@AM_DEFAULT_V@)
     439am__v_RUST_0 = @echo "  RUST     " $@;
     440am__v_RUST_1 =
     441AM_V_NODEJS = $(am__v_NODEJS_@AM_V@)
     442am__v_NODEJS_ = $(am__v_NODEJS_@AM_DEFAULT_V@)
     443am__v_NODEJS_0 = @echo "  NODEJS     " $@;
     444am__v_NODEJS_1 =
     445AM_V_JAVAC = $(am__v_JAVAC_@AM_V@)
     446am__v_JAVAC_ = $(am__v_JAVAC_@AM_DEFAULT_V@)
     447am__v_JAVAC_0 = @echo "  JAVAC   " $@;
     448am__v_JAVAC_1 =
    441449lib_LTLIBRARIES = libcfa.la libcfathread.la
    442450gdbwaittarget = ""
  • libcfa/src/bits/containers.hfa

    raefb247 rbdfc032  
    1010// Created On       : Tue Oct 31 16:38:50 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jun 26 08:52:20 2019
    13 // Update Count     : 4
     12// Last Modified On : Wed Jan 15 07:42:35 2020
     13// Update Count     : 28
    1414
    1515#pragma once
     
    4444
    4545        forall(dtype T | sized(T))
    46         static inline T& ?[?]( __small_array(T) & this, __lock_size_t idx) {
     46        static inline T & ?[?]( __small_array(T) & this, __lock_size_t idx ) {
    4747                return ((typeof(this.data))this.data)[idx];
    4848        }
    4949
    5050        forall(dtype T | sized(T))
    51         static inline T& ?[?]( const __small_array(T) & this, __lock_size_t idx) {
     51        static inline T & ?[?]( const __small_array(T) & this, __lock_size_t idx ) {
    5252                return ((typeof(this.data))this.data)[idx];
    5353        }
    5454
     55        forall(dtype T)
     56        static inline T * begin( const __small_array(T) & this ) {
     57                return ((typeof(this.data))this.data);
     58        }
     59
    5560        forall(dtype T | sized(T))
    56         static inline T* begin( const __small_array(T) & this ) {
    57                 return ((typeof(this.data))this.data);
    58         }
    59 
    60         forall(dtype T | sized(T))
    61         static inline T* end( const __small_array(T) & this ) {
     61        static inline T * end( const __small_array(T) & this ) {
    6262                return ((typeof(this.data))this.data) + this.size;
    6363        }
     
    7070#ifdef __cforall
    7171        trait is_node(dtype T) {
    72                 T*& get_next( T& );
     72                T *& get_next( T & );
    7373        };
    7474#endif
     
    9797        forall(dtype T)
    9898        static inline void ?{}( __stack(T) & this ) {
    99                 (this.top){ NULL };
    100         }
    101 
    102         forall(dtype T | is_node(T) | sized(T))
    103         static inline void push( __stack(T) & this, T * val ) {
    104                 verify( !get_next( *val ) );
    105                 get_next( *val ) = this.top;
    106                 this.top = val;
    107         }
    108 
    109         forall(dtype T | is_node(T) | sized(T))
    110         static inline T * pop( __stack(T) & this ) {
    111                 T * top = this.top;
    112                 if( top ) {
    113                         this.top = get_next( *top );
    114                         get_next( *top ) = NULL;
    115                 }
    116                 return top;
    117         }
    118 
    119         forall(dtype T | is_node(T))
    120         static inline int ?!=?( const __stack(T) & this, __attribute__((unused)) zero_t zero ) {
    121                 return this.top != 0;
     99                (this.top){ 0p };
     100        }
     101
     102        static inline forall( dtype T | is_node(T) ) {
     103                void push( __stack(T) & this, T * val ) {
     104                        verify( !get_next( *val ) );
     105                        get_next( *val ) = this.top;
     106                        this.top = val;
     107                }
     108
     109                T * pop( __stack(T) & this ) {
     110                        T * top = this.top;
     111                        if( top ) {
     112                                this.top = get_next( *top );
     113                                get_next( *top ) = 0p;
     114                        }
     115                        return top;
     116                }
     117
     118                int ?!=?( const __stack(T) & this, __attribute__((unused)) zero_t zero ) {
     119                        return this.top != 0;
     120                }
    122121        }
    123122#endif
     
    145144
    146145#ifdef __cforall
    147 
    148         forall(dtype T)
    149         static inline void ?{}( __queue(T) & this ) with( this ) {
    150                 head{ NULL };
    151                 tail{ &head };
    152         }
    153 
    154         forall(dtype T | is_node(T) | sized(T))
    155         static inline void append( __queue(T) & this, T * val ) with( this ) {
    156                 verify(tail != NULL);
    157                 *tail = val;
    158                 tail = &get_next( *val );
    159         }
    160 
    161         forall(dtype T | is_node(T) | sized(T))
    162         static inline T * pop_head( __queue(T) & this ) {
    163                 T * head = this.head;
    164                 if( head ) {
    165                         this.head = get_next( *head );
    166                         if( !get_next( *head ) ) {
    167                                 this.tail = &this.head;
    168                         }
    169                         get_next( *head ) = NULL;
    170                 }
    171                 return head;
    172         }
    173 
    174         forall(dtype T | is_node(T) | sized(T))
    175         static inline T * remove( __queue(T) & this, T ** it ) with( this ) {
    176                 T * val = *it;
    177                 verify( val );
    178 
    179                 (*it) = get_next( *val );
    180 
    181                 if( tail == &get_next( *val ) ) {
    182                         tail = it;
    183                 }
    184 
    185                 get_next( *val ) = NULL;
    186 
    187                 verify( (head == NULL) == (&head == tail) );
    188                 verify( *tail == NULL );
    189                 return val;
    190         }
    191 
    192         forall(dtype T | is_node(T))
    193         static inline int ?!=?( const __queue(T) & this, __attribute__((unused)) zero_t zero ) {
    194                 return this.head != 0;
     146        static inline forall( dtype T | is_node(T) ) {
     147                void ?{}( __queue(T) & this ) with( this ) {
     148                        head{ 0p };
     149                        tail{ &head };
     150                }
     151
     152                void append( __queue(T) & this, T * val ) with( this ) {
     153                        verify(tail != 0p);
     154                        *tail = val;
     155                        tail = &get_next( *val );
     156                }
     157
     158                T * pop_head( __queue(T) & this ) {
     159                        T * head = this.head;
     160                        if( head ) {
     161                                this.head = get_next( *head );
     162                                if( !get_next( *head ) ) {
     163                                        this.tail = &this.head;
     164                                }
     165                                get_next( *head ) = 0p;
     166                        }
     167                        return head;
     168                }
     169
     170                T * remove( __queue(T) & this, T ** it ) with( this ) {
     171                        T * val = *it;
     172                        verify( val );
     173
     174                        (*it) = get_next( *val );
     175
     176                        if( tail == &get_next( *val ) ) {
     177                                tail = it;
     178                        }
     179
     180                        get_next( *val ) = 0p;
     181
     182                        verify( (head == 0p) == (&head == tail) );
     183                        verify( *tail == 0p );
     184                        return val;
     185                }
     186
     187                int ?!=?( const __queue(T) & this, __attribute__((unused)) zero_t zero ) {
     188                        return this.head != 0;
     189                }
    195190        }
    196191#endif
     
    223218
    224219#ifdef __cforall
    225 
    226         forall(dtype T | sized(T))
     220        forall(dtype T )
    227221        static inline [void] ?{}( __dllist(T) & this, * [T * & next, T * & prev] ( T & ) __get ) {
    228                 this.head{ NULL };
     222                this.head{ 0p };
    229223                this.__get = __get;
    230224        }
     
    232226        #define next 0
    233227        #define prev 1
    234         forall(dtype T | sized(T))
    235         static inline void push_front( __dllist(T) & this, T & node ) with( this ) {
    236                 verify(__get);
    237                 if ( head ) {
    238                         __get( node ).next = head;
    239                         __get( node ).prev = __get( *head ).prev;
    240                         // inserted node must be consistent before it is seen
     228        static inline forall(dtype T) {
     229                void push_front( __dllist(T) & this, T & node ) with( this ) {
     230                        verify(__get);
     231                        if ( head ) {
     232                                __get( node ).next = head;
     233                                __get( node ).prev = __get( *head ).prev;
     234                                // inserted node must be consistent before it is seen
     235                                // prevent code movement across barrier
     236                                asm( "" : : : "memory" );
     237                                __get( *head ).prev = &node;
     238                                T & _prev = *__get( node ).prev;
     239                                __get( _prev ).next = &node;
     240                        } else {
     241                                __get( node ).next = &node;
     242                                __get( node ).prev = &node;
     243                        }
     244
    241245                        // prevent code movement across barrier
    242246                        asm( "" : : : "memory" );
    243                         __get( *head ).prev = &node;
    244                         T & _prev = *__get( node ).prev;
    245                         __get( _prev ).next = &node;
    246                 }
    247                 else {
    248                         __get( node ).next = &node;
    249                         __get( node ).prev = &node;
    250                 }
    251 
    252                 // prevent code movement across barrier
    253                 asm( "" : : : "memory" );
    254                 head = &node;
    255         }
    256 
    257         forall(dtype T | sized(T))
    258         static inline void remove( __dllist(T) & this, T & node ) with( this ) {
    259                 verify(__get);
    260                 if ( &node == head ) {
    261                         if ( __get( *head ).next == head ) {
    262                                 head = NULL;
    263                         }
    264                         else {
    265                                 head = __get( *head ).next;
    266                         }
    267                 }
    268                 __get( *__get( node ).next ).prev = __get( node ).prev;
    269                 __get( *__get( node ).prev ).next = __get( node ).next;
    270                 __get( node ).next = NULL;
    271                 __get( node ).prev = NULL;
    272         }
    273 
    274         forall(dtype T | sized(T))
    275         static inline int ?!=?( const __dllist(T) & this, __attribute__((unused)) zero_t zero ) {
    276                 return this.head != 0;
     247                        head = &node;
     248                }
     249
     250                void remove( __dllist(T) & this, T & node ) with( this ) {
     251                        verify(__get);
     252                        if ( &node == head ) {
     253                                if ( __get( *head ).next == head ) {
     254                                        head = 0p;
     255                                } else {
     256                                        head = __get( *head ).next;
     257                                }
     258                        }
     259                        __get( *__get( node ).next ).prev = __get( node ).prev;
     260                        __get( *__get( node ).prev ).next = __get( node ).next;
     261                        __get( node ).next = 0p;
     262                        __get( node ).prev = 0p;
     263                }
     264
     265                int ?!=?( const __dllist(T) & this, __attribute__((unused)) zero_t zero ) {
     266                        return this.head != 0;
     267                }
    277268        }
    278269        #undef next
     
    286277
    287278#endif
     279
     280// Local Variables: //
     281// tab-width: 4 //
     282// End: //
  • libcfa/src/bits/defs.hfa

    raefb247 rbdfc032  
    1010// Created On       : Thu Nov  9 13:24:10 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb  8 16:22:41 2018
    13 // Update Count     : 8
     12// Last Modified On : Tue Jan 28 22:38:27 2020
     13// Update Count     : 9
    1414//
    1515
     
    3434
    3535#ifdef __cforall
    36 void abort ( const char fmt[], ... ) __attribute__ (( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ ));
     36void abort( const char fmt[], ... ) __attribute__ (( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ ));
     37void abort( bool signalAbort, const char fmt[], ... ) __attribute__ (( format(printf, 2, 3), __nothrow__, __leaf__, __noreturn__ ));
    3738extern "C" {
    3839#endif
  • libcfa/src/bits/signal.hfa

    raefb247 rbdfc032  
    4040        sigaddset( &act.sa_mask, SIGALRM );             // disabled during signal handler
    4141        sigaddset( &act.sa_mask, SIGUSR1 );
     42        sigaddset( &act.sa_mask, SIGSEGV );
     43        sigaddset( &act.sa_mask, SIGBUS );
     44        sigaddset( &act.sa_mask, SIGILL );
     45        sigaddset( &act.sa_mask, SIGFPE );
     46        sigaddset( &act.sa_mask, SIGHUP );              // revert to default on second delivery
     47        sigaddset( &act.sa_mask, SIGTERM );
     48        sigaddset( &act.sa_mask, SIGINT );
    4249        act.sa_flags = flags;
    4350
    44         if ( sigaction( sig, &act, NULL ) == -1 ) {
     51        if ( sigaction( sig, &act, 0p ) == -1 ) {
    4552                __cfaabi_dbg_print_buffer_decl(
    4653                        " __cfaabi_sigaction( sig:%d, handler:%p, flags:%d ), problem installing signal handler, error(%d) %s.\n",
     
    4855                );
    4956                _exit( EXIT_FAILURE );
    50         }
     57        } // if
    5158}
    52 
    53 // Sigaction wrapper : restore default handler
    54 static void __cfaabi_sigdefault( int sig ) {
    55         struct sigaction act;
    56 
    57         act.sa_handler = SIG_DFL;
    58         act.sa_flags = 0;
    59         sigemptyset( &act.sa_mask );
    60 
    61         if ( sigaction( sig, &act, NULL ) == -1 ) {
    62                 __cfaabi_dbg_print_buffer_decl(
    63                         " __cfaabi_sigdefault( sig:%d ), problem reseting signal handler, error(%d) %s.\n",
    64                         sig, errno, strerror( errno )
    65                 );
    66                 _exit( EXIT_FAILURE );
    67         }
    68 }
  • libcfa/src/clock.hfa

    raefb247 rbdfc032  
    1010// Created On       : Thu Apr 12 14:36:06 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jun 13 21:21:13 2019
    13 // Update Count     : 8
     12// Last Modified On : Mon Jan  6 12:49:58 2020
     13// Update Count     : 9
    1414//
    1515
    1616#include <time.hfa>
    17 
    1817
    1918//######################### C time #########################
     
    2625static inline tm * localtime_r( time_t tp, tm * result ) { return localtime_r( &tp, result ); }
    2726
    28 
    2927//######################### Clock #########################
    3028
    3129struct Clock {                                                                                  // private
    3230        Duration offset;                                                                        // for virtual clock: contains offset from real-time
    33         int clocktype;                                                                          // implementation only -1 (virtual), CLOCK_REALTIME
    3431};
    3532
    3633static inline {
    37         void resetClock( Clock & clk ) with( clk ) {
    38                 clocktype = CLOCK_REALTIME_COARSE;
    39         } // Clock::resetClock
    40 
    4134        void resetClock( Clock & clk, Duration adj ) with( clk ) {
    42                 clocktype = -1;
    4335                offset = adj + __timezone`s;                                    // timezone (global) is (UTC - local time) in seconds
    4436        } // resetClock
    4537
    46         void ?{}( Clock & clk ) { resetClock( clk ); }
    4738        void ?{}( Clock & clk, Duration adj ) { resetClock( clk, adj ); }
    4839
     
    8980                return ret;
    9081        } // getTime
     82
     83        Time getCPUTime() {
     84                timespec ts;
     85                clock_gettime( CLOCK_THREAD_CPUTIME_ID, &ts );
     86                return (Time){ ts };
     87    } // getCPUTime
    9188} // distribution
    9289
  • libcfa/src/concurrency/CtxSwitch-x86_64.S

    raefb247 rbdfc032  
    8787CtxInvokeStub:
    8888        movq %rbx, %rdi
    89         jmp *%r12
     89        movq %r12, %rsi
     90        jmp *%r13
    9091        .size  CtxInvokeStub, .-CtxInvokeStub
    9192
  • libcfa/src/concurrency/alarm.cfa

    raefb247 rbdfc032  
    1010// Created On       : Fri Jun 2 11:31:25 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Dec  3 22:47:24 2019
    13 // Update Count     : 68
     12// Last Modified On : Sun Jan  5 08:41:36 2020
     13// Update Count     : 69
    1414//
    1515
     
    3939
    4040void __kernel_set_timer( Duration alarm ) {
    41         verifyf(alarm >= 1`us || alarm == 0, "Setting timer to < 1us (%jins)", alarm.tv);
     41        verifyf(alarm >= 1`us || alarm == 0, "Setting timer to < 1us (%jins)", alarm`ns);
    4242        setitimer( ITIMER_REAL, &(itimerval){ alarm }, 0p );
    4343}
  • libcfa/src/concurrency/coroutine.cfa

    raefb247 rbdfc032  
    187187// is not inline (We can't inline Cforall in C)
    188188extern "C" {
    189         void __suspend_internal(void) {
    190                 suspend();
    191         }
    192 
    193         void __leave_coroutine( coroutine_desc * src ) {
     189        void __leave_coroutine( struct coroutine_desc * src ) {
    194190                coroutine_desc * starter = src->cancellation != 0 ? src->last : src->starter;
    195191
     
    207203                CoroutineCtxSwitch( src, starter );
    208204        }
     205
     206        struct coroutine_desc * __finish_coroutine(void) {
     207                struct coroutine_desc * cor = kernelTLS.this_thread->curr_cor;
     208
     209                if(cor->state == Primed) {
     210                        suspend();
     211                }
     212
     213                cor->state = Active;
     214
     215                return cor;
     216        }
    209217}
    210218
  • libcfa/src/concurrency/coroutine.hfa

    raefb247 rbdfc032  
    6161// Start coroutine routines
    6262extern "C" {
    63       forall(dtype T | is_coroutine(T))
    64       void CtxInvokeCoroutine(T * this);
     63        void CtxInvokeCoroutine(void (*main)(void *), void * this);
    6564
    66       forall(dtype T | is_coroutine(T))
    67       void CtxStart(T * this, void ( *invoke)(T *));
     65        forall(dtype T)
     66        void CtxStart(void (*main)(T &), struct coroutine_desc * cor, T & this, void (*invoke)(void (*main)(void *), void *));
    6867
    6968        extern void _CtxCoroutine_Unwind(struct _Unwind_Exception * storage, struct coroutine_desc *) __attribute__ ((__noreturn__));
     
    129128
    130129        if( unlikely(dst->context.SP == 0p) ) {
     130                TL_GET( this_thread )->curr_cor = dst;
    131131                __stack_prepare(&dst->stack, 65000);
    132                 CtxStart(&cor, CtxInvokeCoroutine);
     132                CtxStart(main, dst, cor, CtxInvokeCoroutine);
     133                TL_GET( this_thread )->curr_cor = src;
    133134        }
    134135
  • libcfa/src/concurrency/invoke.c

    raefb247 rbdfc032  
    2929// Called from the kernel when starting a coroutine or task so must switch back to user mode.
    3030
    31 extern void __suspend_internal(void);
    32 extern void __leave_coroutine( struct coroutine_desc * );
    33 extern void __finish_creation( struct thread_desc * );
    34 extern void __leave_thread_monitor( struct thread_desc * this );
     31extern void __leave_coroutine ( struct coroutine_desc * );
     32extern struct coroutine_desc * __finish_coroutine(void);
     33extern void __leave_thread_monitor();
    3534extern void disable_interrupts() OPTIONAL_THREAD;
    3635extern void enable_interrupts( __cfaabi_dbg_ctx_param );
     
    3837void CtxInvokeCoroutine(
    3938        void (*main)(void *),
    40         struct coroutine_desc *(*get_coroutine)(void *),
    4139        void *this
    4240) {
    43         struct coroutine_desc* cor = get_coroutine( this );
     41        // Finish setting up the coroutine by setting its state
     42        struct coroutine_desc * cor = __finish_coroutine();
    4443
    45         if(cor->state == Primed) {
    46                 __suspend_internal();
    47         }
    48 
    49         cor->state = Active;
    50 
     44        // Call the main of the coroutine
    5145        main( this );
    5246
     
    8377
    8478void CtxInvokeThread(
    85         void (*dtor)(void *),
    8679        void (*main)(void *),
    87         struct thread_desc *(*get_thread)(void *),
    8880        void *this
    8981) {
    90         // Fetch the thread handle from the user defined thread structure
    91         struct thread_desc* thrd = get_thread( this );
    92 
    93         // First suspend, once the thread arrives here,
    94         // the function pointer to main can be invalidated without risk
    95         __finish_creation( thrd );
    96 
    9782        // Officially start the thread by enabling preemption
    9883        enable_interrupts( __cfaabi_dbg_ctx );
     
    10893        // The order of these 4 operations is very important
    10994        //Final suspend, should never return
    110         __leave_thread_monitor( thrd );
     95        __leave_thread_monitor();
    11196        __cabi_abort( "Resumed dead thread" );
    11297}
    11398
    114 
    11599void CtxStart(
    116100        void (*main)(void *),
    117         struct coroutine_desc *(*get_coroutine)(void *),
     101        struct coroutine_desc * cor,
    118102        void *this,
    119103        void (*invoke)(void *)
    120104) {
    121         struct coroutine_desc * cor = get_coroutine( this );
    122105        struct __stack_t * stack = cor->stack.storage;
    123106
     
    138121
    139122        fs->dummyReturn = NULL;
    140         fs->argument[0] = this;     // argument to invoke
     123        fs->argument[0] = main;     // argument to invoke
     124        fs->argument[1] = this;     // argument to invoke
    141125        fs->rturn = invoke;
    142126
     
    156140        fs->dummyReturn = NULL;
    157141        fs->rturn = CtxInvokeStub;
    158         fs->fixedRegisters[0] = this;
    159         fs->fixedRegisters[1] = invoke;
     142        fs->fixedRegisters[0] = main;
     143        fs->fixedRegisters[1] = this;
     144        fs->fixedRegisters[2] = invoke;
    160145
    161146#elif defined( __ARM_ARCH )
    162 
     147#error ARM needs to be upgrade to use to parameters like X86/X64 (A.K.A. : I broke this and do not know how to fix it)
    163148        struct FakeStack {
    164149                float fpRegs[16];                       // floating point registers
  • libcfa/src/concurrency/kernel.cfa

    raefb247 rbdfc032  
    1010// Created On       : Tue Jan 17 12:27:26 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Dec  5 16:25:52 2019
    13 // Update Count     : 52
     12// Last Modified On : Thu Jan 30 22:55:50 2020
     13// Update Count     : 56
    1414//
    1515
     
    469469        );
    470470
    471         Abort( pthread_attr_setstack( &attr, stack, stacksize ), "pthread_attr_setstack" ); 
     471        Abort( pthread_attr_setstack( &attr, stack, stacksize ), "pthread_attr_setstack" );
    472472
    473473        Abort( pthread_create( pthread, &attr, start, arg ), "pthread_create" );
     
    490490        verify( ! kernelTLS.preemption_state.enabled );
    491491
     492        kernelTLS.this_thread->curr_cor = dst;
    492493        __stack_prepare( &dst->stack, 65000 );
    493         CtxStart(&this->runner, CtxInvokeCoroutine);
     494        CtxStart(main, dst, this->runner, CtxInvokeCoroutine);
    494495
    495496        verify( ! kernelTLS.preemption_state.enabled );
     
    505506        CtxSwitch( &src->context, &dst->context );
    506507        // when CtxSwitch returns we are back in the src coroutine
     508
     509        mainThread->curr_cor = &mainThread->self_cor;
    507510
    508511        // set state of new coroutine to active
     
    841844                sigemptyset( &mask );
    842845                sigaddset( &mask, SIGALRM );            // block SIGALRM signals
    843                 sigsuspend( &mask );                    // block the processor to prevent further damage during abort
    844                 _exit( EXIT_FAILURE );                  // if processor unblocks before it is killed, terminate it
     846                sigaddset( &mask, SIGUSR1 );            // block SIGALRM signals
     847                sigsuspend( &mask );                            // block the processor to prevent further damage during abort
     848                _exit( EXIT_FAILURE );                          // if processor unblocks before it is killed, terminate it
    845849        }
    846850        else {
  • libcfa/src/concurrency/kernel_private.hfa

    raefb247 rbdfc032  
    8888// Threads
    8989extern "C" {
    90       forall(dtype T | is_thread(T))
    91       void CtxInvokeThread(T * this);
     90      void CtxInvokeThread(void (*main)(void *), void * this);
    9291}
    9392
  • libcfa/src/concurrency/monitor.cfa

    raefb247 rbdfc032  
    243243        // last routine called by a thread.
    244244        // Should never return
    245         void __leave_thread_monitor( thread_desc * thrd ) {
     245        void __leave_thread_monitor() {
     246                thread_desc * thrd = TL_GET( this_thread );
    246247                monitor_desc * this = &thrd->self_mon;
    247248
  • libcfa/src/concurrency/thread.cfa

    raefb247 rbdfc032  
    5858void ?{}( scoped(T)& this ) with( this ) {
    5959        handle{};
    60         __thrd_start(handle);
     60        __thrd_start(handle, main);
    6161}
    6262
     
    6464void ?{}( scoped(T)& this, P params ) with( this ) {
    6565        handle{ params };
    66         __thrd_start(handle);
     66        __thrd_start(handle, main);
    6767}
    6868
     
    7575// Starting and stopping threads
    7676forall( dtype T | is_thread(T) )
    77 void __thrd_start( T& this ) {
     77void __thrd_start( T & this, void (*main_p)(T &) ) {
    7878        thread_desc * this_thrd = get_thread(this);
    7979        thread_desc * curr_thrd = TL_GET( this_thread );
    8080
    8181        disable_interrupts();
    82         CtxStart(&this, CtxInvokeThread);
     82        CtxStart(main_p, get_coroutine(this), this, CtxInvokeThread);
     83
    8384        this_thrd->context.[SP, FP] = this_thrd->self_cor.context.[SP, FP];
    8485        verify( this_thrd->context.SP );
    85         CtxSwitch( &curr_thrd->context, &this_thrd->context );
     86        // CtxSwitch( &curr_thrd->context, &this_thrd->context );
    8687
    8788        ScheduleThread(this_thrd);
    8889        enable_interrupts( __cfaabi_dbg_ctx );
    89 }
    90 
    91 extern "C" {
    92         // KERNEL ONLY
    93         void __finish_creation(thread_desc * this) {
    94                 // set new coroutine that the processor is executing
    95                 // and context switch to it
    96                 verify( kernelTLS.this_thread != this );
    97                 verify( kernelTLS.this_thread->context.SP );
    98                 CtxSwitch( &this->context, &kernelTLS.this_thread->context );
    99         }
    10090}
    10191
  • libcfa/src/concurrency/thread.hfa

    raefb247 rbdfc032  
    5454
    5555forall( dtype T | is_thread(T) )
    56 void __thrd_start( T & this );
     56void __thrd_start( T & this, void (*)(T &) );
    5757
    5858//-----------------------------------------------------------------------------
  • libcfa/src/executor.cfa

    raefb247 rbdfc032  
    88#include <stdio.h>
    99
    10 forall( otype T | is_node(T) | is_monitor(T) ) {
    11     monitor Buffer {                                    // unbounded buffer
    12         __queue_t( T ) queue;                           // unbounded list of work requests
    13         condition delay;
    14     }; // Buffer
    15 
     10forall( dtype T )
     11monitor Buffer {                                        // unbounded buffer
     12    __queue_t( T ) queue;                               // unbounded list of work requests
     13    condition delay;
     14}; // Buffer
     15forall( dtype T | is_node(T) ) {
    1616    void insert( Buffer( T ) & mutex buf, T * elem ) with(buf) {
    1717        append( queue, elem );                          // insert element into buffer
     
    2020
    2121    T * remove( Buffer( T ) & mutex buf ) with(buf) {
    22         if ( ! queue ) wait( delay );                   // no request to process ? => wait
    23         return pop_head( queue );
     22        if ( queue.head != 0 ) wait( delay );                   // no request to process ? => wait
     23//      return pop_head( queue );
    2424    } // remove
    2525} // distribution
  • libcfa/src/interpose.cfa

    raefb247 rbdfc032  
    1010// Created On       : Wed Mar 29 16:10:31 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Dec 13 13:45:21 2019
    13 // Update Count     : 121
     12// Last Modified On : Thu Jan 30 17:47:32 2020
     13// Update Count     : 156
    1414//
    1515
     
    9595        void __cfaabi_interpose_startup(void)  __attribute__(( constructor( STARTUP_PRIORITY_CORE ) ));
    9696        void __cfaabi_interpose_startup( void ) {
    97                 const char *version = NULL;
     97                const char *version = 0p;
    9898
    9999                preload_libgcc();
     
    105105#pragma GCC diagnostic pop
    106106
     107                // As a precaution (and necessity), errors that result in termination are delivered on a separate stack because
     108                // task stacks might be very small (4K) and the signal delivery corrupts memory to the point that a clean
     109                // shutdown is impossible. Also, when a stack overflow encounters the non-accessible sentinel page (debug only)
     110                // and generates a segment fault, the signal cannot be delivered on the sentinel page. Finally, calls to abort
     111                // print a stack trace that uses substantial stack space.
     112
     113                #define MINSTKSZ SIGSTKSZ * 8
     114                static char stack[MINSTKSZ] __attribute__(( aligned (16) ));
     115                static stack_t ss;
     116
     117                ss.ss_sp = stack;
     118                ss.ss_size = MINSTKSZ;
     119                ss.ss_flags = 0;
     120                if ( sigaltstack( &ss, 0p ) == -1 ) {
     121                        abort( "__cfaabi_interpose_startup : internal error, sigaltstack error(%d) %s.", errno, strerror( errno ) );
     122                } // if
     123
    107124                // Failure handler
    108                 __cfaabi_sigaction( SIGSEGV, sigHandler_segv , SA_SIGINFO );
    109                 __cfaabi_sigaction( SIGBUS , sigHandler_segv , SA_SIGINFO );
    110                 __cfaabi_sigaction( SIGILL , sigHandler_ill  , SA_SIGINFO );
    111                 __cfaabi_sigaction( SIGFPE , sigHandler_fpe  , SA_SIGINFO );
    112                 __cfaabi_sigaction( SIGABRT, sigHandler_abrt, SA_SIGINFO | SA_RESETHAND);
    113                 __cfaabi_sigaction( SIGTERM, sigHandler_term , SA_SIGINFO );
    114                 __cfaabi_sigaction( SIGINT , sigHandler_term , SA_SIGINFO );
     125                __cfaabi_sigaction( SIGSEGV, sigHandler_segv, SA_SIGINFO | SA_ONSTACK );
     126                __cfaabi_sigaction( SIGBUS , sigHandler_segv, SA_SIGINFO | SA_ONSTACK );
     127                __cfaabi_sigaction( SIGILL , sigHandler_ill , SA_SIGINFO | SA_ONSTACK );
     128                __cfaabi_sigaction( SIGFPE , sigHandler_fpe , SA_SIGINFO | SA_ONSTACK );
     129                __cfaabi_sigaction( SIGTERM, sigHandler_term, SA_SIGINFO | SA_ONSTACK | SA_RESETHAND ); // one shot handler, return to default
     130                __cfaabi_sigaction( SIGINT , sigHandler_term, SA_SIGINFO | SA_ONSTACK | SA_RESETHAND );
     131                __cfaabi_sigaction( SIGABRT, sigHandler_term, SA_SIGINFO | SA_ONSTACK | SA_RESETHAND );
     132                __cfaabi_sigaction( SIGHUP , sigHandler_term, SA_SIGINFO | SA_ONSTACK | SA_RESETHAND ); // terminal hangup
    115133        }
    116134}
     
    123141void exit( int status, const char fmt[], ... ) __attribute__(( format(printf, 2, 3), __nothrow__, __leaf__, __noreturn__ ));
    124142void abort( const char fmt[], ... ) __attribute__(( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ ));
     143void abort( bool signalAbort, const char fmt[], ... ) __attribute__(( format(printf, 2, 3), __nothrow__, __leaf__, __noreturn__ ));
    125144
    126145extern "C" {
    127146        void abort( void ) __attribute__(( __nothrow__, __leaf__, __noreturn__ )) {
    128                 abort( NULL );
     147                abort( false, NULL ); // FIX ME: 0p does not work
    129148        }
    130149
     
    132151                va_list argp;
    133152                va_start( argp, fmt );
    134                 abort( fmt, argp );
     153                abort( false, fmt, argp );
    135154                va_end( argp );
    136155        }
     
    141160}
    142161
    143 void * kernel_abort    ( void ) __attribute__(( __nothrow__, __leaf__, __weak__ )) { return NULL; }
    144 void   kernel_abort_msg( void * data, char * buffer, int size ) __attribute__(( __nothrow__, __leaf__, __weak__ )) {}
     162void * kernel_abort( void ) __attribute__(( __nothrow__, __leaf__, __weak__ )) { return 0p; }
     163void kernel_abort_msg( void * data, char * buffer, int size ) __attribute__(( __nothrow__, __leaf__, __weak__ )) {}
     164// See concurrency/kernel.cfa for strong definition used in multi-processor mode.
    145165int kernel_abort_lastframe( void ) __attribute__(( __nothrow__, __leaf__, __weak__ )) { return 4; }
    146166
    147167enum { abort_text_size = 1024 };
    148168static char abort_text[ abort_text_size ];
    149 static int abort_lastframe;
    150 
    151 void exit( int status, const char fmt[], ... ) __attribute__(( format(printf, 2, 3), __nothrow__, __leaf__, __noreturn__ )) {
    152     va_list args;
    153     va_start( args, fmt );
    154     vfprintf( stderr, fmt, args );
    155     va_end( args );
    156         __cabi_libc.exit( status );
    157 }
    158 
    159 void abort( const char fmt[], ... ) __attribute__(( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ )) {
    160         void * kernel_data = kernel_abort();                    // must be done here to lock down kernel
    161         int len;
    162 
    163         abort_lastframe = kernel_abort_lastframe();
    164         len = snprintf( abort_text, abort_text_size, "Cforall Runtime error (UNIX pid:%ld) ", (long int)getpid() ); // use UNIX pid (versus getPid)
    165         __cfaabi_dbg_write( abort_text, len );
    166 
    167         if ( fmt ) {
    168                 va_list args;
    169                 va_start( args, fmt );
    170 
    171                 len = vsnprintf( abort_text, abort_text_size, fmt, args );
    172                 va_end( args );
    173                 __cfaabi_dbg_write( abort_text, len );
    174 
    175                 if ( fmt[strlen( fmt ) - 1] != '\n' ) {         // add optional newline if missing at the end of the format text
    176                         __cfaabi_dbg_write( "\n", 1 );
    177                 }
    178         }
    179 
    180         kernel_abort_msg( kernel_data, abort_text, abort_text_size );
    181         __cabi_libc.abort();
    182 }
    183 
    184 static void __cfaabi_backtrace() {
     169
     170static void __cfaabi_backtrace( int start ) {
    185171        enum {
    186172                Frames = 50,                                                                    // maximum number of stack frames
    187                 Start = 8,                                                                              // skip first N stack frames
    188173        };
     174        int last = kernel_abort_lastframe();                            // skip last N stack frames
    189175
    190176        void * array[Frames];
     
    192178        char ** messages = backtrace_symbols( array, size );
    193179
    194         // find executable name
    195         *index( messages[0], '(' ) = '\0';
     180        *index( messages[0], '(' ) = '\0';                                      // find executable name
    196181        __cfaabi_bits_print_nolock( STDERR_FILENO, "Stack back trace for: %s\n", messages[0]);
    197182
    198         for ( int i = Start; i < size - abort_lastframe && messages != 0p; i += 1 ) {
     183        for ( unsigned int i = start; i < size - last && messages != 0p; i += 1 ) {
    199184                char * name = 0p, * offset_begin = 0p, * offset_end = 0p;
    200185
    201                 for ( char * p = messages[i]; *p; ++p ) {
     186                for ( char * p = messages[i]; *p; ++p ) {               // find parantheses and +offset
    202187                        //__cfaabi_bits_print_nolock( "X %s\n", p);
    203                         // find parantheses and +offset
    204188                        if ( *p == '(' ) {
    205189                                name = p;
     
    212196                }
    213197
    214                 // if line contains symbol print it
    215                 int frameNo = i - Start;
     198                // if line contains symbol, print it
     199                int frameNo = i - start;
    216200                if ( name && offset_begin && offset_end && name < offset_begin ) {
    217                         // delimit strings
    218                         *name++ = '\0';
     201                        *name++ = '\0';                                                         // delimit strings
    219202                        *offset_begin++ = '\0';
    220203                        *offset_end++ = '\0';
     
    228211}
    229212
     213void exit( int status, const char fmt[], ... ) {
     214        va_list args;
     215        va_start( args, fmt );
     216        vfprintf( stderr, fmt, args );
     217        va_end( args );
     218        __cabi_libc.exit( status );
     219}
     220
     221void abort( bool signalAbort, const char fmt[], ... ) {
     222        void * kernel_data = kernel_abort();                            // must be done here to lock down kernel
     223        int len;
     224
     225        signal( SIGABRT, SIG_DFL );                                                     // prevent final "real" abort from recursing to handler
     226
     227        len = snprintf( abort_text, abort_text_size, "Cforall Runtime error (UNIX pid:%ld) ", (long int)getpid() ); // use UNIX pid (versus getPid)
     228        __cfaabi_bits_write( STDERR_FILENO, abort_text, len );
     229
     230        if ( fmt ) {
     231                va_list args;
     232                va_start( args, fmt );
     233
     234                len = vsnprintf( abort_text, abort_text_size, fmt, args );
     235                va_end( args );
     236                __cfaabi_bits_write( STDERR_FILENO, abort_text, len );
     237
     238                if ( fmt[strlen( fmt ) - 1] != '\n' ) {                 // add optional newline if missing at the end of the format text
     239                        __cfaabi_dbg_write( "\n", 1 );
     240                }
     241        }
     242
     243        kernel_abort_msg( kernel_data, abort_text, abort_text_size );
     244        __cfaabi_backtrace( signalAbort ? 4 : 3 );
     245
     246        __cabi_libc.abort();                                                            // print stack trace in handler
     247}
     248
     249void abort( const char fmt[], ... ) {
     250        va_list args;
     251        va_start( args, fmt );
     252        abort( false, fmt, args );
     253        va_end( args );
     254}
     255
    230256void sigHandler_segv( __CFA_SIGPARMS__ ) {
    231                 if ( sfp->si_addr == NULL ) {
    232                         abort( "Null pointer (0p) dereference.\n" );
     257                if ( sfp->si_addr == 0p ) {
     258                        abort( true, "Null pointer (0p) dereference.\n" );
    233259                } else {
    234                         abort( "%s at memory location %p.\n"
     260                        abort( true, "%s at memory location %p.\n"
    235261                                   "Possible cause is reading outside the address space or writing to a protected area within the address space with an invalid pointer or subscript.\n",
    236262                                   (sig == SIGSEGV ? "Segment fault" : "Bus error"), sfp->si_addr );
     
    239265
    240266void sigHandler_ill( __CFA_SIGPARMS__ ) {
    241         abort( "Executing illegal instruction at location %p.\n"
     267        abort( true, "Executing illegal instruction at location %p.\n"
    242268                        "Possible cause is stack corruption.\n",
    243269                        sfp->si_addr );
     
    255281          default: msg = "unknown";
    256282        } // choose
    257         abort( "Computation error %s at location %p.\n", msg, sfp->si_addr );
    258 }
    259 
    260 void sigHandler_abrt( __CFA_SIGPARMS__ ) {
    261         __cfaabi_backtrace();
    262 
    263         // reset default signal handler
    264         __cfaabi_sigdefault( SIGABRT );
    265 
    266         raise( SIGABRT );
     283        abort( true, "Computation error %s at location %p.\n", msg, sfp->si_addr );
    267284}
    268285
    269286void sigHandler_term( __CFA_SIGPARMS__ ) {
    270         abort( "Application stopped by %s signal.", sig == SIGINT ? "an interrupt (SIGINT)" : "a terminate (SIGTERM)" );
     287        abort( true, "Application interrupted by signal: %s.\n", strsignal( sig ) );
    271288}
    272289
  • libcfa/src/startup.cfa

    raefb247 rbdfc032  
    1010// Created On       : Tue Jul 24 16:21:57 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Nov 30 07:07:56 2019
    13 // Update Count     : 13
     12// Last Modified On : Fri Dec 13 13:16:45 2019
     13// Update Count     : 29
    1414//
    1515
     16#include <time.h>                                                                               // tzset
    1617#include "startup.hfa"
    17 #include <time.h>                                                                               // tzset
    1818
    1919extern "C" {
    20     static void __cfaabi_appready_startup( void ) __attribute__(( constructor( STARTUP_PRIORITY_APPREADY ) ));
     20    void __cfaabi_appready_startup( void ) __attribute__(( constructor( STARTUP_PRIORITY_APPREADY ) ));
    2121    void __cfaabi_appready_startup( void ) {
    2222                tzset();                                                                                // initialize time global variables
     
    2727    } // __cfaabi_appready_startup
    2828
    29     static void __cfaabi_appready_shutdown( void ) __attribute__(( destructor( STARTUP_PRIORITY_APPREADY ) ));
     29    void __cfaabi_appready_shutdown( void ) __attribute__(( destructor( STARTUP_PRIORITY_APPREADY ) ));
    3030    void __cfaabi_appready_shutdown( void ) {
    3131                #ifdef __CFA_DEBUG__
  • libcfa/src/stdhdr/bfdlink.h

    raefb247 rbdfc032  
    1010// Created On       : Tue Jul 18 07:26:04 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Jul 22 13:49:30 2018
    13 // Update Count     : 4
     12// Last Modified On : Sat Feb  1 07:15:29 2020
     13// Update Count     : 5
    1414//
    1515
    1616// include file uses the CFA keyword "with".
    1717#if ! defined( with )                                                                   // nesting ?
    18 #define with `with`                                                                             // make keyword an identifier
     18#define with ``with``                                                                   // make keyword an identifier
    1919#define __CFA_BFDLINK_H__
    2020#endif
  • libcfa/src/stdhdr/hwloc.h

    raefb247 rbdfc032  
    1010// Created On       : Tue Jul 18 07:45:00 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Jul 22 13:49:58 2018
    13 // Update Count     : 4
     12// Last Modified On : Sat Feb  1 07:15:39 2020
     13// Update Count     : 5
    1414//
    1515
    1616// include file uses the CFA keyword "thread".
    1717#if ! defined( thread )                                                                 // nesting ?
    18 #define thread `thread`                                                                 // make keyword an identifier
     18#define thread ``thread``                                                               // make keyword an identifier
    1919#define __CFA_HWLOC_H__
    2020#endif
  • libcfa/src/stdhdr/krb5.h

    raefb247 rbdfc032  
    1010// Created On       : Tue Jul 18 07:55:44 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Jul 22 13:50:24 2018
    13 // Update Count     : 4
     12// Last Modified On : Sat Feb  1 07:15:47 2020
     13// Update Count     : 5
    1414//
    1515
    1616// include file uses the CFA keyword "enable".
    1717#if ! defined( enable )                                                                 // nesting ?
    18 #define enable `enable`                                                                 // make keyword an identifier
     18#define enable ``enable``                                                               // make keyword an identifier
    1919#define __CFA_KRB5_H__
    2020#endif
  • libcfa/src/stdhdr/math.h

    raefb247 rbdfc032  
    1010// Created On       : Mon Jul  4 23:25:26 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb 22 18:16:07 2018
    13 // Update Count     : 13
     12// Last Modified On : Sat Feb  1 07:15:58 2020
     13// Update Count     : 14
    1414//
    1515
    1616extern "C" {
    1717#if ! defined( exception )                                                              // nesting ?
    18 #define exception `exception`                                                   // make keyword an identifier
     18#define exception ``exception``                                                 // make keyword an identifier
    1919#define __CFA_MATH_H__
    2020#endif
  • libcfa/src/stdhdr/sys/ucontext.h

    raefb247 rbdfc032  
    1010// Created On       : Thu Feb  8 23:48:16 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb  8 23:50:44 2018
    13 // Update Count     : 4
     12// Last Modified On : Sat Feb  1 07:16:05 2020
     13// Update Count     : 5
    1414//
    1515
    1616#if ! defined( ftype )                                                                  // nesting ?
    17 #define ftype `ftype`                                                                   // make keyword an identifier
     17#define ftype ``ftype``                                                                 // make keyword an identifier
    1818#define __CFA_UCONTEXT_H__
    1919#endif
  • libcfa/src/time.cfa

    raefb247 rbdfc032  
    1010// Created On       : Tue Mar 27 13:33:14 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 13 08:41:55 2019
    13 // Update Count     : 65
     12// Last Modified On : Sun Jan  5 17:27:40 2020
     13// Update Count     : 69
    1414//
    1515
     
    3333forall( dtype ostype | ostream( ostype ) ) {
    3434        ostype & ?|?( ostype & os, Duration dur ) with( dur ) {
    35                 (ostype &)(os | tv / TIMEGRAN);                                 // print seconds
    36                 long int ns = (tv < 0 ? -tv : tv) % TIMEGRAN;   // compute nanoseconds
     35                (ostype &)(os | tn / TIMEGRAN);                                 // print seconds
     36                long int ns = (tn < 0 ? -tn : tn) % TIMEGRAN;   // compute nanoseconds
    3737                if ( ns != 0 ) {                                                                // some ?
    3838                        char buf[16];
     
    5252
    5353#ifdef __CFA_DEBUG__
    54 static void tabort( int year, int month, int day, int hour, int min, int sec, int nsec ) {
     54static void tabort( int year, int month, int day, int hour, int min, int sec, int64_t nsec ) {
    5555        abort | "Attempt to create Time( year=" | year | "(>=1970), month=" | month | "(1-12), day=" | day | "(1-31), hour=" | hour | "(0-23), min=" | min | "(0-59), sec=" | sec
    56                   | "(0-60), nsec=" | nsec | "(0-999_999_999), which exceeds range 00:00:00 UTC, January 1, 1970 to 03:14:07 UTC, January 19, 2038.";
     56                  | "(0-60), nsec=" | nsec | "(0-999_999_999), which is not in the range 00:00:00 UTC, January 1, 1970 to 03:14:07 UTC, January 19, 2038, where month and day have 1 origin.";
    5757} // tabort
    5858#endif // __CFA_DEBUG__
    5959
    60 void ?{}( Time & time, int year, int month, int day, int hour, int min, int sec, int nsec ) with( time ) {
     60void ?{}( Time & time, int year, int month, int day, int hour, int min, int sec, int64_t nsec ) with( time ) {
    6161        tm tm;
    6262
    63         tm.tm_isdst = -1;                                                                       // let mktime determine if alternate timezone is in effect
     63        // Values can be in any range (+/-) but result must be in the epoch.
    6464        tm.tm_year = year - 1900;                                                       // mktime uses 1900 as its starting point
    65 #ifdef __CFA_DEBUG__
    66         if ( month < 1 || 12 < month ) {
    67                 tabort( year, month, day, hour, min, sec, nsec );
    68         } // if
    69 #endif // __CFA_DEBUG__
     65        // Make month in range 1-12 to match with day.
    7066        tm.tm_mon = month - 1;                                                          // mktime uses range 0-11
    71 #ifdef __CFA_DEBUG__
    72         if ( day < 1 || 31 < day ) {
    73                 tabort( year, month, day, hour, min, sec, nsec );
    74         } // if
    75 #endif // __CFA_DEBUG__
    7667        tm.tm_mday = day;                                                                       // mktime uses range 1-31
    7768        tm.tm_hour = hour;
    7869        tm.tm_min = min;
    7970        tm.tm_sec = sec;
     71        tm.tm_isdst = -1;                                                                       // let mktime determine if alternate timezone is in effect
    8072        time_t epochsec = mktime( &tm );
    8173#ifdef __CFA_DEBUG__
    82         if ( epochsec == (time_t)-1 ) {
     74        if ( epochsec <= (time_t)-1 ) {                                         // MUST BE LESS THAN OR EQUAL!
    8375                tabort( year, month, day, hour, min, sec, nsec );
    8476        } // if
    8577#endif // __CFA_DEBUG__
    86         tv = (int64_t)(epochsec) * TIMEGRAN + nsec;                     // convert to nanoseconds
     78        tn = (int64_t)(epochsec) * TIMEGRAN + nsec;                     // convert to nanoseconds
    8779#ifdef __CFA_DEBUG__
    88         if ( tv > 2147483647LL * TIMEGRAN ) {                           // between 00:00:00 UTC, January 1, 1970 and 03:14:07 UTC, January 19, 2038.
     80        if ( tn > 2147483647LL * TIMEGRAN ) {                           // between 00:00:00 UTC, January 1, 1970 and 03:14:07 UTC, January 19, 2038.
    8981                tabort( year, month, day, hour, min, sec, nsec );
    9082        } // if
     
    9385
    9486char * yy_mm_dd( Time time, char * buf ) with( time ) {
    95         time_t s = tv / TIMEGRAN;
     87        time_t s = tn / TIMEGRAN;
    9688        tm tm;
    9789        gmtime_r( &s, &tm );                                                            // tm_mon <= 11, tm_mday <= 31
     
    108100
    109101char * mm_dd_yy( Time time, char * buf ) with( time ) {
    110         time_t s = tv / TIMEGRAN;
     102        time_t s = tn / TIMEGRAN;
    111103        tm tm;
    112104        gmtime_r( &s, &tm );                                                            // tm_mon <= 11, tm_mday <= 31
     
    123115
    124116char * dd_mm_yy( Time time, char * buf ) with( time ) {
    125         time_t s = tv / TIMEGRAN;
     117        time_t s = tn / TIMEGRAN;
    126118        tm tm;
    127119        gmtime_r( &s, &tm );                                                            // tm_mon <= 11, tm_mday <= 31
     
    138130
    139131size_t strftime( char * buf, size_t size, const char * fmt, Time time ) with( time ) {
    140         time_t s = tv / TIMEGRAN;
     132        time_t s = tn / TIMEGRAN;
    141133        tm tm;
    142134        gmtime_r( &s, &tm );
     
    147139        ostype & ?|?( ostype & os, Time time ) with( time ) {
    148140                char buf[32];                                                                   // at least 26
    149                 time_t s = tv / TIMEGRAN;
     141                time_t s = tn / TIMEGRAN;
    150142                ctime_r( &s, (char *)&buf );                                    // 26 characters: "Wed Jun 30 21:49:08 1993\n"
    151143                buf[24] = '\0';                                                                 // remove trailing '\n'
    152                 long int ns = (tv < 0 ? -tv : tv) % TIMEGRAN;   // compute nanoseconds
     144                long int ns = (tn < 0 ? -tn : tn) % TIMEGRAN;   // compute nanoseconds
    153145                if ( ns == 0 ) {                                                                // none ?
    154146                        (ostype &)(os | buf);                                           // print date/time/year
  • libcfa/src/time.hfa

    raefb247 rbdfc032  
    1010// Created On       : Wed Mar 14 23:18:57 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Sep 22 12:25:34 2018
    13 // Update Count     : 643
     12// Last Modified On : Mon Jan  6 12:50:16 2020
     13// Update Count     : 653
    1414//
    1515
     
    3232        Duration ?=?( Duration & dur, __attribute__((unused)) zero_t ) { return dur{ 0 }; }
    3333
    34         Duration +?( Duration rhs ) with( rhs ) {       return (Duration)@{ +tv }; }
    35         Duration ?+?( Duration & lhs, Duration rhs ) { return (Duration)@{ lhs.tv + rhs.tv }; }
     34        Duration +?( Duration rhs ) with( rhs ) { return (Duration)@{ +tn }; }
     35        Duration ?+?( Duration & lhs, Duration rhs ) { return (Duration)@{ lhs.tn + rhs.tn }; }
    3636        Duration ?+=?( Duration & lhs, Duration rhs ) { lhs = lhs + rhs; return lhs; }
    3737
    38         Duration -?( Duration rhs ) with( rhs ) { return (Duration)@{ -tv }; }
    39         Duration ?-?( Duration & lhs, Duration rhs ) { return (Duration)@{ lhs.tv - rhs.tv }; }
     38        Duration -?( Duration rhs ) with( rhs ) { return (Duration)@{ -tn }; }
     39        Duration ?-?( Duration & lhs, Duration rhs ) { return (Duration)@{ lhs.tn - rhs.tn }; }
    4040        Duration ?-=?( Duration & lhs, Duration rhs ) { lhs = lhs - rhs; return lhs; }
    4141
    42         Duration ?*?( Duration lhs, int64_t rhs ) { return (Duration)@{ lhs.tv * rhs }; }
    43         Duration ?*?( int64_t lhs, Duration rhs ) { return (Duration)@{ lhs * rhs.tv }; }
     42        Duration ?*?( Duration lhs, int64_t rhs ) { return (Duration)@{ lhs.tn * rhs }; }
     43        Duration ?*?( int64_t lhs, Duration rhs ) { return (Duration)@{ lhs * rhs.tn }; }
    4444        Duration ?*=?( Duration & lhs, int64_t rhs ) { lhs = lhs * rhs; return lhs; }
    4545
    46         int64_t ?/?( Duration lhs, Duration rhs ) { return lhs.tv / rhs.tv; }
    47         Duration ?/?( Duration lhs, int64_t rhs ) { return (Duration)@{ lhs.tv / rhs }; }
     46        int64_t ?/?( Duration lhs, Duration rhs ) { return lhs.tn / rhs.tn; }
     47        Duration ?/?( Duration lhs, int64_t rhs ) { return (Duration)@{ lhs.tn / rhs }; }
    4848        Duration ?/=?( Duration & lhs, int64_t rhs ) { lhs = lhs / rhs; return lhs; }
    49         double div( Duration lhs, Duration rhs ) { return (double)lhs.tv / (double)rhs.tv; }
    50 
    51         Duration ?%?( Duration lhs, Duration rhs ) { return (Duration)@{ lhs.tv % rhs.tv }; }
     49        double div( Duration lhs, Duration rhs ) { return (double)lhs.tn / (double)rhs.tn; }
     50
     51        Duration ?%?( Duration lhs, Duration rhs ) { return (Duration)@{ lhs.tn % rhs.tn }; }
    5252        Duration ?%=?( Duration & lhs, Duration rhs ) { lhs = lhs % rhs; return lhs; }
    5353
    54         bool ?==?( Duration lhs, Duration rhs ) { return lhs.tv == rhs.tv; }
    55         bool ?!=?( Duration lhs, Duration rhs ) { return lhs.tv != rhs.tv; }
    56         bool ?<? ( Duration lhs, Duration rhs ) { return lhs.tv <  rhs.tv; }
    57         bool ?<=?( Duration lhs, Duration rhs ) { return lhs.tv <= rhs.tv; }
    58         bool ?>? ( Duration lhs, Duration rhs ) { return lhs.tv >  rhs.tv; }
    59         bool ?>=?( Duration lhs, Duration rhs ) { return lhs.tv >= rhs.tv; }
    60 
    61         bool ?==?( Duration lhs, __attribute__((unused)) zero_t ) { return lhs.tv == 0; }
    62         bool ?!=?( Duration lhs, __attribute__((unused)) zero_t ) { return lhs.tv != 0; }
    63         bool ?<? ( Duration lhs, __attribute__((unused)) zero_t ) { return lhs.tv <  0; }
    64         bool ?<=?( Duration lhs, __attribute__((unused)) zero_t ) { return lhs.tv <= 0; }
    65         bool ?>? ( Duration lhs, __attribute__((unused)) zero_t ) { return lhs.tv >  0; }
    66         bool ?>=?( Duration lhs, __attribute__((unused)) zero_t ) { return lhs.tv >= 0; }
    67 
    68         Duration abs( Duration rhs ) { return rhs.tv >= 0 ? rhs : -rhs; }
     54        bool ?==?( Duration lhs, Duration rhs ) { return lhs.tn == rhs.tn; }
     55        bool ?!=?( Duration lhs, Duration rhs ) { return lhs.tn != rhs.tn; }
     56        bool ?<? ( Duration lhs, Duration rhs ) { return lhs.tn <  rhs.tn; }
     57        bool ?<=?( Duration lhs, Duration rhs ) { return lhs.tn <= rhs.tn; }
     58        bool ?>? ( Duration lhs, Duration rhs ) { return lhs.tn >  rhs.tn; }
     59        bool ?>=?( Duration lhs, Duration rhs ) { return lhs.tn >= rhs.tn; }
     60
     61        bool ?==?( Duration lhs, __attribute__((unused)) zero_t ) { return lhs.tn == 0; }
     62        bool ?!=?( Duration lhs, __attribute__((unused)) zero_t ) { return lhs.tn != 0; }
     63        bool ?<? ( Duration lhs, __attribute__((unused)) zero_t ) { return lhs.tn <  0; }
     64        bool ?<=?( Duration lhs, __attribute__((unused)) zero_t ) { return lhs.tn <= 0; }
     65        bool ?>? ( Duration lhs, __attribute__((unused)) zero_t ) { return lhs.tn >  0; }
     66        bool ?>=?( Duration lhs, __attribute__((unused)) zero_t ) { return lhs.tn >= 0; }
     67
     68        Duration abs( Duration rhs ) { return rhs.tn >= 0 ? rhs : -rhs; }
    6969
    7070        Duration ?`ns( int64_t nsec ) { return (Duration)@{ nsec }; }
     
    8282        Duration ?`w( double weeks ) { return (Duration)@{ weeks * (7LL * 24LL * 60LL * 60LL * TIMEGRAN) }; }
    8383
    84         int64_t ?`ns( Duration dur ) { return dur.tv; }
    85         int64_t ?`us( Duration dur ) { return dur.tv / (TIMEGRAN / 1_000_000LL); }
    86         int64_t ?`ms( Duration dur ) { return dur.tv / (TIMEGRAN / 1_000LL); }
    87         int64_t ?`s( Duration dur ) { return dur.tv / TIMEGRAN; }
    88         int64_t ?`m( Duration dur ) { return dur.tv / (60LL * TIMEGRAN); }
    89         int64_t ?`h( Duration dur ) { return dur.tv / (60LL * 60LL * TIMEGRAN); }
    90         int64_t ?`d( Duration dur ) { return dur.tv / (24LL * 60LL * 60LL * TIMEGRAN); }
    91         int64_t ?`w( Duration dur ) { return dur.tv / (7LL * 24LL * 60LL * 60LL * TIMEGRAN); }
    92 
    93         Duration max( Duration lhs, Duration rhs ) { return  (lhs.tv < rhs.tv) ? rhs : lhs;}
    94         Duration min( Duration lhs, Duration rhs ) { return !(rhs.tv < lhs.tv) ? lhs : rhs;}
     84        int64_t ?`ns( Duration dur ) { return dur.tn; }
     85        int64_t ?`us( Duration dur ) { return dur.tn / (TIMEGRAN / 1_000_000LL); }
     86        int64_t ?`ms( Duration dur ) { return dur.tn / (TIMEGRAN / 1_000LL); }
     87        int64_t ?`s( Duration dur ) { return dur.tn / TIMEGRAN; }
     88        int64_t ?`m( Duration dur ) { return dur.tn / (60LL * TIMEGRAN); }
     89        int64_t ?`h( Duration dur ) { return dur.tn / (60LL * 60LL * TIMEGRAN); }
     90        int64_t ?`d( Duration dur ) { return dur.tn / (24LL * 60LL * 60LL * TIMEGRAN); }
     91        int64_t ?`w( Duration dur ) { return dur.tn / (7LL * 24LL * 60LL * 60LL * TIMEGRAN); }
     92
     93        Duration max( Duration lhs, Duration rhs ) { return  (lhs.tn < rhs.tn) ? rhs : lhs;}
     94        Duration min( Duration lhs, Duration rhs ) { return !(rhs.tn < lhs.tn) ? lhs : rhs;}
    9595} // distribution
    9696
     
    143143//######################### Time #########################
    144144
    145 void ?{}( Time & time, int year, int month = 0, int day = 0, int hour = 0, int min = 0, int sec = 0, int nsec = 0 );
     145void ?{}( Time & time, int year, int month = 1, int day = 1, int hour = 0, int min = 0, int sec = 0, int64_t nsec = 0 );
    146146static inline {
    147147        Time ?=?( Time & time, __attribute__((unused)) zero_t ) { return time{ 0 }; }
    148148
    149         void ?{}( Time & time, timeval t ) with( time ) { tv = (int64_t)t.tv_sec * TIMEGRAN + t.tv_usec * 1000; }
     149        void ?{}( Time & time, timeval t ) with( time ) { tn = (int64_t)t.tv_sec * TIMEGRAN + t.tv_usec * 1000; }
    150150        Time ?=?( Time & time, timeval t ) with( time ) {
    151                 tv = (int64_t)t.tv_sec * TIMEGRAN + t.tv_usec * (TIMEGRAN / 1_000_000LL);
     151                tn = (int64_t)t.tv_sec * TIMEGRAN + t.tv_usec * (TIMEGRAN / 1_000_000LL);
    152152                return time;
    153153        } // ?=?
    154154
    155         void ?{}( Time & time, timespec t ) with( time ) { tv = (int64_t)t.tv_sec * TIMEGRAN + t.tv_nsec; }
     155        void ?{}( Time & time, timespec t ) with( time ) { tn = (int64_t)t.tv_sec * TIMEGRAN + t.tv_nsec; }
    156156        Time ?=?( Time & time, timespec t ) with( time ) {
    157                 tv = (int64_t)t.tv_sec * TIMEGRAN + t.tv_nsec;
     157                tn = (int64_t)t.tv_sec * TIMEGRAN + t.tv_nsec;
    158158                return time;
    159159        } // ?=?
    160160
    161         Time ?+?( Time & lhs, Duration rhs ) { return (Time)@{ lhs.tv + rhs.tv }; }
     161        Time ?+?( Time & lhs, Duration rhs ) { return (Time)@{ lhs.tn + rhs.tn }; }
    162162        Time ?+?( Duration lhs, Time rhs ) { return rhs + lhs; }
    163163        Time ?+=?( Time & lhs, Duration rhs ) { lhs = lhs + rhs; return lhs; }
    164164
    165         Duration ?-?( Time lhs, Time rhs ) { return (Duration)@{ lhs.tv - rhs.tv }; }
    166         Time ?-?( Time lhs, Duration rhs ) { return (Time)@{ lhs.tv - rhs.tv }; }
     165        Duration ?-?( Time lhs, Time rhs ) { return (Duration)@{ lhs.tn - rhs.tn }; }
     166        Time ?-?( Time lhs, Duration rhs ) { return (Time)@{ lhs.tn - rhs.tn }; }
    167167        Time ?-=?( Time & lhs, Duration rhs ) { lhs = lhs - rhs; return lhs; }
    168         bool ?==?( Time lhs, Time rhs ) { return lhs.tv == rhs.tv; }
    169         bool ?!=?( Time lhs, Time rhs ) { return lhs.tv != rhs.tv; }
    170         bool ?<?( Time lhs, Time rhs ) { return lhs.tv < rhs.tv; }
    171         bool ?<=?( Time lhs, Time rhs ) { return lhs.tv <= rhs.tv; }
    172         bool ?>?( Time lhs, Time rhs ) { return lhs.tv > rhs.tv; }
    173         bool ?>=?( Time lhs, Time rhs ) { return lhs.tv >= rhs.tv; }
     168        bool ?==?( Time lhs, Time rhs ) { return lhs.tn == rhs.tn; }
     169        bool ?!=?( Time lhs, Time rhs ) { return lhs.tn != rhs.tn; }
     170        bool ?<?( Time lhs, Time rhs ) { return lhs.tn < rhs.tn; }
     171        bool ?<=?( Time lhs, Time rhs ) { return lhs.tn <= rhs.tn; }
     172        bool ?>?( Time lhs, Time rhs ) { return lhs.tn > rhs.tn; }
     173        bool ?>=?( Time lhs, Time rhs ) { return lhs.tn >= rhs.tn; }
     174
     175        int64_t ?`ns( Time t ) { return t.tn; }
    174176} // distribution
    175177
     
    194196
    195197static inline void ?{}( timeval & t, Time time ) with( t, time ) {
    196         tv_sec = tv / TIMEGRAN;                                                         // seconds
    197         tv_usec = tv % TIMEGRAN / (TIMEGRAN / 1_000_000LL);     // microseconds
     198        tv_sec = tn / TIMEGRAN;                                                         // seconds
     199        tv_usec = tn % TIMEGRAN / (TIMEGRAN / 1_000_000LL);     // microseconds
    198200} // ?{}
    199201
     
    201203
    202204static inline void ?{}( timespec & t, Time time ) with( t, time ) {
    203         tv_sec = tv / TIMEGRAN;                                                         // seconds
    204         tv_nsec = tv % TIMEGRAN;                                                        // nanoseconds
     205        tv_sec = tn / TIMEGRAN;                                                         // seconds
     206        tv_nsec = tn % TIMEGRAN;                                                        // nanoseconds
    205207} // ?{}
    206208
  • libcfa/src/time_t.hfa

    raefb247 rbdfc032  
    1010// Created On       : Tue Apr 10 14:42:03 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Apr 13 07:51:47 2018
    13 // Update Count     : 6
     12// Last Modified On : Sun Jan  5 08:22:46 2020
     13// Update Count     : 7
    1414//
    1515
     
    2020
    2121struct Duration {                                                                               // private
    22         int64_t tv;                                                                                     // nanoseconds
     22        int64_t tn;                                                                                     // nanoseconds
    2323}; // Duration
    2424
    25 static inline void ?{}( Duration & dur ) with( dur ) { tv = 0; }
    26 static inline void ?{}( Duration & dur, __attribute__((unused)) zero_t ) with( dur ) { tv = 0; }
     25static inline void ?{}( Duration & dur ) with( dur ) { tn = 0; }
     26static inline void ?{}( Duration & dur, __attribute__((unused)) zero_t ) with( dur ) { tn = 0; }
    2727
    2828
     
    3030
    3131struct Time {                                                                                   // private
    32         uint64_t tv;                                                                            // nanoseconds since UNIX epoch
     32        uint64_t tn;                                                                            // nanoseconds since UNIX epoch
    3333}; // Time
    3434
    35 static inline void ?{}( Time & time ) with( time ) { tv = 0; }
    36 static inline void ?{}( Time & time, __attribute__((unused)) zero_t ) with( time ) { tv = 0; }
     35static inline void ?{}( Time & time ) with( time ) { tn = 0; }
     36static inline void ?{}( Time & time, __attribute__((unused)) zero_t ) with( time ) { tn = 0; }
    3737
    3838// Local Variables: //
  • longrun_tests/Makefile.in

    raefb247 rbdfc032  
    492492am__v_CFA_0 = @echo "  CFA     " $@;
    493493am__v_CFA_1 =
    494 AM_V_JAVAC = $(am__v_JAVAC_@AM_V@)
    495 am__v_JAVAC_ = $(am__v_JAVAC_@AM_DEFAULT_V@)
    496 am__v_JAVAC_0 = @echo "  JAVAC   " $@;
    497 am__v_JAVAC_1 =
    498 AM_V_GOC = $(am__v_GOC_@AM_V@)
    499 am__v_GOC_ = $(am__v_GOC_@AM_DEFAULT_V@)
    500 am__v_GOC_0 = @echo "  GOC     " $@;
    501 am__v_GOC_1 =
    502494UPPCC = u++
    503495UPPCOMPILE = $(UPPCC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_UPPFLAGS) $(UPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_CFLAGS) $(CFLAGS)
     
    506498am__v_UPP_0 = @echo "  UPP     " $@;
    507499am__v_UPP_1 =
     500AM_V_GOC = $(am__v_GOC_@AM_V@)
     501am__v_GOC_ = $(am__v_GOC_@AM_DEFAULT_V@)
     502am__v_GOC_0 = @echo "  GOC     " $@;
     503am__v_GOC_1 =
     504AM_V_RUST = $(am__v_RUST_@AM_V@)
     505am__v_RUST_ = $(am__v_RUST_@AM_DEFAULT_V@)
     506am__v_RUST_0 = @echo "  RUST     " $@;
     507am__v_RUST_1 =
     508AM_V_NODEJS = $(am__v_NODEJS_@AM_V@)
     509am__v_NODEJS_ = $(am__v_NODEJS_@AM_DEFAULT_V@)
     510am__v_NODEJS_0 = @echo "  NODEJS     " $@;
     511am__v_NODEJS_1 =
     512AM_V_JAVAC = $(am__v_JAVAC_@AM_V@)
     513am__v_JAVAC_ = $(am__v_JAVAC_@AM_DEFAULT_V@)
     514am__v_JAVAC_0 = @echo "  JAVAC   " $@;
     515am__v_JAVAC_1 =
    508516repeats = 10
    509517max_time = 600
  • src/Common/Stats/Time.h

    raefb247 rbdfc032  
    99// Author           : Thierry Delisle
    1010// Created On       : Fri Mar 01 15:14:11 2019
    11 // Last Modified By :
     11// Last Modified By : Andrew Beach
    1212// Last Modified On :
    1313// Update Count     :
     
    4141                                f();
    4242                        }
     43
     44                        template<typename ret_t = void, typename func_t, typename... arg_t>
     45                        inline ret_t TimeCall(
     46                                        const char *, func_t func, arg_t&&... arg) {
     47                                return func(std::forward<arg_t>(arg)...);
     48                        }
    4349#               else
    4450                        void StartGlobal();
     
    5965                                func();
    6066                        }
     67
     68                        template<typename ret_t = void, typename func_t, typename... arg_t>
     69                        inline ret_t TimeCall(
     70                                        const char * name, func_t func, arg_t&&... arg) {
     71                                BlockGuard guard(name);
     72                                return func(std::forward<arg_t>(arg)...);
     73                        }
    6174#               endif
    6275        }
  • src/Concurrency/Keywords.cc

    raefb247 rbdfc032  
    716716                                new UntypedExpr(
    717717                                        new NameExpr( "__thrd_start" ),
    718                                         { new VariableExpr( param ) }
     718                                        { new VariableExpr( param ), new NameExpr("main") }
    719719                                )
    720720                        )
  • src/Concurrency/Waitfor.cc

    raefb247 rbdfc032  
    1111// Last Modified By :
    1212// Last Modified On :
    13 // Update Count     : 11
     13// Update Count     : 12
    1414//
    1515
     
    4242void foo() {
    4343        while( true ) {
    44                 when( a < 1 ) waitfor( f, a ) { bar(); }
     44                when( a < 1 ) waitfor( f : a ) { bar(); }
    4545                or timeout( swagl() );
    46                 or waitfor( g, a ) { baz(); }
    47                 or waitfor( ^?{}, a ) { break; }
     46                or waitfor( g : a ) { baz(); }
     47                or waitfor( ^?{} : a ) { break; }
    4848                or waitfor( ^?{} ) { break; }
    4949        }
  • src/ControlStruct/LabelFixer.cc

    raefb247 rbdfc032  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Mar 11 22:26:02 2019
    13 // Update Count     : 159
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Tue Jan 21 10:32:00 2020
     13// Update Count     : 160
    1414//
    1515
     
    2121#include "ControlStruct/LabelGenerator.h"  // for LabelGenerator
    2222#include "LabelFixer.h"
    23 #include "MLEMutator.h"                    // for MLEMutator
     23#include "MLEMutator.h"                    // for MultiLevelExitMutator
    2424#include "SynTree/Declaration.h"           // for FunctionDecl
    2525#include "SynTree/Expression.h"            // for NameExpr, Expression, Unty...
     
    4444
    4545        void LabelFixer::postvisit( FunctionDecl * functionDecl ) {
    46                 PassVisitor<MLEMutator> mlemut( resolveJumps(), generator );
    47                 functionDecl->acceptMutator( mlemut );
     46                PassVisitor<MultiLevelExitMutator> mlem( resolveJumps(), generator );
     47                // We start in the body so we can stop when we hit another FunctionDecl.
     48                maybeMutate( functionDecl->statements, mlem );
    4849        }
    4950
     
    7576
    7677
    77         // sets the definition of the labelTable entry to be the provided statement for every label in the list
    78         // parameter. Happens for every kind of statement
     78        // Sets the definition of the labelTable entry to be the provided statement for every label in
     79        // the list parameter. Happens for every kind of statement.
    7980        Label LabelFixer::setLabelsDef( std::list< Label > & llabel, Statement * definition ) {
    8081                assert( definition != 0 );
    8182                assert( llabel.size() > 0 );
    82 
    83                 Entry * e = new Entry( definition );
    8483
    8584                for ( std::list< Label >::iterator i = llabel.begin(); i != llabel.end(); i++ ) {
     
    8786                        l.set_statement( definition ); // attach statement to the label to be used later
    8887                        if ( labelTable.find( l ) == labelTable.end() ) {
    89                                 // all labels on this statement need to use the same entry, so this should only be created once
     88                                // All labels on this statement need to use the same entry,
     89                                // so this should only be created once.
    9090                                // undefined and unused until now, add an entry
    91                                 labelTable[ l ] =  e;
     91                                labelTable[ l ] = new Entry( definition );
    9292                        } else if ( labelTable[ l ]->defined() ) {
    9393                                // defined twice, error
    94                                 SemanticError( l.get_statement()->location, "Duplicate definition of label: " + l.get_name() );
    95                         }       else {
     94                                SemanticError( l.get_statement()->location,
     95                                        "Duplicate definition of label: " + l.get_name() );
     96                        } else {
    9697                                // used previously, but undefined until now -> link with this entry
     98                                // Question: Is changing objects important?
    9799                                delete labelTable[ l ];
    98                                 labelTable[ l ] = e;
     100                                labelTable[ l ] = new Entry( definition );
    99101                        } // if
    100102                } // for
    101103
    102                 // produce one of the labels attached to this statement to be temporarily used as the canonical label
     104                // Produce one of the labels attached to this statement to be temporarily used as the
     105                // canonical label.
    103106                return labelTable[ llabel.front() ]->get_label();
    104107        }
  • src/ControlStruct/MLEMutator.cc

    raefb247 rbdfc032  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Oct 22 17:22:44 2019
    13 // Update Count     : 220
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Wed Jan 22 11:50:00 2020
     13// Update Count     : 223
    1414//
    1515
     
    3333
    3434namespace ControlStruct {
    35         MLEMutator::~MLEMutator() {
     35        MultiLevelExitMutator::~MultiLevelExitMutator() {
    3636                delete targetTable;
    3737                targetTable = 0;
    3838        }
    3939        namespace {
    40                 bool isLoop( const MLEMutator::Entry & e ) { return dynamic_cast< WhileStmt * >( e.get_controlStructure() ) || dynamic_cast< ForStmt * >( e.get_controlStructure() ); }
    41                 bool isSwitch( const MLEMutator::Entry & e ) { return dynamic_cast< SwitchStmt *>( e.get_controlStructure() ); }
    42 
    43                 bool isBreakTarget( const MLEMutator::Entry & e ) { return isLoop( e ) || isSwitch( e ) || dynamic_cast< CompoundStmt *>( e.get_controlStructure() ); }
    44                 bool isContinueTarget( const MLEMutator::Entry & e ) { return isLoop( e ); }
    45                 bool isFallthroughTarget( const MLEMutator::Entry & e ) { return dynamic_cast< CaseStmt *>( e.get_controlStructure() );; }
    46                 bool isFallthroughDefaultTarget( const MLEMutator::Entry & e ) { return isSwitch( e ); }
     40                bool isLoop( const MultiLevelExitMutator::Entry & e ) {
     41                        return dynamic_cast< WhileStmt * >( e.get_controlStructure() )
     42                                || dynamic_cast< ForStmt * >( e.get_controlStructure() );
     43                }
     44                bool isSwitch( const MultiLevelExitMutator::Entry & e ) {
     45                        return dynamic_cast< SwitchStmt *>( e.get_controlStructure() );
     46                }
     47
     48                bool isBreakTarget( const MultiLevelExitMutator::Entry & e ) {
     49                        return isLoop( e ) || isSwitch( e )
     50                                || dynamic_cast< CompoundStmt *>( e.get_controlStructure() );
     51                }
     52                bool isContinueTarget( const MultiLevelExitMutator::Entry & e ) {
     53                        return isLoop( e );
     54                }
     55                bool isFallthroughTarget( const MultiLevelExitMutator::Entry & e ) {
     56                        return dynamic_cast< CaseStmt *>( e.get_controlStructure() );
     57                }
     58                bool isFallthroughDefaultTarget( const MultiLevelExitMutator::Entry & e ) {
     59                        return isSwitch( e );
     60                }
    4761        } // namespace
     62
     63        void MultiLevelExitMutator::premutate( FunctionDecl * ) {
     64                visit_children = false;
     65        }
    4866
    4967        // break labels have to come after the statement they break out of, so mutate a statement, then if they inform us
    5068        // through the breakLabel field tha they need a place to jump to on a break statement, add the break label to the
    5169        // body of statements
    52         void MLEMutator::fixBlock( std::list< Statement * > &kids, bool caseClause ) {
     70        void MultiLevelExitMutator::fixBlock( std::list< Statement * > &kids, bool caseClause ) {
    5371                SemanticErrorException errors;
    5472
     
    8199        }
    82100
    83         void MLEMutator::premutate( CompoundStmt *cmpndStmt ) {
     101        void MultiLevelExitMutator::premutate( CompoundStmt *cmpndStmt ) {
    84102                visit_children = false;
    85103                bool labeledBlock = !(cmpndStmt->labels.empty());
     
    118136                        }
    119137                }
    120                 assertf( false, "Could not find label '%s' on statement %s", originalTarget.get_name().c_str(), toString( stmt ).c_str() );
    121         }
    122 
    123 
    124         Statement *MLEMutator::postmutate( BranchStmt *branchStmt ) throw ( SemanticErrorException ) {
     138                assertf( false, "Could not find label '%s' on statement %s",
     139                        originalTarget.get_name().c_str(), toString( stmt ).c_str() );
     140        }
     141
     142
     143        Statement *MultiLevelExitMutator::postmutate( BranchStmt *branchStmt )
     144                        throw ( SemanticErrorException ) {
    125145                std::string originalTarget = branchStmt->originalTarget;
    126146
     
    230250        }
    231251
    232         Statement *MLEMutator::mutateLoop( Statement *bodyLoop, Entry &e ) {
     252        Statement *MultiLevelExitMutator::mutateLoop( Statement *bodyLoop, Entry &e ) {
    233253                // only generate these when needed
    234254                if( !e.isContUsed() && !e.isBreakUsed() ) return bodyLoop;
     
    253273
    254274        template< typename LoopClass >
    255         void MLEMutator::prehandleLoopStmt( LoopClass * loopStmt ) {
     275        void MultiLevelExitMutator::prehandleLoopStmt( LoopClass * loopStmt ) {
    256276                // remember this as the most recent enclosing loop, then mutate the body of the loop -- this will determine
    257277                // whether brkLabel and contLabel are used with branch statements and will recursively do the same to nested
     
    264284
    265285        template< typename LoopClass >
    266         Statement * MLEMutator::posthandleLoopStmt( LoopClass * loopStmt ) {
     286        Statement * MultiLevelExitMutator::posthandleLoopStmt( LoopClass * loopStmt ) {
    267287                assert( ! enclosingControlStructures.empty() );
    268288                Entry &e = enclosingControlStructures.back();
     
    275295        }
    276296
    277         void MLEMutator::premutate( WhileStmt * whileStmt ) {
     297        void MultiLevelExitMutator::premutate( WhileStmt * whileStmt ) {
    278298                return prehandleLoopStmt( whileStmt );
    279299        }
    280300
    281         void MLEMutator::premutate( ForStmt * forStmt ) {
     301        void MultiLevelExitMutator::premutate( ForStmt * forStmt ) {
    282302                return prehandleLoopStmt( forStmt );
    283303        }
    284304
    285         Statement * MLEMutator::postmutate( WhileStmt * whileStmt ) {
     305        Statement * MultiLevelExitMutator::postmutate( WhileStmt * whileStmt ) {
    286306                return posthandleLoopStmt( whileStmt );
    287307        }
    288308
    289         Statement * MLEMutator::postmutate( ForStmt * forStmt ) {
     309        Statement * MultiLevelExitMutator::postmutate( ForStmt * forStmt ) {
    290310                return posthandleLoopStmt( forStmt );
    291311        }
    292312
    293         void MLEMutator::premutate( IfStmt * ifStmt ) {
     313        void MultiLevelExitMutator::premutate( IfStmt * ifStmt ) {
    294314                // generate a label for breaking out of a labeled if
    295315                bool labeledBlock = !(ifStmt->get_labels().empty());
     
    301321        }
    302322
    303         Statement * MLEMutator::postmutate( IfStmt * ifStmt ) {
     323        Statement * MultiLevelExitMutator::postmutate( IfStmt * ifStmt ) {
    304324                bool labeledBlock = !(ifStmt->get_labels().empty());
    305325                if ( labeledBlock ) {
     
    311331        }
    312332
    313         void MLEMutator::premutate( TryStmt * tryStmt ) {
     333        void MultiLevelExitMutator::premutate( TryStmt * tryStmt ) {
    314334                // generate a label for breaking out of a labeled if
    315335                bool labeledBlock = !(tryStmt->get_labels().empty());
     
    321341        }
    322342
    323         Statement * MLEMutator::postmutate( TryStmt * tryStmt ) {
     343        Statement * MultiLevelExitMutator::postmutate( TryStmt * tryStmt ) {
    324344                bool labeledBlock = !(tryStmt->get_labels().empty());
    325345                if ( labeledBlock ) {
     
    331351        }
    332352
    333         void MLEMutator::premutate( CaseStmt *caseStmt ) {
     353        void MultiLevelExitMutator::premutate( FinallyStmt * ) {
     354                GuardAction([this, old = std::move(enclosingControlStructures)]() {
     355                        enclosingControlStructures = std::move(old);
     356                });
     357                enclosingControlStructures = std::list<Entry>();
     358                GuardValue( inFinally );
     359                inFinally = true;
     360        }
     361
     362        void MultiLevelExitMutator::premutate( ReturnStmt *returnStmt ) {
     363                if ( inFinally ) {
     364                        SemanticError( returnStmt->location, "'return' may not appear in a finally clause" );
     365                }
     366        }
     367
     368        void MultiLevelExitMutator::premutate( CaseStmt *caseStmt ) {
    334369                visit_children = false;
    335370
     
    370405        }
    371406
    372         void MLEMutator::premutate( SwitchStmt *switchStmt ) {
     407        void MultiLevelExitMutator::premutate( SwitchStmt *switchStmt ) {
    373408                // generate a label for breaking out of a labeled switch
    374409                Label brkLabel = generator->newLabel("switchBreak", switchStmt);
     
    396431        }
    397432
    398         Statement * MLEMutator::postmutate( SwitchStmt * switchStmt ) {
     433        Statement * MultiLevelExitMutator::postmutate( SwitchStmt * switchStmt ) {
    399434                Entry &e = enclosingControlStructures.back();
    400435                assert ( e == switchStmt );
  • src/ControlStruct/MLEMutator.h

    raefb247 rbdfc032  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Oct 22 17:22:47 2019
    13 // Update Count     : 45
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Wed Jan 22 11:50:00 2020
     13// Update Count     : 48
    1414//
    1515
     
    3030        class LabelGenerator;
    3131
    32         class MLEMutator : public WithVisitorRef<MLEMutator>, public WithShortCircuiting, public WithGuards {
     32        class MultiLevelExitMutator : public WithVisitorRef<MultiLevelExitMutator>,
     33                        public WithShortCircuiting, public WithGuards {
    3334          public:
    3435                class Entry;
    35                 MLEMutator( std::map<Label, Statement *> *t, LabelGenerator *gen = 0 ) : targetTable( t ), breakLabel(std::string("")), generator( gen ) {}
    36                 ~MLEMutator();
     36                MultiLevelExitMutator( std::map<Label, Statement *> *t, LabelGenerator *gen = 0 ) :
     37                        targetTable( t ), breakLabel(std::string("")), generator( gen ) {}
     38                ~MultiLevelExitMutator();
     39
     40                void premutate( FunctionDecl * );
    3741
    3842                void premutate( CompoundStmt *cmpndStmt );
     
    4751                void premutate( SwitchStmt *switchStmt );
    4852                Statement * postmutate( SwitchStmt *switchStmt );
     53                void premutate( ReturnStmt *returnStmt );
    4954                void premutate( TryStmt *tryStmt );
    5055                Statement * postmutate( TryStmt *tryStmt );
     56                void premutate( FinallyStmt *finallyStmt );
    5157
    5258                Statement *mutateLoop( Statement *bodyLoop, Entry &e );
     
    110116                Label breakLabel;
    111117                LabelGenerator *generator;
     118                bool inFinally = false;
    112119
    113120                template< typename LoopClass >
  • src/Parser/lex.ll

    raefb247 rbdfc032  
    1010 * Created On       : Sat Sep 22 08:58:10 2001
    1111 * Last Modified By : Peter A. Buhr
    12  * Last Modified On : Sun Aug  4 20:53:47 2019
    13  * Update Count     : 719
     12 * Last Modified On : Sat Feb  1 07:16:44 2020
     13 * Update Count     : 724
    1414 */
    1515
     
    330330                                /* identifier */
    331331{identifier}    { IDENTIFIER_RETURN(); }
    332 "`"{identifier}"`" {                                                                    // CFA
    333         yytext[yyleng - 1] = '\0'; yytext += 1;                         // SKULLDUGGERY: remov