Changes in / [2fb35df:41b8ea4]
- Files:
-
- 15 added
- 4 deleted
- 47 edited
Legend:
- Unmodified
- Added
- Removed
-
benchmark/Makefile.am
r2fb35df r41b8ea4 113 113 creation_cfa_generator_DURATION = 1000000000 114 114 creation_upp_coroutine_DURATION = ${creation_cfa_coroutine_eager_DURATION} 115 creation_cfa_thread_DURATION = 10000000116 creation_upp_thread_DURATION = ${creation_cfa_thread_DURATION}117 115 creation_DURATION = 10000000 118 116 … … 148 146 149 147 cleancsv: 150 rm -f compile.csv basic.csv ctxswitch.csv mutex.csv sched uling.csv148 rm -f compile.csv basic.csv ctxswitch.csv mutex.csv schedint.csv 151 149 152 150 jenkins$(EXEEXT): cleancsv … … 159 157 +make mutex.csv 160 158 -+make mutex.diff.csv 161 +make sched uling.csv162 -+make sched uling.diff.csv159 +make schedint.csv 160 -+make schedint.diff.csv 163 161 @DOifskipcompile@ 164 162 cat compile.csv … … 169 167 cat mutex.csv 170 168 -cat mutex.diff.csv 171 cat sched uling.csv172 -cat sched uling.diff.csv169 cat schedint.csv 170 -cat schedint.diff.csv 173 171 174 172 compile.csv: … … 200 198 $(srcdir)/fixcsv.sh $@ 201 199 202 sched uling.csv:200 schedint.csv: 203 201 echo "building $@" 204 202 echo "schedint-1,schedint-2,schedext-1,schedext-2" > $@ … … 291 289 ctxswitch-python_coroutine$(EXEEXT): 292 290 $(BENCH_V_PY)echo "#!/bin/sh" > a.out 293 echo "python3 .7 $(srcdir)/ctxswitch/python_cor.py" >> a.out291 echo "python3 $(srcdir)/ctxswitch/python_cor.py \"$$""@\"" >> a.out 294 292 chmod a+x a.out 295 293 296 294 ctxswitch-nodejs_coroutine$(EXEEXT): 297 295 $(BENCH_V_NODEJS)echo "#!/bin/sh" > a.out 298 echo "nodejs $(srcdir)/ctxswitch/node_cor.js " >> a.out296 echo "nodejs $(srcdir)/ctxswitch/node_cor.js \"$$""@\"" >> a.out 299 297 chmod a+x a.out 300 298 301 299 ctxswitch-nodejs_await$(EXEEXT): 302 300 $(BENCH_V_NODEJS)echo "#!/bin/sh" > a.out 303 echo "nodejs $(srcdir)/ctxswitch/node_await.js " >> a.out301 echo "nodejs $(srcdir)/ctxswitch/node_await.js \"$$""@\"" >> a.out 304 302 chmod a+x a.out 305 303 … … 313 311 $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/ctxswitch/JavaThread.java 314 312 echo "#!/bin/sh" > a.out 315 echo "java JavaThread " >> a.out313 echo "java JavaThread \"$$""@\"" >> a.out 316 314 chmod a+x a.out 317 315 … … 355 353 $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/mutex/JavaThread.java 356 354 echo "#!/bin/sh" > a.out 357 echo "java JavaThread " >> a.out355 echo "java JavaThread \"$$""@\"" >> a.out 358 356 chmod a+x a.out 359 357 … … 387 385 $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/schedint/JavaThread.java 388 386 echo "#!/bin/sh" > a.out 389 echo "java JavaThread " >> a.out387 echo "java JavaThread \"$$""@\"" >> a.out 390 388 chmod a+x a.out 391 389 … … 454 452 creation-python_coroutine$(EXEEXT): 455 453 $(BENCH_V_PY)echo "#!/bin/sh" > a.out 456 echo "python3 .7 $(srcdir)/creation/python_cor.py" >> a.out454 echo "python3 $(srcdir)/creation/python_cor.py \"$$""@\"" >> a.out 457 455 chmod a+x a.out 458 456 459 457 creation-nodejs_coroutine$(EXEEXT): 460 458 $(BENCH_V_NODEJS)echo "#!/bin/sh" > a.out 461 echo "nodejs $(srcdir)/creation/node_cor.js " >> a.out459 echo "nodejs $(srcdir)/creation/node_cor.js \"$$""@\"" >> a.out 462 460 chmod a+x a.out 463 461 … … 471 469 $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/creation/JavaThread.java 472 470 echo "#!/bin/sh" > a.out 473 echo "java JavaThread " >> a.out471 echo "java JavaThread \"$$""@\"" >> a.out 474 472 chmod a+x a.out 475 473 … … 492 490 493 491 compile-array$(EXEEXT): 494 $(CFACOMPILE) - fsyntax-only -w $(testdir)/array.cfa492 $(CFACOMPILE) -DNO_COMPILED_PRAGMA -fsyntax-only -w $(testdir)/array.cfa 495 493 496 494 compile-attributes$(EXEEXT): 497 $(CFACOMPILE) - fsyntax-only -w $(testdir)/attributes.cfa495 $(CFACOMPILE) -DNO_COMPILED_PRAGMA -fsyntax-only -w $(testdir)/attributes.cfa 498 496 499 497 compile-empty$(EXEEXT): 500 $(CFACOMPILE) - fsyntax-only -w $(srcdir)/compile/empty.cfa498 $(CFACOMPILE) -DNO_COMPILED_PRAGMA -fsyntax-only -w $(srcdir)/compile/empty.cfa 501 499 502 500 compile-expression$(EXEEXT): 503 $(CFACOMPILE) - fsyntax-only -w $(testdir)/expression.cfa501 $(CFACOMPILE) -DNO_COMPILED_PRAGMA -fsyntax-only -w $(testdir)/expression.cfa 504 502 505 503 compile-io$(EXEEXT): 506 $(CFACOMPILE) - fsyntax-only -w $(testdir)/io1.cfa504 $(CFACOMPILE) -DNO_COMPILED_PRAGMA -fsyntax-only -w $(testdir)/io1.cfa 507 505 508 506 compile-monitor$(EXEEXT): 509 $(CFACOMPILE) - fsyntax-only -w $(testdir)/concurrent/monitor.cfa507 $(CFACOMPILE) -DNO_COMPILED_PRAGMA -fsyntax-only -w $(testdir)/concurrent/monitor.cfa 510 508 511 509 compile-operators$(EXEEXT): 512 $(CFACOMPILE) - fsyntax-only -w $(testdir)/operators.cfa510 $(CFACOMPILE) -DNO_COMPILED_PRAGMA -fsyntax-only -w $(testdir)/operators.cfa 513 511 514 512 compile-thread$(EXEEXT): 515 $(CFACOMPILE) - fsyntax-only -w $(testdir)/concurrent/thread.cfa513 $(CFACOMPILE) -DNO_COMPILED_PRAGMA -fsyntax-only -w $(testdir)/concurrent/thread.cfa 516 514 517 515 compile-typeof$(EXEEXT): 518 $(CFACOMPILE) - fsyntax-only -w $(testdir)/typeof.cfa516 $(CFACOMPILE) -DNO_COMPILED_PRAGMA -fsyntax-only -w $(testdir)/typeof.cfa 519 517 520 518 ## ========================================================================================================= -
benchmark/creation/JavaThread.java
r2fb35df r41b8ea4 47 47 } 48 48 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]); } 51 51 52 52 for (int i = Integer.parseInt("5"); --i >= 0 ; ) { -
benchmark/ctxswitch/JavaThread.java
r2fb35df r41b8ea4 40 40 } 41 41 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]); } 44 44 45 45 for (int i = Integer.parseInt("5"); --i >= 0 ; ) { -
benchmark/io/http/main.cfa
r2fb35df r41b8ea4 125 125 workers[i].flags = 0; 126 126 } 127 unpark( workers[i] __cfaabi_dbg_ctx2);127 unpark( workers[i] ); 128 128 } 129 129 printf("%d workers started on %d processors\n", options.clopts.nworkers, options.clopts.nprocs); -
benchmark/io/http/worker.cfa
r2fb35df r41b8ea4 22 22 23 23 void main( Worker & this ) { 24 park( __cfaabi_dbg_ctx);24 park(); 25 25 /* paranoid */ assert( this.pipe[0] != -1 ); 26 26 /* paranoid */ assert( this.pipe[1] != -1 ); -
benchmark/io/readv.cfa
r2fb35df r41b8ea4 54 54 55 55 void main( Reader & ) { 56 park( __cfaabi_dbg_ctx);56 park(); 57 57 /* paranoid */ assert( true == __atomic_load_n(&run, __ATOMIC_RELAXED) ); 58 58 … … 151 151 152 152 for(i; nthreads) { 153 unpark( threads[i] __cfaabi_dbg_ctx2);153 unpark( threads[i] ); 154 154 } 155 155 wait(duration, start, end, is_tty); -
benchmark/mutex/JavaThread.java
r2fb35df r41b8ea4 47 47 } 48 48 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]); } 51 51 52 52 for (int n = Integer.parseInt("5"); --n >= 0 ; ) { -
benchmark/readyQ/yield.cfa
r2fb35df r41b8ea4 32 32 33 33 void main( Yielder & this ) { 34 park( __cfaabi_dbg_ctx);34 park(); 35 35 /* paranoid */ assert( true == __atomic_load_n(&run, __ATOMIC_RELAXED) ); 36 36 … … 70 70 71 71 for(i; nthreads) { 72 unpark( threads[i] __cfaabi_dbg_ctx2);72 unpark( threads[i] ); 73 73 } 74 74 wait(duration, start, end, is_tty); -
benchmark/schedint/JavaThread.java
r2fb35df r41b8ea4 75 75 } 76 76 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]); } 79 79 80 80 for (int n = Integer.parseInt("5"); --n >= 0 ; ) { -
doc/LaTeXmacros/common.tex
r2fb35df r41b8ea4 11 11 %% Created On : Sat Apr 9 10:06:17 2016 12 12 %% Last Modified By : Peter A. Buhr 13 %% Last Modified On : Wed Sep 23 21:21:55202014 %% Update Count : 4 5413 %% Last Modified On : Mon Oct 5 09:34:46 2020 14 %% Update Count : 464 15 15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 16 … … 251 251 \makeatother 252 252 253 \newcommand{\CFA Defaults}{%253 \newcommand{\CFAStyle}{% 254 254 \lstset{ 255 language=CFA,256 255 columns=fullflexible, 257 256 basicstyle=\linespread{0.9}\sf, % reduce line spacing and use sanserif font … … 272 271 {<-}{$\leftarrow$}2 {=>}{$\Rightarrow$}2 {->}{\makebox[1ex][c]{\raisebox{0.4ex}{\rule{0.8ex}{0.075ex}}}\kern-0.2ex\textgreater}2, 273 272 }% lstset 274 }% CFA Defaults275 276 \ifdefined\CFALatin% 277 \lstnewenvironment{cfa}[1][]{ \CFADefaults273 }% CFAStyle 274 275 \ifdefined\CFALatin% extra Latin-1 escape characters 276 \lstnewenvironment{cfa}[1][]{ 278 277 \lstset{ 279 278 language=CFA, … … 289 288 % inline code ©...© (copyright symbol) emacs: C-q M-) 290 289 \lstMakeShortInline© % single-character for \lstinline 291 \else% extra Latin-1 escape characters 290 \else% regular ASCI characters 291 \lstnewenvironment{cfa}[1][]{ 292 292 \lstset{ 293 293 language=CFA, 294 294 escapechar=\$, % 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) 295 moredelim=**[is][\color{red}]{@}{@}, % red highlighting @...@ 302 296 }% lstset 303 297 \lstset{#1} -
doc/bibliography/pl.bib
r2fb35df r41b8ea4 1005 1005 key = {Cforall Benchmarks}, 1006 1006 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}}, 1008 1008 } 1009 1009 … … 1973 1973 title = {Cooperating Sequential Processes}, 1974 1974 institution = {Technological University}, 1975 address = {Eindhoven, Neth erlands},1975 address = {Eindhoven, Neth.}, 1976 1976 year = 1965, 1977 1977 note = {Reprinted in \cite{Genuys68} pp. 43--112.} -
doc/papers/concurrency/Paper.tex
r2fb35df r41b8ea4 224 224 {} 225 225 \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}} 227 227 {} 228 228 \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}} 230 230 {} 231 231 \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}} 233 233 {} 234 234 \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}} 236 236 {} 237 237 \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}} 239 239 {} 240 240 … … 284 284 285 285 \begin{document} 286 \linenumbers % comment out to turn off line numbering286 %\linenumbers % comment out to turn off line numbering 287 287 288 288 \maketitle … … 2896 2896 \label{s:RuntimeStructureCluster} 2897 2897 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 .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~\cite{Buhr90a}. 2899 2899 The term \newterm{virtual processor} is introduced as a synonym for kernel thread to disambiguate between user and kernel thread. 2900 2900 From the language perspective, a virtual processor is an actual processor (core). … … 2992 2992 \end{cfa} 2993 2993 where 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. 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; 2995 each @N@ appears after the experiment name in the following tables. 2995 2996 The total time is divided by @N@ to obtain the average time for a benchmark. 2996 2997 Each benchmark experiment is run 13 times and the average appears in the table. 2998 For languages with a runtime JIT (Java, Node.js, Python), a single half-hour long experiment is run to check stability; 2999 all 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. 2997 3000 All 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 benchmark2999 % cp -p benchmark.tar /u/cforall/public_html/doc/concurrent_benchmark.tar3000 3001 3001 3002 \paragraph{Creation} … … 3006 3007 3007 3008 \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 {}; 3011 3011 void ?{}( MyCoroutine & this ) { 3012 3012 #ifdef EAGER … … 3016 3016 void main( MyCoroutine & ) {} 3017 3017 int main() { 3018 BENCH( for ( N ) { @MyCoroutine c;@} )3018 BENCH( for ( N ) { `MyCoroutine c;` } ) 3019 3019 sout | result; 3020 3020 } … … 3030 3030 3031 3031 \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 3037 \uC coroutine & 155.6 & 155.7 & 1.7 \\3038 \uC thread 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.43032 \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 \\ 3039 Python generator (10M) & 123.2 & 124.3 & 4.1 \\ 3040 Node.js generator (10M) & 33.4 & 33.5 & 0.3 \\ 3041 Goroutine thread (10M) & 751.0 & 750.5 & 3.1 \\ 3042 Rust tokio thread (10M) & 1860.0 & 1881.1 & 37.6 \\ 3043 Rust thread (250K) & 53801.0 & 53896.8 & 274.9 \\ 3044 Java thread (250K) & 119256.0 & 119679.2 & 2244.0 \\ 3045 % Java thread (1 000 000) & 123100.0 & 123052.5 & 751.6 \\ 3046 Pthreads thread (250K) & 31465.5 & 31419.5 & 140.4 3047 3047 \end{tabular} 3048 3048 \end{multicols} … … 3053 3053 Internal scheduling is measured using a cycle of two threads signalling and waiting. 3054 3054 Figure~\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. 3055 Note, the \CFA incremental cost for bulk acquire is a fixed cost for small numbers of mutex objects. 3056 User-level threading has one kernel thread, eliminating contention between the threads (direct handoff of the kernel thread). 3057 Kernel-level threading has two kernel threads allowing some contention. 3057 3058 3058 3059 \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] 3061 3062 volatile 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*/; 3065 void call( M & `mutex p1/*, p2, p3, p4*/` ) { 3066 `signal( c );` 3067 } 3068 void wait( M & `mutex p1/*, p2, p3, p4*/` ) { 3068 3069 go = 1; // continue other thread 3069 for ( N ) { @wait( c );@} );3070 for ( N ) { `wait( c );` } ); 3070 3071 } 3071 3072 thread T {}; … … 3092 3093 3093 3094 \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 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 \\ 3100 Rust cond. variable (1M) & 7514.0 & 7437.4 & 397.2 \\ 3101 Java @notify@ monitor (1M) & 8717.0 & 8774.1 & 471.8 \\ 3102 % Java @notify@ monitor (100 000 000) & 8634.0 & 8683.5 & 330.5 \\ 3103 Pthreads cond. variable (1M) & 5553.7 & 5576.1 & 345.6 3103 3104 \end{tabular} 3104 3105 \end{multicols} … … 3109 3110 External scheduling is measured using a cycle of two threads calling and accepting the call using the @waitfor@ statement. 3110 3111 Figure~\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 largelya fixed cost for small numbers of mutex objects.3112 Note, the \CFA incremental cost for bulk acquire is a fixed cost for small numbers of mutex objects. 3112 3113 3113 3114 \begin{multicols}{2} 3114 \ lstset{language=CFA,moredelim=**[is][\color{red}]{@}{@},deletedelim=**[is][]{`}{`}}3115 \setlength{\tabcolsep}{5pt} 3115 3116 \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*/; 3119 void call( M & `mutex p1/*, p2, p3, p4*/` ) {} 3120 void wait( M & `mutex p1/*, p2, p3, p4*/` ) { 3121 for ( N ) { `waitfor( call : p1/*, p2, p3, p4*/ );` } 3121 3122 } 3122 3123 thread T {}; … … 3135 3136 \columnbreak 3136 3137 3137 \vspace*{-1 6pt}3138 \vspace*{-18pt} 3138 3139 \captionof{table}{External-scheduling comparison (nanoseconds)} 3139 3140 \label{t:schedext} 3140 3141 \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.23142 \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 \\ 3147 Go \lstinline[language=Golang]|select| channel (10M) & 365.0 & 365.5 & 1.2 3147 3148 \end{tabular} 3148 3149 \end{multicols} … … 3157 3158 3158 3159 \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*/; 3163 call( M & `mutex p1/*, p2, p3, p4*/` ) {} 3163 3164 int main() { 3164 3165 BENCH( for( N ) call( m1/*, m2, m3, m4*/ ); ) … … 3175 3176 \label{t:mutex} 3176 3177 \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 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 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 3178 \multicolumn{1}{@{}r}{N\hspace*{10pt}} & \multicolumn{1}{c}{Median} &\multicolumn{1}{c}{Average} & \multicolumn{1}{c@{}}{Std Dev} \\ 3179 test-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 \\ 3184 Goroutine mutex lock (50M) & 34.0 & 34.0 & 0.0 \\ 3185 Rust mutex lock (50M) & 33.0 & 33.2 & 0.8 \\ 3186 Java synchronized method (50M) & 31.0 & 30.9 & 0.5 \\ 3187 % Java synchronized method (10 000 000 000) & 31.0 & 30.2 & 0.9 \\ 3188 Pthreads mutex Lock (50M) & 31.0 & 31.1 & 0.4 3188 3189 \end{tabular} 3189 3190 \end{multicols} … … 3214 3215 3215 3216 \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 {}; 3219 void main( C & ) { for () { `suspend;` } } 3220 3220 int main() { // coroutine test 3221 3221 C c; 3222 BENCH( for ( N ) { @resume( c );@} )3222 BENCH( for ( N ) { `resume( c );` } ) 3223 3223 sout | result; 3224 3224 } 3225 3225 int main() { // thread test 3226 BENCH( for ( N ) { @yield();@} )3226 BENCH( for ( N ) { `yield();` } ) 3227 3227 sout | result; 3228 3228 } … … 3237 3237 \label{t:ctx-switch} 3238 3238 \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.93239 \multicolumn{1}{@{}r}{N\hspace*{10pt}} & \multicolumn{1}{c}{Median} &\multicolumn{1}{c}{Average} & \multicolumn{1}{c@{}}{Std Dev} \\ 3240 C 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 \\ 3246 Python generator (100M) & 40.9 & 41.3 & 1.5 \\ 3247 Node.js await (5M) & 1852.2 & 1854.7 & 16.4 \\ 3248 Node.js generator (100M) & 33.3 & 33.4 & 0.3 \\ 3249 Goroutine thread (100M) & 143.0 & 143.3 & 1.1 \\ 3250 Rust async await (100M) & 32.0 & 32.0 & 0.0 \\ 3251 Rust tokio thread (100M) & 143.0 & 143.0 & 1.7 \\ 3252 Rust thread (25M) & 332.0 & 331.4 & 2.4 \\ 3253 Java 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 \\ 3256 Pthreads thread (25M) & 334.3 & 335.2 & 3.9 3257 3257 \end{tabular} 3258 3258 \end{multicols} … … 3263 3263 Languages using 1:1 threading based on pthreads can at best meet or exceed, due to language overhead, the pthread results. 3264 3264 Note, 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. 3265 Languages with M:N threading have better performance than 1:1 because there is no operating-system interactions (context-switching or locking). 3266 As well, for locking experiments, M:N threading has less contention if only one kernel thread is used. 3266 3267 Languages with stackful coroutines have higher cost than stackless coroutines because of stack allocation and context switching; 3267 3268 however, stackful \uC and \CFA coroutines have approximately the same performance as stackless Python and Node.js generators. 3268 3269 The \CFA stackless generator is approximately 25 times faster for suspend/resume and 200 times faster for creation than stackless Python and Node.js generators. 3270 The Node.js context-switch is costly when asynchronous await must enter the event engine because a promise is not fulfilled. 3271 Finally, the benchmark results correlate across programming languages with and without JIT, indicating the JIT has completed any runtime optimizations. 3269 3272 3270 3273 … … 3324 3327 3325 3328 The 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 fromWaterloo-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.3329 This 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. 3327 3330 3328 3331 {% -
doc/papers/concurrency/annex/local.bib
r2fb35df r41b8ea4 59 59 @manual{Cpp-Transactions, 60 60 keywords = {C++, Transactional Memory}, 61 title = {Tech nical Specificationfor C++ Extensions for Transactional Memory},61 title = {Tech. Spec. for C++ Extensions for Transactional Memory}, 62 62 organization= {International Standard ISO/IEC TS 19841:2015 }, 63 63 publisher = {American National Standards Institute}, -
doc/papers/concurrency/mail2
r2fb35df r41b8ea4 959 959 Software: Practice and Experience Editorial Office 960 960 961 962 963 Date: Wed, 2 Sep 2020 20:55:34 +0000 964 From: Richard Jones <onbehalfof@manuscriptcentral.com> 965 Reply-To: R.E.Jones@kent.ac.uk 966 To: tdelisle@uwaterloo.ca, pabuhr@uwaterloo.ca 967 Subject: Software: Practice and Experience - Decision on Manuscript ID 968 SPE-19-0219.R2 969 970 02-Sep-2020 971 972 Dear Dr Buhr, 973 974 Many 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 976 Both 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 978 1) 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 979 Virtual 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 981 2) Kalibera, Tomas and Jones, Richard. Rigorous Benchmarking in Reasonable Time. ISMM 2013. https://doi.org/10.1145/2555670.2464160 982 Experimental 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 984 You 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 986 You 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 988 When 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 990 If 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 992 Once again, thank you for submitting your manuscript to Software: Practice and Experience. I look forward to receiving your revision. 993 994 Sincerely, 995 Richard 996 997 Prof. Richard Jones 998 Editor, Software: Practice and Experience 999 R.E.Jones@kent.ac.uk 1000 1001 Referee(s)' Comments to Author: 1002 1003 Reviewing: 1 1004 1005 Comments to the Author 1006 Overall, I felt that this draft was an improvement on previous drafts and I don't have further changes to request. 1007 1008 I 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 1011 Reviewing: 2 1012 1013 Comments to the Author 1014 First: 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 1016 At 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 1018 Finally, 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 1020 minor points 1021 * don't start sentences with "However" 1022 * most downloaded isn't an "Award" 1023 1024 1025 1026 Date: Thu, 1 Oct 2020 05:34:29 +0000 1027 From: Richard Jones <onbehalfof@manuscriptcentral.com> 1028 Reply-To: R.E.Jones@kent.ac.uk 1029 To: pabuhr@uwaterloo.ca 1030 Subject: Revision reminder - SPE-19-0219.R2 1031 1032 01-Oct-2020 1033 1034 Dear Dr Buhr 1035 1036 SPE-19-0219.R2 1037 1038 This 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 1040 If 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 1042 I look forward to receiving your revision. 1043 1044 Sincerely, 1045 1046 Prof. Richard Jones 1047 Editor, Software: Practice and Experience 1048 1049 https://mc.manuscriptcentral.com/spe 1050 1051 1052 1053 Date: Tue, 6 Oct 2020 15:29:41 +0000 1054 From: Mayank Roy Chowdhury <onbehalfof@manuscriptcentral.com> 1055 Reply-To: speoffice@wiley.com 1056 To: tdelisle@uwaterloo.ca, pabuhr@uwaterloo.ca 1057 Subject: SPE-19-0219.R3 successfully submitted 1058 1059 06-Oct-2020 1060 1061 Dear Dr Buhr, 1062 1063 Your 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 1065 Your manuscript number is SPE-19-0219.R3. Please mention this number in all future correspondence regarding this submission. 1066 1067 You 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 1070 Thank you for submitting your manuscript to Software: Practice and Experience. 1071 1072 Sincerely, 1073 1074 Software: Practice and Experience Editorial Office 1075 -
doc/refrat/refrat.tex
r2fb35df r41b8ea4 11 11 %% Created On : Wed Apr 6 14:52:25 2016 12 12 %% Last Modified By : Peter A. Buhr 13 %% Last Modified On : Thu Sep 24 16:34:51202014 %% Update Count : 1 0913 %% Last Modified On : Mon Oct 5 09:02:53 2020 14 %% Update Count : 110 15 15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 16 … … 63 63 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 64 64 65 \CFA Defaults% use default CFA format-style65 \CFAStyle % use default CFA format-style 66 66 \lstnewenvironment{C++}[1][] % use C++ style 67 67 {\lstset{language=C++,moredelim=**[is][\protect\color{red}]{®}{®},#1}} -
doc/theses/fangren_yu_COOP_S20/Makefile
r2fb35df r41b8ea4 46 46 # File Dependencies # 47 47 48 49 48 ${DOCUMENT} : ${BASE}.ps 50 49 ps2pdf $< -
doc/theses/fangren_yu_COOP_S20/Report.tex
r2fb35df r41b8ea4 1 \documentclass[twoside,1 2pt]{article}1 \documentclass[twoside,11pt]{article} 2 2 3 3 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% … … 11 11 \usepackage[labelformat=simple,aboveskip=0pt,farskip=0pt]{subfig} 12 12 \renewcommand{\thesubfigure}{\alph{subfigure})} 13 \usepackage[flushmargin]{footmisc} % support label/reference in footnote 13 14 \usepackage{latexsym} % \Box glyph 14 15 \usepackage{mathptmx} % better math font with "times" 15 \usepackage {appendix}16 \usepackage[toc]{appendix} % article does not have appendix 16 17 \usepackage[usenames]{color} 17 18 \input{common} % common CFA document macros … … 39 40 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 40 41 41 \CFA Defaults42 \CFAStyle % CFA code-style for all languages 42 43 \lstset{ 43 language=C++, 44 language=C++,moredelim=**[is][\color{red}]{@}{@} % make C++ the default language 44 45 }% lstset 45 46 \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}}{} 47 48 48 49 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% … … 87 88 \section{Overview} 88 89 89 cfa-ccis 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. 90 91 \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. 91 92 … … 381 382 \subsubsection{Source: \lstinline{AST/SymbolTable.hpp}} 382 383 383 384 \subsubsection{Source: \lstinline{SymTab/Indexer.h}}385 386 384 Function 387 385 \begin{C++} … … 612 610 613 611 614 \ begin{appendices}[toc,titletoc]612 \appendix 615 613 \section{Appendix} 616 617 614 618 615 \subsection{Kinds of Type Parameters} 619 616 \label{s:KindsTypeParameters} 620 617 621 A type parameter in a @forall@ clause has three possiblekinds:618 A type parameter in a @forall@ clause has 3 kinds: 622 619 \begin{enumerate}[listparindent=0pt] 623 620 \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 623 A 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 627 A 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} 640 638 641 639 \item 642 640 @ttype@: tuple (variadic) type. 643 641 644 @ttype@ parameter may only appear as type of the last parameter in a function, andit provides a type-safe way to implement variadic functions.642 Restricted to the type for the last parameter in a function, it provides a type-safe way to implement variadic functions. 645 643 Note however, that it has certain restrictions, as described in the implementation section below. 646 644 \end{enumerate} … … 673 671 \begin{enumerate} 674 672 \item 675 All types are function declarations are candidates of implicit parameters.673 All types, variables, and functions are candidates of implicit parameters 676 674 \item 677 675 The parameter (assertion) name must match the actual declarations. 678 \item679 Currently, assertions are all functions.680 Note that since \CFA has variable overloading, implicit value parameters might also be supported in the future.681 676 \end{enumerate} 682 677 … … 732 727 In 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. 733 728 The \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}735 729 736 730 \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" 2 2 3 3 #include <cassert> … … 5 5 #include <algorithm> 6 6 #include <atomic> 7 #include <iostream> 7 8 #include <memory> 8 9 #include <vector> 9 10 10 11 #include <getopt.h> 12 using thrdlib::thread_t; 13 14 15 extern __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" ))); 11 36 12 37 //-------------------- … … 36 61 assert( expected == reset ); 37 62 if( std::atomic_compare_exchange_strong( &state, &expected, self) ) { 38 thrdlib _park( self );63 thrdlib::park( self ); 39 64 ret = true; 40 65 goto END; … … 54 79 if( got == reset ) return false; 55 80 56 thrdlib _unpark( got );81 thrdlib::unpark( got ); 57 82 return true; 58 83 } … … 109 134 the_stats_thread = self; 110 135 fence(); 111 thrdlib _park( self );136 thrdlib::park( self ); 112 137 113 138 std::vector<bool> seen; … … 115 140 116 141 while(last_produced < nproduce) { 117 thrdlib _yield();142 thrdlib::yield(); 118 143 thrd_stats.stats.ran++; 119 144 if( last_produced > 0 ) seen.at(last_produced - 1) = true; … … 147 172 148 173 void Renderer( thread_t self ) { 149 thrdlib _unpark( the_stats_thread );174 thrdlib::unpark( the_stats_thread ); 150 175 for(unsigned i = 0; i < nproduce; i++) { 151 176 auto & frame = frames[i % nframes]; … … 178 203 fsize = 1000; 179 204 nproduce = 60; 205 206 const char * framework; 180 207 181 208 for(;;) { … … 196 223 case -1: 197 224 /* 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]; 198 231 goto run; 199 232 case 'b': … … 228 261 std::cerr << opt << std::endl; 229 262 usage: 230 std::cerr << "Usage: " << argv[0] << " [options] " << std::endl;263 std::cerr << "Usage: " << argv[0] << " [options] framework" << std::endl; 231 264 std::cerr << std::endl; 232 265 std::cerr << " -b, --buff=COUNT Number of frames to buffer" << std::endl; … … 237 270 } 238 271 run: 272 assert( framework ); 239 273 240 274 frames.reset(new Frame[nframes]); … … 246 280 std::cout << "(Buffering " << nframes << ")" << std::endl; 247 281 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 ); 251 285 std::cout << "Created Stats Thread" << std::endl; 252 while( the_stats_thread == nullptr ) thrdlib_yield(); 286 while( the_stats_thread == nullptr ) thrdlib::yield(); 287 253 288 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 ); 257 291 258 292 std::cout << "Running" << std::endl; 259 293 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(); 263 299 264 300 std::cout << "----------" << std::endl; -
doc/user/Makefile
r2fb35df r41b8ea4 55 55 56 56 ${DOCUMENT} : ${BASE}.ps 57 ps2pdf $<57 ps2pdf -dPDFSETTINGS=/prepress $< 58 58 59 59 ${BASE}.ps : ${BASE}.dvi -
doc/user/user.tex
r2fb35df r41b8ea4 11 11 %% Created On : Wed Apr 6 14:53:29 2016 12 12 %% Last Modified By : Peter A. Buhr 13 %% Last Modified On : Thu Sep 24 16:34:52202014 %% Update Count : 399 713 %% Last Modified On : Mon Oct 5 08:57:29 2020 14 %% Update Count : 3998 15 15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 16 … … 66 66 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 67 67 68 \CFA Defaults% use default CFA format-style68 \CFAStyle % use default CFA format-style 69 69 \lstnewenvironment{C++}[1][] % use C++ style 70 70 {\lstset{language=C++,moredelim=**[is][\protect\color{red}]{®}{®},#1}} -
libcfa/src/bits/containers.hfa
r2fb35df r41b8ea4 157 157 tail = &get_next( *val ); 158 158 *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; 159 170 } 160 171 -
libcfa/src/bits/locks.hfa
r2fb35df r41b8ea4 164 164 165 165 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 ); 168 168 static inline struct $thread * active_thread (); 169 169 … … 191 191 /* paranoid */ verify( expected == 0p ); 192 192 if(__atomic_compare_exchange_n(&this.ptr, &expected, active_thread(), false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) { 193 park( __cfaabi_dbg_ctx);193 park(); 194 194 return true; 195 195 } … … 210 210 else { 211 211 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 ); 213 213 return true; 214 214 } … … 244 244 /* paranoid */ verify( expected == 0p ); 245 245 if(__atomic_compare_exchange_n(&this.ptr, &expected, active_thread(), false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) { 246 park( __cfaabi_dbg_ctx);246 park(); 247 247 /* paranoid */ verify( this.ptr == 1p ); 248 248 return true; … … 256 256 struct $thread * got = __atomic_exchange_n( &this.ptr, 1p, __ATOMIC_SEQ_CST); 257 257 if( got == 0p ) return false; 258 unpark( got __cfaabi_dbg_ctx2);258 unpark( got ); 259 259 return true; 260 260 } -
libcfa/src/concurrency/CtxSwitch-i386.S
r2fb35df r41b8ea4 10 10 // Created On : Tue Dec 6 12:27:26 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Aug 16 08:46:22202013 // Update Count : 412 // Last Modified On : Sun Sep 6 18:23:37 2020 13 // Update Count : 5 14 14 // 15 15 … … 35 35 36 36 // 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. 38 38 39 39 movl 4(%esp),%eax … … 50 50 movl %ebp,FP_OFFSET(%eax) 51 51 52 // Copy the "to" context argument from the stack to register eax 53 // Having pushed three words (= 12 bytes) on the stack, the54 // 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). 55 55 56 56 movl 20(%esp),%eax -
libcfa/src/concurrency/alarm.cfa
r2fb35df r41b8ea4 130 130 131 131 register_self( &node ); 132 park( __cfaabi_dbg_ctx);132 park(); 133 133 134 134 /* paranoid */ verify( !node.set ); -
libcfa/src/concurrency/clib/cfathread.cfa
r2fb35df r41b8ea4 34 34 extern "C" { 35 35 //-------------------- 36 // Basic thread manage nemt36 // Basic thread management 37 37 CRunner * cfathread_create( void (*main)( CRunner * ) ) { 38 38 return new( main ); … … 44 44 45 45 void cfathread_park( void ) { 46 park( __cfaabi_dbg_ctx);46 park(); 47 47 } 48 48 49 49 void cfathread_unpark( CRunner * thrd ) { 50 unpark( *thrd __cfaabi_dbg_ctx2);50 unpark( *thrd ); 51 51 } 52 52 -
libcfa/src/concurrency/clib/cfathread.h
r2fb35df r41b8ea4 17 17 #include "invoke.h" 18 18 19 #if defined(__cforall) || defined(__cplu plus)19 #if defined(__cforall) || defined(__cplusplus) 20 20 extern "C" { 21 21 #endif … … 39 39 40 40 41 #if defined(__cforall) || defined(__cplu plus)41 #if defined(__cforall) || defined(__cplusplus) 42 42 } 43 43 #endif -
libcfa/src/concurrency/invoke.h
r2fb35df r41b8ea4 93 93 94 94 }; 95 // Wrapper for gdb 96 struct cfathread_coroutine_t { struct $coroutine debug; }; 95 97 96 98 static inline struct __stack_t * __get_stack( struct $coroutine * cor ) { … … 129 131 struct __condition_node_t * dtor_node; 130 132 }; 133 // Wrapper for gdb 134 struct cfathread_monitor_t { struct $monitor debug; }; 131 135 132 136 struct __monitor_group_t { … … 186 190 } node; 187 191 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; 198 194 #endif 199 195 }; 196 // Wrapper for gdb 197 struct cfathread_thread_t { struct $thread debug; }; 200 198 201 199 #ifdef __CFA_DEBUG__ -
libcfa/src/concurrency/io.cfa
r2fb35df r41b8ea4 69 69 if( block ) { 70 70 enable_interrupts( __cfaabi_dbg_ctx ); 71 park( __cfaabi_dbg_ctx);71 park(); 72 72 disable_interrupts(); 73 73 } … … 97 97 98 98 if(nextt) { 99 unpark( nextt __cfaabi_dbg_ctx2);99 unpark( nextt ); 100 100 enable_interrupts( __cfaabi_dbg_ctx ); 101 101 return true; -
libcfa/src/concurrency/io/setup.cfa
r2fb35df r41b8ea4 247 247 thrd.link.next = 0p; 248 248 thrd.link.prev = 0p; 249 __cfaabi_dbg_debug_do( thrd.unpark_stale = true );250 249 251 250 // Fixup the thread state … … 267 266 268 267 // unpark the fast io_poller 269 unpark( &thrd __cfaabi_dbg_ctx2);268 unpark( &thrd ); 270 269 } 271 270 else { … … 276 275 } 277 276 } else { 278 unpark( &thrd __cfaabi_dbg_ctx2);277 unpark( &thrd ); 279 278 } 280 279 -
libcfa/src/concurrency/kernel.cfa
r2fb35df r41b8ea4 246 246 thrd_dst->state = Active; 247 247 248 __cfaabi_dbg_debug_do(249 thrd_dst->park_stale = true;250 thrd_dst->unpark_stale = true;251 )252 248 // Update global state 253 249 kernelTLS.this_thread = thrd_dst; … … 255 251 /* paranoid */ verify( ! kernelTLS.preemption_state.enabled ); 256 252 /* paranoid */ verify( kernelTLS.this_thread == thrd_dst ); 253 /* paranoid */ verify( thrd_dst->context.SP ); 257 254 /* 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 258 255 /* 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 259 258 260 259 261 260 // set context switch to the thread that the processor is executing 262 verify( thrd_dst->context.SP );263 261 __cfactx_switch( &proc_cor->context, &thrd_dst->context ); 264 262 // when __cfactx_switch returns we are back in the processor coroutine 265 263 264 /* paranoid */ verify( 0x0D15EA5E0D15EA5E == thrd_dst->canary ); 266 265 /* 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 ); 267 266 /* 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 ); 268 268 /* paranoid */ verify( kernelTLS.this_thread == thrd_dst ); 269 269 /* paranoid */ verify( ! kernelTLS.preemption_state.enabled ); … … 288 288 // The thread has halted, it should never be scheduled/run again 289 289 // We may need to wake someone up here since 290 unpark( this->destroyer __cfaabi_dbg_ctx2);290 unpark( this->destroyer ); 291 291 this->destroyer = 0p; 292 292 break RUNNING; … … 298 298 // set state of processor coroutine to active and the thread to inactive 299 299 int old_ticket = __atomic_fetch_sub(&thrd_dst->ticket, 1, __ATOMIC_SEQ_CST); 300 __cfaabi_dbg_debug_do( thrd_dst->park_result = old_ticket; )301 300 switch(old_ticket) { 302 301 case 1: … … 335 334 __x87_store; 336 335 #endif 337 verify( proc_cor->context.SP ); 336 /* paranoid */ verify( proc_cor->context.SP ); 337 /* paranoid */ verify( 0x0D15EA5E0D15EA5E == thrd_src->canary ); 338 338 __cfactx_switch( &thrd_src->context, &proc_cor->context ); 339 /* paranoid */ verify( 0x0D15EA5E0D15EA5E == thrd_src->canary ); 339 340 #if defined( __i386 ) || defined( __x86_64 ) 340 341 __x87_load; … … 368 369 /* paranoid */ #endif 369 370 /* paranoid */ verifyf( thrd->link.next == 0p, "Expected null got %p", thrd->link.next ); 371 /* paranoid */ verify( 0x0D15EA5E0D15EA5E == thrd->canary ); 372 370 373 371 374 if (thrd->preempted == __NO_PREEMPTION) thrd->state = Ready; … … 404 407 405 408 // 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 409 void __unpark( struct __processor_id_t * id, $thread * thrd ) { 410 410 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; )412 411 switch(old_ticket) { 413 412 case 1: … … 427 426 } 428 427 429 void unpark( $thread * thrd __cfaabi_dbg_ctx_param2) {428 void unpark( $thread * thrd ) { 430 429 if( !thrd ) return; 431 430 432 431 disable_interrupts(); 433 __unpark( (__processor_id_t*)kernelTLS.this_processor, thrd __cfaabi_dbg_ctx_fwd2);432 __unpark( (__processor_id_t*)kernelTLS.this_processor, thrd ); 434 433 enable_interrupts( __cfaabi_dbg_ctx ); 435 434 } 436 435 437 void park( __cfaabi_dbg_ctx_param) {436 void park( void ) { 438 437 /* paranoid */ verify( kernelTLS.preemption_state.enabled ); 439 438 disable_interrupts(); 440 439 /* paranoid */ verify( ! kernelTLS.preemption_state.enabled ); 441 440 /* paranoid */ verify( kernelTLS.this_thread->preempted == __NO_PREEMPTION ); 442 443 // record activity444 __cfaabi_dbg_record_thrd( *kernelTLS.this_thread, true, caller );445 441 446 442 returnToKernel(); … … 650 646 // atomically release spin lock and block 651 647 unlock( lock ); 652 park( __cfaabi_dbg_ctx);648 park(); 653 649 return true; 654 650 } … … 671 667 672 668 // make new owner 673 unpark( thrd __cfaabi_dbg_ctx2);669 unpark( thrd ); 674 670 675 671 return thrd != 0p; … … 682 678 count += diff; 683 679 for(release) { 684 unpark( pop_head( waiting ) __cfaabi_dbg_ctx2);680 unpark( pop_head( waiting ) ); 685 681 } 686 682 … … 698 694 this.prev_thrd = kernelTLS.this_thread; 699 695 } 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 }711 696 } 712 697 ) -
libcfa/src/concurrency/kernel/fwd.hfa
r2fb35df r41b8ea4 118 118 119 119 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 ); 122 122 static inline struct $thread * active_thread () { return TL_GET( this_thread ); } 123 123 -
libcfa/src/concurrency/kernel/startup.cfa
r2fb35df r41b8ea4 451 451 link.next = 0p; 452 452 link.prev = 0p; 453 #if defined( __CFA_WITH_VERIFY__ ) 454 canary = 0x0D15EA5E0D15EA5E; 455 #endif 453 456 454 457 node.next = 0p; -
libcfa/src/concurrency/kernel_private.hfa
r2fb35df r41b8ea4 64 64 65 65 // KERNEL ONLY unpark with out disabling interrupts 66 void __unpark( struct __processor_id_t *, $thread * thrd __cfaabi_dbg_ctx_param2);66 void __unpark( struct __processor_id_t *, $thread * thrd ); 67 67 68 68 static inline bool __post(single_sem & this, struct __processor_id_t * id) { … … 77 77 else { 78 78 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 ); 80 80 return true; 81 81 } -
libcfa/src/concurrency/monitor.cfa
r2fb35df r41b8ea4 122 122 123 123 unlock( this->lock ); 124 park( __cfaabi_dbg_ctx);124 park(); 125 125 126 126 __cfaabi_dbg_print_safe( "Kernel : %10p Entered mon %p\n", thrd, this); … … 201 201 // Release the next thread 202 202 /* 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 ); 204 204 205 205 // Park current thread waiting 206 park( __cfaabi_dbg_ctx);206 park(); 207 207 208 208 // Some one was waiting for us, enter … … 222 222 223 223 // Park current thread waiting 224 park( __cfaabi_dbg_ctx);224 park(); 225 225 226 226 /* 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 ); … … 264 264 //We need to wake-up the thread 265 265 /* 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 ); 267 267 } 268 268 … … 493 493 // Wake the threads 494 494 for(int i = 0; i < thread_count; i++) { 495 unpark( threads[i] __cfaabi_dbg_ctx2);495 unpark( threads[i] ); 496 496 } 497 497 498 498 // Everything is ready to go to sleep 499 park( __cfaabi_dbg_ctx);499 park(); 500 500 501 501 // We are back, restore the owners and recursions … … 575 575 576 576 // unpark the thread we signalled 577 unpark( signallee __cfaabi_dbg_ctx2);577 unpark( signallee ); 578 578 579 579 //Everything is ready to go to sleep 580 park( __cfaabi_dbg_ctx);580 park(); 581 581 582 582 … … 679 679 680 680 // unpark the thread we signalled 681 unpark( next __cfaabi_dbg_ctx2);681 unpark( next ); 682 682 683 683 //Everything is ready to go to sleep 684 park( __cfaabi_dbg_ctx);684 park(); 685 685 686 686 // We are back, restore the owners and recursions … … 724 724 725 725 //Everything is ready to go to sleep 726 park( __cfaabi_dbg_ctx);726 park(); 727 727 728 728 -
libcfa/src/concurrency/mutex.cfa
r2fb35df r41b8ea4 42 42 append( blocked_threads, kernelTLS.this_thread ); 43 43 unlock( lock ); 44 park( __cfaabi_dbg_ctx);44 park(); 45 45 } 46 46 else { … … 65 65 this.is_locked = (this.blocked_threads != 0); 66 66 unpark( 67 pop_head( this.blocked_threads ) __cfaabi_dbg_ctx267 pop_head( this.blocked_threads ) 68 68 ); 69 69 unlock( this.lock ); … … 97 97 append( blocked_threads, kernelTLS.this_thread ); 98 98 unlock( lock ); 99 park( __cfaabi_dbg_ctx);99 park(); 100 100 } 101 101 } … … 124 124 owner = thrd; 125 125 recursion_count = (thrd ? 1 : 0); 126 unpark( thrd __cfaabi_dbg_ctx2);126 unpark( thrd ); 127 127 } 128 128 unlock( lock ); … … 142 142 lock( lock __cfaabi_dbg_ctx2 ); 143 143 unpark( 144 pop_head( this.blocked_threads ) __cfaabi_dbg_ctx2144 pop_head( this.blocked_threads ) 145 145 ); 146 146 unlock( lock ); … … 151 151 while(this.blocked_threads) { 152 152 unpark( 153 pop_head( this.blocked_threads ) __cfaabi_dbg_ctx2153 pop_head( this.blocked_threads ) 154 154 ); 155 155 } … … 161 161 append( this.blocked_threads, kernelTLS.this_thread ); 162 162 unlock( this.lock ); 163 park( __cfaabi_dbg_ctx);163 park(); 164 164 } 165 165 … … 170 170 unlock(l); 171 171 unlock(this.lock); 172 park( __cfaabi_dbg_ctx);172 park(); 173 173 lock(l); 174 174 } -
libcfa/src/concurrency/preemption.cfa
r2fb35df r41b8ea4 274 274 kernelTLS.this_stats = this->curr_cluster->stats; 275 275 #endif 276 __unpark( id, this __cfaabi_dbg_ctx2);276 __unpark( id, this ); 277 277 } 278 278 -
libcfa/src/concurrency/thread.cfa
r2fb35df r41b8ea4 39 39 link.prev = 0p; 40 40 link.preferred = -1; 41 #if defined( __CFA_WITH_VERIFY__ ) 42 canary = 0x0D15EA5E0D15EA5E; 43 #endif 41 44 42 45 node.next = 0p; … … 48 51 49 52 void ^?{}($thread& this) with( this ) { 53 #if defined( __CFA_WITH_VERIFY__ ) 54 canary = 0xDEADDEADDEADDEAD; 55 #endif 50 56 unregister(curr_cluster, this); 51 57 ^self_cor{}; -
libcfa/src/concurrency/thread.hfa
r2fb35df r41b8ea4 88 88 //---------- 89 89 // Park thread: block until corresponding call to unpark, won't block if unpark is already called 90 void park( __cfaabi_dbg_ctx_param);90 void park( void ); 91 91 92 92 //---------- 93 93 // Unpark a thread, if the thread is already blocked, schedule it 94 94 // if the thread is not yet block, signal that it should rerun immediately 95 void unpark( $thread * this __cfaabi_dbg_ctx_param2);95 void unpark( $thread * this ); 96 96 97 97 forall( 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);}98 static inline void unpark( T & this ) { if(!&this) return; unpark( get_thread( this ) );} 99 99 100 100 //---------- -
src/Parser/lex.ll
r2fb35df r41b8ea4 10 10 * Created On : Sat Sep 22 08:58:10 2001 11 11 * Last Modified By : Peter A. Buhr 12 * Last Modified On : Sat Feb 15 11:05:50202013 * Update Count : 7 3712 * Last Modified On : Tue Oct 6 18:15:41 2020 13 * Update Count : 743 14 14 */ 15 15 … … 62 62 #define IDENTIFIER_RETURN() RETURN_VAL( typedefTable.isKind( yytext ) ) 63 63 64 #ifdef HAVE_KEYWORDS_FLOATXX 64 #ifdef HAVE_KEYWORDS_FLOATXX // GCC >= 7 => keyword, otherwise typedef 65 65 #define FLOATXX(v) KEYWORD_RETURN(v); 66 66 #else … … 292 292 __restrict__ { KEYWORD_RETURN(RESTRICT); } // GCC 293 293 return { KEYWORD_RETURN(RETURN); } 294 294 /* resume { KEYWORD_RETURN(RESUME); } // CFA */ 295 295 short { KEYWORD_RETURN(SHORT); } 296 296 signed { KEYWORD_RETURN(SIGNED); } -
src/Parser/parser.yy
r2fb35df r41b8ea4 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu May 28 12:11:45202013 // Update Count : 4 50012 // Last Modified On : Tue Oct 6 18:24:18 2020 13 // Update Count : 4610 14 14 // 15 15 … … 278 278 %token OTYPE FTYPE DTYPE TTYPE TRAIT // CFA 279 279 %token SIZEOF OFFSETOF 280 // %token RESUME // CFA281 %token SUSPEND // CFA280 // %token RESUME // CFA 281 %token SUSPEND // CFA 282 282 %token ATTRIBUTE EXTENSION // GCC 283 283 %token IF ELSE SWITCH CASE DEFAULT DO WHILE FOR BREAK CONTINUE GOTO RETURN … … 329 329 %type<en> conditional_expression constant_expression assignment_expression assignment_expression_opt 330 330 %type<en> comma_expression comma_expression_opt 331 %type<en> argument_expression_list_opt 331 %type<en> argument_expression_list_opt argument_expression default_initialize_opt 332 332 %type<ifctl> if_control_expression 333 333 %type<fctl> for_control_expression for_control_expression_list … … 370 370 %type<decl> assertion assertion_list assertion_list_opt 371 371 372 %type<en> 372 %type<en> bit_subrange_size_opt bit_subrange_size 373 373 374 374 %type<decl> basic_declaration_specifier basic_type_name basic_type_specifier direct_type indirect_type … … 793 793 | '(' aggregate_control '&' ')' cast_expression // CFA 794 794 { $$ = new ExpressionNode( build_keyword_cast( $2, $5 ) ); } 795 // VIRTUAL cannot be opt because of look ahead issues796 795 | '(' VIRTUAL ')' cast_expression // CFA 797 796 { $$ = new ExpressionNode( new VirtualCastExpr( maybeMoveBuild< Expression >( $4 ), maybeMoveBuildType( nullptr ) ) ); } … … 920 919 | unary_expression assignment_operator assignment_expression 921 920 { 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 { 925 924 $$ = new ExpressionNode( build_binary_val( $2, $1, $3 ) ); 926 } // if925 // } // if 927 926 } 928 927 | unary_expression '=' '{' initializer_list_opt comma_opt '}' … … 1676 1675 1677 1676 typedef_expression: 1678 // GCC, naming expression type: typedef name = exp; gives a name to the type of an expression1677 // deprecated GCC, naming expression type: typedef name = exp; gives a name to the type of an expression 1679 1678 TYPEDEF identifier '=' assignment_expression 1680 1679 { 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; 1683 1681 } 1684 1682 | typedef_expression pop ',' push identifier '=' assignment_expression 1685 1683 { 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 ; 1712 1687 1713 1688 c_declaration: … … 1715 1690 { $$ = distAttr( $1, $2 ); } 1716 1691 | typedef_declaration 1717 | typedef_expression // GCC, naming expression type1692 | typedef_expression // deprecated GCC, naming expression type 1718 1693 | sue_declaration_specifier 1719 1694 ; … … 2094 2069 { yyy = true; $$ = AggregateDecl::Union; } 2095 2070 | EXCEPTION // CFA 2096 { yyy = true; $$ = AggregateDecl::Exception; } 2071 // { yyy = true; $$ = AggregateDecl::Exception; } 2072 { SemanticError( yylloc, "exception aggregate is currently unimplemented." ); $$ = AggregateDecl::NoAggregate; } 2097 2073 ; 2098 2074 -
tests/.expect/array.txt
r2fb35df r41b8ea4 1 1 array.cfa: In function '_X4mainFi___1': 2 array.cfa:5 4:9: note: #pragma message: Compiled2 array.cfa:55:9: note: #pragma message: Compiled -
tests/.expect/expression.txt
r2fb35df r41b8ea4 1 1 expression.cfa: In function '_X4mainFi___1': 2 expression.cfa:8 8:9: note: #pragma message: Compiled2 expression.cfa:89:9: note: #pragma message: Compiled -
tests/array.cfa
r2fb35df r41b8ea4 1 // -*- Mode: C -*- 2 // 1 // -*- Mode: C -*- 2 // 3 3 // Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo 4 4 // 5 5 // The contents of this file are covered under the licence agreement in the 6 6 // file "LICENCE" distributed with Cforall. 7 // 7 // 8 8 // array.cfa -- test array declarations 9 // 9 // 10 10 // Author : Peter A. Buhr 11 11 // Created On : Tue Feb 19 21:18:06 2019 … … 13 13 // Last Modified On : Sun Sep 27 09:05:40 2020 14 14 // Update Count : 4 15 // 15 // 16 16 17 17 int a1[0]; … … 50 50 51 51 int 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 53 55 } 54 56 -
tests/concurrent/park/contention.cfa
r2fb35df r41b8ea4 21 21 if(blocked[idx]) { 22 22 Thread * thrd = __atomic_exchange_n(&blocked[idx], 0p, __ATOMIC_SEQ_CST); 23 unpark( *thrd __cfaabi_dbg_ctx2);23 unpark( *thrd ); 24 24 } else { 25 25 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(); 28 28 } 29 29 } … … 41 41 int idx = myrand() % blocked_size; 42 42 Thread * thrd = __atomic_exchange_n(&blocked[idx], 0p, __ATOMIC_SEQ_CST); 43 unpark( *thrd __cfaabi_dbg_ctx2);43 unpark( *thrd ); 44 44 yield( myrand() % 20 ); 45 45 } -
tests/concurrent/park/force_preempt.cfa
r2fb35df r41b8ea4 30 30 31 31 // Unpark this thread, don't force a yield 32 unpark( this __cfaabi_dbg_ctx2);32 unpark( this ); 33 33 assert(mask == 0xCAFEBABA); 34 34 … … 43 43 // Park this thread, 44 44 assert(mask == (id_hash ^ 0xCAFEBABA)); 45 park( __cfaabi_dbg_ctx);45 park(); 46 46 assert(mask == (id_hash ^ 0xCAFEBABA)); 47 47 -
tests/concurrent/park/start_parked.cfa
r2fb35df r41b8ea4 3 3 thread Parker {}; 4 4 void main( Parker & ) { 5 park( __cfaabi_dbg_ctx);5 park(); 6 6 } 7 7 … … 9 9 for(1000) { 10 10 Parker parker; 11 unpark( parker __cfaabi_dbg_ctx2);11 unpark( parker ); 12 12 } 13 13 printf( "done\n" ); // non-empty .expect file -
tests/expression.cfa
r2fb35df r41b8ea4 84 84 (S)@{2}`mary; 85 85 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 87 89 } // main
Note: See TracChangeset
for help on using the changeset viewer.