Changes in / [9fb8f01:3d5701e]


Ignore:
Files:
100 added
36 deleted
267 edited

Legend:

Unmodified
Added
Removed
  • .gitignore

    r9fb8f01 r3d5701e  
    2121.deps
    2222.dirstamp
    23 bin
    24 lib
    25 include
    26 share
    27 build
     23/bin
     24/lib
     25/include
     26/share
     27/build
    2828*.class
    2929
  • Jenkins/FullBuild

    r9fb8f01 r3d5701e  
    1717
    1818                                parallel (
     19                                        clang_x86: { trigger_build( 'gcc-8',   'x86' ) },
     20                                        gcc_5_x86: { trigger_build( 'gcc-7',   'x86' ) },
     21                                        gcc_6_x86: { trigger_build( 'gcc-6',   'x86' ) },
     22                                        gcc_9_x64: { trigger_build( 'gcc-9',   'x64' ) },
     23                                        gcc_8_x64: { trigger_build( 'gcc-8',   'x64' ) },
     24                                        gcc_7_x64: { trigger_build( 'gcc-7',   'x64' ) },
    1925                                        gcc_6_x64: { trigger_build( 'gcc-6',   'x64' ) },
    20                                         gcc_6_x86: { trigger_build( 'gcc-6',   'x86' ) },
    2126                                        gcc_5_x64: { trigger_build( 'gcc-5',   'x64' ) },
    22                                         gcc_5_x86: { trigger_build( 'gcc-5',   'x86' ) },
    2327                                        clang_x64: { trigger_build( 'clang',   'x64' ) },
    24                                         clang_x86: { trigger_build( 'clang',   'x86' ) },
    2528                                )
    2629                        }
  • Jenkinsfile

    r9fb8f01 r3d5701e  
    102102
    103103                echo GitLogMessage()
     104
     105                // This is a complete hack but it solves problems with automake thinking it needs to regenerate makefiles
     106                // We fudged automake/missing to handle that but automake stills bakes prints inside the makefiles
     107                // and these cause more problems.
     108                sh 'find . -name Makefile.in -exec touch {} +'
    104109        }
    105110}
     
    155160
    156161def test() {
    157         build_stage('Test: short', !Settings.RunAllTests) {
     162        try {
     163                build_stage('Test: short', !Settings.RunAllTests) {
     164                        dir (BuildDir) {
     165                                //Run the tests from the tests directory
     166                                sh "make --no-print-directory -C tests archiveerrors=${BuildDir}/tests/crashes/short"
     167                        }
     168                }
     169
     170                build_stage('Test: full', Settings.RunAllTests) {
     171                        dir (BuildDir) {
     172                                        //Run the tests from the tests directory
     173                                        sh """make --no-print-directory -C tests timeouts="--timeout=600 --global-timeout=14400" all-tests debug=yes archiveerrors=${BuildDir}/tests/crashes/full-debug"""
     174                                        sh """make --no-print-directory -C tests timeouts="--timeout=600 --global-timeout=14400" all-tests debug=no  archiveerrors=${BuildDir}/tests/crashes/full-nodebug"""
     175                        }
     176                }
     177        }
     178        catch (Exception err) {
     179                echo "Archiving core dumps"
    158180                dir (BuildDir) {
    159                         //Run the tests from the tests directory
    160                         sh 'make --no-print-directory -C tests'
    161                 }
    162         }
    163 
    164         build_stage('Test: full', Settings.RunAllTests) {
    165                 dir (BuildDir) {
    166                         //Run the tests from the tests directory
    167                         sh 'make --no-print-directory -C tests timeouts="--timeout=600 --global-timeout=14400" all-tests debug=yes'
    168                         sh 'make --no-print-directory -C tests timeouts="--timeout=600 --global-timeout=14400" all-tests debug=no '
    169                 }
     181                        archiveArtifacts artifacts: "tests/crashes/**/*", fingerprint: true
     182                }
     183                throw err
    170184        }
    171185}
     
    201215
    202216                //Then publish the results
    203                 do_plot(Settings.RunBenchmark && Settings.Publish, 'compile'       , groupCompile    , false, 'Compilation')
    204                 do_plot(Settings.RunBenchmark && Settings.Publish, 'compile.diff'  , groupCompile    , true , 'Compilation (relative)')
    205                 do_plot(Settings.RunBenchmark && Settings.Publish, 'ctxswitch'     , groupConcurrency, false, 'Context Switching')
    206                 do_plot(Settings.RunBenchmark && Settings.Publish, 'ctxswitch.diff', groupConcurrency, true , 'Context Switching (relative)')
    207                 do_plot(Settings.RunBenchmark && Settings.Publish, 'mutex'         , groupConcurrency, false, 'Mutual Exclusion')
    208                 do_plot(Settings.RunBenchmark && Settings.Publish, 'mutex.diff'    , groupConcurrency, true , 'Mutual Exclusion (relative)')
    209                 do_plot(Settings.RunBenchmark && Settings.Publish, 'signal'        , groupConcurrency, false, 'Internal and External Scheduling')
    210                 do_plot(Settings.RunBenchmark && Settings.Publish, 'signal.diff'   , groupConcurrency, true , 'Internal and External Scheduling (relative)')
     217                do_plot(Settings.RunBenchmark && Settings.Publish, 'compile'        , groupCompile    , false, 'Compilation')
     218                do_plot(Settings.RunBenchmark && Settings.Publish, 'compile.diff'   , groupCompile    , true , 'Compilation (relative)')
     219                do_plot(Settings.RunBenchmark && Settings.Publish, 'ctxswitch'      , groupConcurrency, false, 'Context Switching')
     220                do_plot(Settings.RunBenchmark && Settings.Publish, 'ctxswitch.diff' , groupConcurrency, true , 'Context Switching (relative)')
     221                do_plot(Settings.RunBenchmark && Settings.Publish, 'mutex'          , groupConcurrency, false, 'Mutual Exclusion')
     222                do_plot(Settings.RunBenchmark && Settings.Publish, 'mutex.diff'     , groupConcurrency, true , 'Mutual Exclusion (relative)')
     223                do_plot(Settings.RunBenchmark && Settings.Publish, 'scheduling'     , groupConcurrency, false, 'Internal and External Scheduling')
     224                do_plot(Settings.RunBenchmark && Settings.Publish, 'scheduling.diff', groupConcurrency, true , 'Internal and External Scheduling (relative)')
    211225        }
    212226}
     
    215229//Routine responsible of sending the email notification once the build is completed
    216230//===========================================================================================================
     231@NonCPS
     232def SplitLines(String text) {
     233        def list = []
     234
     235        text.eachLine {
     236                list += it
     237        }
     238
     239        return list
     240}
     241
    217242def GitLogMessage() {
    218243        if (!Settings || !Settings.GitOldRef || !Settings.GitNewRef) return "\nERROR retrieveing git information!\n"
    219244
    220         sh "${SrcDir}/tools/PrettyGitLogs.sh ${SrcDir} ${BuildDir} ${Settings.GitOldRef} ${Settings.GitNewRef}"
    221 
    222         def gitUpdate = readFile("${BuildDir}/GIT_UPDATE")
    223         def gitLog    = readFile("${BuildDir}/GIT_LOG")
    224         def gitDiff   = readFile("${BuildDir}/GIT_DIFF")
     245        def oldRef = Settings.GitOldRef
     246        def newRef = Settings.GitNewRef
     247
     248        def revText = sh(returnStdout: true, script: "git rev-list ${oldRef}..${newRef}").trim()
     249        def revList = SplitLines( revText )
     250
     251        def gitUpdate = ""
     252        revList.each { rev ->
     253                def type = sh(returnStdout: true, script: "git cat-file -t ${rev}").trim()
     254                gitUpdate = gitUpdate + "       via  ${rev} (${type})"
     255        }
     256
     257        def rev = oldRef
     258        def type = sh(returnStdout: true, script: "git cat-file -t ${rev}").trim()
     259        gitUpdate = gitUpdate + "      from  ${rev} (${type})"
     260
     261        def gitLog    = sh(returnStdout: true, script: "git rev-list --format=short ${oldRef}...${newRef}").trim()
     262
     263        def gitDiff   = sh(returnStdout: true, script: "git diff --stat --color ${newRef} ${oldRef}").trim()
     264        gitDiff = gitDiff.replace('[32m', '<span style="color: #00AA00;">')
     265        gitDiff = gitDiff.replace('[31m', '<span style="color: #AA0000;">')
     266        gitDiff = gitDiff.replace('[m', '</span>')
    225267
    226268        return """
     
    321363        BuildSettings(java.util.Collections$UnmodifiableMap param, String branch) {
    322364                switch( param.Compiler ) {
     365                        case 'gcc-9':
     366                                this.Compiler = new CC_Desc('gcc-9', 'g++-9', 'gcc-9')
     367                        break
     368                        case 'gcc-8':
     369                                this.Compiler = new CC_Desc('gcc-8', 'g++-8', 'gcc-8')
     370                        break
     371                        case 'gcc-7':
     372                                this.Compiler = new CC_Desc('gcc-7', 'g++-7', 'gcc-7')
     373                        break
    323374                        case 'gcc-6':
    324375                                this.Compiler = new CC_Desc('gcc-6', 'g++-6', 'gcc-6')
     
    331382                        break
    332383                        case 'clang':
    333                                 this.Compiler = new CC_Desc('clang', 'clang++', 'gcc-6')
     384                                this.Compiler = new CC_Desc('clang', 'clang++-6.0', 'gcc-6')
    334385                        break
    335386                        default :
     
    393444                                        description: 'Which compiler to use',                                   \
    394445                                        name: 'Compiler',                                                                       \
    395                                         choices: 'gcc-6\ngcc-5\ngcc-4.9\nclang',                                        \
    396                                         defaultValue: 'gcc-6',                                                          \
     446                                        choices: 'gcc-9\ngcc-8\ngcc-7\ngcc-6\ngcc-5\ngcc-4.9\nclang',                                   \
     447                                        defaultValue: 'gcc-8',                                                          \
    397448                                ],                                                                                              \
    398449                                [$class: 'ChoiceParameterDefinition',                                           \
  • Makefile.in

    r9fb8f01 r3d5701e  
    264264CCDEPMODE = @CCDEPMODE@
    265265CFACC = @CFACC@
     266CFACC_INSTALL = @CFACC_INSTALL@
    266267CFACPP = @CFACPP@
    267268CFA_BACKEND_CC = @CFA_BACKEND_CC@
     
    294295FGREP = @FGREP@
    295296GREP = @GREP@
     297HAS_DISTCC = @HAS_DISTCC@
    296298HOST_FLAGS = @HOST_FLAGS@
    297299INSTALL = @INSTALL@
  • benchmark/Makefile.am

    r9fb8f01 r3d5701e  
    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
     
    2222
    2323AM_CFLAGS = -O2 -Wall -Wextra -I$(srcdir) -lrt -pthread # -Werror
    24 AM_CFAFLAGS = -quiet -nodebug -in-tree
     24AM_CFAFLAGS = -quiet -nodebug
    2525AM_UPPFLAGS = -quiet -nodebug -multi -std=c++14
    2626
     
    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_PY = $(__bench_v_PY_$(__quiet))
     33BENCH_V_RUSTC = $(__bench_v_RUSTC_$(__quiet))
     34BENCH_V_NODEJS = $(__bench_v_NODEJS_$(__quiet))
    3135BENCH_V_JAVAC = $(__bench_v_JAVAC_$(__quiet))
    32 BENCH_V_UPP = $(__bench_v_UPP_$(__quiet))
    3336
    3437__quiet = verbose
     
    3639__bench_v_CFA_quiet = @
    3740__bench_v_CXX_quiet = @
     41__bench_v_UPP_quiet = @
    3842__bench_v_GOC_quiet = @
     43__bench_v_RUSTC_quiet = @
    3944__bench_v_JAVAC_quiet = @
    40 __bench_v_UPP_quiet = @
    4145__bench_v_CC_verbose = $(AM_V_CC)
    4246__bench_v_CFA_verbose = $(AM_V_CFA)
    4347__bench_v_CXX_verbose = $(AM_V_CXX)
     48__bench_v_UPP_verbose = $(AM_V_UPP)
    4449__bench_v_GOC_verbose = $(AM_V_GOC)
     50__bench_v_PY_verbose = $(AM_V_PY)
     51__bench_v_RUSTC_verbose = $(AM_V_RUST)
     52__bench_v_NODEJS_verbose = $(AM_V_NODEJS)
    4553__bench_v_JAVAC_verbose = $(AM_V_JAVAC)
    46 __bench_v_UPP_verbose = $(AM_V_UPP)
    4754
    4855
     
    5158STATS    = ${abs_top_srcdir}/tools/stat.py
    5259# NEED AT LEAST 4 DATA VALUES FOR BENCHMARKS BECAUSE THE MAX AND MIN VALUES ARE REMOVED
    53 repeats  = 5 # 31 for benchmarks
     60repeats  = 13 # 31 for benchmarks
    5461arch     = x64
    5562skipcompile = no
     
    6269
    6370dummyC.c:
    64         @echo "int main() { return 0; }" > ${@}
     71        echo "int main() { return 0; }" > ${@}
    6572
    6673dummyCXX.cpp:
    67         @echo "int main() { return 0; }" > ${@}
    68 
     74        echo "int main() { return 0; }" > ${@}
     75
     76.SILENT:                # do not print recipe
    6977.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)
     78.PHONY: jenkins cleancsv
     79
     80## =========================================================================================================
     81
     82all : basic$(EXEEXT) ctxswitch$(EXEEXT) mutex$(EXEEXT) schedint$(EXEEXT) schedext$(EXEEXT) creation$(EXEEXT)
     83
     84basic_loop_DURATION = 15000000000
     85basic_function_DURATION = 10000000000
     86basic_tls_fetch_add_DURATION = 10000000000
     87basic_DURATION = 250000000
     88
     89ctxswitch_pthread_DURATION = 25000000
     90ctxswitch_rust_thread_DURATION = $(ctxswitch_pthread_DURATION)
     91ctxswitch_cfa_generator_DURATION = 5000000000
     92ctxswitch_nodejs_await_DURATION = 5000000
     93ctxswitch_DURATION = 100000000
     94
     95#mutex_java_DURATION = 10000000
     96mutex_DURATION = 50000000
     97
     98schedint_pthread_DURATION = 1000000
     99schedint_java_DURATION = $(schedint_pthread_DURATION)
     100schedint_rust_DURATION = $(schedint_pthread_DURATION)
     101schedint_DURATION = 10000000
     102
     103schedext_DURATION = 10000000
     104
     105creation_pthread_DURATION = 250000
     106creation_rust_thread_DURATION = ${creation_pthread_DURATION}
     107creation_java_thread_DURATION = ${creation_pthread_DURATION}
     108creation_cfa_coroutine_DURATION = 100000000
     109creation_cfa_coroutine_eager_DURATION = 10000000
     110creation_upp_coroutine_DURATION = ${creation_cfa_coroutine_eager_DURATION}
     111creation_cfa_thread_DURATION = 10000000
     112creation_upp_thread_DURATION = ${creation_cfa_thread_DURATION}
     113creation_DURATION = 10000000
    74114
    75115%.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
     116        rm -f .result.log
     117        echo "------------------------------------------------------"
     118        echo $<
     119        ${REPEAT} ${repeats} -- ./a.out\
     120                $(if ${$(subst -,_,$(basename $@))_DURATION},\
     121                        ${$(subst -,_,$(basename $@))_DURATION},\
     122                        ${$(firstword $(subst -, ,$(basename $@)))_DURATION}) | tee -a .result.log
     123        ${STATS} .result.log
     124        echo "------------------------------------------------------"
     125        rm -f a.out .result.log *.class
     126
     127#       ${REPEAT} ${repeats} -- /usr/bin/time -f "%Uu %Ss %Er %Mkb" ./a.out
    83128
    84129%.runquiet :
    85         @+make $(basename $@) CFLAGS="-w" __quiet=quiet
    86         @taskset -c 1 ./a.out
    87         @rm -f a.out
     130        +make $(basename $@) CFLAGS="-w" __quiet=quiet
     131        taskset -c 1 ./a.out
     132        rm -f a.out
    88133
    89134%.make :
    90         @printf "${PRINT_FORMAT}" $(basename $(subst compile-,,$@))
    91         @+/usr/bin/time -f ${TIME_FORMAT} make $(basename $@) 2>&1
     135        printf "${PRINT_FORMAT}" $(basename $(subst compile-,,$@))
     136        +/usr/bin/time -f ${TIME_FORMAT} make $(basename $@) 2>&1
    92137
    93138${REPEAT} :
    94         @+make -C ${abs_top_builddir}/tools repeat
     139        +make -C ${abs_top_builddir}/tools repeat
    95140
    96141## =========================================================================================================
     
    98143FIX_NEW_LINES = cat $@ | tr "\n" "\t" | sed -r 's/\t,/,/' | tr "\t" "\n" > $@
    99144
    100 jenkins$(EXEEXT):
     145cleancsv:
     146        rm -f compile.csv basic.csv ctxswitch.csv mutex.csv scheduling.csv
     147
     148jenkins$(EXEEXT): cleancsv
    101149@DOifskipcompile@
    102         @+make compile.csv
    103         @-+make compile.diff.csv
     150        +make compile.csv
     151        -+make compile.diff.csv
    104152@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
     153        +make ctxswitch.csv
     154        -+make ctxswitch.diff.csv
     155        +make mutex.csv
     156        -+make mutex.diff.csv
     157        +make scheduling.csv
     158        -+make scheduling.diff.csv
    111159@DOifskipcompile@
    112160        cat compile.csv
     
    117165        cat mutex.csv
    118166        -cat mutex.diff.csv
    119         cat signal.csv
    120         -cat signal.diff.csv
     167        cat scheduling.csv
     168        -cat scheduling.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 "building $@"
     172        echo "array,attributes,empty,expression,io,monitor,operators,typeof" > $@
     173        +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-array.make >> $@
     174        +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-attributes.make >> $@
     175        +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-empty.make >> $@
     176        +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-expression.make >> $@
     177        +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-io.make >> $@
     178        +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-monitor.make >> $@
     179        +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-operators.make >> $@
     180        +make TIME_FORMAT='%e' PRINT_FORMAT='' compile-typeof.make >> $@
     181        $(srcdir)/fixcsv.sh $@
    133182
    134183ctxswitch.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 $@
     184        echo "building $@"
     185        echo "generator,coroutine,thread" > $@
     186        +make ctxswitch-cfa_generator.runquiet >> $@ && echo -n ',' >> $@
     187        +make ctxswitch-cfa_coroutine.runquiet >> $@ && echo -n ',' >> $@
     188        +make ctxswitch-cfa_thread.runquiet >> $@
     189        $(srcdir)/fixcsv.sh $@
    140190
    141191mutex.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 $@
     192        echo "building $@"
     193        echo "1-monitor,2-monitor" > $@
     194        +make mutex-cfa1.runquiet >> $@ && echo -n ',' >> $@
     195        +make mutex-cfa2.runquiet >> $@
     196        $(srcdir)/fixcsv.sh $@
     197
     198scheduling.csv:
     199        echo "building $@"
     200        echo "schedint-1,schedint-2,schedext-1,schedext-2" > $@
     201        +make schedint-cfa1.runquiet >> $@ && echo -n ',' >> $@
     202        +make schedint-cfa2.runquiet >> $@ && echo -n ',' >> $@
     203        +make schedext-cfa1.runquiet >> $@ && echo -n ',' >> $@
     204        +make schedext-cfa2.runquiet >> $@
     205        $(srcdir)/fixcsv.sh $@
    154206
    155207%.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           \
     208        test -e $(srcdir)/baselines/$(arch)/$< || (echo "Error : Missing baseline for ${<}" && false)
     209        $(srcdir)/baselines/calc.py $(srcdir)/baselines/$(arch)/$(<) $(<) > $@
     210
     211## =========================================================================================================
     212
     213BASIC_DEPEND  =                                 \
     214        basic-loop.run                          \
     215        basic-function.run                      \
     216        basic-fetch_add.run                     \
     217        basic-ttst_lock.run                     \
     218        basic-tls-fetch_add.run
     219
     220basic-loop$(EXEEXT):
     221        $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/loop.c
     222
     223basic-function$(EXEEXT):
     224        $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/function.c
     225
     226basic-fetch_add$(EXEEXT):
     227        $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/fetch_add.c
     228
     229basic-ttst_lock$(EXEEXT):
     230        $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/ttst_lock.c
     231
     232basic-tls-fetch_add$(EXEEXT):
     233        $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/tls_fetch_add.c
     234
     235basic$(EXEEXT): $(BASIC_DEPEND)
     236
     237## =========================================================================================================
     238
     239CTXSWITCH_DEPEND  =                     \
    184240        ctxswitch-cfa_generator.run     \
    185241        ctxswitch-cfa_coroutine.run     \
     
    188244        ctxswitch-upp_coroutine.run     \
    189245        ctxswitch-upp_thread.run        \
    190         ctxswitch-goroutine.run         \
    191         ctxswitch-java_thread.run
    192 
     246        ctxswitch-python_coroutine.run  \
     247        ctxswitch-nodejs_coroutine.run  \
     248        ctxswitch-nodejs_await.run      \
     249        ctxswitch-goroutine_thread.run  \
     250        ctxswitch-rust_thread.run       \
     251        ctxswitch-nodejs_coroutine.run  \
     252        ctxswitch-java_thread.run       \
     253        ctxswitch-pthread.run
    193254
    194255if WITH_LIBFIBRE
    195 CTXSWITCH_DEPEND  +=           \
    196         ctxswitch-kos_fibre.run  \
     256CTXSWITCH_DEPEND  +=                    \
     257        ctxswitch-kos_fibre.run         \
    197258        ctxswitch-kos_fibre2.run
    198 
    199259
    200260ctxswitch-kos_fibre$(EXEEXT):
     
    207267ctxswitch$(EXEEXT): $(CTXSWITCH_DEPEND)
    208268
    209 ctxswitch-pthread$(EXEEXT):
    210         $(BENCH_V_CC)$(COMPILE)    -DBENCH_N=50000000 $(srcdir)/ctxswitch/pthreads.c
    211 
    212269ctxswitch-cfa_generator$(EXEEXT):
    213         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/cfa_gen.cfa
     270        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/ctxswitch/cfa_gen.cfa
    214271
    215272ctxswitch-cfa_coroutine$(EXEEXT):
    216         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/cfa_cor.cfa
     273        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/ctxswitch/cfa_cor.cfa
    217274
    218275ctxswitch-cfa_thread$(EXEEXT):
    219         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/cfa_thrd.cfa
     276        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/ctxswitch/cfa_thrd.cfa
    220277
    221278ctxswitch-cfa_thread2$(EXEEXT):
    222         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/cfa_thrd2.cfa
     279        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/ctxswitch/cfa_thrd2.cfa
    223280
    224281ctxswitch-upp_coroutine$(EXEEXT):
    225         $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/upp_cor.cc
     282        $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/ctxswitch/upp_cor.cc
    226283
    227284ctxswitch-upp_thread$(EXEEXT):
    228         $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/upp_thrd.cc
    229 
    230 ctxswitch-goroutine$(EXEEXT):
     285        $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/ctxswitch/upp_thrd.cc
     286
     287ctxswitch-python_coroutine$(EXEEXT):
     288        $(BENCH_V_PY)echo "#!/bin/sh" > a.out
     289        echo "python3.7 $(srcdir)/ctxswitch/python_cor.py" >> a.out
     290        chmod a+x a.out
     291
     292ctxswitch-nodejs_coroutine$(EXEEXT):
     293        $(BENCH_V_NODEJS)echo "#!/bin/sh" > a.out
     294        echo "nodejs $(srcdir)/ctxswitch/node_cor.js" >> a.out
     295        chmod a+x a.out
     296
     297ctxswitch-nodejs_await$(EXEEXT):
     298        $(BENCH_V_NODEJS)echo "#!/bin/sh" > a.out
     299        echo "nodejs $(srcdir)/ctxswitch/node_await.js" >> a.out
     300        chmod a+x a.out
     301
     302ctxswitch-goroutine_thread$(EXEEXT):
    231303        $(BENCH_V_GOC)go build -o a.out $(srcdir)/ctxswitch/goroutine.go
     304
     305ctxswitch-rust_thread$(EXEEXT):
     306        $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/ctxswitch/rust_thrd.rs
    232307
    233308ctxswitch-java_thread$(EXEEXT):
    234309        $(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           \
     310        echo "#!/bin/sh" > a.out
     311        echo "java JavaThread" >> a.out
     312        chmod a+x a.out
     313
     314ctxswitch-pthread$(EXEEXT):
     315        $(BENCH_V_CC)$(COMPILE) $(srcdir)/ctxswitch/pthreads.c
     316
     317## =========================================================================================================
     318
     319mutex$(EXEEXT) :                \
    246320        mutex-cfa1.run          \
    247321        mutex-cfa2.run          \
    248322        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
     323        mutex-upp.run           \
     324        mutex-go.run            \
     325        mutex-rust.run          \
     326        mutex-java.run          \
     327        mutex-pthread.run
     328
     329mutex-pthread$(EXEEXT):
     330        $(BENCH_V_CC)$(COMPILE) $(srcdir)/mutex/pthreads.c
     331
     332mutex-cfa1$(EXEEXT):
     333        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutex/cfa1.cfa
     334
     335mutex-cfa2$(EXEEXT):
     336        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutex/cfa2.cfa
     337
     338mutex-cfa4$(EXEEXT):
     339        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutex/cfa4.cfa
    253340
    254341mutex-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):
     342        $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/mutex/upp.cc
     343
     344mutex-go$(EXEEXT):
     345        $(BENCH_V_GOC)go build -o a.out $(srcdir)/mutex/goroutine.go
     346
     347mutex-rust$(EXEEXT):
     348        $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/mutex/rust.rs
     349
     350mutex-java$(EXEEXT):
    267351        $(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):
     352        echo "#!/bin/sh" > a.out
     353        echo "java JavaThread" >> a.out
     354        chmod a+x a.out
     355
     356## =========================================================================================================
     357
     358schedint$(EXEEXT) :             \
     359        schedint-cfa1.run       \
     360        schedint-cfa2.run       \
     361        schedint-cfa4.run       \
     362        schedint-upp.run        \
     363        schedint-rust.run       \
     364        schedint-java.run       \
     365        schedint-pthread.run
     366
     367schedint-cfa1$(EXEEXT):
     368        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedint/cfa1.cfa
     369
     370schedint-cfa2$(EXEEXT):
     371        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedint/cfa2.cfa
     372
     373schedint-cfa4$(EXEEXT):
     374        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedint/cfa4.cfa
     375
     376schedint-upp$(EXEEXT):
     377        $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/schedint/upp.cc
     378
     379schedint-rust$(EXEEXT):
     380        $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/schedint/rust.rs
     381
     382schedint-java$(EXEEXT):
    297383        $(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                    \
     384        echo "#!/bin/sh" > a.out
     385        echo "java JavaThread" >> a.out
     386        chmod a+x a.out
     387
     388schedint-pthread$(EXEEXT):
     389        $(BENCH_V_CC)$(COMPILE) $(srcdir)/schedint/pthreads.c
     390
     391## =========================================================================================================
     392
     393schedext$(EXEEXT) :             \
     394        schedext-cfa1.run       \
     395        schedext-cfa2.run       \
     396        schedext-cfa4.run       \
     397        schedext-upp.run        \
     398        schedext-goroutine.run
     399
     400schedext-cfa1$(EXEEXT):
     401        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedext/cfa1.cfa
     402
     403schedext-cfa2$(EXEEXT):
     404        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedext/cfa2.cfa
     405
     406schedext-cfa4$(EXEEXT):
     407        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedext/cfa4.cfa
     408
     409schedext-upp$(EXEEXT):
     410        $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/schedext/upp.cc
     411
     412schedext-goroutine$(EXEEXT):
     413        $(BENCH_V_GOC)go build -o a.out $(srcdir)/schedext/goroutine.go
     414
     415
     416## =========================================================================================================
     417
     418creation$(EXEEXT) :                             \
     419        creation-cfa_generator.run              \
    325420        creation-cfa_coroutine.run              \
    326421        creation-cfa_coroutine_eager.run        \
     
    328423        creation-upp_coroutine.run              \
    329424        creation-upp_thread.run                 \
    330         creation-goroutine.run                  \
    331         creation-java_thread.run
     425        creation-python_coroutine.run           \
     426        creation-nodejs_coroutine.run           \
     427        creation-goroutine_thread.run           \
     428        creation-rust_thread.run                \
     429        creation-java_thread.run                \
     430        creation-pthread.run
     431
     432creation-cfa_generator$(EXEEXT):
     433        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_gen.cfa
    332434
    333435creation-cfa_coroutine$(EXEEXT):
    334         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=10000000 $(srcdir)/creation/cfa_cor.cfa
     436        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_cor.cfa
    335437
    336438creation-cfa_coroutine_eager$(EXEEXT):
    337         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=10000000 $(srcdir)/creation/cfa_cor.cfa  -DEAGER
     439        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_cor.cfa  -DEAGER
    338440
    339441creation-cfa_thread$(EXEEXT):
    340         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=10000000 $(srcdir)/creation/cfa_thrd.cfa
     442        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_thrd.cfa
    341443
    342444creation-upp_coroutine$(EXEEXT):
    343         $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/creation/upp_cor.cc
     445        $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/creation/upp_cor.cc
    344446
    345447creation-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):
     448        $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/creation/upp_thrd.cc
     449
     450creation-python_coroutine$(EXEEXT):
     451        $(BENCH_V_PY)echo "#!/bin/sh" > a.out
     452        echo "python3.7 $(srcdir)/creation/python_cor.py" >> a.out
     453        chmod a+x a.out
     454
     455creation-nodejs_coroutine$(EXEEXT):
     456        $(BENCH_V_NODEJS)echo "#!/bin/sh" > a.out
     457        echo "nodejs $(srcdir)/creation/node_cor.js" >> a.out
     458        chmod a+x a.out
     459
     460creation-goroutine_thread$(EXEEXT):
    352461        $(BENCH_V_GOC)go build -o a.out $(srcdir)/creation/goroutine.go
     462
     463creation-rust_thread$(EXEEXT):
     464        $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/creation/rust_thrd.rs
    353465
    354466creation-java_thread$(EXEEXT):
    355467        $(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) :\
     468        echo "#!/bin/sh" > a.out
     469        echo "java JavaThread" >> a.out
     470        chmod a+x a.out
     471
     472creation-pthread$(EXEEXT):
     473        $(BENCH_V_CC)$(COMPILE) $(srcdir)/creation/pthreads.c
     474
     475## =========================================================================================================
     476
     477compile$(EXEEXT) :              \
    363478        compile-array.make      \
    364479        compile-attributes.make \
     
    370485        compile-typeof.make
    371486
    372 
    373487testdir = $(top_srcdir)/tests
    374488
    375489compile-array$(EXEEXT):
    376         @$(CFACOMPILE) -fsyntax-only -w $(testdir)/array.cfa
     490        $(CFACOMPILE) -fsyntax-only -w $(testdir)/array.cfa
    377491
    378492compile-attributes$(EXEEXT):
    379         @$(CFACOMPILE) -fsyntax-only -w $(testdir)/attributes.cfa
     493        $(CFACOMPILE) -fsyntax-only -w $(testdir)/attributes.cfa
    380494
    381495compile-empty$(EXEEXT):
    382         @$(CFACOMPILE) -fsyntax-only -w $(srcdir)/compile/empty.cfa
     496        $(CFACOMPILE) -fsyntax-only -w $(srcdir)/compile/empty.cfa
    383497
    384498compile-expression$(EXEEXT):
    385         @$(CFACOMPILE) -fsyntax-only -w $(testdir)/expression.cfa
     499        $(CFACOMPILE) -fsyntax-only -w $(testdir)/expression.cfa
    386500
    387501compile-io$(EXEEXT):
    388         @$(CFACOMPILE) -fsyntax-only -w $(testdir)/io1.cfa
     502        $(CFACOMPILE) -fsyntax-only -w $(testdir)/io1.cfa
    389503
    390504compile-monitor$(EXEEXT):
    391         @$(CFACOMPILE) -fsyntax-only -w $(testdir)/concurrent/monitor.cfa
     505        $(CFACOMPILE) -fsyntax-only -w $(testdir)/concurrent/monitor.cfa
    392506
    393507compile-operators$(EXEEXT):
    394         @$(CFACOMPILE) -fsyntax-only -w $(testdir)/operators.cfa
     508        $(CFACOMPILE) -fsyntax-only -w $(testdir)/operators.cfa
    395509
    396510compile-thread$(EXEEXT):
    397         @$(CFACOMPILE) -fsyntax-only -w $(testdir)/concurrent/thread.cfa
     511        $(CFACOMPILE) -fsyntax-only -w $(testdir)/concurrent/thread.cfa
    398512
    399513compile-typeof$(EXEEXT):
    400         @$(CFACOMPILE) -fsyntax-only -w $(testdir)/typeof.cfa
     514        $(CFACOMPILE) -fsyntax-only -w $(testdir)/typeof.cfa
     515
     516## =========================================================================================================
     517
     518size$(EXEEXT) : size-cfa.runquiet
     519
     520size-cfa$(EXEEXT):
     521        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/size/size.cfa
  • benchmark/Makefile.in

    r9fb8f01 r3d5701e  
    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
     
    214214CCDEPMODE = @CCDEPMODE@
    215215CFACC = @CFACC@
     216CFACC_INSTALL = @CFACC_INSTALL@
    216217CFACPP = @CFACPP@
    217218CFA_BACKEND_CC = @CFA_BACKEND_CC@
     
    244245FGREP = @FGREP@
    245246GREP = @GREP@
     247HAS_DISTCC = @HAS_DISTCC@
    246248HOST_FLAGS = @HOST_FLAGS@
    247249INSTALL = @INSTALL@
     
    350352LTCFACOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
    351353        $(LIBTOOLFLAGS) --mode=compile $(CFACC) $(DEFS) \
    352         $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CFAFLAGS) $(CFAFLAGS) \
    353         $(AM_CFLAGS) $(CFLAGS)
     354        $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CFAFLAGS) $(AM_CFLAGS) $(CFAFLAGS) $(CFLAGS)
    354355
    355356AM_V_CFA = $(am__v_CFA_@AM_V@)
     
    357358am__v_CFA_0 = @echo "  CFA     " $@;
    358359am__v_CFA_1 =
    359 AM_V_JAVAC = $(am__v_JAVAC_@AM_V@)
    360 am__v_JAVAC_ = $(am__v_JAVAC_@AM_DEFAULT_V@)
    361 am__v_JAVAC_0 = @echo "  JAVAC   " $@;
    362 am__v_JAVAC_1 =
    363 AM_V_GOC = $(am__v_GOC_@AM_V@)
    364 am__v_GOC_ = $(am__v_GOC_@AM_DEFAULT_V@)
    365 am__v_GOC_0 = @echo "  GOC     " $@;
    366 am__v_GOC_1 =
    367360UPPCC = u++
    368361UPPCOMPILE = $(UPPCC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_UPPFLAGS) $(UPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_CFLAGS) $(CFLAGS)
     
    371364am__v_UPP_0 = @echo "  UPP     " $@;
    372365am__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_PY = $(am__v_PY_@AM_V@)
     371am__v_PY_ = $(am__v_PY_@AM_DEFAULT_V@)
     372am__v_PY_0 = @echo "  PYTHON  " $@;
     373am__v_PY_1 =
     374AM_V_RUST = $(am__v_RUST_@AM_V@)
     375am__v_RUST_ = $(am__v_RUST_@AM_DEFAULT_V@)
     376am__v_RUST_0 = @echo "  RUST    " $@;
     377am__v_RUST_1 =
     378AM_V_NODEJS = $(am__v_NODEJS_@AM_V@)
     379am__v_NODEJS_ = $(am__v_NODEJS_@AM_DEFAULT_V@)
     380am__v_NODEJS_0 = @echo "  NODEJS  " $@;
     381am__v_NODEJS_1 =
     382AM_V_JAVAC = $(am__v_JAVAC_@AM_V@)
     383am__v_JAVAC_ = $(am__v_JAVAC_@AM_DEFAULT_V@)
     384am__v_JAVAC_0 = @echo "  JAVAC   " $@;
     385am__v_JAVAC_1 =
    373386
    374387# applies to both programs
    375388AM_CFLAGS = -O2 -Wall -Wextra -I$(srcdir) -lrt -pthread # -Werror
    376 AM_CFAFLAGS = -quiet -nodebug -in-tree
     389AM_CFAFLAGS = -quiet -nodebug
    377390AM_UPPFLAGS = -quiet -nodebug -multi -std=c++14
    378391BENCH_V_CC = $(__bench_v_CC_$(__quiet))
    379392BENCH_V_CFA = $(__bench_v_CFA_$(__quiet))
    380393BENCH_V_CXX = $(__bench_v_CXX_$(__quiet))
     394BENCH_V_UPP = $(__bench_v_UPP_$(__quiet))
    381395BENCH_V_GOC = $(__bench_v_GOC_$(__quiet))
     396BENCH_V_PY = $(__bench_v_PY_$(__quiet))
     397BENCH_V_RUSTC = $(__bench_v_RUSTC_$(__quiet))
     398BENCH_V_NODEJS = $(__bench_v_NODEJS_$(__quiet))
    382399BENCH_V_JAVAC = $(__bench_v_JAVAC_$(__quiet))
    383 BENCH_V_UPP = $(__bench_v_UPP_$(__quiet))
    384400__quiet = verbose
    385401__bench_v_CC_quiet = @
    386402__bench_v_CFA_quiet = @
    387403__bench_v_CXX_quiet = @
     404__bench_v_UPP_quiet = @
    388405__bench_v_GOC_quiet = @
     406__bench_v_RUSTC_quiet = @
    389407__bench_v_JAVAC_quiet = @
    390 __bench_v_UPP_quiet = @
    391408__bench_v_CC_verbose = $(AM_V_CC)
    392409__bench_v_CFA_verbose = $(AM_V_CFA)
    393410__bench_v_CXX_verbose = $(AM_V_CXX)
     411__bench_v_UPP_verbose = $(AM_V_UPP)
    394412__bench_v_GOC_verbose = $(AM_V_GOC)
     413__bench_v_PY_verbose = $(AM_V_PY)
     414__bench_v_RUSTC_verbose = $(AM_V_RUST)
     415__bench_v_NODEJS_verbose = $(AM_V_NODEJS)
    395416__bench_v_JAVAC_verbose = $(AM_V_JAVAC)
    396 __bench_v_UPP_verbose = $(AM_V_UPP)
    397417TOOLSDIR = ${abs_top_builddir}/tools/
    398418REPEAT = ${abs_top_builddir}/tools/repeat
    399419STATS = ${abs_top_srcdir}/tools/stat.py
    400420# NEED AT LEAST 4 DATA VALUES FOR BENCHMARKS BECAUSE THE MAX AND MIN VALUES ARE REMOVED
    401 repeats = 5 # 31 for benchmarks
     421repeats = 13 # 31 for benchmarks
    402422arch = x64
    403423skipcompile = no
     
    405425PRINT_FORMAT = %20s: #Comments needed for spacing
    406426dummy_SOURCES = dummyC.c dummyCXX.cpp
     427basic_loop_DURATION = 15000000000
     428basic_function_DURATION = 10000000000
     429basic_tls_fetch_add_DURATION = 10000000000
     430basic_DURATION = 250000000
     431ctxswitch_pthread_DURATION = 25000000
     432ctxswitch_rust_thread_DURATION = $(ctxswitch_pthread_DURATION)
     433ctxswitch_cfa_generator_DURATION = 5000000000
     434ctxswitch_nodejs_await_DURATION = 5000000
     435ctxswitch_DURATION = 100000000
     436
     437#mutex_java_DURATION = 10000000
     438mutex_DURATION = 50000000
     439schedint_pthread_DURATION = 1000000
     440schedint_java_DURATION = $(schedint_pthread_DURATION)
     441schedint_rust_DURATION = $(schedint_pthread_DURATION)
     442schedint_DURATION = 10000000
     443schedext_DURATION = 10000000
     444creation_pthread_DURATION = 250000
     445creation_rust_thread_DURATION = ${creation_pthread_DURATION}
     446creation_java_thread_DURATION = ${creation_pthread_DURATION}
     447creation_cfa_coroutine_DURATION = 100000000
     448creation_cfa_coroutine_eager_DURATION = 10000000
     449creation_upp_coroutine_DURATION = ${creation_cfa_coroutine_eager_DURATION}
     450creation_cfa_thread_DURATION = 10000000
     451creation_upp_thread_DURATION = ${creation_cfa_thread_DURATION}
     452creation_DURATION = 10000000
    407453FIX_NEW_LINES = cat $@ | tr "\n" "\t" | sed -r 's/\t,/,/' | tr "\t" "\n" > $@
    408 CTXSWITCH_DEPEND = loop.run function.run fetch_add.run ttst_lock.run \
    409         tls-fetch_add.run ctxswitch-pthread.run \
    410         ctxswitch-cfa_generator.run ctxswitch-cfa_coroutine.run \
    411         ctxswitch-cfa_thread.run ctxswitch-cfa_thread2.run \
    412         ctxswitch-upp_coroutine.run ctxswitch-upp_thread.run \
    413         ctxswitch-goroutine.run ctxswitch-java_thread.run \
    414         $(am__append_1)
     454BASIC_DEPEND = \
     455        basic-loop.run                          \
     456        basic-function.run                      \
     457        basic-fetch_add.run                     \
     458        basic-ttst_lock.run                     \
     459        basic-tls-fetch_add.run
     460
     461CTXSWITCH_DEPEND = ctxswitch-cfa_generator.run \
     462        ctxswitch-cfa_coroutine.run ctxswitch-cfa_thread.run \
     463        ctxswitch-cfa_thread2.run ctxswitch-upp_coroutine.run \
     464        ctxswitch-upp_thread.run ctxswitch-python_coroutine.run \
     465        ctxswitch-nodejs_coroutine.run ctxswitch-nodejs_await.run \
     466        ctxswitch-goroutine_thread.run ctxswitch-rust_thread.run \
     467        ctxswitch-nodejs_coroutine.run ctxswitch-java_thread.run \
     468        ctxswitch-pthread.run $(am__append_1)
    415469testdir = $(top_srcdir)/tests
    416470all: all-am
     
    731785
    732786dummyC.c:
    733         @echo "int main() { return 0; }" > ${@}
     787        echo "int main() { return 0; }" > ${@}
    734788
    735789dummyCXX.cpp:
    736         @echo "int main() { return 0; }" > ${@}
    737 
     790        echo "int main() { return 0; }" > ${@}
     791
     792.SILENT:                # do not print recipe
    738793.NOTPARALLEL:
    739 .PHONY: compile.csv ctxswitch.csv mutex.csv signal.csv
    740 
    741 all : ctxswitch$(EXEEXT) mutex$(EXEEXT) signal$(EXEEXT) waitfor$(EXEEXT) creation$(EXEEXT)
     794.PHONY: jenkins cleancsv
     795
     796all : basic$(EXEEXT) ctxswitch$(EXEEXT) mutex$(EXEEXT) schedint$(EXEEXT) schedext$(EXEEXT) creation$(EXEEXT)
    742797
    743798%.run : %$(EXEEXT) ${REPEAT}
    744         @rm -f .result.log
    745         @echo "------------------------------------------------------"
    746         @echo $<
    747         @${REPEAT} ${repeats} ./a.out | tee -a .result.log
    748         @${STATS} .result.log
    749         @echo "------------------------------------------------------"
    750         @rm -f a.out .result.log *.class
     799        rm -f .result.log
     800        echo "------------------------------------------------------"
     801        echo $<
     802        ${REPEAT} ${repeats} -- ./a.out\
     803                $(if ${$(subst -,_,$(basename $@))_DURATION},\
     804                        ${$(subst -,_,$(basename $@))_DURATION},\
     805                        ${$(firstword $(subst -, ,$(basename $@)))_DURATION}) | tee -a .result.log
     806        ${STATS} .result.log
     807        echo "------------------------------------------------------"
     808        rm -f a.out .result.log *.class
     809
     810#       ${REPEAT} ${repeats} -- /usr/bin/time -f "%Uu %Ss %Er %Mkb" ./a.out
    751811
    752812%.runquiet :
    753         @+make $(basename $@) CFLAGS="-w" __quiet=quiet
    754         @taskset -c 1 ./a.out
    755         @rm -f a.out
     813        +make $(basename $@) CFLAGS="-w" __quiet=quiet
     814        taskset -c 1 ./a.out
     815        rm -f a.out
    756816
    757817%.make :
    758         @printf "${PRINT_FORMAT}" $(basename $(subst compile-,,$@))
    759         @+/usr/bin/time -f ${TIME_FORMAT} make $(basename $@) 2>&1
     818        printf "${PRINT_FORMAT}" $(basename $(subst compile-,,$@))
     819        +/usr/bin/time -f ${TIME_FORMAT} make $(basename $@) 2>&1
    760820
    761821${REPEAT} :
    762         @+make -C ${abs_top_builddir}/tools repeat
    763 
    764 jenkins$(EXEEXT):
     822        +make -C ${abs_top_builddir}/tools repeat
     823
     824cleancsv:
     825        rm -f compile.csv basic.csv ctxswitch.csv mutex.csv scheduling.csv
     826
     827jenkins$(EXEEXT): cleancsv
    765828@DOifskipcompile@
    766         @+make compile.csv
    767         @-+make compile.diff.csv
     829        +make compile.csv
     830        -+make compile.diff.csv
    768831@DOendif@
    769         @+make ctxswitch.csv
    770         @-+make ctxswitch.diff.csv
    771         @+make mutex.csv
    772         @-+make mutex.diff.csv
    773         @+make signal.csv
    774         @-+make signal.diff.csv
     832        +make ctxswitch.csv
     833        -+make ctxswitch.diff.csv
     834        +make mutex.csv
     835        -+make mutex.diff.csv
     836        +make scheduling.csv
     837        -+make scheduling.diff.csv
    775838@DOifskipcompile@
    776839        cat compile.csv
     
    781844        cat mutex.csv
    782845        -cat mutex.diff.csv
    783         cat signal.csv
    784         -cat signal.diff.csv
     846        cat scheduling.csv
     847        -cat scheduling.diff.csv
    785848
    786849compile.csv:
    787         @echo "array,attributes,empty,expression,io,monitor,operators,typeof" > $@
    788         @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-array.make >> $@
    789         @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-attributes.make >> $@
    790         @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-empty.make >> $@
    791         @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-expression.make >> $@
    792         @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-io.make >> $@
    793         @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-monitor.make >> $@
    794         @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-operators.make >> $@
    795         @+make TIME_FORMAT='%e' PRINT_FORMAT='' compile-typeof.make >> $@
    796         @$(srcdir)/fixcsv.sh $@
     850        echo "building $@"
     851        echo "array,attributes,empty,expression,io,monitor,operators,typeof" > $@
     852        +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-array.make >> $@
     853        +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-attributes.make >> $@
     854        +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-empty.make >> $@
     855        +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-expression.make >> $@
     856        +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-io.make >> $@
     857        +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-monitor.make >> $@
     858        +make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-operators.make >> $@
     859        +make TIME_FORMAT='%e' PRINT_FORMAT='' compile-typeof.make >> $@
     860        $(srcdir)/fixcsv.sh $@
    797861
    798862ctxswitch.csv:
    799         @echo "generator,coroutine,thread" > $@
    800         @+make ctxswitch-cfa_generator.runquiet >> $@ && echo -n ',' >> $@
    801         @+make ctxswitch-cfa_coroutine.runquiet >> $@ && echo -n ',' >> $@
    802         @+make ctxswitch-cfa_thread.runquiet >> $@
    803         @$(srcdir)/fixcsv.sh $@
     863        echo "building $@"
     864        echo "generator,coroutine,thread" > $@
     865        +make ctxswitch-cfa_generator.runquiet >> $@ && echo -n ',' >> $@
     866        +make ctxswitch-cfa_coroutine.runquiet >> $@ && echo -n ',' >> $@
     867        +make ctxswitch-cfa_thread.runquiet >> $@
     868        $(srcdir)/fixcsv.sh $@
    804869
    805870mutex.csv:
    806         @echo "1-monitor,2-monitor" > $@
    807         @+make mutex-cfa1.runquiet >> $@ && echo -n ',' >> $@
    808         @+make mutex-cfa2.runquiet >> $@
    809         @$(srcdir)/fixcsv.sh $@
    810 
    811 signal.csv:
    812         @echo "signal-1,signal-2,waitfor-1,waitfor-2" > $@
    813         @+make signal-cfa1.runquiet >> $@ && echo -n ',' >> $@
    814         @+make signal-cfa2.runquiet >> $@ && echo -n ',' >> $@
    815         @+make waitfor-cfa1.runquiet >> $@ && echo -n ',' >> $@
    816         @+make waitfor-cfa2.runquiet >> $@
    817         @$(srcdir)/fixcsv.sh $@
     871        echo "building $@"
     872        echo "1-monitor,2-monitor" > $@
     873        +make mutex-cfa1.runquiet >> $@ && echo -n ',' >> $@
     874        +make mutex-cfa2.runquiet >> $@
     875        $(srcdir)/fixcsv.sh $@
     876
     877scheduling.csv:
     878        echo "building $@"
     879        echo "schedint-1,schedint-2,schedext-1,schedext-2" > $@
     880        +make schedint-cfa1.runquiet >> $@ && echo -n ',' >> $@
     881        +make schedint-cfa2.runquiet >> $@ && echo -n ',' >> $@
     882        +make schedext-cfa1.runquiet >> $@ && echo -n ',' >> $@
     883        +make schedext-cfa2.runquiet >> $@
     884        $(srcdir)/fixcsv.sh $@
    818885
    819886%.diff.csv: %.csv
    820         @test -e $(srcdir)/baselines/$(arch)/$< || (echo "Error : Missing baseline for ${<}" && false)
    821         @$(srcdir)/baselines/calc.py $(srcdir)/baselines/$(arch)/$(<) $(<) > $@
    822 
    823 loop$(EXEEXT):
    824         $(BENCH_V_CC)$(COMPILE) -DBENCH_N=5000000000 $(srcdir)/loop.c
    825 
    826 function$(EXEEXT):
    827         $(BENCH_V_CC)$(COMPILE) -DBENCH_N=5000000000 $(srcdir)/function.c
    828 
    829 fetch_add$(EXEEXT):
    830         $(BENCH_V_CC)$(COMPILE) -DBENCH_N=500000000  $(srcdir)/fetch_add.c
    831 
    832 ttst_lock$(EXEEXT):
    833         $(BENCH_V_CC)$(COMPILE) -DBENCH_N=500000000  $(srcdir)/ttst_lock.c
    834 
    835 tls-fetch_add$(EXEEXT):
    836         $(BENCH_V_CC)$(COMPILE) -DBENCH_N=500000000  $(srcdir)/tls-fetch_add.c
     887        test -e $(srcdir)/baselines/$(arch)/$< || (echo "Error : Missing baseline for ${<}" && false)
     888        $(srcdir)/baselines/calc.py $(srcdir)/baselines/$(arch)/$(<) $(<) > $@
     889
     890basic-loop$(EXEEXT):
     891        $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/loop.c
     892
     893basic-function$(EXEEXT):
     894        $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/function.c
     895
     896basic-fetch_add$(EXEEXT):
     897        $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/fetch_add.c
     898
     899basic-ttst_lock$(EXEEXT):
     900        $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/ttst_lock.c
     901
     902basic-tls-fetch_add$(EXEEXT):
     903        $(BENCH_V_CC)$(COMPILE) $(srcdir)/basic/tls_fetch_add.c
     904
     905basic$(EXEEXT): $(BASIC_DEPEND)
    837906
    838907@WITH_LIBFIBRE_TRUE@ctxswitch-kos_fibre$(EXEEXT):
     
    844913ctxswitch$(EXEEXT): $(CTXSWITCH_DEPEND)
    845914
    846 ctxswitch-pthread$(EXEEXT):
    847         $(BENCH_V_CC)$(COMPILE)    -DBENCH_N=50000000 $(srcdir)/ctxswitch/pthreads.c
    848 
    849915ctxswitch-cfa_generator$(EXEEXT):
    850         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/cfa_gen.cfa
     916        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/ctxswitch/cfa_gen.cfa
    851917
    852918ctxswitch-cfa_coroutine$(EXEEXT):
    853         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/cfa_cor.cfa
     919        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/ctxswitch/cfa_cor.cfa
    854920
    855921ctxswitch-cfa_thread$(EXEEXT):
    856         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/cfa_thrd.cfa
     922        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/ctxswitch/cfa_thrd.cfa
    857923
    858924ctxswitch-cfa_thread2$(EXEEXT):
    859         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/cfa_thrd2.cfa
     925        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/ctxswitch/cfa_thrd2.cfa
    860926
    861927ctxswitch-upp_coroutine$(EXEEXT):
    862         $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/upp_cor.cc
     928        $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/ctxswitch/upp_cor.cc
    863929
    864930ctxswitch-upp_thread$(EXEEXT):
    865         $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/ctxswitch/upp_thrd.cc
    866 
    867 ctxswitch-goroutine$(EXEEXT):
     931        $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/ctxswitch/upp_thrd.cc
     932
     933ctxswitch-python_coroutine$(EXEEXT):
     934        $(BENCH_V_PY)echo "#!/bin/sh" > a.out
     935        echo "python3.7 $(srcdir)/ctxswitch/python_cor.py" >> a.out
     936        chmod a+x a.out
     937
     938ctxswitch-nodejs_coroutine$(EXEEXT):
     939        $(BENCH_V_NODEJS)echo "#!/bin/sh" > a.out
     940        echo "nodejs $(srcdir)/ctxswitch/node_cor.js" >> a.out
     941        chmod a+x a.out
     942
     943ctxswitch-nodejs_await$(EXEEXT):
     944        $(BENCH_V_NODEJS)echo "#!/bin/sh" > a.out
     945        echo "nodejs $(srcdir)/ctxswitch/node_await.js" >> a.out
     946        chmod a+x a.out
     947
     948ctxswitch-goroutine_thread$(EXEEXT):
    868949        $(BENCH_V_GOC)go build -o a.out $(srcdir)/ctxswitch/goroutine.go
     950
     951ctxswitch-rust_thread$(EXEEXT):
     952        $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/ctxswitch/rust_thrd.rs
    869953
    870954ctxswitch-java_thread$(EXEEXT):
    871955        $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/ctxswitch/JavaThread.java
    872         @echo "#!/bin/sh" > a.out
    873         @echo "java JavaThread" >> a.out
    874         @chmod a+x a.out
    875 
    876 mutex$(EXEEXT) :\
    877         loop.run                        \
    878         function.run            \
    879         fetch_add.run           \
    880         mutex-pthread_lock.run  \
    881         mutex-upp.run           \
     956        echo "#!/bin/sh" > a.out
     957        echo "java JavaThread" >> a.out
     958        chmod a+x a.out
     959
     960ctxswitch-pthread$(EXEEXT):
     961        $(BENCH_V_CC)$(COMPILE) $(srcdir)/ctxswitch/pthreads.c
     962
     963mutex$(EXEEXT) :                \
    882964        mutex-cfa1.run          \
    883965        mutex-cfa2.run          \
    884966        mutex-cfa4.run          \
    885         mutex-java_thread.run
    886 
    887 mutex-pthread_lock$(EXEEXT):
    888         $(BENCH_V_CC)$(COMPILE)    -DBENCH_N=50000000 $(srcdir)/mutex/pthreads.c
     967        mutex-upp.run           \
     968        mutex-go.run            \
     969        mutex-rust.run          \
     970        mutex-java.run          \
     971        mutex-pthread.run
     972
     973mutex-pthread$(EXEEXT):
     974        $(BENCH_V_CC)$(COMPILE) $(srcdir)/mutex/pthreads.c
     975
     976mutex-cfa1$(EXEEXT):
     977        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutex/cfa1.cfa
     978
     979mutex-cfa2$(EXEEXT):
     980        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutex/cfa2.cfa
     981
     982mutex-cfa4$(EXEEXT):
     983        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutex/cfa4.cfa
    889984
    890985mutex-upp$(EXEEXT):
    891         $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/mutex/upp.cc
    892 
    893 mutex-cfa1$(EXEEXT):
    894         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=5000000  $(srcdir)/mutex/cfa1.cfa
    895 
    896 mutex-cfa2$(EXEEXT):
    897         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=5000000  $(srcdir)/mutex/cfa2.cfa
    898 
    899 mutex-cfa4$(EXEEXT):
    900         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=5000000  $(srcdir)/mutex/cfa4.cfa
    901 
    902 mutex-java_thread$(EXEEXT):
     986        $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/mutex/upp.cc
     987
     988mutex-go$(EXEEXT):
     989        $(BENCH_V_GOC)go build -o a.out $(srcdir)/mutex/goroutine.go
     990
     991mutex-rust$(EXEEXT):
     992        $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/mutex/rust.rs
     993
     994mutex-java$(EXEEXT):
    903995        $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/mutex/JavaThread.java
    904         @echo "#!/bin/sh" > a.out
    905         @echo "java JavaThread" >> a.out
    906         @chmod a+x a.out
    907 
    908 signal$(EXEEXT) :\
    909         signal-pthread_cond.run \
    910         signal-upp.run          \
    911         signal-cfa1.run         \
    912         signal-cfa2.run         \
    913         signal-cfa4.run         \
    914         signal-java_thread.run
    915 
    916 signal-pthread_cond$(EXEEXT):
    917         $(BENCH_V_CC)$(COMPILE)    -DBENCH_N=500000  $(srcdir)/schedint/pthreads.c
    918 
    919 signal-upp$(EXEEXT):
    920         $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=5000000 $(srcdir)/schedint/upp.cc
    921 
    922 signal-cfa1$(EXEEXT):
    923         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000  $(srcdir)/schedint/cfa1.cfa
    924 
    925 signal-cfa2$(EXEEXT):
    926         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000  $(srcdir)/schedint/cfa2.cfa
    927 
    928 signal-cfa4$(EXEEXT):
    929         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000  $(srcdir)/schedint/cfa4.cfa
    930 
    931 signal-java_thread$(EXEEXT):
     996        echo "#!/bin/sh" > a.out
     997        echo "java JavaThread" >> a.out
     998        chmod a+x a.out
     999
     1000schedint$(EXEEXT) :             \
     1001        schedint-cfa1.run       \
     1002        schedint-cfa2.run       \
     1003        schedint-cfa4.run       \
     1004        schedint-upp.run        \
     1005        schedint-rust.run       \
     1006        schedint-java.run       \
     1007        schedint-pthread.run
     1008
     1009schedint-cfa1$(EXEEXT):
     1010        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedint/cfa1.cfa
     1011
     1012schedint-cfa2$(EXEEXT):
     1013        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedint/cfa2.cfa
     1014
     1015schedint-cfa4$(EXEEXT):
     1016        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedint/cfa4.cfa
     1017
     1018schedint-upp$(EXEEXT):
     1019        $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/schedint/upp.cc
     1020
     1021schedint-rust$(EXEEXT):
     1022        $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/schedint/rust.rs
     1023
     1024schedint-java$(EXEEXT):
    9321025        $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/schedint/JavaThread.java
    933         @echo "#!/bin/sh" > a.out
    934         @echo "java JavaThread" >> a.out
    935         @chmod a+x a.out
    936 
    937 waitfor$(EXEEXT) :\
    938         waitfor-upp.run         \
    939         waitfor-cfa1.run                \
    940         waitfor-cfa2.run                \
    941         waitfor-cfa4.run
    942 
    943 waitfor-upp$(EXEEXT):
    944         $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=5000000 $(srcdir)/schedext/upp.cc
    945 
    946 waitfor-cfa1$(EXEEXT):
    947         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000  $(srcdir)/schedext/cfa1.cfa
    948 
    949 waitfor-cfa2$(EXEEXT):
    950         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000  $(srcdir)/schedext/cfa2.cfa
    951 
    952 waitfor-cfa4$(EXEEXT):
    953         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=500000  $(srcdir)/schedext/cfa4.cfa
    954 
    955 creation$(EXEEXT) :\
    956         creation-pthread.run                    \
     1026        echo "#!/bin/sh" > a.out
     1027        echo "java JavaThread" >> a.out
     1028        chmod a+x a.out
     1029
     1030schedint-pthread$(EXEEXT):
     1031        $(BENCH_V_CC)$(COMPILE) $(srcdir)/schedint/pthreads.c
     1032
     1033schedext$(EXEEXT) :             \
     1034        schedext-cfa1.run       \
     1035        schedext-cfa2.run       \
     1036        schedext-cfa4.run       \
     1037        schedext-upp.run        \
     1038        schedext-goroutine.run
     1039
     1040schedext-cfa1$(EXEEXT):
     1041        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedext/cfa1.cfa
     1042
     1043schedext-cfa2$(EXEEXT):
     1044        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedext/cfa2.cfa
     1045
     1046schedext-cfa4$(EXEEXT):
     1047        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedext/cfa4.cfa
     1048
     1049schedext-upp$(EXEEXT):
     1050        $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/schedext/upp.cc
     1051
     1052schedext-goroutine$(EXEEXT):
     1053        $(BENCH_V_GOC)go build -o a.out $(srcdir)/schedext/goroutine.go
     1054
     1055creation$(EXEEXT) :                             \
     1056        creation-cfa_generator.run              \
    9571057        creation-cfa_coroutine.run              \
    9581058        creation-cfa_coroutine_eager.run        \
     
    9601060        creation-upp_coroutine.run              \
    9611061        creation-upp_thread.run                 \
    962         creation-goroutine.run                  \
    963         creation-java_thread.run
     1062        creation-python_coroutine.run           \
     1063        creation-nodejs_coroutine.run           \
     1064        creation-goroutine_thread.run           \
     1065        creation-rust_thread.run                \
     1066        creation-java_thread.run                \
     1067        creation-pthread.run
     1068
     1069creation-cfa_generator$(EXEEXT):
     1070        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_gen.cfa
    9641071
    9651072creation-cfa_coroutine$(EXEEXT):
    966         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=10000000 $(srcdir)/creation/cfa_cor.cfa
     1073        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_cor.cfa
    9671074
    9681075creation-cfa_coroutine_eager$(EXEEXT):
    969         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=10000000 $(srcdir)/creation/cfa_cor.cfa  -DEAGER
     1076        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_cor.cfa  -DEAGER
    9701077
    9711078creation-cfa_thread$(EXEEXT):
    972         $(BENCH_V_CFA)$(CFACOMPILE) -DBENCH_N=10000000 $(srcdir)/creation/cfa_thrd.cfa
     1079        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_thrd.cfa
    9731080
    9741081creation-upp_coroutine$(EXEEXT):
    975         $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/creation/upp_cor.cc
     1082        $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/creation/upp_cor.cc
    9761083
    9771084creation-upp_thread$(EXEEXT):
    978         $(BENCH_V_UPP)$(UPPCOMPILE) -DBENCH_N=50000000 $(srcdir)/creation/upp_thrd.cc
    979 
    980 creation-pthread$(EXEEXT):
    981         $(BENCH_V_CC)$(COMPILE)    -DBENCH_N=250000   $(srcdir)/creation/pthreads.c
    982 
    983 creation-goroutine$(EXEEXT):
     1085        $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/creation/upp_thrd.cc
     1086
     1087creation-python_coroutine$(EXEEXT):
     1088        $(BENCH_V_PY)echo "#!/bin/sh" > a.out
     1089        echo "python3.7 $(srcdir)/creation/python_cor.py" >> a.out
     1090        chmod a+x a.out
     1091
     1092creation-nodejs_coroutine$(EXEEXT):
     1093        $(BENCH_V_NODEJS)echo "#!/bin/sh" > a.out
     1094        echo "nodejs $(srcdir)/creation/node_cor.js" >> a.out
     1095        chmod a+x a.out
     1096
     1097creation-goroutine_thread$(EXEEXT):
    9841098        $(BENCH_V_GOC)go build -o a.out $(srcdir)/creation/goroutine.go
     1099
     1100creation-rust_thread$(EXEEXT):
     1101        $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/creation/rust_thrd.rs
    9851102
    9861103creation-java_thread$(EXEEXT):
    9871104        $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/creation/JavaThread.java
    988         @echo "#!/bin/sh" > a.out
    989         @echo "java JavaThread" >> a.out
    990         @chmod a+x a.out
    991 
    992 compile$(EXEEXT) :\
     1105        echo "#!/bin/sh" > a.out
     1106        echo "java JavaThread" >> a.out
     1107        chmod a+x a.out
     1108
     1109creation-pthread$(EXEEXT):
     1110        $(BENCH_V_CC)$(COMPILE) $(srcdir)/creation/pthreads.c
     1111
     1112compile$(EXEEXT) :              \
    9931113        compile-array.make      \
    9941114        compile-attributes.make \
     
    10011121
    10021122compile-array$(EXEEXT):
    1003         @$(CFACOMPILE) -fsyntax-only -w $(testdir)/array.cfa
     1123        $(CFACOMPILE) -fsyntax-only -w $(testdir)/array.cfa
    10041124
    10051125compile-attributes$(EXEEXT):
    1006         @$(CFACOMPILE) -fsyntax-only -w $(testdir)/attributes.cfa
     1126        $(CFACOMPILE) -fsyntax-only -w $(testdir)/attributes.cfa
    10071127
    10081128compile-empty$(EXEEXT):
    1009         @$(CFACOMPILE) -fsyntax-only -w $(srcdir)/compile/empty.cfa
     1129        $(CFACOMPILE) -fsyntax-only -w $(srcdir)/compile/empty.cfa
    10101130
    10111131compile-expression$(EXEEXT):
    1012         @$(CFACOMPILE) -fsyntax-only -w $(testdir)/expression.cfa
     1132        $(CFACOMPILE) -fsyntax-only -w $(testdir)/expression.cfa
    10131133
    10141134compile-io$(EXEEXT):
    1015         @$(CFACOMPILE) -fsyntax-only -w $(testdir)/io1.cfa
     1135        $(CFACOMPILE) -fsyntax-only -w $(testdir)/io1.cfa
    10161136
    10171137compile-monitor$(EXEEXT):
    1018         @$(CFACOMPILE) -fsyntax-only -w $(testdir)/concurrent/monitor.cfa
     1138        $(CFACOMPILE) -fsyntax-only -w $(testdir)/concurrent/monitor.cfa
    10191139
    10201140compile-operators$(EXEEXT):
    1021         @$(CFACOMPILE) -fsyntax-only -w $(testdir)/operators.cfa
     1141        $(CFACOMPILE) -fsyntax-only -w $(testdir)/operators.cfa
    10221142
    10231143compile-thread$(EXEEXT):
    1024         @$(CFACOMPILE) -fsyntax-only -w $(testdir)/concurrent/thread.cfa
     1144        $(CFACOMPILE) -fsyntax-only -w $(testdir)/concurrent/thread.cfa
    10251145
    10261146compile-typeof$(EXEEXT):
    1027         @$(CFACOMPILE) -fsyntax-only -w $(testdir)/typeof.cfa
     1147        $(CFACOMPILE) -fsyntax-only -w $(testdir)/typeof.cfa
     1148
     1149size$(EXEEXT) : size-cfa.runquiet
     1150
     1151size-cfa$(EXEEXT):
     1152        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/size/size.cfa
    10281153
    10291154# Tell versions [3.59,3.63) of GNU make to not export all variables.
  • benchmark/bench.h

    r9fb8f01 r3d5701e  
    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

    r9fb8f01 r3d5701e  
    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

    r9fb8f01 r3d5701e  
    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

    r9fb8f01 r3d5701e  
    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

    r9fb8f01 r3d5701e  
    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

    r9fb8f01 r3d5701e  
    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

    r9fb8f01 r3d5701e  
    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

    r9fb8f01 r3d5701e  
    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

    r9fb8f01 r3d5701e  
    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

    r9fb8f01 r3d5701e  
    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

    r9fb8f01 r3d5701e  
    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

    r9fb8f01 r3d5701e  
    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

    r9fb8f01 r3d5701e  
    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

    r9fb8f01 r3d5701e  
    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

    r9fb8f01 r3d5701e  
    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

    r9fb8f01 r3d5701e  
    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

    r9fb8f01 r3d5701e  
    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

    r9fb8f01 r3d5701e  
    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

    r9fb8f01 r3d5701e  
    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

    r9fb8f01 r3d5701e  
    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

    r9fb8f01 r3d5701e  
    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

    r9fb8f01 r3d5701e  
    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

    r9fb8f01 r3d5701e  
    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

    r9fb8f01 r3d5701e  
    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

    r9fb8f01 r3d5701e  
    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

    r9fb8f01 r3d5701e  
    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

    r9fb8f01 r3d5701e  
    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

    r9fb8f01 r3d5701e  
    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

    r9fb8f01 r3d5701e  
    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

    r9fb8f01 r3d5701e  
    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

    r9fb8f01 r3d5701e  
    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

    r9fb8f01 r3d5701e  
    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

    r9fb8f01 r3d5701e  
    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

    r9fb8f01 r3d5701e  
    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

    r9fb8f01 r3d5701e  
    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

    r9fb8f01 r3d5701e  
    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: //
  • configure

    r9fb8f01 r3d5701e  
    663663ac_ct_DUMPBIN
    664664DUMPBIN
    665 LD
    666665FGREP
    667666EGREP
     
    701700LDFLAGS
    702701CXXFLAGS
    703 CXX
    704702CFA_FLAGS
    705703LIBCFA_TARGET_MAKEFILES
     
    717715BUILD_IN_TREE_FLAGS
    718716CFACPP
     717CFACC_INSTALL
    719718CFACC
    720719DRIVER_DIR
     
    723722CFA_INCDIR
    724723CFA_PREFIX
     724HAS_DISTCC
     725LD
     726CXX
     727ENABLE_DISTCC_FALSE
     728ENABLE_DISTCC_TRUE
    725729DOendif
    726730DOifskipcompile
     
    797801enable_silent_rules
    798802with_cfa_name
     803enable_distcc
    799804with_target_hosts
    800805enable_gprofiler
     
    14591464  --enable-silent-rules   less verbose build output (undo: "make V=1")
    14601465  --disable-silent-rules  verbose build output (undo: "make V=0")
     1466  --enable-distcc     whether or not to enable distributed compilation
    14611467  --enable-gprofiler     whether or not to enable gprofiler tools (if available)
    14621468  --enable-demangler     whether or not to build the demangler (executable and library)
     
    31843190
    31853191#==============================================================================
     3192# distcc support
     3193
     3194# Check whether --enable-distcc was given.
     3195if test "${enable_distcc+set}" = set; then :
     3196  enableval=$enable_distcc; enable_distcc=$enableval
     3197else
     3198  enable_distcc=no
     3199fi
     3200
     3201
     3202 if test x$enable_distcc = xyes; then
     3203  ENABLE_DISTCC_TRUE=
     3204  ENABLE_DISTCC_FALSE='#'
     3205else
     3206  ENABLE_DISTCC_TRUE='#'
     3207  ENABLE_DISTCC_FALSE=
     3208fi
     3209
     3210HAS_DISTCC="False"
     3211
     3212if test x$enable_distcc = xyes; then
     3213        CXX="distcc ${CXX}"
     3214        LD="distcc ${LD} -lstdc++"
     3215        HAS_DISTCC="True"
     3216        echo "Enabling distributed builds"
     3217fi
     3218
     3219
     3220
     3221
     3222
     3223#==============================================================================
    31863224# Installation paths
    31873225
     
    32663304DRIVER_DIR=${TOP_BUILDDIR}driver/
    32673305CFACC=${DRIVER_DIR}cfa
     3306CFACC_INSTALL=${CFA_BINDIR}${CFA_NAME}
    32683307CFACPP=${DRIVER_DIR}cfa-cpp
     3308
    32693309
    32703310
     
    1701717057fi
    1701817058
     17059if test -z "${ENABLE_DISTCC_TRUE}" && test -z "${ENABLE_DISTCC_FALSE}"; then
     17060  as_fn_error $? "conditional \"ENABLE_DISTCC\" was never defined.
     17061Usually this means the macro was only invoked conditionally." "$LINENO" 5
     17062fi
    1701917063if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then
    1702017064  as_fn_error $? "conditional \"AMDEP\" was never defined.
  • configure.ac

    r9fb8f01 r3d5701e  
    5858
    5959#==============================================================================
     60# distcc support
     61
     62AC_ARG_ENABLE(distcc,
     63        [  --enable-distcc     whether or not to enable distributed compilation],
     64        enable_distcc=$enableval, enable_distcc=no)
     65
     66AM_CONDITIONAL([ENABLE_DISTCC], [test x$enable_distcc = xyes])
     67HAS_DISTCC="False"
     68
     69if test x$enable_distcc = xyes; then
     70        CXX="distcc ${CXX}"
     71        LD="distcc ${LD} -lstdc++"
     72        HAS_DISTCC="True"
     73        echo "Enabling distributed builds"
     74fi
     75
     76AC_SUBST(CXX)
     77AC_SUBST(LD)
     78AC_SUBST(HAS_DISTCC)
     79
     80#==============================================================================
    6081# Installation paths
    6182M4CFA_PARSE_PREFIX
     
    7293DRIVER_DIR=${TOP_BUILDDIR}driver/
    7394CFACC=${DRIVER_DIR}cfa
     95CFACC_INSTALL=${CFA_BINDIR}${CFA_NAME}
    7496CFACPP=${DRIVER_DIR}cfa-cpp
    7597AC_SUBST(DRIVER_DIR)
    7698AC_SUBST(CFACC)
     99AC_SUBST(CFACC_INSTALL)
    77100AC_SUBST(CFACPP)
    78101
  • doc/papers/concurrency/Paper.tex

    r9fb8f01 r3d5701e  
    239239\lstMakeShortInline@%
    240240
     241\newcommand{\commenttd}[1]{{\color{red}{Thierry : #1}}}
     242
    241243\let\OLDthebibliography\thebibliography
    242244\renewcommand\thebibliography[1]{
     
    11631165% }
    11641166% int main() {
    1165 % 
     1167%
    11661168%       for ( int i = 0; i < 10; i += 1 ) {
    11671169%               printf( "%d\n", fib() );
     
    18341836                if ( random() % 3 ) transfer( b1, b2, 7 );
    18351837        }
    1836 }   
     1838}
    18371839int main() {
    18381840        `Person p1 = { b1, b2 }, p2 = { b2, b1 };`
     
    18641866                if ( random() % 3 ) transfer( b1, b2, 7 );
    18651867        }
    1866 }   
     1868}
    18671869int main() {
    18681870        `thread p1(person, ref(b1), ref(b2)), p2(person, ref(b2), ref(b1));`
     
    27392741% \section{Parallelism}
    27402742% \label{s:Parallelism}
    2741 % 
     2743%
    27422744% Historically, computer performance was about processor speeds.
    27432745% However, with heat dissipation being a direct consequence of speed increase, parallelism is the new source for increased performance~\cite{Sutter05, Sutter05b}.
     
    27462748% However, kernel threads are better as an implementation tool because of complexity and higher cost.
    27472749% Therefore, different abstractions are often layered onto kernel threads to simplify them, \eg pthreads.
    2748 % 
    2749 % 
     2750%
     2751%
    27502752% \subsection{User Threads}
    2751 % 
     2753%
    27522754% A direct improvement on kernel threads is user threads, \eg Erlang~\cite{Erlang} and \uC~\cite{uC++book}.
    27532755% This approach provides an interface that matches the language paradigms, gives more control over concurrency by the language runtime, and an abstract (and portable) interface to the underlying kernel threads across operating systems.
     
    27552757% Like kernel threads, user threads support preemption, which maximizes nondeterminism, but increases the potential for concurrency errors: race, livelock, starvation, and deadlock.
    27562758% \CFA adopts user-threads to provide more flexibility and a low-cost mechanism to build any other concurrency approach, \eg thread pools and actors~\cite{Actors}.
    2757 % 
     2759%
    27582760% A variant of user thread is \newterm{fibres}, which removes preemption, \eg Go~\cite{Go} @goroutine@s.
    27592761% Like functional programming, which removes mutation and its associated problems, removing preemption from concurrency reduces nondeterminism, making race and deadlock errors more difficult to generate.
  • driver/Makefile.in

    r9fb8f01 r3d5701e  
    201201CCDEPMODE = @CCDEPMODE@
    202202CFACC = @CFACC@
     203CFACC_INSTALL = @CFACC_INSTALL@
    203204CFACPP = @CFACPP@
    204205CFA_BACKEND_CC = @CFA_BACKEND_CC@
     
    231232FGREP = @FGREP@
    232233GREP = @GREP@
     234HAS_DISTCC = @HAS_DISTCC@
    233235HOST_FLAGS = @HOST_FLAGS@
    234236INSTALL = @INSTALL@
  • driver/cc1.cc

    r9fb8f01 r3d5701e  
    1010// Created On       : Fri Aug 26 14:23:51 2005
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Aug 23 15:06:27 2019
    13 // Update Count     : 371
     12// Last Modified On : Sun Oct 20 08:14:33 2019
     13// Update Count     : 385
    1414//
    1515
     
    3333
    3434
    35 static string installlibdir( CFA_LIBDIR );                              // fixed location of cc1 and cfa-cpp commands when installed
    36 static string compiler_path( CFA_BACKEND_CC );                  // path/name of C compiler
     35static string compiler_path( CFA_BACKEND_CC );                  // C compiler path/name
    3736static bool CFA_flag = false;                                                   // -CFA flag
    3837static bool save_temps = false;                                                 // -save-temps flag
    3938static string o_file;
     39static string bprefix;
    4040
    4141
     
    5858
    5959
    60 static string __CFA_FLAGPREFIX__( "__CFA_FLAG" );
     60static string __CFA_FLAGPREFIX__( "__CFA_FLAG" );               // "N__=" suffix
    6161
    6262static void checkEnv1( const char * args[], int & nargs ) { // stage 1
     
    7070
    7171                if ( prefix( arg, __CFA_FLAGPREFIX__ ) ) {
    72                         string val( arg.substr( __CFA_FLAGPREFIX__.size() + 4 ) );
     72                        string val( arg.substr( arg.find_first_of( "=" ) + 1 ) );
    7373                        if ( prefix( val, "-compiler=" ) ) {
    7474                                compiler_path = val.substr( 10 );
     
    8989
    9090                if ( prefix( arg, __CFA_FLAGPREFIX__ ) ) {
    91                         string val( arg.substr( __CFA_FLAGPREFIX__.size() + 4 ) );
     91                        string val( arg.substr( arg.find_first_of( "=" ) + 1 ) );
    9292                        if ( prefix( val, "-compiler=" ) ) {
    9393                                compiler_path = val.substr( 10 );
     
    9898                        } else if ( prefix( val, "-o=" ) ) {            // output file for -CFA
    9999                                o_file = val.substr( 3 );
    100                         } else {
    101                                 args[nargs++] = ( *new string( arg.substr( __CFA_FLAGPREFIX__.size() + 4 ) ) ).c_str();
     100                        } else if ( prefix( val, "-B=" ) ) {            // location of cfa-cpp
     101                                bprefix = val.substr( 3 );
     102                        } else {                                                                        // normal flag for cfa-cpp
     103                                args[nargs++] = ( *new string( arg.substr( arg.find_first_of( "=" ) + 1 ) ) ).c_str();
    102104                        } // if
    103105                } // if
     
    106108
    107109
    108 static char tmpname[] = P_tmpdir "/CFAXXXXXX.i";
     110static char tmpname[] = P_tmpdir "/CFAXXXXXX.ifa";
    109111static int tmpfilefd = -1;
    110112static bool startrm = false;
     
    291293
    292294                execvp( args[0], (char * const *)args );                // should not return
    293                 perror( "CC1 Translator error: stage 1, execvp" );
     295                perror( "CC1 Translator error: stage 1 cpp, execvp" );
     296                cerr << " invoked " << args[0] << endl;
    294297                exit( EXIT_FAILURE );
    295298        } // if
     
    332335        #endif // __DEBUG_H__
    333336
     337        enum {
     338                Color_Auto   = 0,
     339                Color_Always = 1,
     340                Color_Never  = 2,
     341        } color_arg = Color_Auto;
     342
     343        const char * color_names[3] = { "--colors=auto", "--colors=always", "--colors=never" };
     344
    334345        // process all the arguments
    335346
     
    338349                if ( prefix( arg, "-" ) ) {
    339350                        // strip inappropriate flags
     351
     352                        if ( prefix( arg, "-fdiagnostics-color=" ) ) {
     353                                string choice = arg.substr(20);
     354                                     if(choice == "always") color_arg = Color_Always;
     355                                else if(choice == "never" ) color_arg = Color_Never;
     356                                else if(choice == "auto"  ) color_arg = Color_Auto;
     357                        } else if ( arg == "-fno-diagnostics-color" ) {
     358                                color_arg = Color_Auto;
     359                        }
    340360
    341361                        if ( arg == "-quiet" || arg == "-version" || arg == "-fpreprocessed" ||
     
    411431                        } // if
    412432                } else {
    413                         tmpfilefd = mkstemps( tmpname, 2 );
     433                        tmpfilefd = mkstemps( tmpname, 4 );
    414434                        if ( tmpfilefd == -1 ) {
    415435                                perror( "CC1 Translator error: stage 2, mkstemp" );
     
    427447
    428448        if ( fork() == 0 ) {                                                            // child runs CFA
    429                 cargs[0] = ( *new string( installlibdir + "cfa-cpp" ) ).c_str();
    430 
     449                cargs[0] = ( *new string( bprefix + "cfa-cpp" ) ).c_str();
    431450                cargs[ncargs++] = cpp_in;
    432451
     
    438457                        cargs[ncargs++] = cfa_cpp_out.c_str();
    439458                } // if
    440                 cargs[ncargs] = nullptr;                                                        // terminate argument list
     459
     460                cargs[ncargs++] = color_names[color_arg];
     461
     462                cargs[ncargs] = nullptr;                                                // terminate argument list
    441463
    442464                #ifdef __DEBUG_H__
     
    448470
    449471                execvp( cargs[0], (char * const *)cargs );              // should not return
    450                 perror( "CC1 Translator error: stage 2, execvp" );
     472                perror( "CC1 Translator error: stage 2 cfa-cpp, execvp" );
     473                cerr << " invoked " << cargs[0] << endl;
    451474                exit( EXIT_FAILURE );
    452475        } // if
     
    484507                args[0] = compiler_path.c_str();
    485508                args[nargs++] = "-S";                                                   // only compile and put assembler output in specified file
    486                 if ( save_temps ) {                                                             // make gcc accept .ifa suffix
    487                         args[nargs++] = "-x";
    488                         args[nargs++] = "cpp-output";
    489                 } // if
     509                args[nargs++] = "-x";
     510                args[nargs++] = "cpp-output";
     511
    490512                args[nargs++] = cfa_cpp_out.c_str();
    491513                args[nargs] = nullptr;                                                  // terminate argument list
     
    500522
    501523                execvp( args[0], (char * const *)args );                // should not return
    502                 perror( "CC1 Translator error: stage 2, execvp" );
     524                perror( "CC1 Translator error: stage 2 cc1, execvp" );
     525                cerr << " invoked " << args[0] << endl;
    503526                exit( EXIT_FAILURE );                                                   // tell gcc not to go any further
    504527        } // if
    505528
    506529        wait( &code );                                                                          // wait for child to finish
     530        rmtmpfile();                                                                            // remove tmpname
    507531
    508532        if ( WIFSIGNALED(code) ) {                                                      // child failed ?
    509                 rmtmpfile();                                                                    // remove tmpname
    510533                cerr << "CC1 Translator error: stage 2, child failed " << WTERMSIG(code) << endl;
    511534                exit( EXIT_FAILURE );
     
    516539        #endif // __DEBUG_H__
    517540
    518         rmtmpfile();                                                                            // remove tmpname
    519541        exit( WEXITSTATUS( code ) );                                            // stop regardless of success or failure
    520542} // Stage2
  • driver/cfa.cc

    r9fb8f01 r3d5701e  
    1010// Created On       : Tue Aug 20 13:44:49 2002
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Aug 23 16:27:07 2019
    13 // Update Count     : 411
     12// Last Modified On : Fri Jan 31 16:48:03 2020
     13// Update Count     : 421
    1414//
    1515
    1616#include <iostream>
    17 #include <cstdio>                                                                               // perror
    18 #include <cstdlib>                                                                              // putenv, exit
    19 #include <unistd.h>                                                                             // execvp
    20 #include <string>                                                                               // STL version
    21 #include <string.h>                                                                             // strcmp
    22 #include <algorithm>                                                                    // find
     17#include <cstdio>      // perror
     18#include <cstdlib>     // putenv, exit
     19#include <climits>     // PATH_MAX
     20#include <unistd.h>    // execvp
     21#include <string>      // STL version
     22#include <string.h>    // strcmp
     23#include <algorithm>   // find
    2324
    2425#include <sys/types.h>
     
    3334using std::to_string;
    3435
    35 //#define __DEBUG_H__
    36 
     36// #define __DEBUG_H__
     37
     38// "N__=" suffix
     39static string __CFA_FLAGPREFIX__( "__CFA_FLAG" );
    3740
    3841void Putenv( char * argv[], string arg ) {
    39         static int flags = 0;                                                           // environment variables must have unique names
    40 
    41         if ( putenv( (char *)( *new string( string( "__CFA_FLAG" + to_string( flags++ ) + "__=" ) + arg ) ).c_str() ) ) {
     42        // environment variables must have unique names
     43        static int flags = 0;
     44
     45        if ( putenv( (char *)( *new string( string( __CFA_FLAGPREFIX__ + to_string( flags++ ) + "__=" ) + arg ) ).c_str() ) ) {
    4246                cerr << argv[0] << " error, cannot set environment variable." << endl;
    4347                exit( EXIT_FAILURE );
     
    4549} // Putenv
    4650
    47 
    48 bool prefix( const string & arg, const string & pre ) { // check if string has prefix
     51// check if string has prefix
     52bool prefix( const string & arg, const string & pre ) {
    4953        return arg.substr( 0, pre.size() ) == pre;
    5054} // prefix
    5155
    52 bool suffix( const string & arg ) {                                             // check if string has suffix
     56inline bool ends_with(const string & str, const string & sfix) {
     57        if (sfix.size() > str.size()) return false;
     58        return std::equal(str.rbegin(), str.rbegin() + sfix.size(), sfix.rbegin(), sfix.rend());
     59}
     60
     61// check if string has suffix
     62bool suffix( const string & arg ) {
    5363        enum { NumSuffixes = 3 };
    5464        static const string suffixes[NumSuffixes] = { "cfa", "hfa", "ifa" };
     
    6474    struct stat info;
    6575    if ( stat( path.c_str(), &info ) != 0 ) return false;
    66     if ( info.st_mode & S_IFDIR ) return true;
    67         return false;
     76        return (info.st_mode & S_IFDIR) != 0;
    6877} // dirExists
     78
     79static inline string dir(const string & path) {
     80        return path.substr(0, path.find_last_of('/'));
     81}
     82
     83// Different path modes
     84enum PathMode {
     85        Installed,     // cfa is installed, use prefix
     86        BuildTree,     // cfa is in the tree, use source and build tree
     87        Distributed    // cfa is distributed, use build tree for includes and executable directory for .cfs
     88};
     89
     90// Get path mode from /proc
     91PathMode FromProc() {
     92        std::string abspath;
     93        abspath.resize(PATH_MAX);
     94
     95        // get executable path from /proc/self/exe
     96        ssize_t size = readlink("/proc/self/exe", const_cast<char*>(abspath.c_str()), abspath.size());
     97        if(size <= 0) {
     98                std::cerr << "Error could not evaluate absolute path from /proc/self/exe" << std::endl;
     99                std::cerr << "Failed with " << std::strerror(errno) << std::endl;
     100                std::exit(1);
     101        }
     102
     103        // Trim extra characters
     104        abspath.resize(size);
     105
     106        // Are we installed
     107        if(abspath.rfind(CFA_BINDIR  , 0) == 0) { return Installed; }
     108
     109        // Is this the build tree
     110        if(abspath.rfind(TOP_BUILDDIR, 0) == 0) { return BuildTree; }
     111
     112        // Does this look like distcc
     113        if(abspath.find("/.cfadistcc/") != std::string::npos) { return Distributed; }
     114
     115        // None of the above? Give up since we don't know where the prelude or include directories are
     116        std::cerr << "Cannot find required files from excutable path " << abspath << std::endl;
     117        std::exit(1);
     118}
    69119
    70120
     
    82132        string heading;                                                                         // banner printed at start of cfa compilation
    83133        string arg;                                                                                     // current command-line argument during command-line parsing
    84         string Bprefix;                                                                         // path where gcc looks for compiler command steps
     134        string bprefix;                                                                         // path where gcc looks for compiler steps
    85135        string langstd;                                                                         // language standard
    86136
     
    103153        bool m32 = false;                                                                       // -m32 flag
    104154        bool m64 = false;                                                                       // -m64 flag
    105         bool intree = false;                                                            // build in tree
     155        bool compiling_libs = false;
    106156        int o_file = 0;                                                                         // -o filename position
     157
     158        PathMode path = FromProc();
    107159
    108160        const char *args[argc + 100];                                           // cfa command line values, plus some space for additional flags
     
    135187                        } else if ( arg == "-XCFA" ) {                          // CFA pass through
    136188                                i += 1;
     189                                if ( i == argc ) continue;                              // next argument available ?
    137190                                Putenv( argv, argv[i] );
    138191
     
    159212                        } else if ( arg == "-no-include-stdhdr" ) {
    160213                                noincstd_flag = true;                                   // strip the no-include-stdhdr flag
    161                         } else if ( arg == "-in-tree" ) {
    162                                 intree = true;
     214                        } else if ( arg == "-cfalib") {
     215                                compiling_libs = true;
    163216                        } else if ( arg == "-compiler" ) {
    164217                                // use the user specified compiler
     
    211264                                } // if
    212265                        } else if ( prefix( arg, "-B" ) ) {
    213                                 Bprefix = arg.substr(2);                                // strip the -B flag
    214                                 args[nargs++] = ( *new string( string("-D__GCC_BPREFIX__=") + Bprefix ) ).c_str();
     266                                bprefix = arg.substr(2);                                // strip the -B flag
    215267                        } else if ( arg == "-c" || arg == "-S" || arg == "-E" || arg == "-M" || arg == "-MM" ) {
    216268                                args[nargs++] = argv[i];                                // pass argument along
     
    263315        // -E flag stops at cc1 stage 1, so cfa-cpp in cc1 stage 2 is never executed.
    264316        if ( cpp_flag && CFA_flag ) {
    265                 cerr << argv[0] << " error, cannot use -E and -CFA flags together." << endl;
    266                 exit( EXIT_FAILURE );
     317                CFA_flag = false;
     318                cerr << argv[0] << " warning, both -E and -CFA flags specified, using -E and ignoring -CFA." << endl;
    267319        } // if
    268320
    269321        // add the CFA include-library paths, which allow direct access to header files without directory qualification
    270         if ( ! intree ) {
     322        string libbase;
     323        switch(path) {
     324        case Installed:
    271325                args[nargs++] = "-I" CFA_INCDIR;
    272                 if ( ! noincstd_flag ) {                                                // do not use during build
     326                // do not use during build
     327                if ( ! noincstd_flag ) {
    273328                        args[nargs++] = "-I" CFA_INCDIR "stdhdr";
    274329                } // if
    275330                args[nargs++] = "-I" CFA_INCDIR "concurrency";
    276331                args[nargs++] = "-I" CFA_INCDIR "containers";
    277         } else {
     332                libbase = CFA_LIBDIR;
     333                break;
     334        case BuildTree:
     335        case Distributed:
    278336                args[nargs++] = "-I" TOP_SRCDIR "libcfa/src";
    279                 if ( ! noincstd_flag ) {                                                // do not use during build
     337                // do not use during build
     338                if ( ! noincstd_flag ) {
    280339                        args[nargs++] = "-I" TOP_SRCDIR "libcfa/src" "/stdhdr";
    281340                } // if
    282341                args[nargs++] = "-I" TOP_SRCDIR "libcfa/src" "/concurrency";
    283342                args[nargs++] = "-I" TOP_SRCDIR "libcfa/src" "/containers";
     343
     344                libbase = TOP_BUILDDIR "libcfa/";
     345
     346                break;
    284347        } // if
    285348
     
    288351        args[nargs++] = "stdbool.h";
    289352
    290         string libbase;
    291         if ( ! intree ) {
    292                 libbase = CFA_LIBDIR;
    293         } else {
    294                 libbase = TOP_BUILDDIR "libcfa/";
     353        if( compiling_libs ) {
    295354                Putenv( argv, "-t" );
    296355        } // if
     
    305364        } // if
    306365
    307         string libdir( libbase + arch + "-" + (nolib ? "nolib" : (debug ? "debug": "nodebug")) );
    308         if ( ! dirExists( libdir ) ) {
    309                 cerr << argv[0] << " internal error, cannot find prelude directory " << libdir << endl;
    310                 exit( EXIT_FAILURE );
    311         } // if
     366        const char * config = nolib ? "nolib" : (debug ? "debug": "nodebug");
     367        string libdir = libbase + arch + "-" + config;
     368
     369        if (path != Distributed) {
     370                if ( ! nolib && ! dirExists( libdir ) ) {
     371                        cerr << argv[0] << " internal error, configuration " << config << " not installed." << endl;
     372                        cerr << "Was looking for " << libdir << endl;
     373                        for(int i = 1; i < argc; i++) {
     374                                cerr << argv[i] << " ";
     375                        }
     376                        cerr << endl;
     377                        libdir = libbase + arch + "-" + "nolib";
     378                } // if
     379
     380                if ( ! dirExists( libdir ) ) {
     381                        cerr << argv[0] << " internal error, cannot find prelude directory." << endl;
     382                        cerr << "Was looking for " << libdir << endl;
     383                        exit( EXIT_FAILURE );
     384                } // if
     385        } // if
     386
     387        switch(path) {
     388        case Installed   : Putenv( argv, "--prelude-dir=" + libdir ); break;
     389        case BuildTree   : Putenv( argv, "--prelude-dir=" + libdir + "/prelude" ); break;
     390        case Distributed : Putenv( argv, "--prelude-dir=" + dir(argv[0]) ); break;
     391        }
    312392
    313393        for ( int i = 0; i < nlibs; i += 1 ) {                          // copy non-user libraries after all user libraries
     
    322402                args[nargs++] = "-Xlinker";
    323403                args[nargs++] = "--undefined=__cfaabi_appready_startup";
    324 
    325                 // include the cfa library in case it's needed
    326                 args[nargs++] = ( *new string( string("-L" ) + libdir + (intree ? "/src/.libs" : "")) ).c_str();
    327                 args[nargs++] = ( *new string( string("-Wl,-rpath," ) + libdir + (intree ? "/src/.libs" : "")) ).c_str();
     404                args[nargs++] = "-z";
     405                args[nargs++] = "execstack";
     406
     407                // include the cfa library in case it is needed
     408                args[nargs++] = ( *new string( string("-L" ) + libdir + (path != Installed ? "/src/.libs" : "")) ).c_str();
     409                args[nargs++] = ( *new string( string("-Wl,-rpath," ) + libdir + (path != Installed ? "/src/.libs" : "")) ).c_str();
    328410                args[nargs++] = "-Wl,--push-state,--as-needed";
    329411                args[nargs++] = "-lcfathread";
    330412                args[nargs++] = "-Wl,--pop-state";
     413                args[nargs++] = "-Wl,--push-state,--no-as-needed";
    331414                args[nargs++] = "-lcfa";
    332                 args[nargs++] = "-lpthread";
     415                args[nargs++] = "-Wl,--pop-state";
     416                args[nargs++] = "-pthread";
    333417                args[nargs++] = "-ldl";
    334418                args[nargs++] = "-lrt";
     
    361445        } // if
    362446
    363         Putenv( argv, "--prelude-dir=" + libdir + (intree ? "/prelude" : "") );
    364 
    365447        if ( debug ) {
    366448                heading += " (debug)";
     
    370452        } // if
    371453
    372         if ( Bprefix.length() == 0 ) {
    373                 Bprefix = ! intree ? installlibdir : srcdriverdir;
    374                 if ( Bprefix[Bprefix.length() - 1] != '/' ) Bprefix += '/';
    375                 args[nargs++] = ( *new string( string("-D__GCC_BPREFIX__=") + Bprefix ) ).c_str();
     454        if ( bprefix.length() == 0 ) {
     455                switch(path) {
     456                case Installed   : bprefix = installlibdir; break;
     457                case BuildTree   : bprefix = srcdriverdir ; break;
     458                case Distributed : bprefix = dir(argv[0]) ; break;
     459                }
     460                if ( bprefix[bprefix.length() - 1] != '/' ) bprefix += '/';
     461                Putenv( argv, string("-B=") + bprefix );
    376462        } // if
    377463
     
    401487                args[nargs++] = "-fgnu89-inline";
    402488                args[nargs++] = "-D__int8_t_defined";                   // prevent gcc type-size attributes
    403                 args[nargs++] = ( *new string( string("-B") + Bprefix ) ).c_str();
     489                args[nargs++] = ( *new string( string("-B") + bprefix ) ).c_str();
    404490        } else {
    405491                cerr << argv[0] << " error, compiler \"" << compiler_name << "\" unsupported." << endl;
     
    415501                cerr << " \"" << args[i] << "\"" << endl;
    416502        } // for
     503        cerr << endl;
    417504        #endif // __DEBUG_H__
    418505
    419506        if ( ! quiet ) {
    420507                cerr << "CFA " << "Version " << Version << heading << endl;
    421 
    422508                if ( help ) {
    423509                        cerr <<
  • libcfa/Makefile.in

    r9fb8f01 r3d5701e  
    231231CFACC = @CFACC@
    232232CFACPP = @CFACPP@
     233CFADIR_HASH = @CFADIR_HASH@
    233234CFA_BINDIR = @CFA_BINDIR@
    234235CFA_INCDIR = @CFA_INCDIR@
     
    274275LIPO = @LIPO@
    275276LN_S = @LN_S@
     277LOCAL_CC1 = @LOCAL_CC1@
     278LOCAL_CFACC = @LOCAL_CFACC@
    276279LTLIBOBJS = @LTLIBOBJS@
    277280LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
  • libcfa/automake/missing

    • Property mode changed from 120000 to 100644
    r9fb8f01 r3d5701e  
    1 /usr/share/automake-1.15/missing
     1#! /bin/sh
     2# Tdelisle : having the Makefiles.in automatically regenerated causes problems
     3#            when using multiple versions of automake, even if only on end user machines
     4#            therefore I am disabling that feature by commenting this script
     5exit 0
  • libcfa/configure

    r9fb8f01 r3d5701e  
    707707CONFIG_CFLAGS
    708708ARCH_FLAGS
     709CFADIR_HASH
     710LOCAL_CC1
     711LOCAL_CFACC
    709712CFACPP
    710713CFACC
     714ENABLE_DISTCC_FALSE
     715ENABLE_DISTCC_TRUE
    711716CFA_VERSION
    712717DRIVER_DIR
     
    783788enable_option_checking
    784789enable_silent_rules
     790enable_distcc
    785791with_cfa_name
    786792enable_shared
     
    14451451  --enable-silent-rules   less verbose build output (undo: "make V=1")
    14461452  --disable-silent-rules  verbose build output (undo: "make V=0")
     1453  --enable-distcc     whether or not to enable distributed compilation
    14471454  --enable-shared[=PKGS]  build shared libraries [default=yes]
    14481455  --enable-static[=PKGS]  build static libraries [default=yes]
     
    29412948
    29422949
    2943 CFACC=${DRIVER_DIR}cfa
     2950# Check whether --enable-distcc was given.
     2951if test "${enable_distcc+set}" = set; then :
     2952  enableval=$enable_distcc; enable_distcc=$enableval
     2953else
     2954  enable_distcc=no
     2955fi
     2956
     2957
     2958echo -n "checking for distributated build... "
     2959if test x$enable_distcc = xno; then
     2960        CFACC=${DRIVER_DIR}cfa
     2961        echo "no"
     2962else
     2963        tools="$(readlink -m $ac_confdir/)/../tools/build"
     2964        config=$(basename $(readlink -f .))
     2965        echo "$tools/distcc_hash $config"
     2966        CFADIR_HASH=$($tools/distcc_hash $config)
     2967        CFACC="distcc ~/.cfadistcc/${CFADIR_HASH}/cfa"
     2968        echo "yes (hash=${CFADIR_HASH})"
     2969fi
    29442970CFACPP=${DRIVER_DIR}cfa-cpp
     2971LOCAL_CFACC=${DRIVER_DIR}cfa
     2972LOCAL_CC1=${DRIVER_DIR}cc1
     2973
     2974 if test x$enable_distcc = xyes; then
     2975  ENABLE_DISTCC_TRUE=
     2976  ENABLE_DISTCC_FALSE='#'
     2977else
     2978  ENABLE_DISTCC_TRUE='#'
     2979  ENABLE_DISTCC_FALSE=
     2980fi
     2981
     2982
     2983
     2984
     2985
    29452986
    29462987
     
    29593000case $CONFIGURATION in
    29603001        "debug"   )
    2961                 CONFIG_CFLAGS="-Og -g"
     3002                CONFIG_CFLAGS="-O0 -g"
    29623003                CONFIG_CFAFLAGS="-debug"
    29633004                CONFIG_BUILDLIB="yes"
     
    1698217023fi
    1698317024
     17025if test -z "${ENABLE_DISTCC_TRUE}" && test -z "${ENABLE_DISTCC_FALSE}"; then
     17026  as_fn_error $? "conditional \"ENABLE_DISTCC\" was never defined.
     17027Usually this means the macro was only invoked conditionally." "$LINENO" 5
     17028fi
    1698417029if test -z "${BUILDLIB_TRUE}" && test -z "${BUILDLIB_FALSE}"; then
    1698517030  as_fn_error $? "conditional \"BUILDLIB\" was never defined.
  • libcfa/configure.ac

    r9fb8f01 r3d5701e  
    2727AC_ARG_VAR(CFA_VERSION, [The long version of cfa])
    2828
    29 CFACC=${DRIVER_DIR}cfa
     29AC_ARG_ENABLE(distcc,
     30        [  --enable-distcc     whether or not to enable distributed compilation],
     31        enable_distcc=$enableval, enable_distcc=no)
     32
     33echo -n "checking for distributated build... "
     34if test x$enable_distcc = xno; then
     35        CFACC=${DRIVER_DIR}cfa
     36        echo "no"
     37else
     38        tools="$(readlink -m $ac_confdir/)/../tools/build"
     39        config=$(basename $(readlink -f .))
     40        echo "$tools/distcc_hash $config"
     41        CFADIR_HASH=$($tools/distcc_hash $config)
     42        CFACC="distcc ~/.cfadistcc/${CFADIR_HASH}/cfa"
     43        echo "yes (hash=${CFADIR_HASH})"
     44fi
    3045CFACPP=${DRIVER_DIR}cfa-cpp
     46LOCAL_CFACC=${DRIVER_DIR}cfa
     47LOCAL_CC1=${DRIVER_DIR}cc1
     48
     49AM_CONDITIONAL([ENABLE_DISTCC], [test x$enable_distcc = xyes])
     50
    3151AC_SUBST(CFACC)
    3252AC_SUBST(CFACPP)
     53AC_SUBST(LOCAL_CFACC)
     54AC_SUBST(LOCAL_CC1)
     55AC_SUBST(CFADIR_HASH)
    3356AC_SUBST(CFA_VERSION)
    3457
     
    4568case $CONFIGURATION in
    4669        "debug"   )
    47                 CONFIG_CFLAGS="-Og -g"
     70                CONFIG_CFLAGS="-O0 -g"
    4871                CONFIG_CFAFLAGS="-debug"
    4972                CONFIG_BUILDLIB="yes"
  • libcfa/prelude/Makefile.am

    r9fb8f01 r3d5701e  
    1111## Created On       : Sun May 31 08:54:01 2015
    1212## Last Modified By : Peter A. Buhr
    13 ## Last Modified On : Wed Dec 14 15:00:35 2016
    14 ## Update Count     : 205
     13## Last Modified On : Mon Feb  3 21:27:18 2020
     14## Update Count     : 208
    1515###############################################################################
    1616
     
    2323cfalib_DATA = gcc-builtins.cf builtins.cf extras.cf prelude.cfa bootloader.c
    2424
    25 CC = @CFACC@
     25CC = @LOCAL_CFACC@
    2626AM_CFLAGS = -g -Wall -Wno-unused-function -fPIC @ARCH_FLAGS@ @CONFIG_CFLAGS@
    2727AM_CFAFLAGS = @CONFIG_CFAFLAGS@
     
    3636extras.cf : ${srcdir}/extras.regx ${srcdir}/extras.c
    3737        ${AM_V_GEN}gcc ${AM_CFLAGS} -E ${srcdir}/extras.c | grep -f ${srcdir}/extras.regx > extras.cf
     38        ${AM_V_GEN}gcc ${AM_CFLAGS} -E ${srcdir}/extras.c | grep -zo -f ${srcdir}/extras.regx2 | tr '\0' '\n' >> extras.cf
    3839
    3940# create forward declarations for gcc builtins
     
    5455
    5556# create forward declarations for cfa builtins
    56 builtins.cf : builtins.c ${CC}
     57builtins.cf : builtins.c @LOCAL_CFACC@
    5758        ${AM_V_GEN}gcc ${AM_CFLAGS} -E -P ${<} -o ${@} -MD -MP -MF $(DEPDIR)/builtins.Po -D__cforall
    5859        ${AM_V_at}sed -i 's/builtins.o/builtins.cf/g' $(DEPDIR)/builtins.Po
     
    6869MOSTLYCLEANFILES = bootloader.c builtins.cf extras.cf gcc-builtins.c gcc-builtins.cf prelude.cfa
    6970MAINTAINERCLEANFILES = ${addprefix ${libdir}/,${cfalib_DATA}} ${addprefix ${libdir}/,${lib_LIBRARIES}}
     71
     72if ENABLE_DISTCC
     73distribution: @LOCAL_CFACC@ @LOCAL_CC1@ @CFACPP@ gcc-builtins.cf builtins.cf extras.cf prelude.cfa bootloader.c $(srcdir)/../../tools/build/push2dist.sh
     74        ${AM_V_GEN}$(srcdir)/../../tools/build/push2dist.sh @CFADIR_HASH@
     75        @echo "Dummy file to track distribution to remote hosts" > ${@}
     76
     77all: all-am distribution
     78endif ENABLE_DISTCC
  • libcfa/prelude/Makefile.in

    r9fb8f01 r3d5701e  
    1 # Makefile.in generated by automake 1.15 from Makefile.am.
     1# Makefile.in generated by automake 1.16.1 from Makefile.am.
    22# @configure_input@
    33
    4 # Copyright (C) 1994-2014 Free Software Foundation, Inc.
     4# Copyright (C) 1994-2018 Free Software Foundation, Inc.
    55
    66# This Makefile.in is free software; the Free Software Foundation
     
    167167AUTOMAKE = @AUTOMAKE@
    168168AWK = @AWK@
    169 CC = @CFACC@
     169CC = @LOCAL_CFACC@
    170170CCAS = @CCAS@
    171171CCASDEPMODE = @CCASDEPMODE@
     
    174174CFACC = @CFACC@
    175175CFACPP = @CFACPP@
     176CFADIR_HASH = @CFADIR_HASH@
    176177CFA_BINDIR = @CFA_BINDIR@
    177178CFA_INCDIR = @CFA_INCDIR@
     
    217218LIPO = @LIPO@
    218219LN_S = @LN_S@
     220LOCAL_CC1 = @LOCAL_CC1@
     221LOCAL_CFACC = @LOCAL_CFACC@
    219222LTLIBOBJS = @LTLIBOBJS@
    220223LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
     
    328331            cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
    329332          *) \
    330             echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
    331             cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
     333            echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
     334            cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
    332335        esac;
    333336
     
    374377
    375378
    376 distdir: $(DISTFILES)
     379distdir: $(BUILT_SOURCES)
     380        $(MAKE) $(AM_MAKEFLAGS) distdir-am
     381
     382distdir-am: $(DISTFILES)
    377383        @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
    378384        topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
     
    537543extras.cf : ${srcdir}/extras.regx ${srcdir}/extras.c
    538544        ${AM_V_GEN}gcc ${AM_CFLAGS} -E ${srcdir}/extras.c | grep -f ${srcdir}/extras.regx > extras.cf
     545        ${AM_V_GEN}gcc ${AM_CFLAGS} -E ${srcdir}/extras.c | grep -zo -f ${srcdir}/extras.regx2 | tr '\0' '\n' >> extras.cf
    539546
    540547# create forward declarations for gcc builtins
     
    555562
    556563# create forward declarations for cfa builtins
    557 builtins.cf : builtins.c ${CC}
     564builtins.cf : builtins.c @LOCAL_CFACC@
    558565        ${AM_V_GEN}gcc ${AM_CFLAGS} -E -P ${<} -o ${@} -MD -MP -MF $(DEPDIR)/builtins.Po -D__cforall
    559566        ${AM_V_at}sed -i 's/builtins.o/builtins.cf/g' $(DEPDIR)/builtins.Po
     
    566573maintainer-clean-local :
    567574        rm -rf $(DEPDIR)
     575
     576@ENABLE_DISTCC_TRUE@distribution: @LOCAL_CFACC@ @LOCAL_CC1@ @CFACPP@ gcc-builtins.cf builtins.cf extras.cf prelude.cfa bootloader.c $(srcdir)/../../tools/build/push2dist.sh
     577@ENABLE_DISTCC_TRUE@    ${AM_V_GEN}$(srcdir)/../../tools/build/push2dist.sh @CFADIR_HASH@
     578@ENABLE_DISTCC_TRUE@    @echo "Dummy file to track distribution to remote hosts" > ${@}
     579
     580@ENABLE_DISTCC_TRUE@all: all-am distribution
    568581
    569582# Tell versions [3.59,3.63) of GNU make to not export all variables.
  • libcfa/prelude/builtins.c

    r9fb8f01 r3d5701e  
    1010// Created On       : Fri Jul 21 16:21:03 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jun 25 18:06:52 2019
    13 // Update Count     : 97
     12// Last Modified On : Thu Nov 21 16:31:39 2019
     13// Update Count     : 101
    1414//
    1515
     
    6969
    7070// universal typed pointer constant
    71 // Compiler issue: there is a problem with anonymous types that do not have a size.
    72 static inline forall( dtype DT | sized(DT) ) DT * intptr( uintptr_t addr ) { return (DT *)addr; }
     71static inline forall( dtype DT ) DT * intptr( uintptr_t addr ) { return (DT *)addr; }
    7372
    7473// exponentiation operator implementation
  • libcfa/prelude/extras.regx

    r9fb8f01 r3d5701e  
    1919typedef.* uint32_t;
    2020typedef.* uint64_t;
     21typedef.* __uint_least16_t;
     22typedef.* __uint_least32_t;
    2123typedef.* char16_t;
    2224typedef.* char32_t;
    2325typedef.* wchar_t;
    24 extern.*\*malloc\(.*\).*
    25 extern.* free\(.*\).*
    26 extern.* exit\(.*\).*
    27 extern.* atexit\(.*\).*
    28 extern.* abort\(.*\).*
    29 extern.* printf\(.*\).*
  • libcfa/prelude/prototypes.awk

    r9fb8f01 r3d5701e  
    1010# Created On       : Sat May 16 07:57:37 2015
    1111# Last Modified By : Peter A. Buhr
    12 # Last Modified On : Thu Jun  6 20:46:28 2019
    13 # Update Count     : 34
     12# Last Modified On : Sat Feb  8 09:46:58 2020
     13# Update Count     : 36
    1414#
    1515
     
    1717
    1818BEGIN {
    19   FS = "[( )]"
     19        FS = "[( )]"
    2020        # order so string search is longest string
    2121        i=-1
     
    8484
    8585/BT_FN/ {
    86         for (i = 1; i <= NF; i++) {
    87           if( match($i, "BT_FN") != 0 ) {
    88                 prototypes[$i] = $i
    89           }
     86        for (i = 1; i <= NF; i += 1 ) {
     87                if ( match($i, "BT_FN") != 0 ) {
     88                        prototypes[$i] = $i
     89                }
    9090        }
    91   }
     91}
    9292
    9393END {
     
    103103
    104104        for ( prototype in prototypes ) {
    105           # printf( "//\"%s\"\n", prototype )
    106           if ( index( "BT_LAST", prototype ) == 1 ) {
    107                 continue
    108           } # if
     105                # printf( "//\"%s\"\n", prototype )
     106                if ( index( "BT_LAST", prototype ) == 1 ) {
     107                        continue
     108                } # if
    109109
    110           printf( "#define %s(NAME) FUNC_SIMPLE(", prototype )
     110                printf( "#define %s(NAME) FUNC_SIMPLE(", prototype )
    111111
    112           if ( sub( "BT_FN_", "", prototype ) == 0 ) {
    113                 printf( "\n********** BAD MACRO NAME \"%s\" **********\n", prototype )
    114                 exit 0
    115           } # if
     112                if ( sub( "BT_FN_", "", prototype ) == 0 ) {
     113                        printf( "\n********** BAD MACRO NAME \"%s\" **********\n", prototype )
     114                        exit 0
     115                } # if
    116116
    117           # generate function return type as macro
    118           for ( t = 0; t < N; t += 1 ) {                                        # find longest match
    119                 type = types[t];
    120                 if ( index( prototype, type ) == 1 ) {          # found match
    121                   printf( "BT_%s, NAME", type )
    122                   sub( type, "", prototype )
    123                   break;
     117                # generate function return type as macro
     118                for ( t = 0; t < N; t += 1 ) {                                  # find longest match
     119                        type = types[t];
     120                        if ( index( prototype, type ) == 1 ) {          # found match
     121                                printf( "BT_%s, NAME", type )
     122                                sub( type, "", prototype )
     123                                break;
     124                        } # if
     125                } # for
     126
     127                # generate function parameter types as macro
     128                if ( index( prototype, "VAR" ) != 2 ) {                 # C-style empty parameters ?
     129                        for ( p = 0; length( prototype ) > 0; p += 1 ) { # until all parameters types are removed
     130                                sub( "_", "", prototype)                                # remove "_"
     131                                printf( ", ", type )
     132                                temp = prototype
     133                                for ( t = 0; t < N; t += 1 ) {                  # find longest match
     134                                        type = types[t];
     135                                        if ( index( prototype, type ) == 1 ) { # found match
     136                                                printf( "BT_%s", type )
     137                                                sub( type, "", prototype )
     138                                                break;
     139                                        } # if
     140                                } # for
     141                                if ( temp == prototype ) {                              # no match found for parameter in macro table
     142                                        printf( "\n********** MISSING TYPE \"%s\" **********\n", prototype )
     143                                        exit 0
     144                                } # if
     145                        } # for
    124146                } # if
    125           } # for
    126 
    127           # generate function parameter types as macro
    128           if ( index( prototype, "VAR" ) != 2 ) {                       # C-style empty parameters ?
    129                 for ( p = 0; length( prototype ) > 0; p += 1 ) { # until all parameters types are removed
    130                   sub( "_", "", prototype)                              # remove "_"
    131                   printf( ", ", type )
    132                   temp = prototype
    133                   for ( t = 0; t < N; t += 1 ) {                        # find longest match
    134                         type = types[t];
    135                         if ( index( prototype, type ) == 1 ) { # found match
    136                           printf( "BT_%s", type )
    137                           sub( type, "", prototype )
    138                           break;
    139                         } # if
    140                   } # for
    141                   if ( temp == prototype ) {                            # no match found for parameter in macro table
    142                         printf( "\n********** MISSING TYPE \"%s\" **********\n", prototype )
    143                         exit 0
    144                   } # if
    145                 } # for
    146           } # if
    147           printf( ")\n" )
     147                printf( ")\n" )
    148148        } # for
    149149
  • libcfa/prelude/sync-builtins.cf

    r9fb8f01 r3d5701e  
    11char __sync_fetch_and_add(volatile char *, char,...);
    2 char __sync_fetch_and_add_1(volatile char *, char,...);
    32signed char __sync_fetch_and_add(volatile signed char *, signed char,...);
    4 signed char __sync_fetch_and_add_1(volatile signed char *, signed char,...);
    53unsigned char __sync_fetch_and_add(volatile unsigned char *, unsigned char,...);
    6 unsigned char __sync_fetch_and_add_1(volatile unsigned char *, unsigned char,...);
    74signed short __sync_fetch_and_add(volatile signed short *, signed short,...);
    8 signed short __sync_fetch_and_add_2(volatile signed short *, signed short,...);
    95unsigned short __sync_fetch_and_add(volatile unsigned short *, unsigned short,...);
    10 unsigned short __sync_fetch_and_add_2(volatile unsigned short *, unsigned short,...);
    116signed int __sync_fetch_and_add(volatile signed int *, signed int,...);
    12 signed int __sync_fetch_and_add_4(volatile signed int *, signed int,...);
    137unsigned int __sync_fetch_and_add(volatile unsigned int *, unsigned int,...);
    14 unsigned int __sync_fetch_and_add_4(volatile unsigned int *, unsigned int,...);
     8signed long int __sync_fetch_and_add(volatile signed long int *, signed long int,...);
     9unsigned long int __sync_fetch_and_add(volatile unsigned long int *, unsigned long int,...);
    1510signed long long int __sync_fetch_and_add(volatile signed long long int *, signed long long int,...);
    16 signed long long int __sync_fetch_and_add_8(volatile signed long long int *, signed long long int,...);
    1711unsigned long long int __sync_fetch_and_add(volatile unsigned long long int *, unsigned long long int,...);
    18 unsigned long long int __sync_fetch_and_add_8(volatile unsigned long long int *, unsigned long long int,...);
    1912#if defined(__SIZEOF_INT128__)
    2013signed __int128 __sync_fetch_and_add(volatile signed __int128 *, signed __int128,...);
    21 signed __int128 __sync_fetch_and_add_16(volatile signed __int128 *, signed __int128,...);
    2214unsigned __int128 __sync_fetch_and_add(volatile unsigned __int128 *, unsigned __int128,...);
    23 unsigned __int128 __sync_fetch_and_add_16(volatile unsigned __int128 *, unsigned __int128,...);
    2415#endif
    2516
    2617char __sync_fetch_and_sub(volatile char *, char,...);
    27 char __sync_fetch_and_sub_1(volatile char *, char,...);
    2818signed char __sync_fetch_and_sub(volatile signed char *, signed char,...);
    29 signed char __sync_fetch_and_sub_1(volatile signed char *, signed char,...);
    3019unsigned char __sync_fetch_and_sub(volatile unsigned char *, unsigned char,...);
    31 unsigned char __sync_fetch_and_sub_1(volatile unsigned char *, unsigned char,...);
    3220signed short __sync_fetch_and_sub(volatile signed short *, signed short,...);
    33 signed short __sync_fetch_and_sub_2(volatile signed short *, signed short,...);
    3421unsigned short __sync_fetch_and_sub(volatile unsigned short *, unsigned short,...);
    35 unsigned short __sync_fetch_and_sub_2(volatile unsigned short *, unsigned short,...);
    3622signed int __sync_fetch_and_sub(volatile signed int *, signed int,...);
    37 signed int __sync_fetch_and_sub_4(volatile signed int *, signed int,...);
    3823unsigned int __sync_fetch_and_sub(volatile unsigned int *, unsigned int,...);
    39 unsigned int __sync_fetch_and_sub_4(volatile unsigned int *, unsigned int,...);
     24signed long int __sync_fetch_and_sub(volatile signed long int *, signed long int,...);
     25unsigned long int __sync_fetch_and_sub(volatile unsigned long int *, unsigned long int,...);
    4026signed long long int __sync_fetch_and_sub(volatile signed long long int *, signed long long int,...);
    41 signed long long int __sync_fetch_and_sub_8(volatile signed long long int *, signed long long int,...);
    4227unsigned long long int __sync_fetch_and_sub(volatile unsigned long long int *, unsigned long long int,...);
    43 unsigned long long int __sync_fetch_and_sub_8(volatile unsigned long long int *, unsigned long long int,...);
    4428#if defined(__SIZEOF_INT128__)
    4529signed __int128 __sync_fetch_and_sub(volatile signed __int128 *, signed __int128,...);
    46 signed __int128 __sync_fetch_and_sub_16(volatile signed __int128 *, signed __int128,...);
    4730unsigned __int128 __sync_fetch_and_sub(volatile unsigned __int128 *, unsigned __int128,...);
    48 unsigned __int128 __sync_fetch_and_sub_16(volatile unsigned __int128 *, unsigned __int128,...);
    4931#endif
    5032
    5133char __sync_fetch_and_or(volatile char *, char,...);
    52 char __sync_fetch_and_or_1(volatile char *, char,...);
    5334signed char __sync_fetch_and_or(volatile signed char *, signed char,...);
    54 signed char __sync_fetch_and_or_1(volatile signed char *, signed char,...);
    5535unsigned char __sync_fetch_and_or(volatile unsigned char *, unsigned char,...);
    56 unsigned char __sync_fetch_and_or_1(volatile unsigned char *, unsigned char,...);
    5736signed short __sync_fetch_and_or(volatile signed short *, signed short,...);
    58 signed short __sync_fetch_and_or_2(volatile signed short *, signed short,...);
    5937unsigned short __sync_fetch_and_or(volatile unsigned short *, unsigned short,...);
    60 unsigned short __sync_fetch_and_or_2(volatile unsigned short *, unsigned short,...);
    6138signed int __sync_fetch_and_or(volatile signed int *, signed int,...);
    62 signed int __sync_fetch_and_or_4(volatile signed int *, signed int,...);
    6339unsigned int __sync_fetch_and_or(volatile unsigned int *, unsigned int,...);
    64 unsigned int __sync_fetch_and_or_4(volatile unsigned int *, unsigned int,...);
     40signed long int __sync_fetch_and_or(volatile signed long int *, signed long int,...);
     41unsigned long int __sync_fetch_and_or(volatile unsigned long int *, unsigned long int,...);
    6542signed long long int __sync_fetch_and_or(volatile signed long long int *, signed long long int,...);
    66 signed long long int __sync_fetch_and_or_8(volatile signed long long int *, signed long long int,...);
    6743unsigned long long int __sync_fetch_and_or(volatile unsigned long long int *, unsigned long long int,...);
    68 unsigned long long int __sync_fetch_and_or_8(volatile unsigned long long int *, unsigned long long int,...);
    6944#if defined(__SIZEOF_INT128__)
    7045signed __int128 __sync_fetch_and_or(volatile signed __int128 *, signed __int128,...);
    71 signed __int128 __sync_fetch_and_or_16(volatile signed __int128 *, signed __int128,...);
    7246unsigned __int128 __sync_fetch_and_or(volatile unsigned __int128 *, unsigned __int128,...);
    73 unsigned __int128 __sync_fetch_and_or_16(volatile unsigned __int128 *, unsigned __int128,...);
    7447#endif
    7548
    7649char __sync_fetch_and_and(volatile char *, char,...);
    77 char __sync_fetch_and_and_1(volatile char *, char,...);
    7850signed char __sync_fetch_and_and(volatile signed char *, signed char,...);
    79 signed char __sync_fetch_and_and_1(volatile signed char *, signed char,...);
    8051unsigned char __sync_fetch_and_and(volatile unsigned char *, unsigned char,...);
    81 unsigned char __sync_fetch_and_and_1(volatile unsigned char *, unsigned char,...);
    8252signed short __sync_fetch_and_and(volatile signed short *, signed short,...);
    83 signed short __sync_fetch_and_and_2(volatile signed short *, signed short,...);
    8453unsigned short __sync_fetch_and_and(volatile unsigned short *, unsigned short,...);
    85 unsigned short __sync_fetch_and_and_2(volatile unsigned short *, unsigned short,...);
    8654signed int __sync_fetch_and_and(volatile signed int *, signed int,...);
    87 signed int __sync_fetch_and_and_4(volatile signed int *, signed int,...);
    8855unsigned int __sync_fetch_and_and(volatile unsigned int *, unsigned int,...);
    89 unsigned int __sync_fetch_and_and_4(volatile unsigned int *, unsigned int,...);
     56signed long int __sync_fetch_and_and(volatile signed long int *, signed long int,...);
     57unsigned long int __sync_fetch_and_and(volatile unsigned long int *, unsigned long int,...);
    9058signed long long int __sync_fetch_and_and(volatile signed long long int *, signed long long int,...);
    91 signed long long int __sync_fetch_and_and_8(volatile signed long long int *, signed long long int,...);
    9259unsigned long long int __sync_fetch_and_and(volatile unsigned long long int *, unsigned long long int,...);
    93 unsigned long long int __sync_fetch_and_and_8(volatile unsigned long long int *, unsigned long long int,...);
    9460#if defined(__SIZEOF_INT128__)
    9561signed __int128 __sync_fetch_and_and(volatile signed __int128 *, signed __int128,...);
    96 signed __int128 __sync_fetch_and_and_16(volatile signed __int128 *, signed __int128,...);
    9762unsigned __int128 __sync_fetch_and_and(volatile unsigned __int128 *, unsigned __int128,...);
    98 unsigned __int128 __sync_fetch_and_and_16(volatile unsigned __int128 *, unsigned __int128,...);
    9963#endif
    10064
    10165char __sync_fetch_and_xor(volatile char *, char,...);
    102 char __sync_fetch_and_xor_1(volatile char *, char,...);
    10366signed char __sync_fetch_and_xor(volatile signed char *, signed char,...);
    104 signed char __sync_fetch_and_xor_1(volatile signed char *, signed char,...);
    10567unsigned char __sync_fetch_and_xor(volatile unsigned char *, unsigned char,...);
    106 unsigned char __sync_fetch_and_xor_1(volatile unsigned char *, unsigned char,...);
    10768signed short __sync_fetch_and_xor(volatile signed short *, signed short,...);
    108 signed short __sync_fetch_and_xor_2(volatile signed short *, signed short,...);
    10969unsigned short __sync_fetch_and_xor(volatile unsigned short *, unsigned short,...);
    110 unsigned short __sync_fetch_and_xor_2(volatile unsigned short *, unsigned short,...);
    11170signed int __sync_fetch_and_xor(volatile signed int *, signed int,...);
    112 signed int __sync_fetch_and_xor_4(volatile signed int *, signed int,...);
    11371unsigned int __sync_fetch_and_xor(volatile unsigned int *, unsigned int,...);
    114 unsigned int __sync_fetch_and_xor_4(volatile unsigned int *, unsigned int,...);
     72signed long int __sync_fetch_and_xor(volatile signed long int *, signed long int,...);
     73unsigned long int __sync_fetch_and_xor(volatile unsigned long int *, unsigned long int,...);
    11574signed long long int __sync_fetch_and_xor(volatile signed long long int *, signed long long int,...);
    116 signed long long int __sync_fetch_and_xor_8(volatile signed long long int *, signed long long int,...);
    11775unsigned long long int __sync_fetch_and_xor(volatile unsigned long long int *, unsigned long long int,...);
    118 unsigned long long int __sync_fetch_and_xor_8(volatile unsigned long long int *, unsigned long long int,...);
    11976#if defined(__SIZEOF_INT128__)
    12077signed __int128 __sync_fetch_and_xor(volatile signed __int128 *, signed __int128,...);
    121 signed __int128 __sync_fetch_and_xor_16(volatile signed __int128 *, signed __int128,...);
    12278unsigned __int128 __sync_fetch_and_xor(volatile unsigned __int128 *, unsigned __int128,...);
    123 unsigned __int128 __sync_fetch_and_xor_16(volatile unsigned __int128 *, unsigned __int128,...);
    12479#endif
    12580
    12681char __sync_fetch_and_nand(volatile char *, char,...);
    127 char __sync_fetch_and_nand_1(volatile char *, char,...);
    12882signed char __sync_fetch_and_nand(volatile signed char *, signed char,...);
    129 signed char __sync_fetch_and_nand_1(volatile signed char *, signed char,...);
    13083unsigned char __sync_fetch_and_nand(volatile unsigned char *, unsigned char,...);
    131 unsigned char __sync_fetch_and_nand_1(volatile unsigned char *, unsigned char,...);
    13284signed short __sync_fetch_and_nand(volatile signed short *, signed short,...);
    133 signed short __sync_fetch_and_nand_2(volatile signed short *, signed short,...);
    13485unsigned short __sync_fetch_and_nand(volatile unsigned short *, unsigned short,...);
    135 unsigned short __sync_fetch_and_nand_2(volatile unsigned short *, unsigned short,...);
    13686signed int __sync_fetch_and_nand(volatile signed int *, signed int,...);
    137