- File:
-
- 1 edited
-
doc/papers/concurrency/Paper.tex (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
doc/papers/concurrency/Paper.tex
rc8ad5d9 rd046db2 19 19 \usepackage{listings} % format program code 20 20 \usepackage[labelformat=simple,aboveskip=0pt,farskip=0pt]{subfig} 21 \renewcommand{\thesubfigure}{(\Alph{subfigure})} 22 \captionsetup{justification=raggedright,singlelinecheck=false} 21 \renewcommand{\thesubfigure}{(\alph{subfigure})} 23 22 \usepackage{siunitx} 24 23 \sisetup{ binary-units=true } … … 99 98 \newcommand{\abbrevFont}{\textit} % set empty for no italics 100 99 \@ifundefined{eg}{ 101 \newcommand{\EG}{\abbrevFont{e} \abbrevFont{g}}100 \newcommand{\EG}{\abbrevFont{e}.\abbrevFont{g}.} 102 101 \newcommand*{\eg}{% 103 102 \@ifnextchar{,}{\EG}% … … 106 105 }}{}% 107 106 \@ifundefined{ie}{ 108 \newcommand{\IE}{\abbrevFont{i} \abbrevFont{e}}107 \newcommand{\IE}{\abbrevFont{i}.\abbrevFont{e}.} 109 108 \newcommand*{\ie}{% 110 109 \@ifnextchar{,}{\IE}% … … 144 143 _Alignas, _Alignof, __alignof, __alignof__, asm, __asm, __asm__, __attribute, __attribute__, 145 144 auto, _Bool, catch, catchResume, choose, _Complex, __complex, __complex__, __const, __const__, 146 coroutine, disable, dtype, enable, exception, __extension__, fallthrough, fallthru, finally,145 coroutine, disable, dtype, enable, __extension__, exception, fallthrough, fallthru, finally, 147 146 __float80, float80, __float128, float128, forall, ftype, _Generic, _Imaginary, __imag, __imag__, 148 147 inline, __inline, __inline__, __int128, int128, __label__, monitor, mutex, _Noreturn, one_t, or, … … 170 169 literate={-}{\makebox[1ex][c]{\raisebox{0.4ex}{\rule{0.8ex}{0.1ex}}}}1 {^}{\raisebox{0.6ex}{$\scriptstyle\land\,$}}1 171 170 {~}{\raisebox{0.3ex}{$\scriptstyle\sim\,$}}1 % {`}{\ttfamily\upshape\hspace*{-0.1ex}`}1 172 {<-}{$\leftarrow$}2 {=>}{$\Rightarrow$}2 {->}{\makebox[1ex][c]{\raisebox{0. 4ex}{\rule{0.8ex}{0.075ex}}}\kern-0.2ex{\textgreater}}2,171 {<-}{$\leftarrow$}2 {=>}{$\Rightarrow$}2 {->}{\makebox[1ex][c]{\raisebox{0.5ex}{\rule{0.8ex}{0.075ex}}}\kern-0.2ex{\textgreater}}2, 173 172 moredelim=**[is][\color{red}]{`}{`}, 174 173 }% lstset … … 217 216 \author[1]{Thierry Delisle} 218 217 \author[1]{Peter A. Buhr*} 219 \authormark{ DELISLE \textsc{et al.}}220 221 \address[1]{\orgdiv{Cheriton School of Computer Science}, \orgname{University of Waterloo}, \orgaddress{\state{ Waterloo, ON}, \country{Canada}}}222 223 \corres{*Peter A. Buhr, Cheriton School of Computer Science, University of Waterloo, 200 University Avenue West, Waterloo, ON, N2L 3G1, Canada.\email{pabuhr{\char`\@}uwaterloo.ca}}224 225 \fundingInfo{Natural Sciences and Engineering Research Council of Canada} 218 \authormark{Thierry Delisle \textsc{et al}} 219 220 \address[1]{\orgdiv{Cheriton School of Computer Science}, \orgname{University of Waterloo}, \orgaddress{\state{Ontario}, \country{Canada}}} 221 222 \corres{*Peter A. Buhr, \email{pabuhr{\char`\@}uwaterloo.ca}} 223 \presentaddress{Cheriton School of Computer Science, University of Waterloo, Waterloo, ON, N2L 3G1, Canada} 224 226 225 227 226 \abstract[Summary]{ 228 227 \CFA is a modern, polymorphic, \emph{non-object-oriented} extension of the C programming language. 229 228 This paper discusses the design of the concurrency and parallelism features in \CFA, and the concurrent runtime-system. 230 These features are created from scratch as ISO C lacks concurrency, relying largely on pthreads library.229 These features are created from scratch as ISO C lacks concurrency, relying largely on pthreads. 231 230 Coroutines and lightweight (user) threads are introduced into the language. 232 231 In addition, monitors are added as a high-level mechanism for mutual exclusion and synchronization. … … 256 255 Examples of high-level approaches are task based~\cite{TBB}, message passing~\cite{Erlang,MPI}, and implicit threading~\cite{OpenMP}. 257 256 258 This paper use sthe following terminology.257 This paper used the following terminology. 259 258 A \newterm{thread} is a fundamental unit of execution that runs a sequence of code and requires a stack to maintain state. 260 Multiple simultaneous threads give rise to \newterm{concurrency}, which requires locking to ensure safe communication and access to shared data.259 Multiple simultaneous threads gives rise to \newterm{concurrency}, which requires locking to ensure safe communication and access to shared data. 261 260 % Correspondingly, concurrency is defined as the concepts and challenges that occur when multiple independent (sharing memory, timing dependencies, \etc) concurrent threads are introduced. 262 261 \newterm{Locking}, and by extension locks, are defined as a mechanism to prevent progress of threads to provide safety. 263 262 \newterm{Parallelism} is running multiple threads simultaneously. 264 263 Parallelism implies \emph{actual} simultaneous execution, where concurrency only requires \emph{apparent} simultaneous execution. 265 As such, parallelism only affects performance, which is observed through differences in space and/or time.264 As such, parallelism is only observable in differences in performance, which is observed through differences in timing. 266 265 267 266 Hence, there are two problems to be solved in the design of concurrency for a programming language: concurrency and parallelism. 268 While these two concepts are often combined, they are distinct, requiring different tools~\cite[\S~2]{Buhr05a}.267 While these two concepts are often combined, they are in fact distinct, requiring different tools~\cite[\S~2]{Buhr05a}. 269 268 Concurrency tools handle synchronization and mutual exclusion, while parallelism tools handle performance, cost and resource utilization. 270 269 … … 279 278 280 279 The following is a quick introduction to the \CFA language, specifically tailored to the features needed to support concurrency. 281 Most of the following code examples can be found on the \CFA website~\cite{Cforall}. 282 283 \CFA is an extension of ISO-C, and therefore, supports all of the same paradigms as C. 284 %It is a non-object-oriented system-language, meaning most of the major abstractions have either no runtime overhead or can be opted out easily. 280 281 \CFA is an extension of ISO-C and therefore supports all of the same paradigms as C. 282 It is a non-object-oriented system-language, meaning most of the major abstractions have either no runtime overhead or can be opted out easily. 285 283 Like C, the basics of \CFA revolve around structures and routines, which are thin abstractions over machine code. 286 284 The vast majority of the code produced by the \CFA translator respects memory layouts and calling conventions laid out by C. 287 Interestingly, while \CFA is not an object-oriented language, lacking the concept of a receiver (\eg @this@) and inheritance, it does have some notion of objects\footnote{C defines the term objects as : ``region of data storage in the execution environment, the contents of which can represent285 Interestingly, while \CFA is not an object-oriented language, lacking the concept of a receiver (\eg {\tt this}), it does have some notion of objects\footnote{C defines the term objects as : ``region of data storage in the execution environment, the contents of which can represent 288 286 values''~\cite[3.15]{C11}}, most importantly construction and destruction of objects. 287 Most of the following code examples can be found on the \CFA website~\cite{Cforall}. 289 288 290 289 … … 294 293 In regards to concurrency, the semantic difference between pointers and references are not particularly relevant, but since this document uses mostly references, here is a quick overview of the semantics: 295 294 \begin{cfa} 296 int x, y, z; 297 int * p1 = &x, ** p2 = &p1, *** p3 = &p2, $\C{// pointers to x}$ 298 & r1 = x, && r2 = r1, &&& r3 = r2; $\C{// references to x}$ 299 300 *p1 = 3; **p2 = 3; ***p3 = 3; $\C{// change x}$ 301 r1 = 3; r2 = 3; r3 = 3; $\C{// change x}$ 302 **p3 = &y; *p3 = &z; $\C{// change p1, p2}$ 303 &&r3 = &y; &r3 = &z; $\C{// change p1, p2}$ 304 int & ar[3] = {x, y, z}; $\C{// initialize array of references}$ 305 306 typeof( ar[1]) p; $\C{// is int, referenced object type}$ 307 typeof(&ar[1]) q; $\C{// is int \&, reference type}$ 308 sizeof( ar[1]) == sizeof(int); $\C{// is true, referenced object size}$ 309 sizeof(&ar[1]) == sizeof(int *); $\C{// is true, reference size}$ 295 int x, *p1 = &x, **p2 = &p1, ***p3 = &p2, 296 &r1 = x, &&r2 = r1, &&&r3 = r2; 297 ***p3 = 3; $\C{// change x}$ 298 r3 = 3; $\C{// change x, ***r3}$ 299 **p3 = ...; $\C{// change p1}$ 300 *p3 = ...; $\C{// change p2}$ 301 int y, z, & ar[3] = {x, y, z}; $\C{// initialize array of references}$ 302 typeof( ar[1]) p; $\C{// is int, referenced object type}$ 303 typeof(&ar[1]) q; $\C{// is int \&, reference type}$ 304 sizeof( ar[1]) == sizeof(int); $\C{// is true, referenced object size}$ 305 sizeof(&ar[1]) == sizeof(int *); $\C{// is true, reference size}$ 310 306 \end{cfa} 311 307 The important take away from this code example is that a reference offers a handle to an object, much like a pointer, but which is automatically dereferenced for convenience. … … 630 626 \end{lrbox} 631 627 \subfloat[3 States, internal variables]{\label{f:Coroutine3States}\usebox\myboxA} 632 \qquad \qquad628 \qquad 633 629 \subfloat[1 State, internal variables]{\label{f:Coroutine1State}\usebox\myboxB} 634 630 \caption{\CFA Coroutine Fibonacci Implementations} … … 657 653 658 654 \begin{figure} 659 \begin{cfa}[xleftmargin=4\parindentlnth] 655 \centering 656 \begin{cfa} 660 657 `coroutine` Format { 661 658 char ch; $\C{// used for communication}$
Note:
See TracChangeset
for help on using the changeset viewer.