Changeset ce55a81
- Timestamp:
- Sep 4, 2020, 2:14:10 PM (3 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 14d8a9b
- Parents:
- 56c44dc (diff), 2801829 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Files:
-
- 24 added
- 66 edited
- 8 moved
Legend:
- Unmodified
- Added
- Removed
-
.gitignore
r56c44dc rce55a81 18 18 **/Makefile 19 19 **/Makefile.in 20 **/Makefile.dist.in 20 21 /version 21 22 -
Makefile.am
r56c44dc rce55a81 21 21 22 22 SUBDIRS = driver src . @LIBCFA_TARGET_DIRS@ 23 DIST_SUBDIRS = driver src . libcfa benchmark longrun_tests tests tools tools/prettyprinter 23 24 24 25 @LIBCFA_TARGET_MAKEFILES@ : Makefile $(srcdir)/libcfa/configure … … 26 27 @ls $(config_file) || (echo "Missing config.data, re-run configure script again" && false) 27 28 @$(eval config_data = $(shell cat $(config_file))) 28 @echo "Configuring libcfa with '$(config_data)''"29 @echo "Configuring libcfa ($(abs_top_srcdir)/libcfa/configure) with '$(config_data)' from $(shell pwd) / $(dir $@)" 29 30 @cd $(dir $@) && $(abs_top_srcdir)/libcfa/configure $(config_data) 30 31 … … 32 33 33 34 man1_MANS = doc/man/cfa.1 35 36 EXTRA_DIST = LICENSE doc/man/cfa.1 libcfa/configure libcfa/Makefile.dist.am libcfa/Makefile.dist.in 34 37 35 38 debug=yes -
benchmark/Makefile.am
r56c44dc rce55a81 66 66 # Dummy hack tricks 67 67 EXTRA_PROGRAMS = dummy # build but do not install 68 dummy_SOURCES = dummyC.c dummyCXX.cpp68 nodist_dummy_SOURCES = dummyC.c dummyCXX.cpp 69 69 70 70 dummyC.c: … … 80 80 ## ========================================================================================================= 81 81 82 all : basic$(EXEEXT) ctxswitch$(EXEEXT) mutex$(EXEEXT) schedint$(EXEEXT) schedext$(EXEEXT) creation$(EXEEXT) 82 # all is used by make dist so ignore it 83 all: 84 85 all-bench : basic$(EXEEXT) ctxswitch$(EXEEXT) mutex$(EXEEXT) schedint$(EXEEXT) schedext$(EXEEXT) creation$(EXEEXT) 83 86 84 87 basic_loop_DURATION = 15000000000 … … 476 479 ## ========================================================================================================= 477 480 478 compile$(EXEEXT) : \481 bcompile$(EXEEXT) : \ 479 482 compile-array.make \ 480 483 compile-attributes.make \ -
configure.ac
r56c44dc rce55a81 137 137 \'--enable-gprofiler=*) ;; 138 138 \'--disable-gprofiler) ;; 139 140 # skip this, it only causes problems 141 \'--srcdir=*) ;; 139 142 140 143 # append all other arguments to the sub configure arguments … … 202 205 203 206 LIBCFA_TARGET_DIRS="${LIBCFA_TARGET_DIRS} ${lib_dir}" 207 LIBCFA_1TARGET_DIR="${lib_dir}" 204 208 LIBCFA_TARGET_MAKEFILES="${LIBCFA_TARGET_MAKEFILES} ${lib_dir}/Makefile" 205 209 … … 213 217 214 218 AC_SUBST(LIBCFA_TARGET_DIRS) 219 AC_SUBST(LIBCFA_1TARGET_DIR) 215 220 AC_SUBST(LIBCFA_TARGET_MAKEFILES) 216 221 … … 278 283 driver/Makefile 279 284 src/Makefile 280 benchmark/Makefile285 libcfa/Makefile:libcfa/Makefile.dist.in 281 286 tests/Makefile 282 287 longrun_tests/Makefile 288 benchmark/Makefile 283 289 tools/Makefile 284 290 tools/prettyprinter/Makefile -
doc/LaTeXmacros/common.tex
r56c44dc rce55a81 11 11 %% Created On : Sat Apr 9 10:06:17 2016 12 12 %% Last Modified By : Peter A. Buhr 13 %% Last Modified On : Fri May 24 07:59:54 201914 %% Update Count : 38 213 %% Last Modified On : Fri Sep 4 13:56:52 2020 14 %% Update Count : 383 15 15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 16 … … 36 36 % Names used in the document. 37 37 38 \usepackage{xspace} 38 39 \newcommand{\CFAIcon}{\textsf{C}\raisebox{\depth}{\rotatebox{180}{\textsf{A}}}\xspace} % Cforall symbolic name 39 40 \newcommand{\CFA}{\protect\CFAIcon} % safe for section/caption … … 241 242 }% 242 243 244 \usepackage{listings} % format program code 243 245 \usepackage{lstlang} 244 246 -
doc/man/cfa.1
r56c44dc rce55a81 11 11 .\" Created On : Wed Jul 26 22:34:47 2017 12 12 .\" Last Modified By : Peter A. Buhr 13 .\" Last Modified On : Thu Jul 27 10:29:29 201714 .\" Update Count : 4413 .\" Last Modified On : Wed Sep 2 17:59:53 2020 14 .\" Update Count : 78 15 15 .\" 16 16 .\" nroff -man cfa.1 … … 23 23 .ds Cf "Cforall 24 24 .\" 25 .TH cfa 1 2017-07-27 cfa-\*(Mg25 .TH CFA 1 "2020-09-2" cfa-\*(Mg "\*(Cf Project" 26 26 .SH NAME 27 cfa \- \*(Cf Translator and Runtime Library27 cfa \- \*(Cf project translator and runtime library to enhance C 28 28 .SH SYNOPSIS 29 cfa [gcc-options] [C/\*(Cf source-files] [assembler/loader files] 29 cfa [cfa/gcc-options] 30 [cfa/c source-files] 31 [assembler/loader files] 30 32 .SH DESCRIPTION 33 \*(Cf (C-for-all) is an open-source project extending ISO C with modern safety and productivity features, while still ensuring backwards compatibility with C and its programmers. 34 31 35 The cfa command compiles C and \*(Cf source files and links C/\*(Cf object 32 36 files named on the command line. … … 34 38 The cfa command introduces a translator pass over the specified source files 35 39 after the C preprocessor but before the C compilation. The translator converts 36 new \*(Cf constructs into C statements. The cfa command also provides the 37 runtime library, which is linked with each \*(Cf application. 40 new \*(Cf constructs into C statements. The cfa command also provides a fully 41 concurrent (user-level threads) runtime library, which is linked with the 42 \*(Cf application. 38 43 39 44 The command line options depend on the particular C compiler used (gcc/clang 40 45 supported). As with most C compilers, the output is sent to the file a.out(5) 41 46 unless the -o option is present on the command line. See the reference pages 42 for gcc(1) for more information .47 for gcc(1) for more information on command line options. 43 48 .SH OPTIONS 44 49 When multiple conflicting options appear on the command line, e.g., … … 50 55 All of the options available to the gcc compiler are available to the cfa 51 56 translator. The following gcc flags are implicitly turned on: 52 .IP -std=gnu99 3 53 The 1999 C standard plus GNU extensions. 54 .IP -fgnu89-inline 55 Use the traditional GNU semantics for inline routines in C99 mode, which allows inline routines in header files. 57 .IP "-std=gnu11" 3 58 The 2011 C standard plus GNU extensions. 59 .IP "-fgnu89-inline" 60 Use the traditional GNU semantics for inline routines in C11 mode, which allows inline routines in header files. 61 .IP "-imacros stdbool.h" 62 Include stdbool.h to get defines for bool/true/false. 63 .IP "-latomic -lm" 64 Provide access to double-wide CAS instruction and math library. 56 65 .LP 57 66 The following additional options are available: 58 .IP -CFA367 .IP "-CFA" 3 59 68 Only the C preprocessor and the \*(Cf translator steps are performed and the transformed program is written to standard output, which makes it possible to examine the code generated by the \*(Cf translator. 60 69 The generated code starts with the standard \*(Cf prelude. 61 .IP -debug70 .IP "-debug" 62 71 The program is linked with the debugging version of the runtime system. 63 72 The debug version performs runtime checks to help during the debugging phase of a \*(Cf program, but can substantially slow program execution. 64 73 The runtime checks should only be removed after the program is completely debugged. 65 74 .B This option is the default. 66 .IP -nodebug75 .IP "-nodebug" 67 76 The program is linked with the non-debugging version of the runtime system, so the execution of the program is faster. 68 77 .I However, no runtime checks or asserts are performed so errors usually result in abnormal program behaviour or termination. 69 .IP -help78 .IP "-help" 70 79 Information about the set of \*(Cf compilation flags is printed. 71 .IP -nohelp80 .IP "-nohelp" 72 81 Information about the set of \*(Cf compilation flags is not printed. 73 82 .B This option is the default. 74 .IP -quiet83 .IP "-quiet" 75 84 The \*(Cf compilation message is not printed at the beginning of a compilation. 76 .IP -noquiet85 .IP "-noquiet" 77 86 The \*(Cf compilation message is printed at the beginning of a compilation. 78 87 .B This option is the default. … … 81 90 available. These variables allow conditional compilation of programs that must 82 91 work differently in these situations. 83 .IP __CFA_MAJOR__392 .IP "__CFA_MAJOR__" 3 84 93 is available during preprocessing and its value is the major version number of \*(Cf. 85 .IP __CFA_MINOR__94 .IP "__CFA_MINOR__" 86 95 is available during preprocessing and its value is the minor version number of \*(Cf. 87 .IP __CFA_PATCH__96 .IP "__CFA_PATCH__" 88 97 is available during preprocessing and its value is the patch level number of \*(Cf. 89 98 .IP "__CFA__, __CFORALL__, and __cforall" 90 99 are always available during preprocessing and have no value. 91 .IP __CFA_DEBUG__100 .IP "__CFA_DEBUG__" 92 101 is available during preprocessing if the -debug compilation option is 93 102 specified. … … 116 125 .SH REFERENCES 117 126 .HP 3 118 \*(Cf Reference and Rational Manual 127 .I \*(Cf Home Page 119 128 .br 120 http ://plg.uwaterloo.ca/~cforall/refrat.pdf129 https://cforall.uwaterloo.ca 121 130 .HP 122 131 .I \*(Cf User Manual 123 132 .br 124 http://plg.uwaterloo.ca/~cforall/user.pdf 133 https://cforall.uwaterloo.ca/doc/user.pdf 134 .SH BUILDS 135 Nightly builds are available here https://cforall.uwaterloo.ca/jenkins 125 136 .SH BUGS 126 Bugs should be reported to trac@plg.cs.uwaterloo.ca.137 Bugs reportss are available here https://cforall.uwaterloo.ca/trac 127 138 .SH COPYRIGHT 128 139 \*(Cf is covered under the licence agreement in the distribution. 129 140 .SH AUTHORS 130 141 Andrew Beach, Richard Bilson, Peter A. Buhr, Thierry Delisle, Glen Ditchfield, 131 Rodolfo G. Esteves, Aaron Moss, Rob Schluntz 142 Rodolfo G. Esteves, Aaron Moss, Rob Schluntz, Mubeen Zulfiqar -
doc/theses/thierry_delisle_PhD/comp_II/Makefile
r56c44dc rce55a81 12 12 13 13 ## Define the text source files. 14 15 SOURCES = ${addsuffix .tex, \16 comp_II \17 }18 19 14 FIGURES = ${addsuffix .tex, \ 20 base \21 empty \22 15 emptybit \ 23 16 emptytree \ 24 17 emptytls \ 25 18 resize \ 26 system \27 19 } 28 20 29 21 PICTURES = ${addsuffix .pstex, \ 22 base \ 23 empty \ 24 system \ 30 25 } 31 26 … … 37 32 38 33 ## Define the documents that need to be made. 34 all: comp_II.pdf presentation.pdf 35 comp_II.pdf: ${FIGURES} ${PICTURES} 36 presentation.pdf: presentationstyle.sty base.dark.pstex empty.dark.pstex system.dark.pstex 39 37 40 DOCUMENT = comp_II.pdf 38 DOCUMENT = comp_II.pdf presentation.pdf 41 39 BASE = ${basename ${DOCUMENT}} 42 40 … … 52 50 # File Dependencies # 53 51 54 ${DOCUMENT} : ${BASE}.ps 52 %.pdf : build/%.ps | ${Build} 55 53 ps2pdf $< 56 54 57 ${BASE}.ps : ${BASE}.dvi 58 dvips $ {Build}/$< -o $@55 build/%.ps : build/%.dvi | ${Build} 56 dvips $< -o $@ 59 57 60 ${BASE}.dvi : Makefile ${GRAPHS} ${PROGRAMS} ${PICTURES} ${FIGURES} ${SOURCES} \ 61 ${Macros}/common.tex ${Macros}/indexstyle ../../../bibliography/pl.bib \ 62 local.bib glossary.tex | ${Build} 58 build/%.dvi : %.tex Makefile | ${Build} 63 59 # Must have *.aux file containing citations for bibtex 64 if [ ! -r ${basename $@}.aux ] ; then ${LaTeX} $ {basename $@}.tex; fi65 -${BibTeX} ${ Build}/${basename $@}60 if [ ! -r ${basename $@}.aux ] ; then ${LaTeX} $< ; fi 61 -${BibTeX} ${basename $@} 66 62 # Some citations reference others so run again to resolve these citations 67 ${LaTeX} $ {basename $@}.tex68 -${BibTeX} ${ Build}/${basename $@}63 ${LaTeX} $< 64 -${BibTeX} ${basename $@} 69 65 # Make index from *.aux entries and input index at end of document 70 makeglossaries -q -s ${Build}/${basename $@}.ist ${Build}/${basename $@}66 -makeglossaries -q -s ${basename $@}.ist ${basename $@} 71 67 # Run again to finish citations 72 ${LaTeX} $ {basename $@}.tex68 ${LaTeX} $< 73 69 74 70 ## Define the default recipes. … … 77 73 mkdir -p ${Build} 78 74 79 %.tex : img/%.fig ${Build}75 %.tex : img/%.fig | ${Build} 80 76 fig2dev -L eepic $< > ${Build}/$@ 81 77 … … 87 83 fig2dev -L pstex_t -p ${Build}/$@ $< > ${Build}/$@_t 88 84 85 ## pstex with inverted colors 86 %.dark.pstex : img/%.fig Makefile | ${Build} 87 fig2dev -L pstex $< > ${Build}/$@ 88 sed -i 's/\/col-1 {0 setgray} bind def/\/col-1 {1 setgray} bind def/g' ${Build}/$@ 89 sed -i 's/\/col0 {0.000 0.000 0.000 srgb} bind def/\/col0 {1.000 1.000 1.000 srgb} bind def/g' ${Build}/$@ 90 sed -i 's/\/col7 {1.000 1.000 1.000 srgb} bind def/\/col7 {0.000 0.000 0.000 srgb} bind def/g' ${Build}/$@ 91 fig2dev -L pstex_t -p ${Build}/$@ $< > ${Build}/$@_t 92 89 93 # Local Variables: # 90 94 # compile-command: "make" # -
doc/theses/thierry_delisle_PhD/comp_II/comp_II.tex
r56c44dc rce55a81 63 63 It aims to add high-productivity features while maintaining the predictable performance of C. 64 64 As such, concurrency in \CFA\cite{Delisle19} aims to offer simple and safe high-level tools while still allowing performant code. 65 \CFA concurrent code is written in the synchronous programming paradigm but uses \glspl{uthrd} in order to achieve the simplicity and maintainability of synchronous programming without sacrificing the efficiency of asynchronous program ing.65 \CFA concurrent code is written in the synchronous programming paradigm but uses \glspl{uthrd} in order to achieve the simplicity and maintainability of synchronous programming without sacrificing the efficiency of asynchronous programming. 66 66 As such, the \CFA \newterm{scheduler} is a preemptive user-level scheduler that maps \glspl{uthrd} onto \glspl{kthrd}. 67 67 … … 75 75 and the cost of scheduling, \ie deciding which thread to run next among all the threads ready to run. 76 76 \end{enumerate} 77 The first cost is generally constant and fixed\footnote{Affecting the constant context-switch cost is whether it is done in one step, after the scheduling, or in two steps, context-switching to a fixed third-thread before scheduling.}, while the scheduling cost can vary based on the system state. 78 Adding multiple \glspl{kthrd} does not fundamentally change the scheduler semantics or requirements, it simply adds new correctness requirements, \ie \newterm{linearizability}\footnote{Meaning however fast the CPU threads run, there is an equivalent sequential order that gives the same result.}, and a new dimension to performance: scalability, where scheduling cost now also depends on contention. 79 77 The first cost is generally constant and fixed\footnote{Affecting the constant context-switch cost is whether it is done in one step, after the scheduling, or in two steps, context-switching to a third fixed thread before scheduling.}, while the scheduling cost can vary based on the system state. 78 Adding multiple \glspl{kthrd} does not fundamentally change the scheduler semantics or requirements, it simply adds new correctness requirements, \ie \newterm{linearizability}\footnote{Meaning, however fast the CPU threads run, there is an equivalent sequential order that gives the same result.}, and a new dimension to performance: scalability, where scheduling cost now also depends on contention. 80 79 The more threads switch, the more the administration cost of scheduling becomes noticeable. 81 80 It is therefore important to build a scheduler with the lowest possible cost and latency. … … 84 83 While the illusion of simultaneity is easier to reason about, it can break down if the scheduler allows too much unfairness. 85 84 Therefore, the scheduler should offer as much fairness as needed to guarantee eventual progress, but use unfairness to help performance. 86 In practice, threads must wait in turn but there can be advantages to unfair scheduling, similar to the the express cash-register at a grocery store.85 In practice, threads must wait in turn but there can be advantages to unfair scheduling, similar to the express cash register at a grocery store. 87 86 88 87 The goal of this research is to produce a scheduler that is simple for programmers to understand and offers good performance. … … 93 92 \end{quote} 94 93 95 For a general 96 As such, scheduling performance is generally either defined by the best case scenario, \ie a workload to which the scheduler is tailored, or the worst case scenario, \ie the scheduler behaves no worstthan \emph{X}.94 For a general-purpose scheduler, it is impossible to produce an optimal algorithm as it would require knowledge of the future behaviour of threads. 95 As such, scheduling performance is generally either defined by the best-case scenario, \ie a workload to which the scheduler is tailored, or the worst-case scenario, \ie the scheduler behaves no worse than \emph{X}. 97 96 For this proposal, the performance is evaluated using the second approach to allow \CFA programmers to rely on scheduling performance. 98 97 Because there is no optimal scheduler, ultimately \CFA may allow programmers to write their own scheduler; but that is not the subject of this proposal, which considers only the default scheduler. … … 101 100 To achieve the \CFA scheduling goal includes: 102 101 \begin{enumerate} 103 \item 104 producing a scheduling strategy with sufficient fairness guarantees, 105 \item 106 creating an abstraction layer over the operating system to handle kernel-threads spinning unnecessarily, 107 \item 108 scheduling blocking I/O operations, 109 \item 110 and writing sufficient library tools to allow developers to indirectly use the scheduler, either through tuning knobs or replacing the default scheduler. 102 \item producing a scheduling strategy with sufficient fairness guarantees, 103 \item creating an abstraction layer over the operating system to handle kernel-threads spinning unnecessarily, 104 \item scheduling blocking I/O operations, 105 \item and writing sufficient library tools to allow developers to indirectly use the scheduler, either through tuning knobs or replacing the default scheduler. 111 106 \end{enumerate} 112 107 … … 119 114 \paragraph{Correctness} As with any other concurrent data structure or algorithm, the correctness requirement is paramount. 120 115 The scheduler cannot allow threads to be dropped from the ready queue, \ie scheduled but never run, or be executed multiple times when only being scheduled once. 121 Since \CFA concurrency has no spurious wake up, this definition of correctness also means the scheduler should have no spurious wakeup.116 Since \CFA concurrency has no spurious wake up, this definition of correctness also means the scheduler should have no spurious wake up. 122 117 The \CFA scheduler must be correct. 123 118 … … 130 125 The \CFA scheduler should offer good performance for all three metrics. 131 126 132 \paragraph{Fairness} Like performance, this requirement has several aspect : eventual progress, predictability and performance reliability.127 \paragraph{Fairness} Like performance, this requirement has several aspects : eventual progress, predictability and performance reliability. 133 128 \newterm{Eventual progress} guarantees every scheduled thread is eventually run, \ie prevent starvation. 134 As a hard requirement, the \CFA scheduler must guarantee eventual progress, otherwise the above 135 \newterm{Predictability} and \newterm{reliability} mean ssimilar workloads achieve similar performance and programmer execution intuition is respected.136 For example, a thread that yields aggressively should not run more often th en other tasks.129 As a hard requirement, the \CFA scheduler must guarantee eventual progress, otherwise the above-mentioned illusion of simultaneous execution is broken and the scheduler becomes much more complex to reason about. 130 \newterm{Predictability} and \newterm{reliability} mean similar workloads achieve similar performance and programmer execution intuition is respected. 131 For example, a thread that yields aggressively should not run more often than other tasks. 137 132 While this is intuitive, it does not hold true for many work-stealing or feedback based schedulers. 138 133 The \CFA scheduler must guarantee eventual progress and should be predictable and offer reliable performance. … … 150 145 151 146 \begin{enumerate} 152 \item Threads live long enough for useful feedback information to be togathered.147 \item Threads live long enough for useful feedback information to be gathered. 153 148 \item Threads belong to multiple users so fairness across threads is insufficient. 154 149 \end{enumerate} … … 157 152 Since \CFA has the explicit goal of allowing many smaller threads, this can naturally lead to threads with much shorter lifetimes that are only scheduled a few times. 158 153 Scheduling strategies based on feedback cannot be effective in these cases because there is no opportunity to measure the metrics that underlie the algorithm. 159 Note, the problem of \newterm{feedback convergence} (reacting too slowly to scheduling events) is not specific to short 154 Note, the problem of \newterm{feedback convergence} (reacting too slowly to scheduling events) is not specific to short-lived threads but can also occur with threads that show drastic changes in scheduling, \eg threads running for long periods of time and then suddenly blocking and unblocking quickly and repeatedly. 160 155 161 156 In the context of operating systems, these concerns can be overshadowed by a more pressing concern : security. … … 164 159 In the case of the \CFA scheduler, every thread runs in the same user space and is controlled by the same user. 165 160 Fairness across users is therefore a given and it is then possible to safely ignore the possibility that threads are malevolent. 166 This approach allows for a much simpler fairness metric and in this proposal \emph{fairness} is defined as: when multiple threads are cycling through the system, the total ordering of threads being scheduled, \ie pushed onto the ready -queue, should not differ much from the total ordering of threads being executed, \ie popped from the ready-queue.161 This approach allows for a much simpler fairness metric and in this proposal \emph{fairness} is defined as: when multiple threads are cycling through the system, the total ordering of threads being scheduled, \ie pushed onto the ready queue, should not differ much from the total ordering of threads being executed, \ie popped from the ready queue. 167 162 168 163 Since feedback is not necessarily feasible within the lifetime of all threads and a simple fairness metric can be used, the scheduling strategy proposed for the \CFA runtime does not use per-threads feedback. … … 172 167 Another broad category of schedulers are priority schedulers. 173 168 In these scheduling strategies, threads have priorities and the runtime schedules the threads with the highest priority before scheduling other threads. 174 Threads with equal priority are scheduled using a secondary strategy, often something simple like round -robin or FIFO.169 Threads with equal priority are scheduled using a secondary strategy, often something simple like round robin or FIFO. 175 170 A consequence of priority is that, as long as there is a thread with a higher priority that desires to run, a thread with a lower priority does not run. 176 171 This possible starving of threads can dramatically increase programming complexity since starving threads and priority inversion (prioritizing a lower priority thread) can both lead to serious problems. 177 172 178 173 An important observation is that threads do not need to have explicit priorities for problems to occur. 179 Indeed, any system with multiple ready -queues that attempts to exhaust one queue before accessing the other queues, essentially provide implicit priority, which can encounter starvation problems.174 Indeed, any system with multiple ready queues that attempts to exhaust one queue before accessing the other queues, essentially provide implicit priority, which can encounter starvation problems. 180 175 For example, a popular scheduling strategy that suffers from implicit priorities is work stealing. 181 176 \newterm{Work stealing} is generally presented as follows: … … 191 186 192 187 \subsection{Schedulers without feedback or priorities} 193 This proposal conjectures that i sis possible to construct a default scheduler for the \CFA runtime that offers good scalability and a simple fairness guarantee that is easy for programmers to reason about.188 This proposal conjectures that it is possible to construct a default scheduler for the \CFA runtime that offers good scalability and a simple fairness guarantee that is easy for programmers to reason about. 194 189 The simplest fairness guarantee is FIFO ordering, \ie threads scheduled first run first. 195 190 However, enforcing FIFO ordering generally conflicts with scalability across multiple processors because of the additional synchronization. … … 217 212 Pushing new data is done by selecting one of these underlying queues at random, recording a timestamp for the operation and pushing to the selected queue. 218 213 Popping is done by selecting two queues at random and popping from the queue with the oldest timestamp. 219 A higher number of underlying queues lead sto less contention on each queue and therefore better performance.214 A higher number of underlying queues lead to less contention on each queue and therefore better performance. 220 215 In a loaded system, it is highly likely the queues are non-empty, \ie several tasks are on each of the underlying queues. 221 216 This means that selecting a queue at random to pop from is highly likely to yield a queue with available items. … … 224 219 \begin{figure} 225 220 \begin{center} 226 \input{base }221 \input{base.pstex_t} 227 222 \end{center} 228 223 \caption{Relaxed FIFO list at the base of the scheduler: an array of strictly FIFO lists. 229 The timestamp is in all nodes and cell arrays.}224 The timestamp is in all nodes and cell arrays.} 230 225 \label{fig:base} 231 226 \end{figure} … … 233 228 \begin{figure} 234 229 \begin{center} 235 \input{empty }230 \input{empty.pstex_t} 236 231 \end{center} 237 232 \caption{``More empty'' state of the queue: the array contains many empty cells.} … … 245 240 Overall performance is therefore influenced by the contention on the underlying queues and pop performance is influenced by the item density. 246 241 247 This leads to four performance cases for the centralized ready -queue, as depicted in Table~\ref{tab:perfcases}.242 This leads to four performance cases for the centralized ready queue, as depicted in Table~\ref{tab:perfcases}. 248 243 The number of processors (many or few) refers to the number of kernel threads \emph{actively} attempting to pop user threads from the queues, not the total number of kernel threads. 249 244 The number of threads (many or few) refers to the number of user threads ready to be run. … … 321 316 Sparse global information helps high-contention cases but increases latency in zero-contention-cases, to read and ``aggregate'' the information\footnote{Hierarchical structures, \eg binary search tree, effectively aggregate information but follow pointer chains, learning information at each node. 322 317 Similarly, other sparse schemes need to read multiple cachelines to acquire all the information needed.}. 323 Finally, dense local information has both the advantages of low latency in zero-contention cases and scalability in high-contention cases , however the information can become stale making it difficult to use to ensure correctness.324 The fact that these solutions have these fundamental limits suggest to me a better solution that attempts to combine these properties in an interesting way s.318 Finally, dense local information has both the advantages of low latency in zero-contention cases and scalability in high-contention cases. However the information can become stale making it difficult to use to ensure correctness. 319 The fact that these solutions have these fundamental limits suggest to me a better solution that attempts to combine these properties in an interesting way. 325 320 Also, the lock discussed in Section~\ref{sec:resize} allows for solutions that adapt to the number of processors, which could also prove useful. 326 321 … … 328 323 329 324 How much scalability is actually needed is highly debatable. 330 \emph{libfibre}\cite{libfibre} has compared favo rably to other schedulers in webserver tests\cite{Karsten20} and uses a single atomic counter in its scheduling algorithm similarly to the proposed bitmask.325 \emph{libfibre}\cite{libfibre} has compared favourably to other schedulers in webserver tests\cite{Karsten20} and uses a single atomic counter in its scheduling algorithm similarly to the proposed bitmask. 331 326 As such, the single atomic instruction on a shared cacheline may be sufficiently performant. 332 327 333 328 I have built a prototype of this ready queue in the shape of a data queue, \ie nodes on the queue are structures with a single int representing a thread and intrusive data fields. 334 Using this prototype I ran preliminary performance experiments that confirm the expected performance in Table~\ref{tab:perfcases}.329 Using this prototype, I ran preliminary performance experiments that confirm the expected performance in Table~\ref{tab:perfcases}. 335 330 However, these experiments only offer a hint at the actual performance of the scheduler since threads form more complex operations than simple integer nodes, \eg threads are not independent of each other, when a thread blocks some other thread must intervene to wake it. 336 331 … … 341 336 \begin{figure} 342 337 \begin{center} 343 \input{system }338 \input{system.pstex_t} 344 339 \end{center} 345 340 \caption{Global structure of the \CFA runtime system.} … … 354 349 This assumption is made both in the design of the proposed scheduler as well as in the original design of the \CFA runtime system. 355 350 As such, the proposed scheduler must honour the correctness of this behaviour but does not have any performance objectives with regard to resizing a cluster. 356 How long adding or removing processors take and how much this disrupts the performance of other threads is considered a secondary concern since it should be amortized over long period of times.351 How long adding or removing processors take and how much this disrupts the performance of other threads is considered a secondary concern since it should be amortized over long periods of times. 357 352 However, as mentioned in Section~\ref{sec:queue}, contention on the underlying queues can have a direct impact on performance. 358 353 The number of underlying queues must therefore be adjusted as the number of processors grows or shrinks. … … 372 367 This description effectively matches with the description of a reader-writer lock, infrequent but invasive updates among frequent read operations. 373 368 In the case of the ready queue described above, read operations are operations that push or pop from the ready queue but do not invalidate any references to the ready queue data structures. 374 Writes on the other handwould add or remove inner queues, invalidating references to the array of inner queues in a process.369 Writes, on the other hand, would add or remove inner queues, invalidating references to the array of inner queues in a process. 375 370 Therefore, the current proposed approach to this problem is to add a per-cluster reader-writer lock around the ready queue to prevent restructuring of the ready-queue data-structure while threads are being pushed or popped. 376 371 … … 380 375 381 376 \paragraph{Objectives and Existing Work} 382 The lock must offer scalability and performance on par with the actual ready -queue in order not to introduce a new bottleneck.377 The lock must offer scalability and performance on par with the actual ready queue in order not to introduce a new bottleneck. 383 378 I have already built a lock that fits the desired requirements and preliminary testing show scalability and performance that exceed the target. 384 379 As such, I do not consider this lock to be a risk for this project. … … 396 391 give back unneeded CPU time associated with a process to other user processors executing on the computer, 397 392 \item 398 and reduce energy consumption in cases where more idle kernel-threads translate to idle CPUs, which can cycle down.393 and reduce energy consumption in cases where more idle kernel-threads translate into idle CPUs, which can cycle down. 399 394 \end{enumerate} 400 395 Support for idle sleep broadly involves calling the operating system to block the kernel thread and handling the race between a blocking thread and the waking thread, and handling which kernel thread should sleep or wake up. … … 403 398 This operation is equivalent to the classic problem of missing signals when using condition variables: the ``sleepy'' processor indicates its intention to block but has not yet gone to sleep when another processor attempts to wake it up. 404 399 The waking-up operation sees the blocked process and signals it, but the blocking process is racing to sleep so the signal is missed. 405 In cases where kernel threads are managed as processors on the current cluster, lo osing signals is not necessarily critical, because at least some processors on the cluster are awake and may check for more processors eventually.400 In cases where kernel threads are managed as processors on the current cluster, losing signals is not necessarily critical, because at least some processors on the cluster are awake and may check for more processors eventually. 406 401 Individual processors always finish scheduling user threads before looking for new work, which means that the last processor to go to sleep cannot miss threads scheduled from inside the cluster (if they do, that demonstrates the ready queue is not linearizable). 407 402 However, this guarantee does not hold if threads are scheduled from outside the cluster, either due to an external event like timers and I/O, or due to a user (or kernel) thread migrating from a different cluster. … … 413 408 414 409 Another important issue is avoiding kernel threads sleeping and waking frequently because there is a significant operating-system cost. 415 This scenario happens when a program oscillates between high and low activity, needing most and then lessprocessors.410 This scenario happens when a program oscillates between high and low activity, needing most and then fewer processors. 416 411 A possible partial solution is to order the processors so that the one which most recently went to sleep is woken up. 417 412 This allows other sleeping processors to reach deeper sleep state (when these are available) while keeping ``hot'' processors warmer. … … 420 415 421 416 A final important aspect of idle sleep is when should processors make the decision to sleep and when is it appropriate for sleeping processors to be woken up. 422 Processors that are unnecessarily unblocked lead to unnecessary contention, CPU usage, and power consumption, while too many sleeping processors can lead to sub -optimal throughput.423 Furthermore, transitions from sleeping to awake and vice -versa also add unnecessary latency.417 Processors that are unnecessarily unblocked lead to unnecessary contention, CPU usage, and power consumption, while too many sleeping processors can lead to suboptimal throughput. 418 Furthermore, transitions from sleeping to awake and vice versa also add unnecessary latency. 424 419 There is already a wealth of research on the subject\cite{schillings1996engineering, wiki:thunderherd} and I may use an existing approach for the idle-sleep heuristic in this project, \eg\cite{Karsten20}. 425 420 … … 430 425 It is preferable to block the user thread performing the I/O and reuse the underlying kernel-thread to run other ready user threads. 431 426 This approach requires intercepting user-thread calls to I/O operations, redirecting them to an asynchronous I/O interface, and handling the multiplexing/demultiplexing between the synchronous and asynchronous API. 432 As such, there are three components needed to implement edsupport for asynchronous I/O:427 As such, there are three components needed to implement support for asynchronous I/O: 433 428 \begin{enumerate} 434 429 \item … … 446 441 It is sufficient to make one work in the complex context of the \CFA runtime. 447 442 \uC uses the $select$\cite{select} as its interface, which handles ttys, pipes and sockets, but not disk. 448 $select$ entails significant complexity and is being replaced in UNIX operating -systems, which make it a less interesting alternative.443 $select$ entails significant complexity and is being replaced in UNIX operating systems, which make it a less interesting alternative. 449 444 Another popular interface is $epoll$\cite{epoll}, which is supposed to be cheaper than $select$. 450 However, $epoll$ also does not handle the file system and anec todal evidence suggest it has problem with linux pipes and $TTY$s.445 However, $epoll$ also does not handle the file system and anecdotal evidence suggest it has problems with Linux pipes and $TTY$s. 451 446 A popular cross-platform alternative is $libuv$\cite{libuv}, which offers asynchronous sockets and asynchronous file system operations (among other features). 452 447 However, as a full-featured library it includes much more than I need and could conflict with other features of \CFA unless significant effort is made to merge them together. 453 448 A very recent alternative that I am investigating is $io_uring$\cite{io_uring}. 454 It claims to address some of the issues with $epoll$ and my early investigating suggest that the claim is accurate.455 $io_uring$ uses a much more general approach where system calls are register to a queue and later executed by the kernel, rather than relying on system calls to return an error instead of blocking and subsequently waiting for changes on file descriptors.449 It claims to address some of the issues with $epoll$ and my early investigating suggests that the claim is accurate. 450 $io_uring$ uses a much more general approach where system calls are registered to a queue and later executed by the kernel, rather than relying on system calls to return an error instead of blocking and subsequently waiting for changes on file descriptors. 456 451 I believe this approach allows for fewer problems, \eg the manpage for $open$\cite{open} states: 457 452 \begin{quote} 458 459 460 Since $O_NONBLOCK$ semantics might eventually be implemented, applications should not depend upon blocking behavior when specifying this flag for regular files and block devices.453 Note that [the $O_NONBLOCK$ flag] has no effect for regular files and block devices; 454 that is, I/O operations will (briefly) block when device activity is required, regardless of whether $O_NONBLOCK$ is set. 455 Since $O_NONBLOCK$ semantics might eventually be implemented, applications should not depend upon blocking behaviour when specifying this flag for regular files and block devices. 461 456 \end{quote} 462 457 This makes approach based on $epoll$/$select$ less reliable since they may not work for every file descriptors. 463 For this reason, I plan to use $io_uring$ as the OS abstraction for the \CFA runtime ,unless further work shows problems I haven't encountered yet.458 For this reason, I plan to use $io_uring$ as the OS abstraction for the \CFA runtime unless further work shows problems I haven't encountered yet. 464 459 However, only a small subset of the features are available in Ubuntu as of April 2020\cite{wiki:ubuntu-linux}, which will limit performance comparisons. 465 460 I do not believe this will affect the comparison result. … … 490 485 \section{Discussion} 491 486 I believe that runtime system and scheduling are still open topics. 492 Many ``state of the art'' production frameworks still use single threaded event-loops because of performance considerations, \eg \cite{nginx-design}, and, to my knowledge, no wideylavailable system language offers modern threading facilities.487 Many ``state of the art'' production frameworks still use single-threaded event loops because of performance considerations, \eg \cite{nginx-design}, and, to my knowledge, no widely available system language offers modern threading facilities. 493 488 I believe the proposed work offers a novel runtime and scheduling package, where existing work only offers fragments that users must assemble themselves when possible. 494 489 … … 501 496 \hline November 2020 & March 2021 & Completion of the implementation. \\ 502 497 \hline March 2021 & April 2021 & Final Performance experiments. \\ 503 \hline May 2021 & August 2021 & Thesis writing and defen se. \\498 \hline May 2021 & August 2021 & Thesis writing and defence. \\ 504 499 \hline 505 500 \end{tabular} -
doc/theses/thierry_delisle_PhD/comp_II/img/base.fig
r56c44dc rce55a81 1 #FIG 3.2 Produced by xfig version 3.2. 5c1 #FIG 3.2 Produced by xfig version 3.2.7b 2 2 Landscape 3 3 Center 4 4 Inches 5 Letter 5 Letter 6 6 100.00 7 7 Single … … 13 13 1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 6975 4200 20 20 6975 4200 6995 4200 14 14 -6 15 6 2400 2100 3000 270016 1 3 0 1 0 7 50 -1 -1 0.000 1 0.0000 2700 2400 300 300 2700 2400 3000 240017 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 218 2400 2475 3000 247519 4 1 0 50 -1 0 11 0.0000 2 120 210 2700 2650 TS\00120 -621 6 2400 3000 3000 360022 1 3 0 1 0 7 50 -1 -1 0.000 1 0.0000 2700 3300 300 300 2700 3300 3000 330023 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 224 2400 3375 3000 337525 4 1 0 50 -1 0 11 0.0000 2 120 210 2700 3550 TS\00126 -627 15 1 3 0 1 0 7 50 -1 -1 0.000 1 0.0000 3900 2400 300 300 3900 2400 4200 2400 28 16 1 3 0 1 0 7 50 -1 -1 0.000 1 0.0000 3900 3300 300 300 3900 3300 4200 3300 … … 33 21 1 3 0 1 0 7 50 -1 -1 0.000 1 0.0000 6300 3300 300 300 6300 3300 6600 3300 34 22 1 3 0 1 0 7 50 -1 -1 0.000 1 0.0000 4509 3302 300 300 4509 3302 4809 3302 23 1 3 0 1 0 7 50 -1 -1 0.000 1 0.0000 2700 3300 300 300 2700 3300 3000 3300 24 1 3 0 1 0 7 50 -1 -1 0.000 1 0.0000 2700 2400 300 300 2700 2400 3000 2400 35 25 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 36 26 3000 3900 3000 4500 … … 73 63 1 1 1.00 45.00 90.00 74 64 6300 4200 6300 3600 75 2 1 0 1 07 50 -1 -1 0.000 0 0 -1 1 0 265 2 1 0 1 -1 7 50 -1 -1 0.000 0 0 -1 1 0 2 76 66 1 1 1.00 45.00 90.00 77 67 2700 4200 2700 3600 … … 81 71 1 1 1.00 45.00 90.00 82 72 4500 4200 4500 3600 83 4 2 0 50 -1 0 12 0.0000 2 180 660 2100 4200 Array of\001 84 4 2 0 50 -1 0 12 0.0000 2 165 600 2100 4425 Queues\001 85 4 2 0 50 -1 0 12 0.0000 2 135 645 2100 3075 Threads\001 86 4 2 0 50 -1 0 12 0.0000 2 180 525 2100 2850 Ready\001 87 4 1 0 50 -1 0 11 0.0000 2 120 210 2700 4450 TS\001 73 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 74 2400 3375 3000 3375 75 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 76 2400 2475 3000 2475 77 4 2 -1 50 -1 0 12 0.0000 2 135 630 2100 3075 Threads\001 78 4 2 -1 50 -1 0 12 0.0000 2 165 450 2100 2850 Ready\001 79 4 1 -1 50 -1 0 11 0.0000 2 135 180 2700 4450 TS\001 80 4 2 -1 50 -1 0 12 0.0000 2 165 720 2100 4200 Array of\001 81 4 2 -1 50 -1 0 12 0.0000 2 150 540 2100 4425 Queues\001 82 4 1 -1 50 -1 0 11 0.0000 2 135 180 2700 3550 TS\001 83 4 1 -1 50 -1 0 11 0.0000 2 135 180 2700 2650 TS\001 -
doc/theses/thierry_delisle_PhD/comp_II/img/empty.fig
r56c44dc rce55a81 1 #FIG 3.2 Produced by xfig version 3.2. 5c1 #FIG 3.2 Produced by xfig version 3.2.7b 2 2 Landscape 3 3 Center 4 4 Inches 5 Letter 5 Letter 6 6 100.00 7 7 Single … … 41 41 1 1 1.00 45.00 90.00 42 42 2700 4200 2700 3600 43 4 2 0 50 -1 0 12 0.0000 2 180 660 2100 4200 Array of\00144 4 2 0 50 -1 0 12 0.0000 2 165 600 2100 4425 Queues\00145 4 2 0 50 -1 0 12 0.0000 2 135 6452100 3075 Threads\00146 4 2 0 50 -1 0 12 0.0000 2 180 5252100 2850 Ready\00143 4 2 -1 50 -1 0 12 0.0000 2 165 720 2100 4200 Array of\001 44 4 2 -1 50 -1 0 12 0.0000 2 150 540 2100 4425 Queues\001 45 4 2 -1 50 -1 0 12 0.0000 2 135 630 2100 3075 Threads\001 46 4 2 -1 50 -1 0 12 0.0000 2 165 450 2100 2850 Ready\001 -
doc/theses/thierry_delisle_PhD/comp_II/img/system.fig
r56c44dc rce55a81 3 3 Center 4 4 Inches 5 Letter 5 Letter 6 6 100.00 7 7 Single … … 165 165 4 1 -1 0 0 0 10 0.0000 2 105 990 2175 3525 Discrete-event\001 166 166 4 1 -1 0 0 0 10 0.0000 2 135 795 2175 4350 preemption\001 167 4 0 -1 0 0 0 10 0.0000 2 150 1290 2325 4875 gen rator/coroutine\001167 4 0 -1 0 0 0 10 0.0000 2 150 1290 2325 4875 generator/coroutine\001 168 168 4 0 -1 0 0 0 10 0.0000 2 120 270 4050 4875 task\001 169 169 4 0 -1 0 0 0 10 0.0000 2 105 450 7050 4875 cluster\001 -
driver/cfa.cc
r56c44dc rce55a81 10 10 // Created On : Tue Aug 20 13:44:49 2002 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Aug 20 23:43:59202013 // Update Count : 43 612 // Last Modified On : Wed Sep 2 17:59:20 2020 13 // Update Count : 438 14 14 // 15 15 … … 437 437 #endif // __x86_64__ 438 438 args[nargs++] = "-ldl"; 439 args[nargs++] = "-lrt";440 439 args[nargs++] = "-lm"; 441 440 } // if -
libcfa/prelude/Makefile.am
r56c44dc rce55a81 22 22 cfalibdir = ${CFA_LIBDIR} 23 23 cfalib_DATA = gcc-builtins.cf builtins.cf extras.cf prelude.cfa bootloader.c defines.hfa 24 25 EXTRA_DIST = bootloader.cf builtins.c builtins.def extras.c extras.regx extras.regx2 prelude-gen.cc prototypes.awk prototypes.c prototypes.sed sync-builtins.cf 24 26 25 27 CC = @LOCAL_CFACC@ -
libcfa/src/Makefile.am
r56c44dc rce55a81 31 31 # AM_CFAFLAGS for only cfa source 32 32 # use -no-include-stdhdr to prevent rebuild cycles 33 # The built sources must not depend on the installed headers34 AM_CFAFLAGS = -quiet -cfalib -I$(srcdir)/stdhdr $(if $(findstring ${gdbwaittarget}, ${@}), -XCFA --gdb) @CONFIG_CFAFLAGS@33 # The built sources must not depend on the installed inst_headers_src 34 AM_CFAFLAGS = -quiet -cfalib -I$(srcdir)/stdhdr -I$(srcdir)/concurrency $(if $(findstring ${gdbwaittarget}, ${@}), -XCFA --gdb) @CONFIG_CFAFLAGS@ 35 35 AM_CFLAGS = -g -Wall -Wno-unused-function -fPIC -fexceptions -pthread @ARCH_FLAGS@ @CONFIG_CFLAGS@ 36 36 AM_CCASFLAGS = -g -Wall -Wno-unused-function @ARCH_FLAGS@ @CONFIG_CFLAGS@ … … 39 39 #---------------------------------------------------------------------------------------------------------------- 40 40 if BUILDLIB 41 headers_nosrc = bitmanip.hfa exception.hfa math.hfa gmp.hfa time_t.hfa clock.hfa \ 42 bits/align.hfa bits/containers.hfa bits/defs.hfa bits/debug.hfa bits/locks.hfa \ 43 containers/list.hfa containers/stackLockFree.hfa concurrency/iofwd.hfa 41 inst_headers_nosrc = \ 42 bitmanip.hfa \ 43 clock.hfa \ 44 exception.hfa \ 45 gmp.hfa \ 46 math.hfa \ 47 time_t.hfa \ 48 bits/align.hfa \ 49 bits/containers.hfa \ 50 bits/debug.hfa \ 51 bits/defs.hfa \ 52 bits/locks.hfa \ 53 concurrency/iofwd.hfa \ 54 containers/list.hfa \ 55 containers/stackLockFree.hfa 44 56 45 headers = common.hfa fstream.hfa heap.hfa iostream.hfa iterator.hfa limits.hfa rational.hfa \ 46 time.hfa stdlib.hfa parseargs.hfa \ 47 containers/maybe.hfa containers/pair.hfa containers/result.hfa containers/vector.hfa 57 inst_headers_src = \ 58 common.hfa \ 59 fstream.hfa \ 60 heap.hfa \ 61 iostream.hfa \ 62 iterator.hfa \ 63 limits.hfa \ 64 parseargs.hfa \ 65 rational.hfa \ 66 stdlib.hfa \ 67 time.hfa \ 68 containers/maybe.hfa \ 69 containers/pair.hfa \ 70 containers/result.hfa \ 71 containers/vector.hfa 48 72 49 libsrc = startup.cfa interpose.cfa bits/debug.cfa assert.cfa exception.c virtual.c ${headers:.hfa=.cfa} 73 libsrc = ${inst_headers_src} ${inst_headers_src:.hfa=.cfa} \ 74 assert.cfa \ 75 bits/algorithm.hfa \ 76 bits/debug.cfa \ 77 exception.c \ 78 exception.h \ 79 interpose.cfa \ 80 lsda.h \ 81 startup.cfa \ 82 startup.hfa \ 83 virtual.c \ 84 virtual.h 50 85 51 86 # not all platforms support concurrency, add option do disable it 52 thread_headers_nosrc = bits/random.hfa concurrency/invoke.h concurrency/kernel/fwd.hfa 87 inst_thread_headers_nosrc = \ 88 bits/random.hfa \ 89 concurrency/invoke.h \ 90 concurrency/kernel/fwd.hfa 53 91 54 thread_headers = concurrency/coroutine.hfa concurrency/thread.hfa concurrency/kernel.hfa \ 55 concurrency/monitor.hfa concurrency/mutex.hfa concurrency/exception.hfa 92 inst_thread_headers_src = \ 93 concurrency/coroutine.hfa \ 94 concurrency/exception.hfa \ 95 concurrency/kernel.hfa \ 96 concurrency/monitor.hfa \ 97 concurrency/mutex.hfa \ 98 concurrency/thread.hfa 56 99 57 thread_libsrc = concurrency/CtxSwitch-@ARCHITECTURE@.S concurrency/alarm.cfa \ 58 concurrency/invoke.c concurrency/io.cfa concurrency/iocall.cfa \ 59 concurrency/io/setup.cfa \ 60 concurrency/kernel/startup.cfa concurrency/preemption.cfa \ 61 concurrency/ready_queue.cfa concurrency/stats.cfa \ 62 ${thread_headers:.hfa=.cfa} 100 thread_libsrc = ${inst_thread_headers_src} ${inst_thread_headers_src:.hfa=.cfa} \ 101 bits/signal.hfa \ 102 concurrency/alarm.cfa \ 103 concurrency/alarm.hfa \ 104 concurrency/CtxSwitch-@ARCHITECTURE@.S \ 105 concurrency/invoke.c \ 106 concurrency/io.cfa \ 107 concurrency/io/setup.cfa \ 108 concurrency/io/types.hfa \ 109 concurrency/iocall.cfa \ 110 concurrency/iofwd.hfa \ 111 concurrency/kernel_private.hfa \ 112 concurrency/kernel/startup.cfa \ 113 concurrency/preemption.cfa \ 114 concurrency/preemption.hfa \ 115 concurrency/ready_queue.cfa \ 116 concurrency/ready_subqueue.hfa \ 117 concurrency/snzi.hfa \ 118 concurrency/stats.cfa \ 119 concurrency/stats.hfa \ 120 concurrency/stats.hfa 121 63 122 else 64 headers=65 thread_headers=66 headers_nosrc =67 thread_headers_nosrc =123 inst_headers_src = 124 inst_thread_headers_src = 125 inst_headers_nosrc = 126 inst_thread_headers_nosrc = 68 127 libsrc = 69 128 endif … … 115 174 116 175 #---------------------------------------------------------------------------------------------------------------- 117 libcfa_la_SOURCES = prelude.cfa ${libsrc} 176 libcfa_la_SOURCES = ${libsrc} 177 nodist_libcfa_la_SOURCES = prelude.cfa 118 178 libcfa_la_LDFLAGS = -version-info @CFA_VERSION@ 119 179 … … 124 184 125 185 cfa_includedir = $(CFA_INCDIR) 126 nobase_cfa_include_HEADERS = ${stdhdr} ${headers} ${headers_nosrc} ${thread_headers} ${thread_headers_nosrc} 186 nobase_cfa_include_HEADERS = ${stdhdr} ${inst_headers_src} ${inst_headers_nosrc} ${inst_thread_headers_src} ${inst_thread_headers_nosrc} 187 EXTRA_DIST = stdhdr 127 188 128 189 #---------------------------------------------------------------------------------------------------------------- -
libcfa/src/bits/defs.hfa
r56c44dc rce55a81 10 10 // Created On : Thu Nov 9 13:24:10 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Aug 13 22:00:23202013 // Update Count : 1912 // Last Modified On : Wed Aug 26 16:22:32 2020 13 // Update Count : 20 14 14 // 15 15 … … 49 49 50 50 static inline long long int rdtscl(void) { 51 #if defined( __aarch64__ ) 51 #if defined( __i386 ) || defined( __x86_64 ) 52 unsigned int lo, hi; 53 __asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi)); 54 return ( (unsigned long long)lo)|( ((unsigned long long)hi)<<32 ); 55 #elif defined( __aarch64__ ) || defined( __arm__ ) 52 56 // https://github.com/google/benchmark/blob/v1.1.0/src/cycleclock.h#L116 53 57 long long int virtual_timer_value; … … 55 59 return virtual_timer_value; 56 60 #else 57 unsigned int lo, hi; 58 __asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi)); 59 return ( (unsigned long long)lo)|( ((unsigned long long)hi)<<32 ); 61 #error unsupported hardware architecture 60 62 #endif // __ARM_ARCH 61 63 } -
libcfa/src/bits/locks.hfa
r56c44dc rce55a81 218 218 } 219 219 220 // Semaphore which only supports a single thread and one post 221 // Semaphore which only supports a single thread 220 // Synchronozation primitive which only supports a single thread and one post 221 // Similar to a binary semaphore with a 'one shot' semantic 222 // is expected to be discarded after each party call their side 222 223 struct oneshot { 224 // Internal state : 225 // 0p : is initial state (wait will block) 226 // 1p : fulfilled (wait won't block) 227 // any thread : a thread is currently waiting 223 228 struct $thread * volatile ptr; 224 229 }; … … 231 236 void ^?{}(oneshot & this) {} 232 237 238 // Wait for the post, return immidiately if it already happened. 239 // return true if the thread was parked 233 240 bool wait(oneshot & this) { 234 241 for() { … … 244 251 } 245 252 253 // Mark as fulfilled, wake thread if needed 254 // return true if a thread was unparked 246 255 bool post(oneshot & this) { 247 256 struct $thread * got = __atomic_exchange_n( &this.ptr, 1p, __ATOMIC_SEQ_CST); … … 251 260 } 252 261 } 262 263 // base types for future to build upon 264 // It is based on the 'oneshot' type to allow multiple futures 265 // to block on the same instance, permitting users to block a single 266 // thread on "any of" [a given set of] futures. 267 // does not support multiple threads waiting on the same future 268 struct future_t { 269 // Internal state : 270 // 0p : is initial state (wait will block) 271 // 1p : fulfilled (wait won't block) 272 // 2p : in progress () 273 // 3p : abandoned, server should delete 274 // any oneshot : a context has been setup to wait, a thread could wait on it 275 struct oneshot * volatile ptr; 276 }; 277 278 static inline { 279 void ?{}(future_t & this) { 280 this.ptr = 0p; 281 } 282 283 void ^?{}(future_t & this) {} 284 285 // check if the future is available 286 bool available( future_t & this ) { 287 return this.ptr == 1p; 288 } 289 290 // Prepare the future to be waited on 291 // intented to be use by wait, wait_any, waitfor, etc. rather than used directly 292 bool setup( future_t & this, oneshot & wait_ctx ) { 293 /* paranoid */ verify( wait_ctx.ptr == 0p ); 294 // The future needs to set the wait context 295 for() { 296 struct oneshot * expected = this.ptr; 297 // Is the future already fulfilled? 298 if(expected == 1p) return false; // Yes, just return false (didn't block) 299 300 // The future is not fulfilled, try to setup the wait context 301 /* paranoid */ verify( expected == 0p ); 302 if(__atomic_compare_exchange_n(&this.ptr, &expected, &wait_ctx, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) { 303 return true; 304 } 305 } 306 } 307 308 // Stop waiting on a future 309 // When multiple futures are waited for together in "any of" pattern 310 // futures that weren't fulfilled before the thread woke up 311 // should retract the wait ctx 312 // intented to be use by wait, wait_any, waitfor, etc. rather than used directly 313 void retract( future_t & this, oneshot & wait_ctx ) { 314 // Remove the wait context 315 struct oneshot * got = __atomic_exchange_n( &this.ptr, 0p, __ATOMIC_SEQ_CST); 316 317 // got == 0p: future was never actually setup, just return 318 if( got == 0p ) return; 319 320 // got == wait_ctx: since fulfil does an atomic_swap, 321 // if we got back the original then no one else saw context 322 // It is safe to delete (which could happen after the return) 323 if( got == &wait_ctx ) return; 324 325 // got == 1p: the future is ready and the context was fully consumed 326 // the server won't use the pointer again 327 // It is safe to delete (which could happen after the return) 328 if( got == 1p ) return; 329 330 // got == 2p: the future is ready but the context hasn't fully been consumed 331 // spin until it is safe to move on 332 if( got == 2p ) { 333 while( this.ptr != 1p ) Pause(); 334 return; 335 } 336 337 // got == any thing else, something wen't wrong here, abort 338 abort("Future in unexpected state"); 339 } 340 341 // Mark the future as abandoned, meaning it will be deleted by the server 342 void abandon( future_t & this ) { 343 struct oneshot * got = __atomic_exchange_n( &this.ptr, 3p, __ATOMIC_SEQ_CST); 344 345 // got == 2p: the future is ready but the context hasn't fully been consumed 346 // spin until it is safe to move on 347 if( got == 2p ) { 348 while( this.ptr != 1p ) Pause(); 349 } 350 return; 351 } 352 353 // from the server side, mark the future as fulfilled 354 // delete it if needed 355 bool fulfil( future_t & this ) { 356 for() { 357 struct oneshot * expected = this.ptr; 358 // was this abandoned? 359 if( expected == 3p ) { free( &this ); return false; } 360 361 /* paranoid */ verify( expected != 1p ); // Future is already fulfilled, should not happen 362 /* paranoid */ verify( expected != 2p ); // Future is bein fulfilled by someone else, this is even less supported then the previous case. 363 364 // If there is a wait context, we need to consume it and mark it as consumed after 365 // If there is no context then we can skip the in progress phase 366 struct oneshot * want = expected == 0p ? 1p : 2p; 367 if(__atomic_compare_exchange_n(&this.ptr, &expected, want, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) { 368 if( expected == 0p ) { /* paranoid */ verify( this.ptr == 1p); return false; } 369 bool ret = post( *expected ); 370 __atomic_store_n( &this.ptr, 1p, __ATOMIC_SEQ_CST); 371 return ret; 372 } 373 } 374 375 } 376 377 // Wait for the future to be fulfilled 378 bool wait( future_t & this ) { 379 oneshot temp; 380 if( !setup(this, temp) ) return false; 381 382 // Wait context is setup, just wait on it 383 bool ret = wait( temp ); 384 385 // Wait for the future to tru 386 while( this.ptr == 2p ) Pause(); 387 // Make sure the state makes sense 388 // Should be fulfilled, could be in progress but it's out of date if so 389 // since if that is the case, the oneshot was fulfilled (unparking this thread) 390 // and the oneshot should not be needed any more 391 __attribute__((unused)) struct oneshot * was = this.ptr; 392 /* paranoid */ verifyf( was == 1p, "Expected this.ptr to be 1p, was %p\n", was ); 393 394 // Mark the future as fulfilled, to be consistent 395 // with potential calls to avail 396 // this.ptr = 1p; 397 return ret; 398 } 399 } 253 400 #endif -
libcfa/src/concurrency/CtxSwitch-arm64.S
r56c44dc rce55a81 2 2 // Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo 3 3 // 4 // CtxSwitch-arm .S --4 // CtxSwitch-arm64.S -- 5 5 // 6 6 // Author : Peter A. Buhr 7 7 // Created On : Sun Aug 16 07:50:13 2020 8 8 // Last Modified By : Peter A. Buhr 9 // Last Modified On : Thu Aug 20 18:43:51202010 // Update Count : 2 49 // Last Modified On : Wed Aug 26 16:24:59 2020 10 // Update Count : 25 11 11 // 12 12 … … 26 26 #define SAVE 20 * 8 27 27 28 .file "CtxSwitch-arm .S"28 .file "CtxSwitch-arm64.S" 29 29 .text 30 30 .align 2 31 31 .global __cfactx_switch 32 .type __cfactx_switch, @function32 .type __cfactx_switch, %function 33 33 __cfactx_switch: 34 34 … … 91 91 .align 2 92 92 .global __cfactx_invoke_stub 93 .type __cfactx_invoke_stub, @function93 .type __cfactx_invoke_stub, %function 94 94 __cfactx_invoke_stub: 95 95 mov x0, x19 // load main as parameter 0 -
libcfa/src/concurrency/kernel.cfa
r56c44dc rce55a81 10 10 // Created On : Tue Jan 17 12:27:26 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Aug 14 15:23:00 202013 // Update Count : 6912 // Last Modified On : Mon Aug 31 07:08:20 2020 13 // Update Count : 71 14 14 // 15 15 … … 74 74 ) 75 75 76 #elif defined( __ARM_ARCH ) 76 #elif defined( __arm__ ) 77 #define __x87_store 78 #define __x87_load 79 80 #elif defined( __aarch64__ ) 77 81 #define __x87_store \ 78 82 uint32_t __fpcntl[2]; \ … … 93 97 94 98 #else 95 #error un knownhardware architecture99 #error unsupported hardware architecture 96 100 #endif 97 101 -
libcfa/src/concurrency/preemption.cfa
r56c44dc rce55a81 10 10 // Created On : Mon Jun 5 14:20:42 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Aug 21 13:45:32202013 // Update Count : 5 212 // Last Modified On : Wed Aug 26 16:46:03 2020 13 // Update Count : 53 14 14 // 15 15 … … 56 56 #elif defined( __x86_64 ) 57 57 #define CFA_REG_IP gregs[REG_RIP] 58 #elif defined( __ARM_ARCH ) 58 #elif defined( __arm__ ) 59 #define CFA_REG_IP arm_pc 60 #elif defined( __aarch64__ ) 59 61 #define CFA_REG_IP pc 60 62 #else 61 #error un knownhardware architecture63 #error unsupported hardware architecture 62 64 #endif 63 65 -
libcfa/src/exception.c
r56c44dc rce55a81 10 10 // Created On : Mon Jun 26 15:13:00 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Aug 21 11:27:56202013 // Update Count : 2912 // Last Modified On : Sat Aug 29 15:52:22 2020 13 // Update Count : 34 14 14 // 15 15 … … 18 18 19 19 #include "exception.h" 20 21 // Implementation of the secret header is hardware dependent.22 #if defined( __x86_64 ) || defined( __i386 )23 #elif defined( __ARM_ARCH )24 #warning FIX ME: check if anything needed for ARM25 #else26 #warning Exception Handling: No known architecture detected.27 #endif28 20 29 21 #include <stdlib.h> … … 34 26 #include "stdhdr/assert.h" 35 27 36 // FIX ME: temporary hack to keep ARM build working 28 #if defined( __ARM_ARCH ) 29 #warning FIX ME: temporary hack to keep ARM build working 37 30 #ifndef _URC_FATAL_PHASE1_ERROR 38 31 #define _URC_FATAL_PHASE1_ERROR 3 … … 41 34 #define _URC_FATAL_PHASE2_ERROR 2 42 35 #endif // ! _URC_FATAL_PHASE2_ERROR 36 #endif // __ARM_ARCH 43 37 44 38 #include "lsda.h" … … 626 620 627 621 #pragma GCC pop_options 622 623 #elif defined( __ARM_ARCH ) 624 _Unwind_Reason_Code __gcfa_personality_v0( 625 int version, 626 _Unwind_Action actions, 627 unsigned long long exception_class, 628 struct _Unwind_Exception * unwind_exception, 629 struct _Unwind_Context * unwind_context) { 630 return _URC_CONTINUE_UNWIND; 631 } 632 633 __attribute__((noinline)) 634 void __cfaehm_try_terminate(void (*try_block)(), 635 void (*catch_block)(int index, exception_t * except), 636 __attribute__((unused)) int (*match_block)(exception_t * except)) { 637 } 638 #else 639 #error unsupported hardware architecture 628 640 #endif // __x86_64 || __i386 -
libcfa/src/heap.cfa
r56c44dc rce55a81 10 10 // Created On : Tue Dec 19 21:58:35 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Aug 24 20:29:24 202013 // Update Count : 9 2612 // Last Modified On : Thu Sep 3 16:22:54 2020 13 // Update Count : 943 14 14 // 15 15 … … 29 29 #include "math.hfa" // ceiling 30 30 #include "bitmanip.hfa" // is_pow2, ceiling2 31 32 #define MIN(x, y) (y > x ? x : y)33 31 34 32 static bool traceHeap = false; … … 956 954 957 955 headers( "realloc", naddr, header, freeElem, bsize, oalign ); 958 memcpy( naddr, oaddr, MIN( osize, size ) ); // copy bytes956 memcpy( naddr, oaddr, min( osize, size ) ); // copy bytes 959 957 free( oaddr ); 960 958 … … 1218 1216 #endif // __STATISTICS__ 1219 1217 1220 // If size is equal to 0, either NULL or a pointer suitable to be passed to free() is returned.1221 if ( unlikely( size == 0 ) ) { free( oaddr ); return 0p; } // special cases1222 if ( unlikely( oaddr == 0p ) ) {1223 #ifdef __STATISTICS__1224 __atomic_add_fetch( &resize_storage, size, __ATOMIC_SEQ_CST );1225 #endif // __STATISTICS__1226 return memalignNoStats( nalign, size );1227 } // if1228 1229 1218 if ( unlikely( nalign < libAlign() ) ) nalign = libAlign(); // reset alignment to minimum 1230 1219 #ifdef __CFA_DEBUG__ … … 1233 1222 #endif // __CFA_DEBUG__ 1234 1223 1235 HeapManager.Storage.Header * header; 1236 HeapManager.FreeHeader * freeElem; 1237 size_t bsize, oalign; 1238 headers( "resize", oaddr, header, freeElem, bsize, oalign ); 1239 size_t odsize = dataStorage( bsize, oaddr, header ); // data storage available in bucket 1240 1241 if ( oalign <= nalign && (uintptr_t)oaddr % nalign == 0 ) { // <= alignment and new alignment happens to match 1242 if ( oalign > libAlign() ) { // fake header ? 1224 // If size is equal to 0, either NULL or a pointer suitable to be passed to free() is returned. 1225 if ( unlikely( size == 0 ) ) { free( oaddr ); return 0p; } // special cases 1226 if ( unlikely( oaddr == 0p ) ) { 1227 #ifdef __STATISTICS__ 1228 __atomic_add_fetch( &resize_storage, size, __ATOMIC_SEQ_CST ); 1229 #endif // __STATISTICS__ 1230 return memalignNoStats( nalign, size ); 1231 } // if 1232 1233 // Attempt to reuse existing storage. 1234 HeapManager.Storage.Header * header = headerAddr( oaddr ); 1235 if ( unlikely ( ( header->kind.fake.alignment & 1 == 1 && // old fake header ? 1236 (uintptr_t)oaddr % nalign == 0 && // lucky match ? 1237 header->kind.fake.alignment <= nalign && // ok to leave LSB at 1 1238 nalign <= 128 ) // not too much alignment storage wasted ? 1239 || ( header->kind.fake.alignment & 1 != 1 && // old real header ( aligned on libAlign ) ? 1240 nalign == libAlign() ) ) ) { // new alignment also on libAlign 1241 1242 HeapManager.FreeHeader * freeElem; 1243 size_t bsize, oalign; 1244 headers( "resize", oaddr, header, freeElem, bsize, oalign ); 1245 size_t odsize = dataStorage( bsize, oaddr, header ); // data storage available in bucket 1246 1247 if ( size <= odsize && odsize <= size * 2 ) { // allow 50% wasted data storage 1243 1248 headerAddr( oaddr )->kind.fake.alignment = nalign | 1; // update alignment (could be the same) 1244 } // if 1245 if ( size <= odsize && odsize <= size * 2 ) { // allow 50% wasted storage for smaller size 1246 header->kind.real.blockSize &= -2; // turn off 0 fill 1247 header->kind.real.size = size; // reset allocation size 1249 1250 header->kind.real.blockSize &= -2; // turn off 0 fill 1251 header->kind.real.size = size; // reset allocation size 1248 1252 return oaddr; 1249 1253 } // if … … 1267 1271 #endif // __CFA_DEBUG__ 1268 1272 1273 // If size is equal to 0, either NULL or a pointer suitable to be passed to free() is returned. 1274 if ( unlikely( size == 0 ) ) { free( oaddr ); return 0p; } // special cases 1275 if ( unlikely( oaddr == 0p ) ) { 1276 #ifdef __STATISTICS__ 1277 __atomic_add_fetch( &realloc_calls, 1, __ATOMIC_SEQ_CST ); 1278 __atomic_add_fetch( &realloc_storage, size, __ATOMIC_SEQ_CST ); 1279 #endif // __STATISTICS__ 1280 return memalignNoStats( nalign, size ); 1281 } // if 1282 1269 1283 HeapManager.Storage.Header * header; 1270 1284 HeapManager.FreeHeader * freeElem; … … 1272 1286 headers( "realloc", oaddr, header, freeElem, bsize, oalign ); 1273 1287 1274 if ( oalign <= nalign && (uintptr_t)oaddr % nalign == 0 ) { // <= alignment and new alignment happens to match 1275 if ( oalign > libAlign() ) { // fake header ? 1276 headerAddr( oaddr )->kind.fake.alignment = nalign | 1; // update alignment (could be the same) 1277 } // if 1288 // Attempt to reuse existing storage. 1289 if ( unlikely ( ( header->kind.fake.alignment & 1 == 1 && // old fake header ? 1290 (uintptr_t)oaddr % nalign == 0 && // lucky match ? 1291 header->kind.fake.alignment <= nalign && // ok to leave LSB at 1 1292 nalign <= 128 ) // not too much alignment storage wasted ? 1293 || ( header->kind.fake.alignment & 1 != 1 && // old real header ( aligned on libAlign ) ? 1294 nalign == libAlign() ) ) ) { // new alignment also on libAlign 1295 1296 headerAddr( oaddr )->kind.fake.alignment = nalign | 1; // update alignment (could be the same) 1278 1297 return realloc( oaddr, size ); 1298 1279 1299 } // if 1280 1300 … … 1286 1306 #endif // __STATISTICS__ 1287 1307 1288 // If size is equal to 0, either NULL or a pointer suitable to be passed to free() is returned.1289 if ( unlikely( size == 0 ) ) { free( oaddr ); return 0p; } // special cases1290 if ( unlikely( oaddr == 0p ) ) return memalignNoStats( nalign, size );1291 1292 1308 size_t osize = header->kind.real.size; // old allocation size 1293 1309 bool ozfill = (header->kind.real.blockSize & 2) != 0; // old allocation zero filled … … 1296 1312 1297 1313 headers( "realloc", naddr, header, freeElem, bsize, oalign ); 1298 memcpy( naddr, oaddr, MIN( osize, size ) ); // copy bytes1314 memcpy( naddr, oaddr, min( osize, size ) ); // copy bytes 1299 1315 free( oaddr ); 1300 1316 -
libcfa/src/stdlib.hfa
r56c44dc rce55a81 10 10 // Created On : Thu Jan 28 17:12:35 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Aug 14 23:38:50202013 // Update Count : 50 412 // Last Modified On : Tue Sep 1 20:32:34 2020 13 // Update Count : 505 14 14 // 15 15 … … 44 44 45 45 // Macro because of returns 46 #define $VAR_ALLOC( allocation, alignment ) \47 if ( _Alignof(T) <= libAlign() ) return (T *)(void *)allocation( (size_t)sizeof(T) ); /* C allocation */ \48 else return (T *)alignment( _Alignof(T), sizeof(T) )49 50 46 #define $ARRAY_ALLOC( allocation, alignment, dim ) \ 51 47 if ( _Alignof(T) <= libAlign() ) return (T *)(void *)allocation( dim, (size_t)sizeof(T) ); /* C allocation */ \ 52 48 else return (T *)alignment( _Alignof(T), dim, sizeof(T) ) 53 49 54 #define $RE_SPECIALS( ptr, size, allocation, alignment ) \55 if ( unlikely( size == 0 ) || unlikely( ptr == 0p ) ) { \56 if ( unlikely( size == 0 ) ) free( ptr ); \57 $VAR_ALLOC( malloc, memalign ); \58 } /* if */59 60 50 static inline forall( dtype T | sized(T) ) { 61 51 // Cforall safe equivalents, i.e., implicit size specification 62 52 63 53 T * malloc( void ) { 64 $VAR_ALLOC( malloc, memalign ); 54 if ( _Alignof(T) <= libAlign() ) return (T *)(void *)malloc( (size_t)sizeof(T) ); // C allocation 55 else return (T *)memalign( _Alignof(T), sizeof(T) ); 65 56 } // malloc 66 57 … … 74 65 75 66 T * resize( T * ptr, size_t size ) { // CFA resize, eliminate return-type cast 76 $RE_SPECIALS( ptr, size, malloc, memalign );77 67 if ( _Alignof(T) <= libAlign() ) return (T *)(void *)resize( (void *)ptr, size ); // CFA resize 78 68 else return (T *)(void *)resize( (void *)ptr, _Alignof(T), size ); // CFA resize … … 80 70 81 71 T * realloc( T * ptr, size_t size ) { // CFA realloc, eliminate return-type cast 82 $RE_SPECIALS( ptr, size, malloc, memalign );83 72 if ( _Alignof(T) <= libAlign() ) return (T *)(void *)realloc( (void *)ptr, size ); // C realloc 84 73 else return (T *)(void *)realloc( (void *)ptr, _Alignof(T), size ); // CFA realloc … … 189 178 size_t copy_end = 0; 190 179 191 if (Resize) {192 ptr = (T*) (void *) resize( ( int*)Resize, Align, Dim * size );193 } else if ( Realloc) {180 if ( Resize ) { 181 ptr = (T*) (void *) resize( (void *)Resize, Align, Dim * size ); 182 } else if ( Realloc ) { 194 183 if (Fill.tag != '0') copy_end = min(malloc_size( Realloc ), Dim * size); 195 ptr = (T*) (void *) realloc( ( int*)Realloc, Align, Dim * size );184 ptr = (T*) (void *) realloc( (void *)Realloc, Align, Dim * size ); 196 185 } else { 197 186 ptr = (T*) (void *) memalign( Align, Dim * size ); … … 201 190 memset( (char *)ptr + copy_end, (int)Fill.c, Dim * size - copy_end ); 202 191 } else if(Fill.tag == 't') { 203 for ( int i = copy_end; i < = Dim * size - size; i += size ) {192 for ( int i = copy_end; i < Dim * size; i += size ) { 204 193 memcpy( (char *)ptr + i, &Fill.t, size ); 205 194 } … … 207 196 memcpy( (char *)ptr + copy_end, Fill.at, min(Dim * size - copy_end, Fill.size) ); 208 197 } else if(Fill.tag == 'T') { 209 for ( int i = copy_end; i < = Dim * size - size; i += size ) {198 for ( int i = copy_end; i < Dim * size; i += size ) { 210 199 memcpy( (char *)ptr + i, Fill.at, size ); 211 200 } -
src/AST/Convert.cpp
r56c44dc rce55a81 705 705 new KeywordCastExpr( 706 706 get<Expression>().accept1(node->arg), 707 castTarget 707 castTarget, 708 {node->concrete_target.field, node->concrete_target.getter} 708 709 ) 709 710 ); … … 2087 2088 old->location, 2088 2089 GET_ACCEPT_1(arg, Expr), 2089 castTarget 2090 castTarget, 2091 {old->concrete_target.field, old->concrete_target.getter} 2090 2092 ) 2091 2093 ); -
src/AST/Copy.hpp
r56c44dc rce55a81 21 21 #include "Stmt.hpp" 22 22 #include "Type.hpp" 23 #include <unordered_set> 24 #include <unordered_map> 23 25 24 26 namespace ast { -
src/AST/Expr.hpp
r56c44dc rce55a81 312 312 public: 313 313 ptr<Expr> arg; 314 struct Concrete { 315 std::string field; 316 std::string getter; 317 318 Concrete() = default; 319 Concrete(const Concrete &) = default; 320 }; 314 321 ast::AggregateDecl::Aggregate target; 322 Concrete concrete_target; 323 315 324 316 325 KeywordCastExpr( const CodeLocation & loc, const Expr * a, ast::AggregateDecl::Aggregate t ) 317 326 : Expr( loc ), arg( a ), target( t ) {} 327 328 KeywordCastExpr( const CodeLocation & loc, const Expr * a, ast::AggregateDecl::Aggregate t, const Concrete & ct ) 329 : Expr( loc ), arg( a ), target( t ), concrete_target( ct ) {} 318 330 319 331 /// Get a name for the target type -
src/AST/Pass.hpp
r56c44dc rce55a81 48 48 // 49 49 // Several additional features are available through inheritance 50 // | PureVisitor - makes the visitor pure, it never modifies nodes in place and always 51 // clones nodes it needs to make changes to 50 52 // | WithTypeSubstitution - provides polymorphic const TypeSubstitution * env for the 51 53 // current expression … … 266 268 267 269 /// Keep track of the polymorphic const TypeSubstitution * env for the current expression 270 271 /// If used the visitor will always clone nodes. 272 struct PureVisitor {}; 273 268 274 struct WithConstTypeSubstitution { 269 275 const TypeSubstitution * env = nullptr; -
src/AST/Pass.impl.hpp
r56c44dc rce55a81 57 57 58 58 namespace ast { 59 template<typename node_t> 60 node_t * shallowCopy( const node_t * node ); 61 59 62 namespace __pass { 60 63 // Check if this is either a null pointer or a pointer to an empty container … … 62 65 static inline bool empty( T * ptr ) { 63 66 return !ptr || ptr->empty(); 67 } 68 69 template< typename core_t, typename node_t > 70 static inline node_t* mutate(const node_t *node) { 71 return std::is_base_of<PureVisitor, core_t>::value ? ::ast::shallowCopy(node) : ::ast::mutate(node); 64 72 } 65 73 … … 320 328 321 329 if( __pass::differs(old_val, new_val) ) { 322 auto new_parent = mutate(parent);330 auto new_parent = __pass::mutate<core_t>(parent); 323 331 new_parent->*child = new_val; 324 332 parent = new_parent; … … 334 342 if ( node->forall.empty() ) return; 335 343 336 node_t * mut = mutate( node );344 node_t * mut = __pass::mutate<core_t>( node ); 337 345 mut->forall = subs->clone( node->forall, *this ); 338 346 node = mut; … … 894 902 895 903 if(mutated) { 896 auto n = mutate(node);904 auto n = __pass::mutate<core_t>(node); 897 905 n->clauses = std::move( new_clauses ); 898 906 node = n; … … 904 912 auto nval = call_accept( node->field ); \ 905 913 if(nval != node->field ) { \ 906 auto nparent = mutate(node); \914 auto nparent = __pass::mutate<core_t>(node); \ 907 915 nparent->field = nval; \ 908 916 node = nparent; \ … … 1610 1618 1611 1619 if(mutated) { 1612 auto n = mutate(node);1620 auto n = __pass::mutate<core_t>(node); 1613 1621 n->associations = std::move( new_kids ); 1614 1622 node = n; … … 1940 1948 } 1941 1949 if (mutated) { 1942 auto new_node = mutate( node );1950 auto new_node = __pass::mutate<core_t>( node ); 1943 1951 new_node->typeEnv.swap( new_map ); 1944 1952 node = new_node; … … 1956 1964 } 1957 1965 if (mutated) { 1958 auto new_node = mutate( node );1966 auto new_node = __pass::mutate<core_t>( node ); 1959 1967 new_node->varEnv.swap( new_map ); 1960 1968 node = new_node; -
src/AST/Pass.proto.hpp
r56c44dc rce55a81 22 22 template<typename core_t> 23 23 class Pass; 24 25 struct PureVisitor; 24 26 25 27 namespace __pass { -
src/AST/Print.cpp
r56c44dc rce55a81 21 21 #include "Type.hpp" 22 22 #include "TypeSubstitution.hpp" 23 #include "CompilationState.h" 23 24 24 25 #include "Common/utility.h" // for group_iterate … … 239 240 240 241 if ( node->result ) { 241 os << endl << indent << "... with resolved type:" << endl; 242 ++indent; 243 os << indent; 244 node->result->accept( *this ); 245 --indent; 242 if (!deterministic_output) { 243 os << endl << indent << "... with resolved type:" << endl; 244 ++indent; 245 os << indent; 246 node->result->accept( *this ); 247 --indent; 248 } 246 249 } 247 250 -
src/AST/TypeSubstitution.hpp
r56c44dc rce55a81 46 46 template< typename SynTreeClass > 47 47 struct ApplyResult { 48 // const SynTreeClass * node;49 48 ast::ptr<SynTreeClass> node; 50 49 int count; … … 159 158 160 159 // definitition must happen after PassVisitor is included so that WithGuards can be used 161 struct TypeSubstitution::Substituter : public WithGuards, public WithVisitorRef<Substituter> {160 struct TypeSubstitution::Substituter : public WithGuards, public WithVisitorRef<Substituter>, public PureVisitor { 162 161 static size_t traceId; 163 162 … … 187 186 assert( input ); 188 187 Pass<Substituter> sub( *this, false ); 189 input = strict_dynamic_cast< const SynTreeClass * >( deepCopy(input)->accept( sub ) );188 input = strict_dynamic_cast< const SynTreeClass * >( input->accept( sub ) ); 190 189 return { input, sub.core.subCount }; 191 190 } … … 195 194 assert( input ); 196 195 Pass<Substituter> sub( *this, true ); 197 input = strict_dynamic_cast< const SynTreeClass * >( deepCopy(input)->accept( sub ) );196 input = strict_dynamic_cast< const SynTreeClass * >( input->accept( sub ) ); 198 197 return { input, sub.core.subCount }; 199 198 } -
src/AST/module.mk
r56c44dc rce55a81 17 17 SRC_AST = \ 18 18 AST/AssertAcyclic.cpp \ 19 AST/AssertAcyclic.hpp \ 19 20 AST/Attribute.cpp \ 21 AST/Attribute.hpp \ 22 AST/Bitfield.hpp \ 23 AST/Chain.hpp \ 20 24 AST/Convert.cpp \ 25 AST/Convert.hpp \ 26 AST/Copy.hpp \ 27 AST/CVQualifiers.hpp \ 21 28 AST/Decl.cpp \ 29 AST/Decl.hpp \ 22 30 AST/DeclReplacer.cpp \ 31 AST/DeclReplacer.hpp \ 32 AST/Eval.hpp \ 23 33 AST/Expr.cpp \ 34 AST/Expr.hpp \ 24 35 AST/ForallSubstitutionTable.cpp \ 36 AST/ForallSubstitutionTable.hpp \ 37 AST/ForallSubstitutor.hpp \ 38 AST/FunctionSpec.hpp \ 39 AST/Fwd.hpp \ 25 40 AST/GenericSubstitution.cpp \ 41 AST/GenericSubstitution.hpp \ 26 42 AST/Init.cpp \ 43 AST/Init.hpp \ 44 AST/Label.hpp \ 27 45 AST/LinkageSpec.cpp \ 46 AST/LinkageSpec.hpp \ 28 47 AST/Node.cpp \ 48 AST/Node.hpp \ 49 AST/ParseNode.hpp \ 29 50 AST/Pass.cpp \ 51 AST/Pass.hpp \ 52 AST/Pass.impl.hpp \ 53 AST/Pass.proto.hpp \ 30 54 AST/Print.cpp \ 55 AST/Print.hpp \ 31 56 AST/Stmt.cpp \ 57 AST/Stmt.hpp \ 58 AST/StorageClasses.hpp \ 32 59 AST/SymbolTable.cpp \ 60 AST/SymbolTable.hpp \ 33 61 AST/Type.cpp \ 62 AST/Type.hpp \ 34 63 AST/TypeEnvironment.cpp \ 35 AST/TypeSubstitution.cpp 64 AST/TypeEnvironment.hpp \ 65 AST/TypeSubstitution.cpp \ 66 AST/TypeSubstitution.hpp \ 67 AST/Visitor.hpp 36 68 37 69 SRC += $(SRC_AST) -
src/CodeGen/module.mk
r56c44dc rce55a81 20 20 SRC_CODEGEN = \ 21 21 CodeGen/CodeGenerator.cc \ 22 CodeGen/CodeGenerator.h \ 22 23 CodeGen/FixMain.cc \ 24 CodeGen/FixMain.h \ 23 25 CodeGen/GenType.cc \ 24 CodeGen/OperatorTable.cc 26 CodeGen/GenType.h \ 27 CodeGen/OperatorTable.cc \ 28 CodeGen/OperatorTable.h \ 29 CodeGen/Options.h 25 30 26 SRC += $(SRC_CODEGEN) CodeGen/Generate.cc CodeGen/ FixNames.cc31 SRC += $(SRC_CODEGEN) CodeGen/Generate.cc CodeGen/Generate.h CodeGen/FixNames.cc CodeGen/FixNames.h 27 32 SRCDEMANGLE += $(SRC_CODEGEN) -
src/CodeTools/module.mk
r56c44dc rce55a81 15 15 ############################################################################### 16 16 17 SRC += CodeTools/DeclStats.cc \ 17 SRC += \ 18 CodeTools/DeclStats.cc \ 19 CodeTools/DeclStats.h \ 18 20 CodeTools/ResolvProtoDump.cc \ 19 CodeTools/TrackLoc.cc 21 CodeTools/ResolvProtoDump.h \ 22 CodeTools/TrackLoc.cc \ 23 CodeTools/TrackLoc.h -
src/Common/module.mk
r56c44dc rce55a81 17 17 SRC_COMMON = \ 18 18 Common/Assert.cc \ 19 Common/CodeLocation.h \ 20 Common/CompilerError.h \ 21 Common/Debug.h \ 22 Common/ErrorObjects.h \ 19 23 Common/Eval.cc \ 24 Common/FilterCombos.h \ 25 Common/Indenter.h \ 20 26 Common/PassVisitor.cc \ 27 Common/PassVisitor.h \ 28 Common/PassVisitor.impl.h \ 29 Common/PassVisitor.proto.h \ 30 Common/PersistentMap.h \ 31 Common/ScopedMap.h \ 21 32 Common/SemanticError.cc \ 33 Common/SemanticError.h \ 34 Common/Stats.h \ 35 Common/Stats/Base.h \ 22 36 Common/Stats/Counter.cc \ 37 Common/Stats/Counter.h \ 23 38 Common/Stats/Heap.cc \ 39 Common/Stats/Heap.h \ 24 40 Common/Stats/Stats.cc \ 25 41 Common/Stats/Time.cc \ 26 Common/UniqueName.cc 42 Common/Stats/Time.h \ 43 Common/UnimplementedError.h \ 44 Common/UniqueName.cc \ 45 Common/UniqueName.h \ 46 Common/utility.h \ 47 Common/VectorMap.h 27 48 28 49 SRC += $(SRC_COMMON) Common/DebugMalloc.cc -
src/Concurrency/module.mk
r56c44dc rce55a81 15 15 ############################################################################### 16 16 17 SRC += Concurrency/Keywords.cc Concurrency/ Waitfor.cc17 SRC += Concurrency/Keywords.cc Concurrency/Keywords.h Concurrency/Waitfor.cc Concurrency/Waitfor.h 18 18 SRCDEMANGLE += Concurrency/Keywords.cc 19 19 -
src/ControlStruct/module.mk
r56c44dc rce55a81 17 17 SRC_CONTROLSTRUCT = \ 18 18 ControlStruct/ForExprMutator.cc \ 19 ControlStruct/ForExprMutator.h \ 19 20 ControlStruct/LabelFixer.cc \ 21 ControlStruct/LabelFixer.h \ 20 22 ControlStruct/LabelGenerator.cc \ 23 ControlStruct/LabelGenerator.h \ 21 24 ControlStruct/MLEMutator.cc \ 22 ControlStruct/Mutate.cc 25 ControlStruct/MLEMutator.h \ 26 ControlStruct/Mutate.cc \ 27 ControlStruct/Mutate.h 23 28 24 SRC += $(SRC_CONTROLSTRUCT) ControlStruct/ExceptTranslate.cc 29 SRC += $(SRC_CONTROLSTRUCT) ControlStruct/ExceptTranslate.cc ControlStruct/ExceptTranslate.h 25 30 SRCDEMANGLE += $(SRC_CONTROLSTRUCT) 26 31 -
src/GenPoly/module.mk
r56c44dc rce55a81 16 16 17 17 SRC += GenPoly/Box.cc \ 18 GenPoly/Box.h \ 19 GenPoly/ErasableScopedMap.h \ 20 GenPoly/FindFunction.cc \ 21 GenPoly/FindFunction.h \ 18 22 GenPoly/GenPoly.cc \ 23 GenPoly/GenPoly.h \ 24 GenPoly/InstantiateGeneric.cc \ 25 GenPoly/InstantiateGeneric.h \ 26 GenPoly/Lvalue.cc \ 27 GenPoly/Lvalue.h \ 28 GenPoly/ScopedSet.h \ 19 29 GenPoly/ScrubTyVars.cc \ 20 GenPoly/ Lvalue.cc\30 GenPoly/ScrubTyVars.h \ 21 31 GenPoly/Specialize.cc \ 22 GenPoly/FindFunction.cc \ 23 GenPoly/InstantiateGeneric.cc 32 GenPoly/Specialize.h 24 33 25 SRCDEMANGLE += GenPoly/GenPoly.cc GenPoly/ Lvalue.cc34 SRCDEMANGLE += GenPoly/GenPoly.cc GenPoly/GenPoly.h GenPoly/Lvalue.cc GenPoly/Lvalue.h 26 35 -
src/InitTweak/module.mk
r56c44dc rce55a81 15 15 ############################################################################### 16 16 17 SRC += InitTweak/GenInit.cc \ 17 SRC += \ 18 InitTweak/FixGlobalInit.cc \ 19 InitTweak/FixGlobalInit.h \ 18 20 InitTweak/FixInit.cc \ 19 InitTweak/FixGlobalInit.cc \ 20 InitTweak/InitTweak.cc 21 InitTweak/FixInit.h \ 22 InitTweak/GenInit.cc \ 23 InitTweak/GenInit.h \ 24 InitTweak/InitTweak.cc \ 25 InitTweak/InitTweak.h 21 26 22 SRCDEMANGLE += InitTweak/GenInit.cc \ 23 InitTweak/InitTweak.cc 27 SRCDEMANGLE += \ 28 InitTweak/GenInit.cc \ 29 InitTweak/GenInit.h \ 30 InitTweak/InitTweak.cc \ 31 InitTweak/InitTweak.h 24 32 -
src/Makefile.am
r56c44dc rce55a81 20 20 21 21 SRC = main.cc \ 22 CompilationState.cc \ 23 CompilationState.h \ 22 24 MakeLibCfa.cc \ 23 CompilationState.cc 25 MakeLibCfa.h 24 26 25 27 SRCDEMANGLE = CompilationState.cc … … 66 68 ___driver_cfa_cpp_SOURCES = $(SRC) 67 69 ___driver_cfa_cpp_LDADD = -ldl $(LIBPROFILER) $(LIBTCMALLOC) 70 EXTRA_DIST = include/cassert include/optional BasicTypes-gen.cc 68 71 69 72 AM_CXXFLAGS = @HOST_FLAGS@ -Wno-deprecated -Wall -Wextra -DDEBUG_ALL -I./Parser -I$(srcdir)/Parser -I$(srcdir)/include -DYY_NO_INPUT -O3 -g -std=c++14 $(TCMALLOCFLAG) -
src/Parser/module.mk
r56c44dc rce55a81 23 23 Parser/ExpressionNode.cc \ 24 24 Parser/InitializerNode.cc \ 25 Parser/lex.ll \ 25 26 Parser/ParseNode.cc \ 27 Parser/ParseNode.h \ 28 Parser/parser.yy \ 29 Parser/ParserTypes.h \ 30 Parser/parserutility.cc \ 31 Parser/parserutility.h \ 26 32 Parser/StatementNode.cc \ 27 33 Parser/TypeData.cc \ 34 Parser/TypeData.h \ 28 35 Parser/TypedefTable.cc \ 29 Parser/lex.ll \ 30 Parser/parser.yy \ 31 Parser/parserutility.cc 36 Parser/TypedefTable.h 32 37 33 38 MOSTLYCLEANFILES += Parser/lex.cc Parser/parser.cc Parser/parser.hh Parser/parser.output -
src/ResolvExpr/CandidateFinder.cpp
r56c44dc rce55a81 1089 1089 } 1090 1090 1091 void postvisit( const ast::KeywordCastExpr * castExpr ) { 1092 const auto & loc = castExpr->location; 1093 assertf( castExpr->result, "Cast target should have been set in Validate." ); 1094 auto ref = castExpr->result.strict_as<ast::ReferenceType>(); 1095 auto inst = ref->base.strict_as<ast::StructInstType>(); 1096 auto target = inst->base.get(); 1097 1098 CandidateFinder finder{ symtab, tenv }; 1099 1100 auto pick_alternatives = [target, this](CandidateList & found, bool expect_ref) { 1101 for(auto & cand : found) { 1102 const ast::Type * expr = cand->expr->result.get(); 1103 if(expect_ref) { 1104 auto res = dynamic_cast<const ast::ReferenceType*>(expr); 1105 if(!res) { continue; } 1106 expr = res->base.get(); 1107 } 1108 1109 if(auto insttype = dynamic_cast<const ast::TypeInstType*>(expr)) { 1110 auto td = cand->env.lookup(insttype->name); 1111 if(!td) { continue; } 1112 expr = td->bound.get(); 1113 } 1114 1115 if(auto base = dynamic_cast<const ast::StructInstType*>(expr)) { 1116 if(base->base == target) { 1117 candidates.push_back( std::move(cand) ); 1118 reason.code = NoReason; 1119 } 1120 } 1121 } 1122 }; 1123 1124 try { 1125 // Attempt 1 : turn (thread&)X into ($thread&)X.__thrd 1126 // Clone is purely for memory management 1127 std::unique_ptr<const ast::Expr> tech1 { new ast::UntypedMemberExpr(loc, new ast::NameExpr(loc, castExpr->concrete_target.field), castExpr->arg) }; 1128 1129 // don't prune here, since it's guaranteed all alternatives will have the same type 1130 finder.find( tech1.get(), ResolvMode::withoutPrune() ); 1131 pick_alternatives(finder.candidates, false); 1132 1133 return; 1134 } catch(SemanticErrorException & ) {} 1135 1136 // Fallback : turn (thread&)X into ($thread&)get_thread(X) 1137 std::unique_ptr<const ast::Expr> fallback { ast::UntypedExpr::createDeref(loc, new ast::UntypedExpr(loc, new ast::NameExpr(loc, castExpr->concrete_target.getter), { castExpr->arg })) }; 1138 // don't prune here, since it's guaranteed all alternatives will have the same type 1139 finder.find( fallback.get(), ResolvMode::withoutPrune() ); 1140 1141 pick_alternatives(finder.candidates, true); 1142 1143 // Whatever happens here, we have no more fallbacks 1144 } 1145 1091 1146 void postvisit( const ast::UntypedMemberExpr * memberExpr ) { 1092 1147 CandidateFinder aggFinder{ symtab, tenv }; -
src/ResolvExpr/Unify.cc
r56c44dc rce55a81 767 767 /// If this isn't done when satifying ttype assertions, then argument lists can have 768 768 /// different size and structure when they should be compatible. 769 struct TtypeExpander_new : public ast::WithShortCircuiting {769 struct TtypeExpander_new : public ast::WithShortCircuiting, public ast::PureVisitor { 770 770 ast::TypeEnvironment & tenv; 771 771 … … 793 793 // TtypeExpander pass is impure (may mutate nodes in place) 794 794 // need to make nodes shared to prevent accidental mutation 795 ast::ptr<ast::DeclWithType> dc = d; 796 dc = dc->accept( expander ); 795 ast::ptr<ast::DeclWithType> dc = d->accept(expander); 797 796 auto types = flatten( dc->get_type() ); 798 797 for ( ast::ptr< ast::Type > & t : types ) { … … 1114 1113 ast::Pass<TtypeExpander_new> expander{ tenv }; 1115 1114 1116 ast::ptr<ast::TupleType> tuplec = tuple; 1117 ast::ptr<ast::TupleType> tuple2c = tuple2; 1118 const ast::Type * flat = tuplec->accept( expander ); 1119 const ast::Type * flat2 = tuple2c->accept( expander ); 1115 const ast::Type * flat = tuple->accept( expander ); 1116 const ast::Type * flat2 = tuple2->accept( expander ); 1120 1117 1121 1118 auto types = flatten( flat ); -
src/ResolvExpr/module.mk
r56c44dc rce55a81 19 19 ResolvExpr/Alternative.cc \ 20 20 ResolvExpr/AlternativeFinder.cc \ 21 ResolvExpr/AlternativeFinder.h \ 22 ResolvExpr/Alternative.h \ 21 23 ResolvExpr/Candidate.cpp \ 22 24 ResolvExpr/CandidateFinder.cpp \ 25 ResolvExpr/CandidateFinder.hpp \ 26 ResolvExpr/Candidate.hpp \ 23 27 ResolvExpr/CastCost.cc \ 24 28 ResolvExpr/CommonType.cc \ 25 29 ResolvExpr/ConversionCost.cc \ 30 ResolvExpr/ConversionCost.h \ 31 ResolvExpr/Cost.h \ 26 32 ResolvExpr/CurrentObject.cc \ 33 ResolvExpr/CurrentObject.h \ 27 34 ResolvExpr/ExplodedActual.cc \ 35 ResolvExpr/ExplodedActual.h \ 28 36 ResolvExpr/ExplodedArg.cpp \ 37 ResolvExpr/ExplodedArg.hpp \ 29 38 ResolvExpr/FindOpenVars.cc \ 39 ResolvExpr/FindOpenVars.h \ 30 40 ResolvExpr/Occurs.cc \ 31 41 ResolvExpr/PolyCost.cc \ … … 33 43 ResolvExpr/PtrsCastable.cc \ 34 44 ResolvExpr/RenameVars.cc \ 45 ResolvExpr/RenameVars.h \ 35 46 ResolvExpr/ResolveAssertions.cc \ 47 ResolvExpr/ResolveAssertions.h \ 36 48 ResolvExpr/Resolver.cc \ 49 ResolvExpr/Resolver.h \ 37 50 ResolvExpr/ResolveTypeof.cc \ 51 ResolvExpr/ResolveTypeof.h \ 52 ResolvExpr/ResolvMode.h \ 38 53 ResolvExpr/SatisfyAssertions.cpp \ 54 ResolvExpr/SatisfyAssertions.hpp \ 39 55 ResolvExpr/SpecCost.cc \ 40 56 ResolvExpr/TypeEnvironment.cc \ 41 ResolvExpr/Unify.cc 57 ResolvExpr/TypeEnvironment.h \ 58 ResolvExpr/typeops.h \ 59 ResolvExpr/Unify.cc \ 60 ResolvExpr/Unify.h \ 61 ResolvExpr/WidenMode.h 42 62 43 SRC += $(SRC_RESOLVEXPR) ResolvExpr/AlternativePrinter.cc 63 64 SRC += $(SRC_RESOLVEXPR) ResolvExpr/AlternativePrinter.cc ResolvExpr/AlternativePrinter.h 44 65 SRCDEMANGLE += $(SRC_RESOLVEXPR) -
src/SymTab/module.mk
r56c44dc rce55a81 17 17 SRC_SYMTAB = \ 18 18 SymTab/Autogen.cc \ 19 SymTab/Autogen.h \ 19 20 SymTab/FixFunction.cc \ 21 SymTab/FixFunction.h \ 20 22 SymTab/Indexer.cc \ 23 SymTab/Indexer.h \ 21 24 SymTab/Mangler.cc \ 22 25 SymTab/ManglerCommon.cc \ 23 SymTab/Validate.cc 26 SymTab/Mangler.h \ 27 SymTab/Validate.cc \ 28 SymTab/Validate.h 24 29 25 30 SRC += $(SRC_SYMTAB) -
src/SynTree/Expression.cc
r56c44dc rce55a81 30 30 #include "Type.h" // for Type, BasicType, Type::Qualifiers 31 31 #include "TypeSubstitution.h" // for TypeSubstitution 32 #include "CompilationState.h" // for deterministic_output 32 33 33 34 #include "GenPoly/Lvalue.h" … … 71 72 72 73 if ( result ) { 73 os << std::endl << indent << "with resolved type:" << std::endl; 74 os << (indent+1); 75 result->print( os, indent+1 ); 74 if (!deterministic_output) { 75 os << std::endl << indent << "with resolved type:" << std::endl; 76 os << (indent+1); 77 result->print( os, indent+1 ); 78 } 76 79 } 77 80 … … 299 302 } 300 303 301 KeywordCastExpr::KeywordCastExpr( Expression * arg, AggregateDecl::Aggregate target ) : Expression(), arg(arg), target( target ) { 302 } 303 304 KeywordCastExpr::KeywordCastExpr( const KeywordCastExpr & other ) : Expression( other ), arg( maybeClone( other.arg ) ), target( other.target ) { 305 } 304 KeywordCastExpr::KeywordCastExpr( Expression * arg, AggregateDecl::Aggregate target ) : Expression(), arg(arg), target( target ) {} 305 KeywordCastExpr::KeywordCastExpr( Expression * arg, AggregateDecl::Aggregate target, const KeywordCastExpr::Concrete & concrete_target ) : Expression(), arg(arg), target( target ), concrete_target(concrete_target) {} 306 307 KeywordCastExpr::KeywordCastExpr( const KeywordCastExpr & other ) : Expression( other ), arg( maybeClone( other.arg ) ), target( other.target ) {} 306 308 307 309 KeywordCastExpr::~KeywordCastExpr() { -
src/SynTree/Expression.h
r56c44dc rce55a81 248 248 249 249 KeywordCastExpr( Expression * arg, AggregateDecl::Aggregate target ); 250 KeywordCastExpr( Expression * arg, AggregateDecl::Aggregate target, const Concrete & concrete_target ); 250 251 KeywordCastExpr( const KeywordCastExpr & other ); 251 252 virtual ~KeywordCastExpr(); -
src/SynTree/module.mk
r56c44dc rce55a81 20 20 SynTree/ApplicationExpr.cc \ 21 21 SynTree/ArrayType.cc \ 22 SynTree/Attribute.cc \ 23 SynTree/Attribute.h \ 22 24 SynTree/AttrType.cc \ 23 SynTree/ Attribute.cc\25 SynTree/BaseSyntaxNode.h \ 24 26 SynTree/BasicType.cc \ 25 27 SynTree/CommaExpr.cc \ 26 28 SynTree/CompoundStmt.cc \ 27 29 SynTree/Constant.cc \ 30 SynTree/Constant.h \ 31 SynTree/Declaration.cc \ 32 SynTree/Declaration.h \ 33 SynTree/DeclarationWithType.cc \ 28 34 SynTree/DeclReplacer.cc \ 35 SynTree/DeclReplacer.h \ 29 36 SynTree/DeclStmt.cc \ 30 SynTree/Declaration.cc \31 SynTree/DeclarationWithType.cc \32 37 SynTree/Expression.cc \ 38 SynTree/Expression.h \ 33 39 SynTree/FunctionDecl.cc \ 34 40 SynTree/FunctionType.cc \ 35 41 SynTree/Initializer.cc \ 42 SynTree/Initializer.h \ 43 SynTree/Label.h \ 36 44 SynTree/LinkageSpec.cc \ 45 SynTree/LinkageSpec.h \ 46 SynTree/Mutator.h \ 37 47 SynTree/NamedTypeDecl.cc \ 38 48 SynTree/ObjectDecl.cc \ … … 41 51 SynTree/ReferenceType.cc \ 42 52 SynTree/Statement.cc \ 53 SynTree/Statement.h \ 54 SynTree/SynTree.h \ 43 55 SynTree/TupleExpr.cc \ 44 56 SynTree/TupleType.cc \ … … 46 58 SynTree/TypeDecl.cc \ 47 59 SynTree/TypeExpr.cc \ 60 SynTree/Type.h \ 61 SynTree/TypeofType.cc \ 48 62 SynTree/TypeSubstitution.cc \ 49 SynTree/Type ofType.cc\63 SynTree/TypeSubstitution.h \ 50 64 SynTree/VarArgsType.cc \ 65 SynTree/Visitor.h \ 51 66 SynTree/VoidType.cc \ 52 67 SynTree/ZeroOneType.cc -
src/Tuples/module.mk
r56c44dc rce55a81 15 15 ############################################################################### 16 16 17 SRC += Tuples/TupleAssignment.cc Tuples/TupleExpansion.cc Tuples/Explode.cc \ 18 Tuples/Tuples.cc 19 SRCDEMANGLE += Tuples/TupleAssignment.cc Tuples/TupleExpansion.cc Tuples/Explode.cc \ 20 Tuples/Tuples.cc 17 SRC_TUPLES = \ 18 Tuples/Explode.cc \ 19 Tuples/Explode.h \ 20 Tuples/TupleAssignment.cc \ 21 Tuples/TupleExpansion.cc \ 22 Tuples/Tuples.cc \ 23 Tuples/Tuples.h 24 25 26 SRC += $(SRC_TUPLES) 27 SRCDEMANGLE += $(SRC_TUPLES) -
src/Validate/module.mk
r56c44dc rce55a81 15 15 ############################################################################### 16 16 17 SRC += Validate/HandleAttributes.cc Validate/ FindSpecialDecls.cc18 SRCDEMANGLE += Validate/HandleAttributes.cc Validate/ FindSpecialDecls.cc17 SRC += Validate/HandleAttributes.cc Validate/HandleAttributes.h Validate/FindSpecialDecls.cc Validate/FindSpecialDecls.h 18 SRCDEMANGLE += Validate/HandleAttributes.cc Validate/HandleAttributes.h Validate/FindSpecialDecls.cc Validate/FindSpecialDecls.h -
src/Virtual/module.mk
r56c44dc rce55a81 15 15 ############################################################################### 16 16 17 SRC += Virtual/ExpandCasts.cc 17 SRC += Virtual/ExpandCasts.cc Virtual/ExpandCasts.h -
tests/.expect/alloc-ERROR.txt
r56c44dc rce55a81 1 alloc.cfa:36 2:1 error: No reasonable alternatives for expression Applying untyped:1 alloc.cfa:361:1 error: No reasonable alternatives for expression Applying untyped: 2 2 Name: ?=? 3 3 ...to: … … 16 16 Name: stp 17 17 18 with resolved type:19 unsigned long int20 18 21 19 22 20 23 alloc.cfa:36 3:1 error: No reasonable alternatives for expression Applying untyped:21 alloc.cfa:362:1 error: No reasonable alternatives for expression Applying untyped: 24 22 Name: ?=? 25 23 ...to: … … 30 28 Name: stp 31 29 constant expression (10 10: signed int) 32 with resolved type:33 signed int34 30 35 31 36 alloc.cfa:36 4:1 error: No reasonable alternatives for expression Applying untyped:32 alloc.cfa:363:1 error: No reasonable alternatives for expression Applying untyped: 37 33 Name: ?=? 38 34 ...to: -
tests/.expect/alloc.txt
r56c44dc rce55a81 14 14 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 15 15 CFA array alloc, fill 0xef 16 0x efefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef16 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 17 17 CFA array alloc, fill from array 18 0x efefefef 0xefefefef, 0xefefefef 0xefefefef, 0xefefefef 0xefefefef, 0xefefefef 0xefefefef, 0xefefefef 0xefefefef, 0xefefefef 0xefefefef, 0xefefefef 0xefefefef, 0xefefefef 0xefefefef, 0xefefefef 0xefefefef, 0xefefefef 0xefefefef, 0xefefefef 0xefefefef, 0xefefefef 0xefefefef, 0xefefefef 0xefefefef, 0xefefefef 0xefefefef, 0xefefefef 0xefefefef, 0xefefefef 0xefefefef, 0xefefefef 0xefefefef, 0xefefefef 0xefefefef, 0xefefefef 0xefefefef, 0xefefefef 0xefefefef,18 0xdeadbeef 0xdeadbeef, 0xdeadbeef 0xdeadbeef, 0xdeadbeef 0xdeadbeef, 0xdeadbeef 0xdeadbeef, 0xdeadbeef 0xdeadbeef, 0xdeadbeef 0xdeadbeef, 0xdeadbeef 0xdeadbeef, 0xdeadbeef 0xdeadbeef, 0xdeadbeef 0xdeadbeef, 0xdeadbeef 0xdeadbeef, 0xdeadbeef 0xdeadbeef, 0xdeadbeef 0xdeadbeef, 0xdeadbeef 0xdeadbeef, 0xdeadbeef 0xdeadbeef, 0xdeadbeef 0xdeadbeef, 0xdeadbeef 0xdeadbeef, 0xdeadbeef 0xdeadbeef, 0xdeadbeef 0xdeadbeef, 0xdeadbeef 0xdeadbeef, 0xdeadbeef 0xdeadbeef, 19 19 20 20 C realloc 21 0x efefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef21 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 22 22 CFA realloc 23 0x efefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x101010123 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 24 24 25 25 CFA realloc array alloc -
tests/.expect/castError.txt
r56c44dc rce55a81 3 3 Name: f 4 4 ... to: 5 char6 with resolved type:7 5 char Alternatives are: 8 6 Cost ( 1, 0, 0, 0, 0, 0, 0 ): Explicit Cast of: … … 11 9 ... returning nothing 12 10 13 with resolved type:14 pointer to function15 accepting unspecified arguments16 ... returning nothing17 18 11 ... to: 19 char20 with resolved type:21 12 char 22 13 (types: … … 27 18 Cost ( 1, 0, 0, 0, 0, 0, 0 ): Explicit Cast of: 28 19 Variable Expression: f: double 29 with resolved type:30 double31 20 ... to: 32 char33 with resolved type:34 21 char 35 22 (types: … … 40 27 Cost ( 1, 0, 0, 0, 0, 0, 0 ): Explicit Cast of: 41 28 Variable Expression: f: signed int 42 with resolved type:43 signed int44 29 ... to: 45 char46 with resolved type:47 30 char 48 31 (types: … … 56 39 Comma Expression: 57 40 constant expression (3 3: signed int) 58 with resolved type:59 signed int60 41 Name: v 61 ... to: nothing 62 with resolved type: 63 void Alternatives are: 42 ... to: nothing Alternatives are: 64 43 Cost ( 0, 0, 2, 0, 0, 0, 0 ): Generated Cast of: 65 44 Comma Expression: 66 45 constant expression (3 3: signed int) 67 with resolved type:68 signed int69 46 Variable Expression: v: unsigned char 70 with resolved type:71 unsigned char72 with resolved type:73 unsigned char74 47 ... to: nothing 75 with resolved type:76 void77 48 (types: 78 49 void … … 83 54 Comma Expression: 84 55 constant expression (3 3: signed int) 85 with resolved type:86 signed int87 56 Variable Expression: v: signed short int 88 with resolved type:89 signed short int90 with resolved type:91 signed short int92 57 ... to: nothing 93 with resolved type:94 void95 58 (types: 96 59 void … … 106 69 char 107 70 108 with resolved type:109 instance of struct S with body 1110 ... with parameters111 char112 -
tests/.expect/init1.txt
r56c44dc rce55a81 11 11 ... to: 12 12 reference to signed int 13 with resolved type:14 reference to signed int15 13 init1.cfa:97:1 error: No reasonable alternatives for expression Applying untyped: 16 14 Name: ?{} … … 18 16 Generated Cast of: 19 17 Variable Expression: _retval_f_py: pointer to signed int 20 with resolved type:21 pointer to signed int22 18 ... to: 23 reference to pointer to signed int24 with resolved type:25 19 reference to pointer to signed int 26 20 Name: px … … 30 24 ... to: 31 25 reference to float 32 with resolved type:33 reference to float34 26 init1.cfa:107:1 error: No reasonable alternatives for expression Applying untyped: 35 27 Name: ?{} … … 37 29 Generated Cast of: 38 30 Variable Expression: _retval_f_py2: pointer to float 39 with resolved type:40 pointer to float41 31 ... to: 42 reference to pointer to float43 with resolved type:44 32 reference to pointer to float 45 33 Name: cpx … … 49 37 ... to: 50 38 reference to instance of type T (not function type) 51 with resolved type:52 reference to instance of type T (not function type)53 39 init1.cfa:118:1 error: No reasonable alternatives for expression Applying untyped: 54 40 Name: ?{} … … 56 42 Generated Cast of: 57 43 Variable Expression: _retval_anycvt: pointer to instance of type T (not function type) 58 with resolved type:59 pointer to instance of type T (not function type)60 44 ... to: 61 reference to pointer to instance of type T (not function type)62 with resolved type:63 45 reference to pointer to instance of type T (not function type) 64 46 Name: s -
tests/Makefile.am
r56c44dc rce55a81 67 67 avl_test_SOURCES = avltree/avl_test.cfa avltree/avl0.cfa avltree/avl1.cfa avltree/avl2.cfa avltree/avl3.cfa avltree/avl4.cfa avltree/avl-private.cfa 68 68 # automake doesn't know we still need C/CPP rules so pretend like we have a C program 69 _dummy_hack_SOURCES = .dummy_hack.c .dummy_hackxx.cpp69 nodist__dummy_hack_SOURCES = .dummy_hack.c .dummy_hackxx.cpp 70 70 71 71 #---------------------------------------------------------------------------------------------------------------- -
tests/alloc.cfa
r56c44dc rce55a81 47 47 free( ip ); 48 48 49 ip = alloc _set(fill ); // CFA alloc, fill49 ip = alloc( fill`fill ); // CFA alloc, fill 50 50 printf( "CFA alloc, fill %08x\n", *ip ); 51 51 free( ip ); 52 52 53 ip = alloc _set( 3); // CFA alloc, fill53 ip = alloc( 3`fill ); // CFA alloc, fill 54 54 printf( "CFA alloc, fill %d\n", *ip ); 55 55 free( ip ); … … 78 78 free( ip ); 79 79 80 ip = alloc _set( 2 * dim,fill ); // CFA array alloc, fill80 ip = alloc( 2 * dim, fill`fill ); // CFA array alloc, fill 81 81 printf( "CFA array alloc, fill %#hhx\n", fill ); 82 82 for ( i; 2 * dim ) { printf( "%#x ", ip[i] ); } … … 84 84 free( ip ); 85 85 86 ip = alloc _set( 2 * dim, 0xdeadbeef); // CFA array alloc, fill86 ip = alloc( 2 * dim, ((int)0xdeadbeef)`fill ); // CFA array alloc, fill 87 87 printf( "CFA array alloc, fill %#hhx\n", 0xdeadbeef ); 88 88 for ( i; 2 * dim ) { printf( "%#x ", ip[i] ); } … … 90 90 // do not free 91 91 92 ip1 = alloc _set( 2 * dim, ip, 2 * dim); // CFA array alloc, fill92 ip1 = alloc( 2 * dim, [ip, 2 * dim]`fill ); // CFA array alloc, fill 93 93 printf( "CFA array alloc, fill from array\n" ); 94 94 for ( i; 2 * dim ) { printf( "%#x %#x, ", ip[i], ip1[i] ); } … … 117 117 printf( "\n" ); 118 118 119 ip = alloc( ip, dim); // CFA realloc array alloc119 ip = alloc( dim, ip`realloc ); // CFA realloc array alloc 120 120 for ( i; dim ) { ip[i] = 0xdeadbeef; } 121 121 printf( "CFA realloc array alloc\n" ); … … 124 124 // do not free 125 125 126 ip = alloc( ip, 2 * dim); // CFA realloc array alloc126 ip = alloc( 2 * dim, ip`realloc ); // CFA realloc array alloc 127 127 for ( i; dim ~ 2 * dim ) { ip[i] = 0x1010101; } // fill upper part 128 128 printf( "CFA realloc array alloc\n" ); … … 131 131 // do not free 132 132 133 ip = alloc( ip, dim); // CFA realloc array alloc133 ip = alloc( dim, ip`realloc ); // CFA realloc array alloc 134 134 printf( "CFA realloc array alloc\n" ); 135 135 for ( i; dim ) { printf( "%#x ", ip[i] ); } … … 137 137 // do not free 138 138 139 ip = alloc _set( ip, 3 * dim,fill ); // CFA realloc array alloc, fill139 ip = alloc( 3 * dim, ip`realloc, fill`fill ); // CFA realloc array alloc, fill 140 140 printf( "CFA realloc array alloc, fill\n" ); 141 141 for ( i; 3 * dim ) { printf( "%#x ", ip[i] ); } … … 143 143 // do not free 144 144 145 ip = alloc _set( ip, dim,fill ); // CFA realloc array alloc, fill145 ip = alloc( dim, ip`realloc, fill`fill ); // CFA realloc array alloc, fill 146 146 printf( "CFA realloc array alloc, fill\n" ); 147 147 for ( i; dim ) { printf( "%#x ", ip[i] ); } … … 149 149 // do not free 150 150 151 ip = alloc _set( ip, 3 * dim,fill ); // CFA realloc array alloc, fill151 ip = alloc( 3 * dim, ip`realloc, fill`fill ); // CFA realloc array alloc, fill 152 152 printf( "CFA realloc array alloc, fill\n" ); 153 153 for ( i; 3 * dim ) { printf( "%#x ", ip[i] ); } … … 155 155 // do not free 156 156 #if 0 // FIX ME 157 ip = alloc _set( ip, 5 * dim, 5); // CFA realloc array alloc, 5157 ip = alloc( 5 * dim, ip`realloc, 5`fill ); // CFA realloc array alloc, 5 158 158 printf( "CFA realloc array alloc, 5\n" ); 159 159 for ( i; 5 * dim ) { printf( "%#x ", ip[i] ); } … … 161 161 // do not free 162 162 163 ip = alloc _set( ip, dim, 5); // CFA realloc array alloc, 5163 ip = alloc( dim, ip`realloc, 5`fill ); // CFA realloc array alloc, 5 164 164 printf( "CFA realloc array alloc, 5\n" ); 165 165 for ( i; dim ) { printf( "%#x ", ip[i] ); } … … 167 167 // do not free 168 168 169 ip = alloc _set( ip, 5 * dim, 5); // CFA realloc array alloc, 5169 ip = alloc( 5 * dim, ip`realloc, 5`fill ); // CFA realloc array alloc, 5 170 170 printf( "CFA realloc array alloc, 5\n" ); 171 171 for ( i; 5 * dim ) { printf( "%#x ", ip[i] ); } … … 182 182 ip = alloc(); 183 183 *ip = 5; 184 double * dp = alloc( ip );184 double * dp = alloc( ip`resize ); 185 185 *dp = 5.5; 186 S * sp = alloc( dp );186 S * sp = alloc( dp`resize ); 187 187 *sp = (S){ {0, 1, 2, 3, 4} }; 188 ip = alloc( sp );188 ip = alloc( sp`resize ); 189 189 *ip = 3; 190 190 free( ip ); … … 195 195 ip = alloc( 5 ); 196 196 for ( i; 5 ) { ip[i] = 5; } 197 dp = alloc( ip, 5);197 dp = alloc( 5, ip`resize ); 198 198 for ( i; 5 ) { dp[i] = 5.5; } 199 sp = alloc( dp, 5);199 sp = alloc( 5, dp`resize ); 200 200 for ( i; 5 ) { sp[i] = (S){ {0, 1, 2, 3, 4} }; } 201 ip = alloc( sp, 3);201 ip = alloc( 3, sp`resize ); 202 202 for ( i; 3 ) { ip[i] = 3; } 203 ip = alloc( ip, 7);203 ip = alloc( 7, ip`realloc ); 204 204 for ( i; 7 ) { ip[i] = 7; } 205 ip = alloc( ip, 7, false );205 ip = alloc( 7, ip`resize ); 206 206 for ( i; 7 ) { ip[i] = 7; } 207 207 free( ip ); … … 237 237 free( stp ); 238 238 239 stp = &(*alloc _align( Alignment)){ 42, 42.5 }; // CFA alloc_align239 stp = &(*alloc( Alignment`align)){ 42, 42.5 }; // CFA alloc_align 240 240 assert( (uintptr_t)stp % Alignment == 0 ); 241 241 printf( "CFA alloc_align %d %g\n", stp->x, stp->y ); 242 242 free( stp ); 243 243 244 stp = &(*alloc _align( Alignment)){ 42, 42.5 }; // CFA alloc_align244 stp = &(*alloc( Alignment`align )){ 42, 42.5 }; // CFA alloc_align 245 245 assert( (uintptr_t)stp % Alignment == 0 ); 246 246 printf( "CFA alloc_align %d %g\n", stp->x, stp->y ); 247 247 free( stp ); 248 248 249 stp = alloc _align_set( Alignment,fill ); // CFA memalign, fill249 stp = alloc( Alignment`align, fill`fill ); // CFA memalign, fill 250 250 assert( (uintptr_t)stp % Alignment == 0 ); 251 251 printf( "CFA alloc_align fill %#x %a\n", stp->x, stp->y ); 252 252 free( stp ); 253 253 254 stp = alloc _align_set( Alignment, (Struct){ 42, 42.5 }); // CFA memalign, fill254 stp = alloc( Alignment`align, (Struct){ 42, 42.5 }`fill ); // CFA memalign, fill 255 255 assert( (uintptr_t)stp % Alignment == 0 ); 256 256 printf( "CFA alloc_align fill %d %g\n", stp->x, stp->y ); 257 257 // do not free 258 258 259 stp = &(*alloc _align( stp, 4096)){ 42, 42.5 }; // CFA realign259 stp = &(*alloc( stp`realloc, 4096`align )){ 42, 42.5 }; // CFA realign 260 260 assert( (uintptr_t)stp % 4096 == 0 ); 261 261 printf( "CFA alloc_align %d %g\n", stp->x, stp->y ); … … 266 266 printf( "\n" ); 267 267 268 stp = alloc _align( Alignment, dim); // CFA array memalign268 stp = alloc( dim, Alignment`align ); // CFA array memalign 269 269 assert( (uintptr_t)stp % Alignment == 0 ); 270 270 for ( i; dim ) { stp[i] = (Struct){ 42, 42.5 }; } … … 274 274 free( stp ); 275 275 276 stp = alloc _align_set( Alignment, dim,fill ); // CFA array memalign, fill276 stp = alloc( dim, Alignment`align, fill`fill ); // CFA array memalign, fill 277 277 assert( (uintptr_t)stp % Alignment == 0 ); 278 278 printf( "CFA array alloc_align, fill\n" ); … … 281 281 free( stp ); 282 282 283 stp = alloc _align_set( Alignment, dim, (Struct){ 42, 42.5 }); // CFA array memalign, fill283 stp = alloc( dim, Alignment`align, ((Struct){ 42, 42.5 })`fill ); // CFA array memalign, fill 284 284 assert( (uintptr_t)stp % Alignment == 0 ); 285 285 printf( "CFA array alloc_align, fill\n" ); … … 288 288 // do not free 289 289 290 stp1 = alloc _align_set( Alignment, dim, stp, dim); // CFA array memalign, fill290 stp1 = alloc( dim, Alignment`align, [stp, dim]`fill ); // CFA array memalign, fill 291 291 assert( (uintptr_t)stp % Alignment == 0 ); 292 292 printf( "CFA array alloc_align, fill array\n" ); … … 295 295 free( stp1 ); 296 296 297 stp = alloc _align( stp, 4096, dim); // CFA aligned realloc array297 stp = alloc( dim, stp`realloc, 4096`align ); // CFA aligned realloc array 298 298 assert( (uintptr_t)stp % 4096 == 0 ); 299 299 for ( i; dim ) { stp[i] = (Struct){ 42, 42.5 }; } … … 325 325 for ( i; dim ) { printf( "%#x %a, ", sta1[i].x, sta1[i].y ); } 326 326 printf( "\n" ); 327 328 327 329 328 // new, non-array types -
tests/concurrent/examples/boundedBufferEXT.cfa
r56c44dc rce55a81 1 1 // 2 2 // Cforall Version 1.0.0 Copyright (C) 2018 University of Waterloo 3 // 3 // 4 4 // The contents of this file are covered under the licence agreement in the 5 5 // file "LICENCE" distributed with Cforall. … … 87 87 } 88 88 89 enum { Prods = 4, Cons = 5 }; 90 Producer * prods[Prods]; 91 Consumer * cons[Cons]; 92 89 93 int main() { 90 94 Buffer(int) buffer; 91 enum { Prods = 4, Cons = 5 };92 Producer * prods[Prods];93 Consumer * cons[Cons];94 95 int sums[Cons]; 95 96 int i; -
tests/errors/.expect/completeType.x64.txt
r56c44dc rce55a81 6 6 Name: x 7 7 8 ... to: nothing 9 with resolved type: 10 void Alternatives are: 8 ... to: nothing Alternatives are: 11 9 Cost ( 0, 1, 2, 0, 1, -1, 0 ): Generated Cast of: 12 10 Application of … … 22 20 23 21 24 with resolved type:25 pointer to forall26 _90_4_DT: data type27 function28 ... with parameters29 intrinsic pointer to instance of type _90_4_DT (not function type)30 ... returning31 _retval__operator_deref: reference to instance of type _90_4_DT (not function type)32 ... with attributes:33 Attribute with name: unused34 35 36 22 ... to arguments 37 23 Variable Expression: x: pointer to instance of struct A with body 0 38 with resolved type:39 pointer to instance of struct A with body 040 24 41 with resolved type:42 reference to instance of struct A with body 043 25 ... to: nothing 44 with resolved type:45 void46 26 (types: 47 27 void … … 63 43 64 44 65 with resolved type:66 pointer to forall67 _90_4_DT: data type68 function69 ... with parameters70 intrinsic pointer to instance of type _90_4_DT (not function type)71 ... returning72 _retval__operator_deref: reference to instance of type _90_4_DT (not function type)73 ... with attributes:74 Attribute with name: unused75 76 77 45 ... to arguments 78 46 Variable Expression: x: pointer to instance of struct B with body 1 79 with resolved type:80 pointer to instance of struct B with body 181 47 82 with resolved type:83 reference to instance of struct B with body 184 48 ... to: nothing 85 with resolved type:86 void87 49 (types: 88 50 void … … 159 121 ... returning nothing 160 122 161 with resolved type:162 pointer to forall163 _109_0_T: sized data type164 ... with assertions165 ?=?: pointer to function166 ... with parameters167 reference to instance of type _109_0_T (not function type)168 instance of type _109_0_T (not function type)169 ... returning170 _retval__operator_assign: instance of type _109_0_T (not function type)171 ... with attributes:172 Attribute with name: unused173 174 175 ?{}: pointer to function176 ... with parameters177 reference to instance of type _109_0_T (not function type)178 ... returning nothing179 180 ?{}: pointer to function181 ... with parameters182 reference to instance of type _109_0_T (not function type)183 instance of type _109_0_T (not function type)184 ... returning nothing185 186 ^?{}: pointer to function187 ... with parameters188 reference to instance of type _109_0_T (not function type)189 ... returning nothing190 191 192 function193 ... with parameters194 pointer to instance of type _109_0_T (not function type)195 ... returning nothing196 197 123 ... to arguments 198 124 Variable Expression: z: pointer to instance of type T (not function type) 199 with resolved type:200 pointer to instance of type T (not function type)201 125 202 with resolved type:203 void204 126 (types: 205 127 void -
tests/errors/.expect/completeType.x86.txt
r56c44dc rce55a81 6 6 Name: x 7 7 8 ... to: nothing 9 with resolved type: 10 void Alternatives are: 8 ... to: nothing Alternatives are: 11 9 Cost ( 0, 1, 2, 0, 1, -1, 0 ): Generated Cast of: 12 10 Application of … … 22 20 23 21 24 with resolved type:25 pointer to forall26 _89_4_DT: data type27 function28 ... with parameters29 intrinsic pointer to instance of type _89_4_DT (not function type)30 ... returning31 _retval__operator_deref: reference to instance of type _89_4_DT (not function type)32 ... with attributes:33 Attribute with name: unused34 35 36 22 ... to arguments 37 23 Variable Expression: x: pointer to instance of struct A with body 0 38 with resolved type:39 pointer to instance of struct A with body 040 24 41 with resolved type:42 reference to instance of struct A with body 043 25 ... to: nothing 44 with resolved type:45 void46 26 (types: 47 27 void … … 63 43 64 44 65 with resolved type:66 pointer to forall67 _89_4_DT: data type68 function69 ... with parameters70 intrinsic pointer to instance of type _89_4_DT (not function type)71 ... returning72 _retval__operator_deref: reference to instance of type _89_4_DT (not function type)73 ... with attributes:74 Attribute with name: unused75 76 77 45 ... to arguments 78 46 Variable Expression: x: pointer to instance of struct B with body 1 79 with resolved type:80 pointer to instance of struct B with body 181 47 82 with resolved type:83 reference to instance of struct B with body 184 48 ... to: nothing 85 with resolved type:86 void87 49 (types: 88 50 void … … 159 121 ... returning nothing 160 122 161 with resolved type:162 pointer to forall163 _108_0_T: sized data type164 ... with assertions165 ?=?: pointer to function166 ... with parameters167 reference to instance of type _108_0_T (not function type)168 instance of type _108_0_T (not function type)169 ... returning170 _retval__operator_assign: instance of type _108_0_T (not function type)171 ... with attributes:172 Attribute with name: unused173 174 175 ?{}: pointer to function176 ... with parameters177 reference to instance of type _108_0_T (not function type)178 ... returning nothing179 180 ?{}: pointer to function181 ... with parameters182 reference to instance of type _108_0_T (not function type)183 instance of type _108_0_T (not function type)184 ... returning nothing185 186 ^?{}: pointer to function187 ... with parameters188 reference to instance of type _108_0_T (not function type)189 ... returning nothing190 191 192 function193 ... with parameters194 pointer to instance of type _108_0_T (not function type)195 ... returning nothing196 197 123 ... to arguments 198 124 Variable Expression: z: pointer to instance of type T (not function type) 199 with resolved type:200 pointer to instance of type T (not function type)201 125 202 with resolved type:203 void204 126 (types: 205 127 void -
tests/literals.cfa
r56c44dc rce55a81 10 10 // Created On : Sat Sep 9 16:34:38 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Aug 20 13:51:12202013 // Update Count : 22 512 // Last Modified On : Sat Aug 29 10:57:56 2020 13 // Update Count : 226 14 14 // 15 15 … … 151 151 -0X0123456789.0123456789P-09; -0X0123456789.0123456789P-09f; -0X0123456789.0123456789P-09l; -0X0123456789.0123456789P-09F; -0X0123456789.0123456789P-09L; 152 152 153 #if defined( __i386 ) || defined( __x86_64 ) 153 154 #if defined(__GNUC__) && __GNUC_PREREQ(7,0) // gcc version >= 7 154 155 // floating with length, gcc f16/f128x unsupported and no prelude code for any _FloatXXx, so they work by conversion to long double … … 194 195 /* -0x123456789.0123456789P-09F16; */ -0x123456789.0123456789P-09F32; -0x123456789.0123456789P-09F32x; -0x123456789.0123456789P-09F64; -0x123456789.0123456789P-09F64x; -0x123456789.0123456789P-09W; -0x123456789.0123456789P-09F128; -0x123456789.0123456789P-09q; /* -0x123456789.0123456789P-09q; */ 195 196 #endif // __GNUC_PREREQ(7,0) 197 #endif // __i386 ) || __x86_64 196 198 197 199 #ifdef __CFA__ -
tests/pybin/tools.py
r56c44dc rce55a81 238 238 # helper function to check if a files contains only a specific string 239 239 def file_contains_only(file, text) : 240 with open(file ) as f:240 with open(file, encoding="latin-1") as f: # use latin-1 so all chars mean something. 241 241 ff = f.read().strip() 242 242 result = ff == text.strip() -
tests/raii/.expect/ctor-autogen-ERR1.txt
r56c44dc rce55a81 7 7 x: signed int 8 8 ... returning nothing 9 10 with resolved type:11 function12 ... with parameters13 _dst: reference to instance of struct Managed with body 114 x: signed int15 ... returning nothing16 9 17 10 ... deleted by: ?{}: function … … 33 26 34 27 35 with resolved type:36 pointer to function37 ... with parameters38 intrinsic reference to signed int39 intrinsic signed int40 ... returning41 _retval__operator_assign: signed int42 ... with attributes:43 Attribute with name: unused44 45 46 28 ... to arguments 47 29 Generated Cast of: … … 51 33 Generated Cast of: 52 34 Variable Expression: m: reference to instance of struct Managed with body 1 53 with resolved type:54 reference to instance of struct Managed with body 155 35 ... to: 56 36 instance of struct Managed with body 1 57 with resolved type:58 instance of struct Managed with body 159 with resolved type:60 signed int61 37 ... to: 62 reference to signed int63 with resolved type:64 38 reference to signed int 65 39 Generated Cast of: 66 40 constant expression (0 0: zero_t) 67 with resolved type:68 zero_t69 41 ... to: 70 42 signed int 71 with resolved type:72 signed int73 43 74 with resolved type:75 signed int76 44 ... with environment: 77 45 Types: … … 82 50 Generated Cast of: 83 51 Variable Expression: x: instance of struct Managed with body 1 84 with resolved type:85 instance of struct Managed with body 186 52 ... to: 87 53 reference to instance of struct Managed with body 1 88 with resolved type:89 reference to instance of struct Managed with body 190 54 constant expression (123 123: signed int) 91 with resolved type:92 signed int93 55 94 with resolved type:95 void96 56 ... to: nothing 97 with resolved type:98 void -
tests/test.py
r56c44dc rce55a81 116 116 parser.add_argument('--arch', help='Test for specific architecture', type=comma_separated(str), default=None) 117 117 parser.add_argument('--continue', help='When multiple specifications are passed (debug/install/arch), sets whether or not to continue if the last specification failed', type=yes_no, default='yes', dest='continue_') 118 parser.add_argument('--timeout', help='Maximum duration in seconds after a single test is considered to have timed out', type=int, default= 60)118 parser.add_argument('--timeout', help='Maximum duration in seconds after a single test is considered to have timed out', type=int, default=120) 119 119 parser.add_argument('--global-timeout', help='Maximum cumulative duration in seconds after the ALL tests are considered to have timed out', type=int, default=7200) 120 120 parser.add_argument('--timeout-with-gdb', help='Instead of killing the command when it times out, orphan it and print process id to allow gdb to attach', type=yes_no, default="no") … … 194 194 if success(retcode): 195 195 if settings.generating : 196 # if we are o unly generating the output we still need to check that the test actually exists196 # if we are only generating the output we still need to check that the test actually exists 197 197 if no_rule(out_file, test.target()) : 198 198 retcode = 1 -
tests/warnings/.expect/self-assignment.txt
r56c44dc rce55a81 1 1 warnings/self-assignment.cfa:29:1 warning: self assignment of expression: Generated Cast of: 2 2 Variable Expression: j: signed int 3 with resolved type:4 signed int5 3 ... to: 6 reference to signed int7 with resolved type:8 4 reference to signed int 9 5 warnings/self-assignment.cfa:30:1 warning: self assignment of expression: Generated Cast of: 10 6 Variable Expression: s: instance of struct S with body 1 11 with resolved type:12 instance of struct S with body 113 7 ... to: 14 reference to instance of struct S with body 115 with resolved type:16 8 reference to instance of struct S with body 1 17 9 warnings/self-assignment.cfa:31:1 warning: self assignment of expression: Generated Cast of: … … 20 12 ... from aggregate: 21 13 Variable Expression: s: instance of struct S with body 1 22 with resolved type:23 instance of struct S with body 124 with resolved type:25 signed int26 14 ... to: 27 reference to signed int28 with resolved type:29 15 reference to signed int 30 16 warnings/self-assignment.cfa:32:1 warning: self assignment of expression: Generated Cast of: … … 36 22 ... from aggregate: 37 23 Variable Expression: t: instance of struct T with body 1 38 with resolved type:39 instance of struct T with body 140 with resolved type:41 instance of struct S with body 142 with resolved type:43 signed int44 24 ... to: 45 25 reference to signed int 46 with resolved type:47 reference to signed int -
tools/Makefile.am
r56c44dc rce55a81 18 18 ACLOCAL_AMFLAGS = -I automake 19 19 20 AM_CFLAGS = -Wall -Wextra -O2 -g 20 EXTRA_DIST = build/distcc_hash build/push2dist.sh 21 21 22 22 noinst_PROGRAMS = busy catchsig repeat watchdog 23 AM_CFLAGS = -Wall -Wextra -O2 -g 24 busy_LDFLAGS = -pthread 23 25 24 busy_SOURCES = busy.c 25 busy_LDFLAGS = -pthread 26 catchsig_SOURCES = catchsig.c 27 repeat_SOURCES = repeat.c 28 watchdog_SOURCES = watchdog.c 26 nodist_busy_SOURCES = busy.c 27 nodist_catchsig_SOURCES = catchsig.c 28 nodist_repeat_SOURCES = repeat.c 29 nodist_watchdog_SOURCES = watchdog.c -
tools/prettyprinter/Makefile.am
r56c44dc rce55a81 30 30 tools_prettyprinter_PROGRAMS = pretty 31 31 tools_prettyprinterdir = ../ 32 pretty_SOURCES = ${SRC}32 nodist_pretty_SOURCES = ${SRC} 33 33 pretty_LDADD = ${LEXLIB} -ldl # yywrap 34 34 pretty_CXXFLAGS = -Wno-deprecated -Wall -DYY_NO_INPUT -O2 -g -std=c++14
Note: See TracChangeset
for help on using the changeset viewer.