Changes in / [2fb35df:41b8ea4]


Ignore:
Files:
15 added
4 deleted
47 edited

Legend:

Unmodified
Added
Removed
  • benchmark/Makefile.am

    r2fb35df r41b8ea4  
    113113creation_cfa_generator_DURATION = 1000000000
    114114creation_upp_coroutine_DURATION = ${creation_cfa_coroutine_eager_DURATION}
    115 creation_cfa_thread_DURATION = 10000000
    116 creation_upp_thread_DURATION = ${creation_cfa_thread_DURATION}
    117115creation_DURATION = 10000000
    118116
     
    148146
    149147cleancsv:
    150         rm -f compile.csv basic.csv ctxswitch.csv mutex.csv scheduling.csv
     148        rm -f compile.csv basic.csv ctxswitch.csv mutex.csv schedint.csv
    151149
    152150jenkins$(EXEEXT): cleancsv
     
    159157        +make mutex.csv
    160158        -+make mutex.diff.csv
    161         +make scheduling.csv
    162         -+make scheduling.diff.csv
     159        +make schedint.csv
     160        -+make schedint.diff.csv
    163161@DOifskipcompile@
    164162        cat compile.csv
     
    169167        cat mutex.csv
    170168        -cat mutex.diff.csv
    171         cat scheduling.csv
    172         -cat scheduling.diff.csv
     169        cat schedint.csv
     170        -cat schedint.diff.csv
    173171
    174172compile.csv:
     
    200198        $(srcdir)/fixcsv.sh $@
    201199
    202 scheduling.csv:
     200schedint.csv:
    203201        echo "building $@"
    204202        echo "schedint-1,schedint-2,schedext-1,schedext-2" > $@
     
    291289ctxswitch-python_coroutine$(EXEEXT):
    292290        $(BENCH_V_PY)echo "#!/bin/sh" > a.out
    293         echo "python3.7 $(srcdir)/ctxswitch/python_cor.py" >> a.out
     291        echo "python3 $(srcdir)/ctxswitch/python_cor.py \"$$""@\"" >> a.out
    294292        chmod a+x a.out
    295293
    296294ctxswitch-nodejs_coroutine$(EXEEXT):
    297295        $(BENCH_V_NODEJS)echo "#!/bin/sh" > a.out
    298         echo "nodejs $(srcdir)/ctxswitch/node_cor.js" >> a.out
     296        echo "nodejs $(srcdir)/ctxswitch/node_cor.js \"$$""@\"" >> a.out
    299297        chmod a+x a.out
    300298
    301299ctxswitch-nodejs_await$(EXEEXT):
    302300        $(BENCH_V_NODEJS)echo "#!/bin/sh" > a.out
    303         echo "nodejs $(srcdir)/ctxswitch/node_await.js" >> a.out
     301        echo "nodejs $(srcdir)/ctxswitch/node_await.js \"$$""@\"" >> a.out
    304302        chmod a+x a.out
    305303
     
    313311        $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/ctxswitch/JavaThread.java
    314312        echo "#!/bin/sh" > a.out
    315         echo "java JavaThread" >> a.out
     313        echo "java JavaThread \"$$""@\"" >> a.out
    316314        chmod a+x a.out
    317315
     
    355353        $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/mutex/JavaThread.java
    356354        echo "#!/bin/sh" > a.out
    357         echo "java JavaThread" >> a.out
     355        echo "java JavaThread \"$$""@\"" >> a.out
    358356        chmod a+x a.out
    359357
     
    387385        $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/schedint/JavaThread.java
    388386        echo "#!/bin/sh" > a.out
    389         echo "java JavaThread" >> a.out
     387        echo "java JavaThread \"$$""@\"" >> a.out
    390388        chmod a+x a.out
    391389
     
    454452creation-python_coroutine$(EXEEXT):
    455453        $(BENCH_V_PY)echo "#!/bin/sh" > a.out
    456         echo "python3.7 $(srcdir)/creation/python_cor.py" >> a.out
     454        echo "python3 $(srcdir)/creation/python_cor.py \"$$""@\"" >> a.out
    457455        chmod a+x a.out
    458456
    459457creation-nodejs_coroutine$(EXEEXT):
    460458        $(BENCH_V_NODEJS)echo "#!/bin/sh" > a.out
    461         echo "nodejs $(srcdir)/creation/node_cor.js" >> a.out
     459        echo "nodejs $(srcdir)/creation/node_cor.js \"$$""@\"" >> a.out
    462460        chmod a+x a.out
    463461
     
    471469        $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/creation/JavaThread.java
    472470        echo "#!/bin/sh" > a.out
    473         echo "java JavaThread" >> a.out
     471        echo "java JavaThread \"$$""@\"" >> a.out
    474472        chmod a+x a.out
    475473
     
    492490
    493491compile-array$(EXEEXT):
    494         $(CFACOMPILE) -fsyntax-only -w $(testdir)/array.cfa
     492        $(CFACOMPILE) -DNO_COMPILED_PRAGMA -fsyntax-only -w $(testdir)/array.cfa
    495493
    496494compile-attributes$(EXEEXT):
    497         $(CFACOMPILE) -fsyntax-only -w $(testdir)/attributes.cfa
     495        $(CFACOMPILE) -DNO_COMPILED_PRAGMA -fsyntax-only -w $(testdir)/attributes.cfa
    498496
    499497compile-empty$(EXEEXT):
    500         $(CFACOMPILE) -fsyntax-only -w $(srcdir)/compile/empty.cfa
     498        $(CFACOMPILE) -DNO_COMPILED_PRAGMA -fsyntax-only -w $(srcdir)/compile/empty.cfa
    501499
    502500compile-expression$(EXEEXT):
    503         $(CFACOMPILE) -fsyntax-only -w $(testdir)/expression.cfa
     501        $(CFACOMPILE) -DNO_COMPILED_PRAGMA -fsyntax-only -w $(testdir)/expression.cfa
    504502
    505503compile-io$(EXEEXT):
    506         $(CFACOMPILE) -fsyntax-only -w $(testdir)/io1.cfa
     504        $(CFACOMPILE) -DNO_COMPILED_PRAGMA -fsyntax-only -w $(testdir)/io1.cfa
    507505
    508506compile-monitor$(EXEEXT):
    509         $(CFACOMPILE) -fsyntax-only -w $(testdir)/concurrent/monitor.cfa
     507        $(CFACOMPILE) -DNO_COMPILED_PRAGMA -fsyntax-only -w $(testdir)/concurrent/monitor.cfa
    510508
    511509compile-operators$(EXEEXT):
    512         $(CFACOMPILE) -fsyntax-only -w $(testdir)/operators.cfa
     510        $(CFACOMPILE) -DNO_COMPILED_PRAGMA -fsyntax-only -w $(testdir)/operators.cfa
    513511
    514512compile-thread$(EXEEXT):
    515         $(CFACOMPILE) -fsyntax-only -w $(testdir)/concurrent/thread.cfa
     513        $(CFACOMPILE) -DNO_COMPILED_PRAGMA -fsyntax-only -w $(testdir)/concurrent/thread.cfa
    516514
    517515compile-typeof$(EXEEXT):
    518         $(CFACOMPILE) -fsyntax-only -w $(testdir)/typeof.cfa
     516        $(CFACOMPILE) -DNO_COMPILED_PRAGMA -fsyntax-only -w $(testdir)/typeof.cfa
    519517
    520518## =========================================================================================================
  • benchmark/creation/JavaThread.java

    r2fb35df r41b8ea4  
    4747        }
    4848        public static void main(String[] args) throws InterruptedException {
    49                 if ( args.length > 2 ) System.exit( 1 );
    50                 if ( args.length == 2 ) { times = Long.parseLong(args[1]); }
     49                if ( args.length > 1 ) System.exit( 1 );
     50                if ( args.length == 1 ) { times = Long.parseLong(args[0]); }
    5151
    5252                for (int i = Integer.parseInt("5"); --i >= 0 ; ) {
  • benchmark/ctxswitch/JavaThread.java

    r2fb35df r41b8ea4  
    4040        }
    4141        public static void main(String[] args) throws InterruptedException {
    42                 if ( args.length > 2 ) System.exit( 1 );
    43                 if ( args.length == 2 ) { times = Long.parseLong(args[1]); }
     42                if ( args.length > 1 ) System.exit( 1 );
     43                if ( args.length == 1 ) { times = Long.parseLong(args[0]); }
    4444
    4545                for (int i = Integer.parseInt("5"); --i >= 0 ; ) {
  • benchmark/io/http/main.cfa

    r2fb35df r41b8ea4  
    125125                                                workers[i].flags   = 0;
    126126                                        }
    127                                         unpark( workers[i] __cfaabi_dbg_ctx2 );
     127                                        unpark( workers[i] );
    128128                                }
    129129                                printf("%d workers started on %d processors\n", options.clopts.nworkers, options.clopts.nprocs);
  • benchmark/io/http/worker.cfa

    r2fb35df r41b8ea4  
    2222
    2323void main( Worker & this ) {
    24         park( __cfaabi_dbg_ctx );
     24        park();
    2525        /* paranoid */ assert( this.pipe[0] != -1 );
    2626        /* paranoid */ assert( this.pipe[1] != -1 );
  • benchmark/io/readv.cfa

    r2fb35df r41b8ea4  
    5454
    5555void main( Reader & ) {
    56         park( __cfaabi_dbg_ctx );
     56        park();
    5757        /* paranoid */ assert( true == __atomic_load_n(&run, __ATOMIC_RELAXED) );
    5858
     
    151151
    152152                                for(i; nthreads) {
    153                                         unpark( threads[i] __cfaabi_dbg_ctx2 );
     153                                        unpark( threads[i] );
    154154                                }
    155155                                wait(duration, start, end, is_tty);
  • benchmark/mutex/JavaThread.java

    r2fb35df r41b8ea4  
    4747        }
    4848        public static void main(String[] args) throws InterruptedException {
    49                 if ( args.length > 2 ) System.exit( 1 );
    50                 if ( args.length == 2 ) { times = Long.parseLong(args[1]); }
     49                if ( args.length > 1 ) System.exit( 1 );
     50                if ( args.length == 1 ) { times = Long.parseLong(args[0]); }
    5151
    5252                for (int n = Integer.parseInt("5"); --n >= 0 ; ) {
  • benchmark/readyQ/yield.cfa

    r2fb35df r41b8ea4  
    3232
    3333void main( Yielder & this ) {
    34         park( __cfaabi_dbg_ctx );
     34        park();
    3535        /* paranoid */ assert( true == __atomic_load_n(&run, __ATOMIC_RELAXED) );
    3636
     
    7070
    7171                                for(i; nthreads) {
    72                                         unpark( threads[i] __cfaabi_dbg_ctx2 );
     72                                        unpark( threads[i] );
    7373                                }
    7474                                wait(duration, start, end, is_tty);
  • benchmark/schedint/JavaThread.java

    r2fb35df r41b8ea4  
    7575        }
    7676        public static void main(String[] args) throws InterruptedException {
    77                 if ( args.length > 2 ) System.exit( 1 );
    78                 if ( args.length == 2 ) { times = Long.parseLong(args[1]); }
     77                if ( args.length > 1 ) System.exit( 1 );
     78                if ( args.length == 1 ) { times = Long.parseLong(args[0]); }
    7979
    8080                for (int n = Integer.parseInt("5"); --n >= 0 ; ) {
  • doc/LaTeXmacros/common.tex

    r2fb35df r41b8ea4  
    1111%% Created On       : Sat Apr  9 10:06:17 2016
    1212%% Last Modified By : Peter A. Buhr
    13 %% Last Modified On : Wed Sep 23 21:21:55 2020
    14 %% Update Count     : 454
     13%% Last Modified On : Mon Oct  5 09:34:46 2020
     14%% Update Count     : 464
    1515%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1616
     
    251251\makeatother
    252252
    253 \newcommand{\CFADefaults}{%
     253\newcommand{\CFAStyle}{%
    254254\lstset{
    255 language=CFA,
    256255columns=fullflexible,
    257256basicstyle=\linespread{0.9}\sf,                 % reduce line spacing and use sanserif font
     
    272271        {<-}{$\leftarrow$}2 {=>}{$\Rightarrow$}2 {->}{\makebox[1ex][c]{\raisebox{0.4ex}{\rule{0.8ex}{0.075ex}}}\kern-0.2ex\textgreater}2,
    273272}% lstset
    274 }% CFADefaults
    275 
    276 \ifdefined\CFALatin%
    277 \lstnewenvironment{cfa}[1][]{\CFADefaults
     273}% CFAStyle
     274
     275\ifdefined\CFALatin% extra Latin-1 escape characters
     276\lstnewenvironment{cfa}[1][]{
    278277\lstset{
    279278language=CFA,
     
    289288% inline code ©...© (copyright symbol) emacs: C-q M-)
    290289\lstMakeShortInline©                                    % single-character for \lstinline
    291 \else% extra Latin-1 escape characters
     290\else% regular ASCI characters
     291\lstnewenvironment{cfa}[1][]{
    292292\lstset{
    293293language=CFA,
    294294escapechar=\$,                                                  % LaTeX escape in CFA code
    295 moredelim=**[is][\color{red}]{@}{@},    % red highlighting `...` (backtick symbol)
    296 }% lstset
    297 \lstnewenvironment{cfa}[1][]{\CFADefaults
    298 \lstset{
    299 language=CFA,
    300 escapechar=\$,                                                  % LaTeX escape in CFA code
    301 moredelim=**[is][\color{red}]{@}{@},    % red highlighting `...` (backtick symbol)
     295moredelim=**[is][\color{red}]{@}{@},    % red highlighting @...@
    302296}% lstset
    303297\lstset{#1}
  • doc/bibliography/pl.bib

    r2fb35df r41b8ea4  
    10051005    key         = {Cforall Benchmarks},
    10061006    author      = {{\textsf{C}{$\mathbf{\forall}$} Benchmarks}},
    1007     howpublished= {\href{https://plg.uwaterloo.ca/~cforall/doc/CforallConcurrentBenchmarks.tar}{https://\-plg.uwaterloo.ca/\-$\sim$cforall/\-doc/\-CforallConcurrentBenchmarks.tar}},
     1007    howpublished= {\href{https://github.com/cforall/ConcurrentBenchmarks_SPE20}{https://\-github.com/\-cforall/\-ConcurrentBenchmarks\_SPE20}},
    10081008}
    10091009
     
    19731973    title       = {Cooperating Sequential Processes},
    19741974    institution = {Technological University},
    1975     address     = {Eindhoven, Netherlands},
     1975    address     = {Eindhoven, Neth.},
    19761976    year        = 1965,
    19771977    note        = {Reprinted in \cite{Genuys68} pp. 43--112.}
  • doc/papers/concurrency/Paper.tex

    r2fb35df r41b8ea4  
    224224{}
    225225\lstnewenvironment{C++}[1][]                            % use C++ style
    226 {\lstset{language=C++,moredelim=**[is][\protect\color{red}]{`}{`},#1}\lstset{#1}}
     226{\lstset{language=C++,moredelim=**[is][\protect\color{red}]{`}{`}}\lstset{#1}}
    227227{}
    228228\lstnewenvironment{uC++}[1][]
    229 {\lstset{language=uC++,moredelim=**[is][\protect\color{red}]{`}{`},#1}\lstset{#1}}
     229{\lstset{language=uC++,moredelim=**[is][\protect\color{red}]{`}{`}}\lstset{#1}}
    230230{}
    231231\lstnewenvironment{Go}[1][]
    232 {\lstset{language=Golang,moredelim=**[is][\protect\color{red}]{`}{`},#1}\lstset{#1}}
     232{\lstset{language=Golang,moredelim=**[is][\protect\color{red}]{`}{`}}\lstset{#1}}
    233233{}
    234234\lstnewenvironment{python}[1][]
    235 {\lstset{language=python,moredelim=**[is][\protect\color{red}]{`}{`},#1}\lstset{#1}}
     235{\lstset{language=python,moredelim=**[is][\protect\color{red}]{`}{`}}\lstset{#1}}
    236236{}
    237237\lstnewenvironment{java}[1][]
    238 {\lstset{language=java,moredelim=**[is][\protect\color{red}]{`}{`},#1}\lstset{#1}}
     238{\lstset{language=java,moredelim=**[is][\protect\color{red}]{`}{`}}\lstset{#1}}
    239239{}
    240240
     
    284284
    285285\begin{document}
    286 \linenumbers                            % comment out to turn off line numbering
     286%\linenumbers                           % comment out to turn off line numbering
    287287
    288288\maketitle
     
    28962896\label{s:RuntimeStructureCluster}
    28972897
    2898 A \newterm{cluster} is a collection of user and kernel threads, where the kernel threads run the user threads from the cluster's ready queue, and the operating system runs the kernel threads on the processors from its ready queue.
     2898A \newterm{cluster} is a collection of user and kernel threads, where the kernel threads run the user threads from the cluster's ready queue, and the operating system runs the kernel threads on the processors from its ready queue~\cite{Buhr90a}.
    28992899The term \newterm{virtual processor} is introduced as a synonym for kernel thread to disambiguate between user and kernel thread.
    29002900From the language perspective, a virtual processor is an actual processor (core).
     
    29922992\end{cfa}
    29932993where CPU time in nanoseconds is from the appropriate language clock.
    2994 Each benchmark is performed @N@ times, where @N@ is selected so the benchmark runs in the range of 2--20 seconds for the specific programming language.
     2994Each benchmark is performed @N@ times, where @N@ is selected so the benchmark runs in the range of 2--20 seconds for the specific programming language;
     2995each @N@ appears after the experiment name in the following tables.
    29952996The total time is divided by @N@ to obtain the average time for a benchmark.
    29962997Each benchmark experiment is run 13 times and the average appears in the table.
     2998For languages with a runtime JIT (Java, Node.js, Python), a single half-hour long experiment is run to check stability;
     2999all long-experiment results are statistically equivalent, \ie median/average/standard-deviation correlate with the short-experiment results, indicating the short experiments reached a steady state.
    29973000All omitted tests for other languages are functionally identical to the \CFA tests and available online~\cite{CforallConcurrentBenchmarks}.
    2998 % tar --exclude-ignore=exclude -cvhf benchmark.tar benchmark
    2999 % cp -p benchmark.tar /u/cforall/public_html/doc/concurrent_benchmark.tar
    30003001
    30013002\paragraph{Creation}
     
    30063007
    30073008\begin{multicols}{2}
    3008 \lstset{language=CFA,moredelim=**[is][\color{red}]{@}{@},deletedelim=**[is][]{`}{`}}
    3009 \begin{cfa}
    3010 @coroutine@ MyCoroutine {};
     3009\begin{cfa}[xleftmargin=0pt]
     3010`coroutine` MyCoroutine {};
    30113011void ?{}( MyCoroutine & this ) {
    30123012#ifdef EAGER
     
    30163016void main( MyCoroutine & ) {}
    30173017int main() {
    3018         BENCH( for ( N ) { @MyCoroutine c;@ } )
     3018        BENCH( for ( N ) { `MyCoroutine c;` } )
    30193019        sout | result;
    30203020}
     
    30303030
    30313031\begin{tabular}[t]{@{}r*{3}{D{.}{.}{5.2}}@{}}
    3032 \multicolumn{1}{@{}c}{} & \multicolumn{1}{c}{Median} & \multicolumn{1}{c}{Average} & \multicolumn{1}{c@{}}{Std Dev} \\
    3033 \CFA generator                  & 0.6           & 0.6           & 0.0           \\
    3034 \CFA coroutine lazy             & 13.4          & 13.1          & 0.5           \\
    3035 \CFA coroutine eager    & 144.7         & 143.9         & 1.5           \\
    3036 \CFA thread                             & 466.4         & 468.0         & 11.3          \\
    3037 \uC coroutine                   & 155.6         & 155.7         & 1.7           \\
    3038 \uC thread                              & 523.4         & 523.9         & 7.7           \\
    3039 Python generator                & 123.2         & 124.3         & 4.1           \\
    3040 Node.js generator               & 33.4          & 33.5          & 0.3           \\
    3041 Goroutine thread                & 751.0         & 750.5         & 3.1           \\
    3042 Rust tokio thread               & 1860.0        & 1881.1        & 37.6          \\
    3043 Rust thread                             & 53801.0       & 53896.8       & 274.9         \\
    3044 Java thread (   10 000)         & 119256.0      & 119679.2      & 2244.0        \\
    3045 Java thread (1 000 000)         & 123100.0      & 123052.5      & 751.6         \\
    3046 Pthreads thread                 & 31465.5       & 31419.5       & 140.4
     3032\multicolumn{1}{@{}r}{N\hspace*{10pt}} & \multicolumn{1}{c}{Median} & \multicolumn{1}{c}{Average} & \multicolumn{1}{c@{}}{Std Dev} \\
     3033\CFA generator (1B)                     & 0.6           & 0.6           & 0.0           \\
     3034\CFA coroutine lazy     (100M)  & 13.4          & 13.1          & 0.5           \\
     3035\CFA coroutine eager (10M)      & 144.7         & 143.9         & 1.5           \\
     3036\CFA thread (10M)                       & 466.4         & 468.0         & 11.3          \\
     3037\uC coroutine (10M)                     & 155.6         & 155.7         & 1.7           \\
     3038\uC thread (10M)                        & 523.4         & 523.9         & 7.7           \\
     3039Python generator (10M)          & 123.2         & 124.3         & 4.1           \\
     3040Node.js generator (10M)         & 33.4          & 33.5          & 0.3           \\
     3041Goroutine thread (10M)          & 751.0         & 750.5         & 3.1           \\
     3042Rust tokio thread (10M)         & 1860.0        & 1881.1        & 37.6          \\
     3043Rust thread     (250K)                  & 53801.0       & 53896.8       & 274.9         \\
     3044Java thread (250K)                      & 119256.0      & 119679.2      & 2244.0        \\
     3045% Java thread (1 000 000)               & 123100.0      & 123052.5      & 751.6         \\
     3046Pthreads thread (250K)          & 31465.5       & 31419.5       & 140.4
    30473047\end{tabular}
    30483048\end{multicols}
     
    30533053Internal scheduling is measured using a cycle of two threads signalling and waiting.
    30543054Figure~\ref{f:schedint} shows the code for \CFA, with results in Table~\ref{t:schedint}.
    3055 Note, the incremental cost of bulk acquire for \CFA, which is largely a fixed cost for small numbers of mutex objects.
    3056 Java scheduling is significantly greater because the benchmark explicitly creates multiple threads in order to prevent the JIT from making the program sequential, \ie removing all locking.
     3055Note, the \CFA incremental cost for bulk acquire is a fixed cost for small numbers of mutex objects.
     3056User-level threading has one kernel thread, eliminating contention between the threads (direct handoff of the kernel thread).
     3057Kernel-level threading has two kernel threads allowing some contention.
    30573058
    30583059\begin{multicols}{2}
    3059 \lstset{language=CFA,moredelim=**[is][\color{red}]{@}{@},deletedelim=**[is][]{`}{`}}
    3060 \begin{cfa}
     3060\setlength{\tabcolsep}{3pt}
     3061\begin{cfa}[xleftmargin=0pt]
    30613062volatile int go = 0;
    3062 @condition c;@
    3063 @monitor@ M {} m1/*, m2, m3, m4*/;
    3064 void call( M & @mutex p1/*, p2, p3, p4*/@ ) {
    3065         @signal( c );@
    3066 }
    3067 void wait( M & @mutex p1/*, p2, p3, p4*/@ ) {
     3063`condition c;`
     3064`monitor` M {} m1/*, m2, m3, m4*/;
     3065void call( M & `mutex p1/*, p2, p3, p4*/` ) {
     3066        `signal( c );`
     3067}
     3068void wait( M & `mutex p1/*, p2, p3, p4*/` ) {
    30683069        go = 1; // continue other thread
    3069         for ( N ) { @wait( c );@ } );
     3070        for ( N ) { `wait( c );` } );
    30703071}
    30713072thread T {};
     
    30923093
    30933094\begin{tabular}{@{}r*{3}{D{.}{.}{5.2}}@{}}
    3094 \multicolumn{1}{@{}c}{} & \multicolumn{1}{c}{Median} & \multicolumn{1}{c}{Average} & \multicolumn{1}{c@{}}{Std Dev} \\
    3095 \CFA @signal@, 1 monitor        & 364.4         & 364.2         & 4.4           \\
    3096 \CFA @signal@, 2 monitor        & 484.4         & 483.9         & 8.8           \\
    3097 \CFA @signal@, 4 monitor        & 709.1         & 707.7         & 15.0          \\
    3098 \uC @signal@ monitor            & 328.3         & 327.4         & 2.4           \\
    3099 Rust cond. variable                     & 7514.0        & 7437.4        & 397.2         \\
    3100 Java @notify@ monitor (  1 000 000)             & 8717.0        & 8774.1        & 471.8         \\
    3101 Java @notify@ monitor (100 000 000)             & 8634.0        & 8683.5        & 330.5         \\
    3102 Pthreads cond. variable         & 5553.7        & 5576.1        & 345.6
     3095\multicolumn{1}{@{}r}{N\hspace*{10pt}} & \multicolumn{1}{c}{Median} & \multicolumn{1}{c}{Average} & \multicolumn{1}{c@{}}{Std Dev} \\
     3096\CFA @signal@, 1 monitor (10M)  & 364.4         & 364.2         & 4.4           \\
     3097\CFA @signal@, 2 monitor (10M)  & 484.4         & 483.9         & 8.8           \\
     3098\CFA @signal@, 4 monitor (10M)  & 709.1         & 707.7         & 15.0          \\
     3099\uC @signal@ monitor (10M)              & 328.3         & 327.4         & 2.4           \\
     3100Rust cond. variable     (1M)            & 7514.0        & 7437.4        & 397.2         \\
     3101Java @notify@ monitor (1M)              & 8717.0        & 8774.1        & 471.8         \\
     3102% Java @notify@ monitor (100 000 000)           & 8634.0        & 8683.5        & 330.5         \\
     3103Pthreads cond. variable (1M)    & 5553.7        & 5576.1        & 345.6
    31033104\end{tabular}
    31043105\end{multicols}
     
    31093110External scheduling is measured using a cycle of two threads calling and accepting the call using the @waitfor@ statement.
    31103111Figure~\ref{f:schedext} shows the code for \CFA with results in Table~\ref{t:schedext}.
    3111 Note, the incremental cost of bulk acquire for \CFA, which is largely a fixed cost for small numbers of mutex objects.
     3112Note, the \CFA incremental cost for bulk acquire is a fixed cost for small numbers of mutex objects.
    31123113
    31133114\begin{multicols}{2}
    3114 \lstset{language=CFA,moredelim=**[is][\color{red}]{@}{@},deletedelim=**[is][]{`}{`}}
     3115\setlength{\tabcolsep}{5pt}
    31153116\vspace*{-16pt}
    3116 \begin{cfa}
    3117 @monitor@ M {} m1/*, m2, m3, m4*/;
    3118 void call( M & @mutex p1/*, p2, p3, p4*/@ ) {}
    3119 void wait( M & @mutex p1/*, p2, p3, p4*/@ ) {
    3120         for ( N ) { @waitfor( call : p1/*, p2, p3, p4*/ );@ }
     3117\begin{cfa}[xleftmargin=0pt]
     3118`monitor` M {} m1/*, m2, m3, m4*/;
     3119void call( M & `mutex p1/*, p2, p3, p4*/` ) {}
     3120void wait( M & `mutex p1/*, p2, p3, p4*/` ) {
     3121        for ( N ) { `waitfor( call : p1/*, p2, p3, p4*/ );` }
    31213122}
    31223123thread T {};
     
    31353136\columnbreak
    31363137
    3137 \vspace*{-16pt}
     3138\vspace*{-18pt}
    31383139\captionof{table}{External-scheduling comparison (nanoseconds)}
    31393140\label{t:schedext}
    31403141\begin{tabular}{@{}r*{3}{D{.}{.}{3.2}}@{}}
    3141 \multicolumn{1}{@{}c}{} & \multicolumn{1}{c}{Median} &\multicolumn{1}{c}{Average} & \multicolumn{1}{c@{}}{Std Dev} \\
    3142 \CFA @waitfor@, 1 monitor       & 367.1 & 365.3 & 5.0   \\
    3143 \CFA @waitfor@, 2 monitor       & 463.0 & 464.6 & 7.1   \\
    3144 \CFA @waitfor@, 4 monitor       & 689.6 & 696.2 & 21.5  \\
    3145 \uC \lstinline[language=uC++]|_Accept| monitor  & 328.2 & 329.1 & 3.4   \\
    3146 Go \lstinline[language=Golang]|select| channel  & 365.0 & 365.5 & 1.2
     3142\multicolumn{1}{@{}r}{N\hspace*{10pt}} & \multicolumn{1}{c}{Median} &\multicolumn{1}{c}{Average} & \multicolumn{1}{c@{}}{Std Dev} \\
     3143\CFA @waitfor@, 1 monitor (10M) & 367.1 & 365.3 & 5.0   \\
     3144\CFA @waitfor@, 2 monitor (10M) & 463.0 & 464.6 & 7.1   \\
     3145\CFA @waitfor@, 4 monitor (10M) & 689.6 & 696.2 & 21.5  \\
     3146\uC \lstinline[language=uC++]|_Accept| monitor (10M)    & 328.2 & 329.1 & 3.4   \\
     3147Go \lstinline[language=Golang]|select| channel (10M)    & 365.0 & 365.5 & 1.2
    31473148\end{tabular}
    31483149\end{multicols}
     
    31573158
    31583159\begin{multicols}{2}
    3159 \lstset{language=CFA,moredelim=**[is][\color{red}]{@}{@},deletedelim=**[is][]{`}{`}}
    3160 \begin{cfa}
    3161 @monitor@ M {} m1/*, m2, m3, m4*/;
    3162 call( M & @mutex p1/*, p2, p3, p4*/@ ) {}
     3160\setlength{\tabcolsep}{3pt}
     3161\begin{cfa}[xleftmargin=0pt]
     3162`monitor` M {} m1/*, m2, m3, m4*/;
     3163call( M & `mutex p1/*, p2, p3, p4*/` ) {}
    31633164int main() {
    31643165        BENCH( for( N ) call( m1/*, m2, m3, m4*/ ); )
     
    31753176\label{t:mutex}
    31763177\begin{tabular}{@{}r*{3}{D{.}{.}{3.2}}@{}}
    3177 \multicolumn{1}{@{}c}{} & \multicolumn{1}{c}{Median} &\multicolumn{1}{c}{Average} & \multicolumn{1}{c@{}}{Std Dev} \\
    3178 test-and-test-set lock                  & 19.1  & 18.9  & 0.4   \\
    3179 \CFA @mutex@ function, 1 arg.   & 48.3  & 47.8  & 0.9   \\
    3180 \CFA @mutex@ function, 2 arg.   & 86.7  & 87.6  & 1.9   \\
    3181 \CFA @mutex@ function, 4 arg.   & 173.4 & 169.4 & 5.9   \\
    3182 \uC @monitor@ member rtn.               & 54.8  & 54.8  & 0.1   \\
    3183 Goroutine mutex lock                    & 34.0  & 34.0  & 0.0   \\
    3184 Rust mutex lock                                 & 33.0  & 33.2  & 0.8   \\
    3185 Java synchronized method (   100 000 000)               & 31.0  & 30.9  & 0.5   \\
    3186 Java synchronized method (10 000 000 000)               & 31.0 & 30.2 & 0.9 \\
    3187 Pthreads mutex Lock                             & 31.0  & 31.1  & 0.4
     3178\multicolumn{1}{@{}r}{N\hspace*{10pt}} & \multicolumn{1}{c}{Median} &\multicolumn{1}{c}{Average} & \multicolumn{1}{c@{}}{Std Dev} \\
     3179test-and-test-set lock (50M)            & 19.1  & 18.9  & 0.4   \\
     3180\CFA @mutex@ function, 1 arg. (50M)     & 48.3  & 47.8  & 0.9   \\
     3181\CFA @mutex@ function, 2 arg. (50M)     & 86.7  & 87.6  & 1.9   \\
     3182\CFA @mutex@ function, 4 arg. (50M)     & 173.4 & 169.4 & 5.9   \\
     3183\uC @monitor@ member rtn. (50M)         & 54.8  & 54.8  & 0.1   \\
     3184Goroutine mutex lock (50M)                      & 34.0  & 34.0  & 0.0   \\
     3185Rust mutex lock (50M)                           & 33.0  & 33.2  & 0.8   \\
     3186Java synchronized method (50M)          & 31.0  & 30.9  & 0.5   \\
     3187% Java synchronized method (10 000 000 000)             & 31.0 & 30.2 & 0.9 \\
     3188Pthreads mutex Lock (50M)                       & 31.0  & 31.1  & 0.4
    31883189\end{tabular}
    31893190\end{multicols}
     
    32143215
    32153216\begin{multicols}{2}
    3216 \lstset{language=CFA,moredelim=**[is][\color{red}]{@}{@},deletedelim=**[is][]{`}{`}}
    3217 \begin{cfa}[aboveskip=0pt,belowskip=0pt]
    3218 @coroutine@ C {};
    3219 void main( C & ) { for () { @suspend;@ } }
     3217\begin{cfa}[xleftmargin=0pt]
     3218`coroutine` C {};
     3219void main( C & ) { for () { `suspend;` } }
    32203220int main() { // coroutine test
    32213221        C c;
    3222         BENCH( for ( N ) { @resume( c );@ } )
     3222        BENCH( for ( N ) { `resume( c );` } )
    32233223        sout | result;
    32243224}
    32253225int main() { // thread test
    3226         BENCH( for ( N ) { @yield();@ } )
     3226        BENCH( for ( N ) { `yield();` } )
    32273227        sout | result;
    32283228}
     
    32373237\label{t:ctx-switch}
    32383238\begin{tabular}{@{}r*{3}{D{.}{.}{3.2}}@{}}
    3239 \multicolumn{1}{@{}c}{} & \multicolumn{1}{c}{Median} &\multicolumn{1}{c}{Average} & \multicolumn{1}{c@{}}{Std Dev} \\
    3240 C function                      & 1.8           & 1.8           & 0.0   \\
    3241 \CFA generator          & 1.8           & 2.0           & 0.3   \\
    3242 \CFA coroutine          & 32.5          & 32.9          & 0.8   \\
    3243 \CFA thread                     & 93.8          & 93.6          & 2.2   \\
    3244 \uC coroutine           & 50.3          & 50.3          & 0.2   \\
    3245 \uC thread                      & 97.3          & 97.4          & 1.0   \\
    3246 Python generator        & 40.9          & 41.3          & 1.5   \\
    3247 Node.js await           & 1852.2        & 1854.7        & 16.4  \\
    3248 Node.js generator       & 33.3          & 33.4          & 0.3   \\
    3249 Goroutine thread        & 143.0         & 143.3         & 1.1   \\
    3250 Rust async await        & 32.0          & 32.0          & 0.0   \\
    3251 Rust tokio thread       & 143.0         & 143.0         & 1.7   \\
    3252 Rust thread                     & 332.0         & 331.4         & 2.4   \\
    3253 Java thread     (      100 000)         & 405.0         & 415.0         & 17.6  \\
    3254 Java thread (  100 000 000)                     & 413.0 & 414.2 & 6.2 \\
    3255 Java thread (5 000 000 000)                     & 415.0 & 415.2 & 6.1 \\
    3256 Pthreads thread         & 334.3         & 335.2         & 3.9
     3239\multicolumn{1}{@{}r}{N\hspace*{10pt}} & \multicolumn{1}{c}{Median} &\multicolumn{1}{c}{Average} & \multicolumn{1}{c@{}}{Std Dev} \\
     3240C function (10B)                        & 1.8           & 1.8           & 0.0   \\
     3241\CFA generator (5B)                     & 1.8           & 2.0           & 0.3   \\
     3242\CFA coroutine (100M)           & 32.5          & 32.9          & 0.8   \\
     3243\CFA thread (100M)                      & 93.8          & 93.6          & 2.2   \\
     3244\uC coroutine (100M)            & 50.3          & 50.3          & 0.2   \\
     3245\uC thread (100M)                       & 97.3          & 97.4          & 1.0   \\
     3246Python generator (100M)         & 40.9          & 41.3          & 1.5   \\
     3247Node.js await (5M)                      & 1852.2        & 1854.7        & 16.4  \\
     3248Node.js generator (100M)        & 33.3          & 33.4          & 0.3   \\
     3249Goroutine thread (100M)         & 143.0         & 143.3         & 1.1   \\
     3250Rust async await (100M)         & 32.0          & 32.0          & 0.0   \\
     3251Rust tokio thread (100M)        & 143.0         & 143.0         & 1.7   \\
     3252Rust thread (25M)                       & 332.0         & 331.4         & 2.4   \\
     3253Java thread (100M)                      & 405.0         & 415.0         & 17.6  \\
     3254% Java thread (  100 000 000)                   & 413.0 & 414.2 & 6.2 \\
     3255% Java thread (5 000 000 000)                   & 415.0 & 415.2 & 6.1 \\
     3256Pthreads thread (25M)           & 334.3         & 335.2         & 3.9
    32573257\end{tabular}
    32583258\end{multicols}
     
    32633263Languages using 1:1 threading based on pthreads can at best meet or exceed, due to language overhead, the pthread results.
    32643264Note, pthreads has a fast zero-contention mutex lock checked in user space.
    3265 Languages with M:N threading have better performance than 1:1 because there is no operating-system interactions.
     3265Languages with M:N threading have better performance than 1:1 because there is no operating-system interactions (context-switching or locking).
     3266As well, for locking experiments, M:N threading has less contention if only one kernel thread is used.
    32663267Languages with stackful coroutines have higher cost than stackless coroutines because of stack allocation and context switching;
    32673268however, stackful \uC and \CFA coroutines have approximately the same performance as stackless Python and Node.js generators.
    32683269The \CFA stackless generator is approximately 25 times faster for suspend/resume and 200 times faster for creation than stackless Python and Node.js generators.
     3270The Node.js context-switch is costly when asynchronous await must enter the event engine because a promise is not fulfilled.
     3271Finally, the benchmark results correlate across programming languages with and without JIT, indicating the JIT has completed any runtime optimizations.
    32693272
    32703273
     
    33243327
    33253328The authors recognize the design assistance of Aaron Moss, Rob Schluntz, Andrew Beach, and Michael Brooks; David Dice for commenting and helping with the Java benchmarks; and Gregor Richards for helping with the Node.js benchmarks.
    3326 This research is funded by a grant from Waterloo-Huawei (\url{http://www.huawei.com}) Joint Innovation Lab. %, and Peter Buhr is partially funded by the Natural Sciences and Engineering Research Council of Canada.
     3329This research is funded by the NSERC/Waterloo-Huawei (\url{http://www.huawei.com}) Joint Innovation Lab. %, and Peter Buhr is partially funded by the Natural Sciences and Engineering Research Council of Canada.
    33273330
    33283331{%
  • doc/papers/concurrency/annex/local.bib

    r2fb35df r41b8ea4  
    5959@manual{Cpp-Transactions,
    6060        keywords        = {C++, Transactional Memory},
    61         title           = {Technical Specification for C++ Extensions for Transactional Memory},
     61        title           = {Tech. Spec. for C++ Extensions for Transactional Memory},
    6262        organization= {International Standard ISO/IEC TS 19841:2015 },
    6363        publisher   = {American National Standards Institute},
  • doc/papers/concurrency/mail2

    r2fb35df r41b8ea4  
    959959Software: Practice and Experience Editorial Office
    960960
     961
     962
     963Date: Wed, 2 Sep 2020 20:55:34 +0000
     964From: Richard Jones <onbehalfof@manuscriptcentral.com>
     965Reply-To: R.E.Jones@kent.ac.uk
     966To: tdelisle@uwaterloo.ca, pabuhr@uwaterloo.ca
     967Subject: Software: Practice and Experience - Decision on Manuscript ID
     968 SPE-19-0219.R2
     969
     97002-Sep-2020
     971
     972Dear Dr Buhr,
     973
     974Many thanks for submitting SPE-19-0219.R2 entitled "Advanced Control-flow and Concurrency in Cforall" to Software: Practice and Experience. The paper has now been reviewed and the comments of the referees are included at the bottom of this letter. I apologise for the length of time it has taken to get these.
     975
     976Both reviewers consider this paper to be close to acceptance. However, before I can accept this paper, I would like you address the comments of Reviewer 2, particularly with regard to the description of the adaptation Java harness to deal with warmup. I would expect to see a convincing argument that the computation has reached a steady state. I would also like you to provide the values for N for each benchmark run. This should be very straightforward for you to do. There are a couple of papers on steady state that you may wish to consult (though I am certainly not pushing my own work).
     977
     9781) Barrett, Edd; Bolz-Tereick, Carl Friedrich; Killick, Rebecca; Mount, Sarah and Tratt, Laurence. Virtual Machine Warmup Blows Hot and Cold. OOPSLA 2017. https://doi.org/10.1145/3133876
     979Virtual Machines (VMs) with Just-In-Time (JIT) compilers are traditionally thought to execute programs in two phases: the initial warmup phase determines which parts of a program would most benefit from dynamic compilation, before JIT compiling those parts into machine code; subsequently the program is said to be at a steady state of peak performance. Measurement methodologies almost always discard data collected during the warmup phase such that reported measurements focus entirely on peak performance. We introduce a fully automated statistical approach, based on changepoint analysis, which allows us to determine if a program has reached a steady state and, if so, whether that represents peak performance or not. Using this, we show that even when run in the most controlled of circumstances, small, deterministic, widely studied microbenchmarks often fail to reach a steady state of peak performance on a variety of common VMs. Repeating our experiment on 3 different machines, we found that at most 43.5% of pairs consistently reach a steady state of peak performance.
     980
     9812) Kalibera, Tomas and Jones, Richard. Rigorous Benchmarking in Reasonable Time. ISMM  2013. https://doi.org/10.1145/2555670.2464160
     982Experimental evaluation is key to systems research. Because modern systems are complex and non-deterministic, good experimental methodology demands that researchers account for uncertainty. To obtain valid results, they are expected to run many iterations of benchmarks, invoke virtual machines (VMs) several times, or even rebuild VM or benchmark binaries more than once. All this repetition costs time to complete experiments. Currently, many evaluations give up on sufficient repetition or rigorous statistical methods, or even run benchmarks only in training sizes. The results reported often lack proper variation estimates and, when a small difference between two systems is reported, some are simply unreliable.In contrast, we provide a statistically rigorous methodology for repetition and summarising results that makes efficient use of experimentation time. Time efficiency comes from two key observations. First, a given benchmark on a given platform is typically prone to much less non-determinism than the common worst-case of published corner-case studies. Second, repetition is most needed where most uncertainty arises (whether between builds, between executions or between iterations). We capture experimentation cost with a novel mathematical model, which we use to identify the number of repetitions at each level of an experiment necessary and sufficient to obtain a given level of precision.We present our methodology as a cookbook that guides researchers on the number of repetitions they should run to obtain reliable results. We also show how to present results with an effect size confidence interval. As an example, we show how to use our methodology to conduct throughput experiments with the DaCapo and SPEC CPU benchmarks on three recent platforms.
     983
     984You have 42 days from the date of this email to submit your revision. If you are unable to complete the revision within this time, please contact me to request a short extension.
     985
     986You can upload your revised manuscript and submit it through your Author Center. Log into https://mc.manuscriptcentral.com/spe and enter your Author Center, where you will find your manuscript title listed under "Manuscripts with Decisions".
     987
     988When submitting your revised manuscript, you will be able to respond to the comments made by the referee(s) in the space provided.  You can use this space to document any changes you make to the original manuscript.
     989
     990If you would like help with English language editing, or other article preparation support, Wiley Editing Services offers expert help with English Language Editing, as well as translation, manuscript formatting, and figure formatting at www.wileyauthors.com/eeo/preparation. You can also check out our resources for Preparing Your Article for general guidance about writing and preparing your manuscript at www.wileyauthors.com/eeo/prepresources.
     991 
     992Once again, thank you for submitting your manuscript to Software: Practice and Experience. I look forward to receiving your revision.
     993
     994Sincerely,
     995Richard
     996
     997Prof. Richard Jones
     998Editor, Software: Practice and Experience
     999R.E.Jones@kent.ac.uk
     1000
     1001Referee(s)' Comments to Author:
     1002
     1003Reviewing: 1
     1004
     1005Comments to the Author
     1006Overall, I felt that this draft was an improvement on previous drafts and I don't have further changes to request.
     1007
     1008I appreciated the new language to clarify the relationship of external and internal scheduling, for example, as well as the new measurements of Rust tokio. Also, while I still believe that the choice between thread/generator/coroutine and so forth could be made crisper and clearer, the current draft of Section 2 did seem adequate to me in terms of specifying the considerations that users would have to take into account to make the choice.
     1009
     1010
     1011Reviewing: 2
     1012
     1013Comments to the Author
     1014First: let me apologise for the delay on this review. I'll blame the global pandemic combined with my institution's senior management's counterproductive decisions for taking up most of my time and all of my energy.
     1015
     1016At this point, reading the responses, I think we've been around the course enough times that further iteration is unlikely to really improve the paper any further, so I'm happy to recommend acceptance.    My main comments are that there were some good points in the responses to *all* the reviews and I strongly encourage the authors to incorporate those discursive responses into the final paper so they may benefit readers as well as reviewers.   I agree with the recommendations of reviewer #2 that the paper could usefully be split in to two, which I think I made to a previous revision, but I'm happy to leave that decision to the Editor.
     1017
     1018Finally, the paper needs to describe how the Java harness was adapted to deal with warmup; why the computation has warmed up and reached a steady state - similarly for js and Python. The tables should also give the "N" chosen for each benchmark run.
     1019 
     1020minor points
     1021* don't start sentences with "However"
     1022* most downloaded isn't an "Award"
     1023
     1024
     1025
     1026Date: Thu, 1 Oct 2020 05:34:29 +0000
     1027From: Richard Jones <onbehalfof@manuscriptcentral.com>
     1028Reply-To: R.E.Jones@kent.ac.uk
     1029To: pabuhr@uwaterloo.ca
     1030Subject: Revision reminder - SPE-19-0219.R2
     1031
     103201-Oct-2020
     1033
     1034Dear Dr Buhr
     1035
     1036SPE-19-0219.R2
     1037
     1038This is a reminder that your opportunity to revise and re-submit your manuscript will expire 14 days from now. If you require more time please contact me directly and I may grant an extension to this deadline, otherwise the option to submit a revision online, will not be available.
     1039
     1040If your article is of potential interest to the general public, (which means it must be timely, groundbreaking, interesting and impact on everyday society) then please e-mail ejp@wiley.co.uk explaining the public interest side of the research. Wiley will then investigate the potential for undertaking a global press campaign on the article.
     1041
     1042I look forward to receiving your revision.
     1043
     1044Sincerely,
     1045
     1046Prof. Richard Jones
     1047Editor, Software: Practice and Experience
     1048
     1049https://mc.manuscriptcentral.com/spe
     1050
     1051
     1052
     1053Date: Tue, 6 Oct 2020 15:29:41 +0000
     1054From: Mayank Roy Chowdhury <onbehalfof@manuscriptcentral.com>
     1055Reply-To: speoffice@wiley.com
     1056To: tdelisle@uwaterloo.ca, pabuhr@uwaterloo.ca
     1057Subject: SPE-19-0219.R3 successfully submitted
     1058
     105906-Oct-2020
     1060
     1061Dear Dr Buhr,
     1062
     1063Your manuscript entitled "Advanced Control-flow and Concurrency in Cforall" has been successfully submitted online and is presently being given full consideration for publication in Software: Practice and Experience.
     1064
     1065Your manuscript number is SPE-19-0219.R3.  Please mention this number in all future correspondence regarding this submission.
     1066
     1067You can view the status of your manuscript at any time by checking your Author Center after logging into https://mc.manuscriptcentral.com/spe.  If you have difficulty using this site, please click the 'Get Help Now' link at the top right corner of the site.
     1068
     1069
     1070Thank you for submitting your manuscript to Software: Practice and Experience.
     1071
     1072Sincerely,
     1073
     1074Software: Practice and Experience Editorial Office
     1075
  • doc/refrat/refrat.tex

    r2fb35df r41b8ea4  
    1111%% Created On       : Wed Apr  6 14:52:25 2016
    1212%% Last Modified By : Peter A. Buhr
    13 %% Last Modified On : Thu Sep 24 16:34:51 2020
    14 %% Update Count     : 109
     13%% Last Modified On : Mon Oct  5 09:02:53 2020
     14%% Update Count     : 110
    1515%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1616
     
    6363%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    6464
    65 \CFADefaults                                                                                    % use default CFA format-style
     65\CFAStyle                                                                                               % use default CFA format-style
    6666\lstnewenvironment{C++}[1][]                            % use C++ style
    6767{\lstset{language=C++,moredelim=**[is][\protect\color{red}]{®}{®},#1}}
  • doc/theses/fangren_yu_COOP_S20/Makefile

    r2fb35df r41b8ea4  
    4646# File Dependencies #
    4747
    48 
    4948${DOCUMENT} : ${BASE}.ps
    5049        ps2pdf $<
  • doc/theses/fangren_yu_COOP_S20/Report.tex

    r2fb35df r41b8ea4  
    1 \documentclass[twoside,12pt]{article}
     1\documentclass[twoside,11pt]{article}
    22
    33%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     
    1111\usepackage[labelformat=simple,aboveskip=0pt,farskip=0pt]{subfig}
    1212\renewcommand{\thesubfigure}{\alph{subfigure})}
     13\usepackage[flushmargin]{footmisc}                                              % support label/reference in footnote
    1314\usepackage{latexsym}                                   % \Box glyph
    1415\usepackage{mathptmx}                                   % better math font with "times"
    15 \usepackage{appendix}
     16\usepackage[toc]{appendix}                                                              % article does not have appendix
    1617\usepackage[usenames]{color}
    1718\input{common}                                          % common CFA document macros
     
    3940%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    4041
    41 \CFADefaults
     42\CFAStyle                                                                                               % CFA code-style for all languages
    4243\lstset{
    43 language=C++,                                                                                   % make C++ the default language
     44language=C++,moredelim=**[is][\color{red}]{@}{@}                % make C++ the default language
    4445}% lstset
    4546\lstnewenvironment{C++}[1][]                            % use C++ style
    46 {\lstset{language=C++,moredelim=**[is][\color{red}]{@}{@},#1}}{}
     47{\lstset{language=C++,moredelim=**[is][\color{red}]{@}{@}}\lstset{#1}}{}
    4748
    4849%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     
    8788\section{Overview}
    8889
    89 cfa-cc is the reference compiler for the \CFA programming language, which is a non-object-oriented extension to C.
     90@cfa-cc@ is the reference compiler for the \CFA programming language, which is a non-object-oriented extension to C.
    9091\CFA attempts to introduce productive modern programming language features to C while maintaining as much backward-compatibility as possible, so that most existing C programs can seamlessly work with \CFA.
    9192
     
    381382\subsubsection{Source: \lstinline{AST/SymbolTable.hpp}}
    382383
    383 
    384 \subsubsection{Source: \lstinline{SymTab/Indexer.h}}
    385 
    386384Function
    387385\begin{C++}
     
    612610
    613611
    614 \begin{appendices}[toc,titletoc]
     612\appendix
    615613\section{Appendix}
    616 
    617614
    618615\subsection{Kinds of Type Parameters}
    619616\label{s:KindsTypeParameters}
    620617
    621 A type parameter in a @forall@ clause has three possible kinds:
     618A type parameter in a @forall@ clause has 3 kinds:
    622619\begin{enumerate}[listparindent=0pt]
    623620\item
    624 @dtype@: any data type (built-in or user defined).
    625 
    626 There is also a difference between opaque types (incomplete types, \ie those with only a forward declaration) and concrete types.
    627 Only concrete types can be directly used as a variable type.
    628 
    629 \CFA provides the @otype@ shorthand to require a type parameter be concrete, which also implicitly asserts the existence of its default and copy constructors, assignment, and destructor\footnote{\CFA implements the same automatic resource management (RAII) semantics as \CC.}.
    630 \item
    631 @ftype@: any function type.
    632 
    633 @ftype@ provides two purposes:
    634 \begin{itemize}
    635 \item
    636 Differentiate function pointer from data pointer because (in theory) some systems have different sizes for these pointers.
    637 \item
    638 Disallow a function pointer to match an overloaded data pointer, since variables and functions can have the same names.
    639 \end{itemize}
     621@dtype@: any data type (built-in or user defined) that is not a concrete type.
     622
     623A non-concrete type is an incomplete type such as an opaque type or pointer/reference with an implicit (pointer) size and implicitly generated reference and dereference operations.
     624\item
     625@otype@: any data type (built-in or user defined) that is concrete type.
     626
     627A concrete type is a complete type, \ie types that can be used to create a variable, which also implicitly asserts the existence of default and copy constructors, assignment, and destructor\footnote{\CFA implements the same automatic resource management (RAII) semantics as \CC.}.
     628% \item
     629% @ftype@: any function type.
     630%
     631% @ftype@ provides two purposes:
     632% \begin{itemize}
     633% \item
     634% Differentiate function pointer from data pointer because (in theory) some systems have different sizes for these pointers.
     635% \item
     636% Disallow a function pointer to match an overloaded data pointer, since variables and functions can have the same names.
     637% \end{itemize}
    640638
    641639\item
    642640@ttype@: tuple (variadic) type.
    643641
    644 @ttype@ parameter may only appear as type of the last parameter in a function, and it provides a type-safe way to implement variadic functions.
     642Restricted to the type for the last parameter in a function, it provides a type-safe way to implement variadic functions.
    645643Note however, that it has certain restrictions, as described in the implementation section below.
    646644\end{enumerate}
     
    673671\begin{enumerate}
    674672\item
    675 All types are function declarations are candidates of implicit parameters.
     673All types, variables, and functions are candidates of implicit parameters
    676674\item
    677675The parameter (assertion) name must match the actual declarations.
    678 \item
    679 Currently, assertions are all functions.
    680 Note that since \CFA has variable overloading, implicit value parameters might also be supported in the future.
    681676\end{enumerate}
    682677
     
    732727In particular, polymorphic variadic recursion must be structural (\ie the number of arguments decreases in any possible recursive calls), otherwise code generation gets into an infinite loop.
    733728The \CFA compiler sets a limit on assertion depth and reports an error if assertion resolution does not terminate within the limit (as for \lstinline[language=C++]@templates@ in \CC).
    734 \end{appendices}
    735729
    736730\bibliographystyle{plain}
  • doc/theses/thierry_delisle_PhD/code/readQ_example/proto-gui/main.cpp

    r2fb35df r41b8ea4  
    1 #include "thrdlib/thread.h"
     1#include "thrdlib/thread.hpp"
    22
    33#include <cassert>
     
    55#include <algorithm>
    66#include <atomic>
     7#include <iostream>
    78#include <memory>
    89#include <vector>
    910
    1011#include <getopt.h>
     12using thrdlib::thread_t;
     13
     14
     15extern __attribute__((aligned(128))) thread_local struct {
     16        void * volatile this_thread;
     17        void * volatile this_processor;
     18        void * volatile this_stats;
     19
     20        struct {
     21                volatile unsigned short disable_count;
     22                volatile bool enabled;
     23                volatile bool in_progress;
     24        } preemption_state;
     25
     26        #if defined(__SIZEOF_INT128__)
     27                __uint128_t rand_seed;
     28        #else
     29                uint64_t rand_seed;
     30        #endif
     31        struct {
     32                uint64_t fwd_seed;
     33                uint64_t bck_seed;
     34        } ready_rng;
     35} kernelTLS __attribute__ ((tls_model ( "initial-exec" )));
    1136
    1237//--------------------
     
    3661                        assert( expected == reset );
    3762                        if( std::atomic_compare_exchange_strong( &state, &expected, self) ) {
    38                                 thrdlib_park( self );
     63                                thrdlib::park( self );
    3964                                ret = true;
    4065                                goto END;
     
    5479                if( got == reset ) return false;
    5580
    56                 thrdlib_unpark( got );
     81                thrdlib::unpark( got );
    5782                return true;
    5883        }
     
    109134        the_stats_thread = self;
    110135        fence();
    111         thrdlib_park( self );
     136        thrdlib::park( self );
    112137
    113138        std::vector<bool> seen;
     
    115140
    116141        while(last_produced < nproduce) {
    117                 thrdlib_yield();
     142                thrdlib::yield();
    118143                thrd_stats.stats.ran++;
    119144                if( last_produced > 0 ) seen.at(last_produced - 1) = true;
     
    147172
    148173void Renderer( thread_t self ) {
    149         thrdlib_unpark( the_stats_thread );
     174        thrdlib::unpark( the_stats_thread );
    150175        for(unsigned i = 0; i < nproduce; i++) {
    151176                auto & frame = frames[i % nframes];
     
    178203        fsize    = 1000;
    179204        nproduce = 60;
     205
     206        const char * framework;
    180207
    181208        for(;;) {
     
    196223                        case -1:
    197224                                /* paranoid */ assert(optind <= argc);
     225                                if( optind == argc ) {
     226                                        std::cerr << "Must specify a framework" << std::endl;
     227                                        goto usage;
     228
     229                                }
     230                                framework = argv[optind];
    198231                                goto run;
    199232                        case 'b':
     
    228261                                std::cerr << opt << std::endl;
    229262                        usage:
    230                                 std::cerr << "Usage: " << argv[0] << " [options]" << std::endl;
     263                                std::cerr << "Usage: " << argv[0] << " [options] framework" << std::endl;
    231264                                std::cerr << std::endl;
    232265                                std::cerr << "  -b, --buff=COUNT    Number of frames to buffer" << std::endl;
     
    237270        }
    238271        run:
     272        assert( framework );
    239273
    240274        frames.reset(new Frame[nframes]);
     
    246280        std::cout << "(Buffering " << nframes << ")" << std::endl;
    247281
    248         thrdlib_setproccnt( 2 );
    249 
    250         thread_t stats     = thrdlib_create( Stats    );
     282        thrdlib::init( framework, 2 );
     283
     284        thread_t stats     = thrdlib::create( Stats );
    251285        std::cout << "Created Stats Thread" << std::endl;
    252         while( the_stats_thread == nullptr ) thrdlib_yield();
     286        while( the_stats_thread == nullptr ) thrdlib::yield();
     287
    253288        std::cout << "Creating Main Threads" << std::endl;
    254         thread_t renderer  = thrdlib_create( Renderer  );
    255         // while(true);
    256         thread_t simulator = thrdlib_create( Simulator );
     289        thread_t renderer  = thrdlib::create( Renderer  );
     290        thread_t simulator = thrdlib::create( Simulator );
    257291
    258292        std::cout << "Running" << std::endl;
    259293
    260         thrdlib_join( simulator );
    261         thrdlib_join( renderer  );
    262         thrdlib_join( stats     );
     294        thrdlib::join( simulator );
     295        thrdlib::join( renderer  );
     296        thrdlib::join( stats     );
     297
     298        thrdlib::clean();
    263299
    264300        std::cout << "----------" << std::endl;
  • doc/user/Makefile

    r2fb35df r41b8ea4  
    5555
    5656${DOCUMENT} : ${BASE}.ps
    57         ps2pdf $<
     57        ps2pdf -dPDFSETTINGS=/prepress $<
    5858
    5959${BASE}.ps : ${BASE}.dvi
  • doc/user/user.tex

    r2fb35df r41b8ea4  
    1111%% Created On       : Wed Apr  6 14:53:29 2016
    1212%% Last Modified By : Peter A. Buhr
    13 %% Last Modified On : Thu Sep 24 16:34:52 2020
    14 %% Update Count     : 3997
     13%% Last Modified On : Mon Oct  5 08:57:29 2020
     14%% Update Count     : 3998
    1515%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1616
     
    6666%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    6767
    68 \CFADefaults                                                                                    % use default CFA format-style
     68\CFAStyle                                                                                               % use default CFA format-style
    6969\lstnewenvironment{C++}[1][]                            % use C++ style
    7070{\lstset{language=C++,moredelim=**[is][\protect\color{red}]{®}{®},#1}}
  • libcfa/src/bits/containers.hfa

    r2fb35df r41b8ea4  
    157157                        tail = &get_next( *val );
    158158                        *tail = 1p;
     159                }
     160
     161                T * peek( __queue(T) & this ) {
     162                        verify(*this.tail == 1p);
     163                        T * head = this.head;
     164                        if( head != 1p ) {
     165                                verify(*this.tail == 1p);
     166                                return head;
     167                        }
     168                        verify(*this.tail == 1p);
     169                        return 0p;
    159170                }
    160171
  • libcfa/src/bits/locks.hfa

    r2fb35df r41b8ea4  
    164164
    165165        struct $thread;
    166         extern void park( __cfaabi_dbg_ctx_param );
    167         extern void unpark( struct $thread * this __cfaabi_dbg_ctx_param2 );
     166        extern void park( void );
     167        extern void unpark( struct $thread * this );
    168168        static inline struct $thread * active_thread ();
    169169
     
    191191                                        /* paranoid */ verify( expected == 0p );
    192192                                        if(__atomic_compare_exchange_n(&this.ptr, &expected, active_thread(), false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) {
    193                                                 park( __cfaabi_dbg_ctx );
     193                                                park();
    194194                                                return true;
    195195                                        }
     
    210210                                else {
    211211                                        if(__atomic_compare_exchange_n(&this.ptr, &expected, 0p, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) {
    212                                                 unpark( expected __cfaabi_dbg_ctx2 );
     212                                                unpark( expected );
    213213                                                return true;
    214214                                        }
     
    244244                                /* paranoid */ verify( expected == 0p );
    245245                                if(__atomic_compare_exchange_n(&this.ptr, &expected, active_thread(), false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) {
    246                                         park( __cfaabi_dbg_ctx );
     246                                        park();
    247247                                        /* paranoid */ verify( this.ptr == 1p );
    248248                                        return true;
     
    256256                        struct $thread * got = __atomic_exchange_n( &this.ptr, 1p, __ATOMIC_SEQ_CST);
    257257                        if( got == 0p ) return false;
    258                         unpark( got __cfaabi_dbg_ctx2 );
     258                        unpark( got );
    259259                        return true;
    260260                }
  • libcfa/src/concurrency/CtxSwitch-i386.S

    r2fb35df r41b8ea4  
    1010// Created On       : Tue Dec 6 12:27:26 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Aug 16 08:46:22 2020
    13 // Update Count     : 4
     12// Last Modified On : Sun Sep  6 18:23:37 2020
     13// Update Count     : 5
    1414//
    1515
     
    3535
    3636        // Copy the "from" context argument from the stack to register eax
    37         // Return address is at 0(%esp), with parameters following
     37        // Return address is at 0(%esp), with parameters following.
    3838
    3939        movl 4(%esp),%eax
     
    5050        movl %ebp,FP_OFFSET(%eax)
    5151
    52         // Copy the "to" context argument from the stack to register eax
    53         // Having pushed three words (= 12 bytes) on the stack, the
    54         // argument is now at 8 + 12 = 20(%esp)
     52        // Copy the "to" context argument from the stack to register eax. Having
     53        // pushed 3 words (= 12 bytes) on the stack, the argument is now at
     54        // 8 + 12 = 20(%esp).
    5555
    5656        movl 20(%esp),%eax
  • libcfa/src/concurrency/alarm.cfa

    r2fb35df r41b8ea4  
    130130
    131131        register_self( &node );
    132         park( __cfaabi_dbg_ctx );
     132        park();
    133133
    134134        /* paranoid */ verify( !node.set );
  • libcfa/src/concurrency/clib/cfathread.cfa

    r2fb35df r41b8ea4  
    3434extern "C" {
    3535        //--------------------
    36         // Basic thread managenemt
     36        // Basic thread management
    3737        CRunner * cfathread_create( void (*main)( CRunner * ) ) {
    3838                return new( main );
     
    4444
    4545        void cfathread_park( void ) {
    46                 park( __cfaabi_dbg_ctx );
     46                park();
    4747        }
    4848
    4949        void cfathread_unpark( CRunner * thrd ) {
    50                 unpark( *thrd __cfaabi_dbg_ctx2 );
     50                unpark( *thrd );
    5151        }
    5252
  • libcfa/src/concurrency/clib/cfathread.h

    r2fb35df r41b8ea4  
    1717#include "invoke.h"
    1818
    19 #if defined(__cforall) || defined(__cpluplus)
     19#if defined(__cforall) || defined(__cplusplus)
    2020extern "C" {
    2121#endif
     
    3939
    4040
    41 #if defined(__cforall) || defined(__cpluplus)
     41#if defined(__cforall) || defined(__cplusplus)
    4242}
    4343#endif
  • libcfa/src/concurrency/invoke.h

    r2fb35df r41b8ea4  
    9393
    9494        };
     95        // Wrapper for gdb
     96        struct cfathread_coroutine_t { struct $coroutine debug; };
    9597
    9698        static inline struct __stack_t * __get_stack( struct $coroutine * cor ) {
     
    129131                struct __condition_node_t * dtor_node;
    130132        };
     133        // Wrapper for gdb
     134        struct cfathread_monitor_t { struct $monitor debug; };
    131135
    132136        struct __monitor_group_t {
     
    186190                } node;
    187191
    188                 #ifdef __CFA_DEBUG__
    189                         // previous function to park/unpark the thread
    190                         const char * park_caller;
    191                         int park_result;
    192                         enum __Coroutine_State park_state;
    193                         bool park_stale;
    194                         const char * unpark_caller;
    195                         int unpark_result;
    196                         enum __Coroutine_State unpark_state;
    197                         bool unpark_stale;
     192                #if defined( __CFA_WITH_VERIFY__ )
     193                        unsigned long long canary;
    198194                #endif
    199195        };
     196        // Wrapper for gdb
     197        struct cfathread_thread_t { struct $thread debug; };
    200198
    201199        #ifdef __CFA_DEBUG__
  • libcfa/src/concurrency/io.cfa

    r2fb35df r41b8ea4  
    6969                if( block ) {
    7070                        enable_interrupts( __cfaabi_dbg_ctx );
    71                         park( __cfaabi_dbg_ctx );
     71                        park();
    7272                        disable_interrupts();
    7373                }
     
    9797
    9898                if(nextt) {
    99                         unpark( nextt __cfaabi_dbg_ctx2 );
     99                        unpark( nextt );
    100100                        enable_interrupts( __cfaabi_dbg_ctx );
    101101                        return true;
  • libcfa/src/concurrency/io/setup.cfa

    r2fb35df r41b8ea4  
    247247                                        thrd.link.next = 0p;
    248248                                        thrd.link.prev = 0p;
    249                                         __cfaabi_dbg_debug_do( thrd.unpark_stale = true );
    250249
    251250                                        // Fixup the thread state
     
    267266
    268267                                // unpark the fast io_poller
    269                                 unpark( &thrd __cfaabi_dbg_ctx2 );
     268                                unpark( &thrd );
    270269                        }
    271270                        else {
     
    276275                        }
    277276                } else {
    278                         unpark( &thrd __cfaabi_dbg_ctx2 );
     277                        unpark( &thrd );
    279278                }
    280279
  • libcfa/src/concurrency/kernel.cfa

    r2fb35df r41b8ea4  
    246246                thrd_dst->state = Active;
    247247
    248                 __cfaabi_dbg_debug_do(
    249                         thrd_dst->park_stale   = true;
    250                         thrd_dst->unpark_stale = true;
    251                 )
    252248                // Update global state
    253249                kernelTLS.this_thread = thrd_dst;
     
    255251                /* paranoid */ verify( ! kernelTLS.preemption_state.enabled );
    256252                /* paranoid */ verify( kernelTLS.this_thread == thrd_dst );
     253                /* paranoid */ verify( thrd_dst->context.SP );
    257254                /* paranoid */ verifyf( ((uintptr_t)thrd_dst->context.SP) < ((uintptr_t)__get_stack(thrd_dst->curr_cor)->base ) || thrd_dst->curr_cor == proc_cor, "ERROR : Destination $thread %p has been corrupted.\n StackPointer too small.\n", thrd_dst ); // add escape condition if we are setting up the processor
    258255                /* paranoid */ verifyf( ((uintptr_t)thrd_dst->context.SP) > ((uintptr_t)__get_stack(thrd_dst->curr_cor)->limit) || thrd_dst->curr_cor == proc_cor, "ERROR : Destination $thread %p has been corrupted.\n StackPointer too large.\n", thrd_dst ); // add escape condition if we are setting up the processor
     256                /* paranoid */ verify( 0x0D15EA5E0D15EA5E == thrd_dst->canary );
     257
    259258
    260259
    261260                // set context switch to the thread that the processor is executing
    262                 verify( thrd_dst->context.SP );
    263261                __cfactx_switch( &proc_cor->context, &thrd_dst->context );
    264262                // when __cfactx_switch returns we are back in the processor coroutine
    265263
     264                /* paranoid */ verify( 0x0D15EA5E0D15EA5E == thrd_dst->canary );
    266265                /* paranoid */ verifyf( ((uintptr_t)thrd_dst->context.SP) > ((uintptr_t)__get_stack(thrd_dst->curr_cor)->limit), "ERROR : Destination $thread %p has been corrupted.\n StackPointer too large.\n", thrd_dst );
    267266                /* paranoid */ verifyf( ((uintptr_t)thrd_dst->context.SP) < ((uintptr_t)__get_stack(thrd_dst->curr_cor)->base ), "ERROR : Destination $thread %p has been corrupted.\n StackPointer too small.\n", thrd_dst );
     267                /* paranoid */ verify( thrd_dst->context.SP );
    268268                /* paranoid */ verify( kernelTLS.this_thread == thrd_dst );
    269269                /* paranoid */ verify( ! kernelTLS.preemption_state.enabled );
     
    288288                        // The thread has halted, it should never be scheduled/run again
    289289                        // We may need to wake someone up here since
    290                         unpark( this->destroyer __cfaabi_dbg_ctx2 );
     290                        unpark( this->destroyer );
    291291                        this->destroyer = 0p;
    292292                        break RUNNING;
     
    298298                // set state of processor coroutine to active and the thread to inactive
    299299                int old_ticket = __atomic_fetch_sub(&thrd_dst->ticket, 1, __ATOMIC_SEQ_CST);
    300                 __cfaabi_dbg_debug_do( thrd_dst->park_result = old_ticket; )
    301300                switch(old_ticket) {
    302301                        case 1:
     
    335334                        __x87_store;
    336335                #endif
    337                 verify( proc_cor->context.SP );
     336                /* paranoid */ verify( proc_cor->context.SP );
     337                /* paranoid */ verify( 0x0D15EA5E0D15EA5E == thrd_src->canary );
    338338                __cfactx_switch( &thrd_src->context, &proc_cor->context );
     339                /* paranoid */ verify( 0x0D15EA5E0D15EA5E == thrd_src->canary );
    339340                #if defined( __i386 ) || defined( __x86_64 )
    340341                        __x87_load;
     
    368369        /* paranoid */ #endif
    369370        /* paranoid */ verifyf( thrd->link.next == 0p, "Expected null got %p", thrd->link.next );
     371        /* paranoid */ verify( 0x0D15EA5E0D15EA5E == thrd->canary );
     372
    370373
    371374        if (thrd->preempted == __NO_PREEMPTION) thrd->state = Ready;
     
    404407
    405408// KERNEL ONLY unpark with out disabling interrupts
    406 void __unpark(  struct __processor_id_t * id, $thread * thrd __cfaabi_dbg_ctx_param2 ) {
    407         // record activity
    408         __cfaabi_dbg_record_thrd( *thrd, false, caller );
    409 
     409void __unpark(  struct __processor_id_t * id, $thread * thrd ) {
    410410        int old_ticket = __atomic_fetch_add(&thrd->ticket, 1, __ATOMIC_SEQ_CST);
    411         __cfaabi_dbg_debug_do( thrd->unpark_result = old_ticket; thrd->unpark_state = thrd->state; )
    412411        switch(old_ticket) {
    413412                case 1:
     
    427426}
    428427
    429 void unpark( $thread * thrd __cfaabi_dbg_ctx_param2 ) {
     428void unpark( $thread * thrd ) {
    430429        if( !thrd ) return;
    431430
    432431        disable_interrupts();
    433         __unpark( (__processor_id_t*)kernelTLS.this_processor, thrd __cfaabi_dbg_ctx_fwd2 );
     432        __unpark( (__processor_id_t*)kernelTLS.this_processor, thrd );
    434433        enable_interrupts( __cfaabi_dbg_ctx );
    435434}
    436435
    437 void park( __cfaabi_dbg_ctx_param ) {
     436void park( void ) {
    438437        /* paranoid */ verify( kernelTLS.preemption_state.enabled );
    439438        disable_interrupts();
    440439        /* paranoid */ verify( ! kernelTLS.preemption_state.enabled );
    441440        /* paranoid */ verify( kernelTLS.this_thread->preempted == __NO_PREEMPTION );
    442 
    443         // record activity
    444         __cfaabi_dbg_record_thrd( *kernelTLS.this_thread, true, caller );
    445441
    446442        returnToKernel();
     
    650646                // atomically release spin lock and block
    651647                unlock( lock );
    652                 park( __cfaabi_dbg_ctx );
     648                park();
    653649                return true;
    654650        }
     
    671667
    672668        // make new owner
    673         unpark( thrd __cfaabi_dbg_ctx2 );
     669        unpark( thrd );
    674670
    675671        return thrd != 0p;
     
    682678        count += diff;
    683679        for(release) {
    684                 unpark( pop_head( waiting ) __cfaabi_dbg_ctx2 );
     680                unpark( pop_head( waiting ) );
    685681        }
    686682
     
    698694                        this.prev_thrd = kernelTLS.this_thread;
    699695                }
    700 
    701                 void __cfaabi_dbg_record_thrd($thread & this, bool park, const char prev_name[]) {
    702                         if(park) {
    703                                 this.park_caller   = prev_name;
    704                                 this.park_stale    = false;
    705                         }
    706                         else {
    707                                 this.unpark_caller = prev_name;
    708                                 this.unpark_stale  = false;
    709                         }
    710                 }
    711696        }
    712697)
  • libcfa/src/concurrency/kernel/fwd.hfa

    r2fb35df r41b8ea4  
    118118
    119119        extern "Cforall" {
    120                 extern void park( __cfaabi_dbg_ctx_param );
    121                 extern void unpark( struct $thread * this __cfaabi_dbg_ctx_param2 );
     120                extern void park( void );
     121                extern void unpark( struct $thread * this );
    122122                static inline struct $thread * active_thread () { return TL_GET( this_thread ); }
    123123
  • libcfa/src/concurrency/kernel/startup.cfa

    r2fb35df r41b8ea4  
    451451        link.next = 0p;
    452452        link.prev = 0p;
     453        #if defined( __CFA_WITH_VERIFY__ )
     454                canary = 0x0D15EA5E0D15EA5E;
     455        #endif
    453456
    454457        node.next = 0p;
  • libcfa/src/concurrency/kernel_private.hfa

    r2fb35df r41b8ea4  
    6464
    6565// KERNEL ONLY unpark with out disabling interrupts
    66 void __unpark( struct __processor_id_t *, $thread * thrd __cfaabi_dbg_ctx_param2 );
     66void __unpark( struct __processor_id_t *, $thread * thrd );
    6767
    6868static inline bool __post(single_sem & this, struct __processor_id_t * id) {
     
    7777                else {
    7878                        if(__atomic_compare_exchange_n(&this.ptr, &expected, 0p, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) {
    79                                 __unpark( id, expected __cfaabi_dbg_ctx2 );
     79                                __unpark( id, expected );
    8080                                return true;
    8181                        }
  • libcfa/src/concurrency/monitor.cfa

    r2fb35df r41b8ea4  
    122122
    123123                unlock( this->lock );
    124                 park( __cfaabi_dbg_ctx );
     124                park();
    125125
    126126                __cfaabi_dbg_print_safe( "Kernel : %10p Entered  mon %p\n", thrd, this);
     
    201201                // Release the next thread
    202202                /* paranoid */ verifyf( urgent->owner->waiting_thread == this->owner, "Expected owner to be %p, got %p (r: %i, m: %p)", kernelTLS.this_thread, this->owner, this->recursion, this );
    203                 unpark( urgent->owner->waiting_thread __cfaabi_dbg_ctx2 );
     203                unpark( urgent->owner->waiting_thread );
    204204
    205205                // Park current thread waiting
    206                 park( __cfaabi_dbg_ctx );
     206                park();
    207207
    208208                // Some one was waiting for us, enter
     
    222222
    223223                // Park current thread waiting
    224                 park( __cfaabi_dbg_ctx );
     224                park();
    225225
    226226                /* paranoid */ verifyf( kernelTLS.this_thread == this->owner, "Expected owner to be %p, got %p (r: %i, m: %p)", kernelTLS.this_thread, this->owner, this->recursion, this );
     
    264264        //We need to wake-up the thread
    265265        /* paranoid */ verifyf( !new_owner || new_owner == this->owner, "Expected owner to be %p, got %p (m: %p)", new_owner, this->owner, this );
    266         unpark( new_owner __cfaabi_dbg_ctx2 );
     266        unpark( new_owner );
    267267}
    268268
     
    493493        // Wake the threads
    494494        for(int i = 0; i < thread_count; i++) {
    495                 unpark( threads[i] __cfaabi_dbg_ctx2 );
     495                unpark( threads[i] );
    496496        }
    497497
    498498        // Everything is ready to go to sleep
    499         park( __cfaabi_dbg_ctx );
     499        park();
    500500
    501501        // We are back, restore the owners and recursions
     
    575575
    576576        // unpark the thread we signalled
    577         unpark( signallee __cfaabi_dbg_ctx2 );
     577        unpark( signallee );
    578578
    579579        //Everything is ready to go to sleep
    580         park( __cfaabi_dbg_ctx );
     580        park();
    581581
    582582
     
    679679
    680680                                // unpark the thread we signalled
    681                                 unpark( next __cfaabi_dbg_ctx2 );
     681                                unpark( next );
    682682
    683683                                //Everything is ready to go to sleep
    684                                 park( __cfaabi_dbg_ctx );
     684                                park();
    685685
    686686                                // We are back, restore the owners and recursions
     
    724724
    725725        //Everything is ready to go to sleep
    726         park( __cfaabi_dbg_ctx );
     726        park();
    727727
    728728
  • libcfa/src/concurrency/mutex.cfa

    r2fb35df r41b8ea4  
    4242                append( blocked_threads, kernelTLS.this_thread );
    4343                unlock( lock );
    44                 park( __cfaabi_dbg_ctx );
     44                park();
    4545        }
    4646        else {
     
    6565        this.is_locked = (this.blocked_threads != 0);
    6666        unpark(
    67                 pop_head( this.blocked_threads ) __cfaabi_dbg_ctx2
     67                pop_head( this.blocked_threads )
    6868        );
    6969        unlock( this.lock );
     
    9797                append( blocked_threads, kernelTLS.this_thread );
    9898                unlock( lock );
    99                 park( __cfaabi_dbg_ctx );
     99                park();
    100100        }
    101101}
     
    124124                owner = thrd;
    125125                recursion_count = (thrd ? 1 : 0);
    126                 unpark( thrd __cfaabi_dbg_ctx2 );
     126                unpark( thrd );
    127127        }
    128128        unlock( lock );
     
    142142        lock( lock __cfaabi_dbg_ctx2 );
    143143        unpark(
    144                 pop_head( this.blocked_threads ) __cfaabi_dbg_ctx2
     144                pop_head( this.blocked_threads )
    145145        );
    146146        unlock( lock );
     
    151151        while(this.blocked_threads) {
    152152                unpark(
    153                         pop_head( this.blocked_threads ) __cfaabi_dbg_ctx2
     153                        pop_head( this.blocked_threads )
    154154                );
    155155        }
     
    161161        append( this.blocked_threads, kernelTLS.this_thread );
    162162        unlock( this.lock );
    163         park( __cfaabi_dbg_ctx );
     163        park();
    164164}
    165165
     
    170170        unlock(l);
    171171        unlock(this.lock);
    172         park( __cfaabi_dbg_ctx );
     172        park();
    173173        lock(l);
    174174}
  • libcfa/src/concurrency/preemption.cfa

    r2fb35df r41b8ea4  
    274274                kernelTLS.this_stats = this->curr_cluster->stats;
    275275        #endif
    276         __unpark( id, this __cfaabi_dbg_ctx2 );
     276        __unpark( id, this );
    277277}
    278278
  • libcfa/src/concurrency/thread.cfa

    r2fb35df r41b8ea4  
    3939        link.prev = 0p;
    4040        link.preferred = -1;
     41        #if defined( __CFA_WITH_VERIFY__ )
     42                canary = 0x0D15EA5E0D15EA5E;
     43        #endif
    4144
    4245        node.next = 0p;
     
    4851
    4952void ^?{}($thread& this) with( this ) {
     53        #if defined( __CFA_WITH_VERIFY__ )
     54                canary = 0xDEADDEADDEADDEAD;
     55        #endif
    5056        unregister(curr_cluster, this);
    5157        ^self_cor{};
  • libcfa/src/concurrency/thread.hfa

    r2fb35df r41b8ea4  
    8888//----------
    8989// Park thread: block until corresponding call to unpark, won't block if unpark is already called
    90 void park( __cfaabi_dbg_ctx_param );
     90void park( void );
    9191
    9292//----------
    9393// Unpark a thread, if the thread is already blocked, schedule it
    9494//                  if the thread is not yet block, signal that it should rerun immediately
    95 void unpark( $thread * this __cfaabi_dbg_ctx_param2 );
     95void unpark( $thread * this );
    9696
    9797forall( dtype T | is_thread(T) )
    98 static inline void unpark( T & this __cfaabi_dbg_ctx_param2 ) { if(!&this) return; unpark( get_thread( this ) __cfaabi_dbg_ctx_fwd2 );}
     98static inline void unpark( T & this ) { if(!&this) return; unpark( get_thread( this ) );}
    9999
    100100//----------
  • src/Parser/lex.ll

    r2fb35df r41b8ea4  
    1010 * Created On       : Sat Sep 22 08:58:10 2001
    1111 * Last Modified By : Peter A. Buhr
    12  * Last Modified On : Sat Feb 15 11:05:50 2020
    13  * Update Count     : 737
     12 * Last Modified On : Tue Oct  6 18:15:41 2020
     13 * Update Count     : 743
    1414 */
    1515
     
    6262#define IDENTIFIER_RETURN()     RETURN_VAL( typedefTable.isKind( yytext ) )
    6363
    64 #ifdef HAVE_KEYWORDS_FLOATXX                                                            // GCC >= 7 => keyword, otherwise typedef
     64#ifdef HAVE_KEYWORDS_FLOATXX                                                    // GCC >= 7 => keyword, otherwise typedef
    6565#define FLOATXX(v) KEYWORD_RETURN(v);
    6666#else
     
    292292__restrict__    { KEYWORD_RETURN(RESTRICT); }                   // GCC
    293293return                  { KEYWORD_RETURN(RETURN); }
    294         /* resume                       { KEYWORD_RETURN(RESUME); }                             // CFA */
     294 /* resume                      { KEYWORD_RETURN(RESUME); }                             // CFA */
    295295short                   { KEYWORD_RETURN(SHORT); }
    296296signed                  { KEYWORD_RETURN(SIGNED); }
  • src/Parser/parser.yy

    r2fb35df r41b8ea4  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu May 28 12:11:45 2020
    13 // Update Count     : 4500
     12// Last Modified On : Tue Oct  6 18:24:18 2020
     13// Update Count     : 4610
    1414//
    1515
     
    278278%token OTYPE FTYPE DTYPE TTYPE TRAIT                                    // CFA
    279279%token SIZEOF OFFSETOF
    280 // %token RESUME                                                                        // CFA
    281 %token SUSPEND                                                                  // CFA
     280// %token RESUME                                                                                        // CFA
     281%token SUSPEND                                                                                  // CFA
    282282%token ATTRIBUTE EXTENSION                                                              // GCC
    283283%token IF ELSE SWITCH CASE DEFAULT DO WHILE FOR BREAK CONTINUE GOTO RETURN
     
    329329%type<en> conditional_expression                constant_expression                     assignment_expression           assignment_expression_opt
    330330%type<en> comma_expression                              comma_expression_opt
    331 %type<en> argument_expression_list_opt          argument_expression                     default_initialize_opt
     331%type<en> argument_expression_list_opt  argument_expression                     default_initialize_opt
    332332%type<ifctl> if_control_expression
    333333%type<fctl> for_control_expression              for_control_expression_list
     
    370370%type<decl> assertion assertion_list assertion_list_opt
    371371
    372 %type<en>   bit_subrange_size_opt bit_subrange_size
     372%type<en> bit_subrange_size_opt bit_subrange_size
    373373
    374374%type<decl> basic_declaration_specifier basic_type_name basic_type_specifier direct_type indirect_type
     
    793793        | '(' aggregate_control '&' ')' cast_expression         // CFA
    794794                { $$ = new ExpressionNode( build_keyword_cast( $2, $5 ) ); }
    795                 // VIRTUAL cannot be opt because of look ahead issues
    796795        | '(' VIRTUAL ')' cast_expression                                       // CFA
    797796                { $$ = new ExpressionNode( new VirtualCastExpr( maybeMoveBuild< Expression >( $4 ), maybeMoveBuildType( nullptr ) ) ); }
     
    920919        | unary_expression assignment_operator assignment_expression
    921920                {
    922                         if ( $2 == OperKinds::AtAssn ) {
    923                                 SemanticError( yylloc, "C @= assignment is currently unimplemented." ); $$ = nullptr;
    924                         } else {
     921//                      if ( $2 == OperKinds::AtAssn ) {
     922//                              SemanticError( yylloc, "C @= assignment is currently unimplemented." ); $$ = nullptr;
     923//                      } else {
    925924                                $$ = new ExpressionNode( build_binary_val( $2, $1, $3 ) );
    926                         } // if
     925//                      } // if
    927926                }
    928927        | unary_expression '=' '{' initializer_list_opt comma_opt '}'
     
    16761675
    16771676typedef_expression:
    1678                 // GCC, naming expression type: typedef name = exp; gives a name to the type of an expression
     1677                // deprecated GCC, naming expression type: typedef name = exp; gives a name to the type of an expression
    16791678        TYPEDEF identifier '=' assignment_expression
    16801679                {
    1681                         // $$ = DeclarationNode::newName( 0 );                  // unimplemented
    1682                         SemanticError( yylloc, "Typedef expression is currently unimplemented." ); $$ = nullptr;
     1680                        SemanticError( yylloc, "Typedef expression is deprecated, use typeof(...) instead." ); $$ = nullptr;
    16831681                }
    16841682        | typedef_expression pop ',' push identifier '=' assignment_expression
    16851683                {
    1686                         // $$ = DeclarationNode::newName( 0 );                  // unimplemented
    1687                         SemanticError( yylloc, "Typedef expression is currently unimplemented." ); $$ = nullptr;
    1688                 }
    1689         ;
    1690 
    1691 //c_declaration:
    1692 //      declaring_list pop ';'
    1693 //      | typedef_declaration pop ';'
    1694 //      | typedef_expression pop ';'                                            // GCC, naming expression type
    1695 //      | sue_declaration_specifier pop ';'
    1696 //      ;
    1697 //
    1698 //declaring_list:
    1699 //              // A semantic check is required to ensure asm_name only appears on declarations with implicit or explicit static
    1700 //              // storage-class
    1701 //       declarator asm_name_opt initializer_opt
    1702 //              {
    1703 //                      typedefTable.addToEnclosingScope( IDENTIFIER );
    1704 //                      $$ = ( $2->addType( $1 ))->addAsmName( $3 )->addInitializer( $4 );
    1705 //              }
    1706 //      | declaring_list ',' attribute_list_opt declarator asm_name_opt initializer_opt
    1707 //              {
    1708 //                      typedefTable.addToEnclosingScope( IDENTIFIER );
    1709 //                      $$ = $1->appendList( $1->cloneBaseType( $4->addAsmName( $5 )->addInitializer( $6 ) ) );
    1710 //              }
    1711 //      ;
     1684                        SemanticError( yylloc, "Typedef expression is deprecated, use typeof(...) instead." ); $$ = nullptr;
     1685                }
     1686        ;
    17121687
    17131688c_declaration:
     
    17151690                { $$ = distAttr( $1, $2 ); }
    17161691        | typedef_declaration
    1717         | typedef_expression                                                            // GCC, naming expression type
     1692        | typedef_expression                                                            // deprecated GCC, naming expression type
    17181693        | sue_declaration_specifier
    17191694        ;
     
    20942069                { yyy = true; $$ = AggregateDecl::Union; }
    20952070        | EXCEPTION                                                                                     // CFA
    2096                 { yyy = true; $$ = AggregateDecl::Exception; }
     2071                // { yyy = true; $$ = AggregateDecl::Exception; }
     2072                { SemanticError( yylloc, "exception aggregate is currently unimplemented." ); $$ = AggregateDecl::NoAggregate; }
    20972073        ;
    20982074
  • tests/.expect/array.txt

    r2fb35df r41b8ea4  
    11array.cfa: In function '_X4mainFi___1':
    2 array.cfa:54:9: note: #pragma message: Compiled
     2array.cfa:55:9: note: #pragma message: Compiled
  • tests/.expect/expression.txt

    r2fb35df r41b8ea4  
    11expression.cfa: In function '_X4mainFi___1':
    2 expression.cfa:88:9: note: #pragma message: Compiled
     2expression.cfa:89:9: note: #pragma message: Compiled
  • tests/array.cfa

    r2fb35df r41b8ea4  
    1 //                               -*- Mode: C -*- 
    2 // 
     1//                               -*- Mode: C -*-
     2//
    33// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
    44//
    55// The contents of this file are covered under the licence agreement in the
    66// file "LICENCE" distributed with Cforall.
    7 // 
     7//
    88// array.cfa -- test array declarations
    9 // 
     9//
    1010// Author           : Peter A. Buhr
    1111// Created On       : Tue Feb 19 21:18:06 2019
     
    1313// Last Modified On : Sun Sep 27 09:05:40 2020
    1414// Update Count     : 4
    15 // 
     15//
    1616
    1717int a1[0];
     
    5050
    5151int main() {
    52         #pragma message( "Compiled" )                                           // force non-empty .expect file
     52        #if !defined(NO_COMPILED_PRAGMA)
     53                #pragma message( "Compiled" )   // force non-empty .expect file
     54        #endif
    5355}
    5456
  • tests/concurrent/park/contention.cfa

    r2fb35df r41b8ea4  
    2121                if(blocked[idx]) {
    2222                        Thread * thrd = __atomic_exchange_n(&blocked[idx], 0p, __ATOMIC_SEQ_CST);
    23                         unpark( *thrd __cfaabi_dbg_ctx2 );
     23                        unpark( *thrd );
    2424                } else {
    2525                        Thread * thrd = __atomic_exchange_n(&blocked[idx], &this, __ATOMIC_SEQ_CST);
    26                         unpark( *thrd __cfaabi_dbg_ctx2 );
    27                         park( __cfaabi_dbg_ctx );
     26                        unpark( *thrd );
     27                        park();
    2828                }
    2929        }
     
    4141                        int idx = myrand() % blocked_size;
    4242                        Thread * thrd = __atomic_exchange_n(&blocked[idx], 0p, __ATOMIC_SEQ_CST);
    43                         unpark( *thrd __cfaabi_dbg_ctx2 );
     43                        unpark( *thrd );
    4444                        yield( myrand() % 20 );
    4545                }
  • tests/concurrent/park/force_preempt.cfa

    r2fb35df r41b8ea4  
    3030
    3131                // Unpark this thread, don't force a yield
    32                 unpark( this __cfaabi_dbg_ctx2 );
     32                unpark( this );
    3333                assert(mask == 0xCAFEBABA);
    3434
     
    4343                // Park this thread,
    4444                assert(mask == (id_hash ^ 0xCAFEBABA));
    45                 park( __cfaabi_dbg_ctx );
     45                park();
    4646                assert(mask == (id_hash ^ 0xCAFEBABA));
    4747
  • tests/concurrent/park/start_parked.cfa

    r2fb35df r41b8ea4  
    33thread Parker {};
    44void main( Parker & ) {
    5         park( __cfaabi_dbg_ctx );
     5        park();
    66}
    77
     
    99        for(1000) {
    1010                Parker parker;
    11                 unpark( parker __cfaabi_dbg_ctx2 );
     11                unpark( parker );
    1212        }
    1313        printf( "done\n" );                                                                     // non-empty .expect file
  • tests/expression.cfa

    r2fb35df r41b8ea4  
    8484        (S)@{2}`mary;
    8585
    86         #pragma message( "Compiled" )                   // force non-empty .expect file
     86        #if !defined(NO_COMPILED_PRAGMA)
     87                #pragma message( "Compiled" )   // force non-empty .expect file
     88        #endif
    8789} // main
Note: See TracChangeset for help on using the changeset viewer.