Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/papers/concurrency/Paper.tex

    rc8ad5d9 rd046db2  
    1919\usepackage{listings}                                           % format program code
    2020\usepackage[labelformat=simple,aboveskip=0pt,farskip=0pt]{subfig}
    21 \renewcommand{\thesubfigure}{(\Alph{subfigure})}
    22 \captionsetup{justification=raggedright,singlelinecheck=false}
     21\renewcommand{\thesubfigure}{(\alph{subfigure})}
    2322\usepackage{siunitx}
    2423\sisetup{ binary-units=true }
     
    9998\newcommand{\abbrevFont}{\textit}                       % set empty for no italics
    10099\@ifundefined{eg}{
    101 \newcommand{\EG}{\abbrevFont{e}\abbrevFont{g}}
     100\newcommand{\EG}{\abbrevFont{e}.\abbrevFont{g}.}
    102101\newcommand*{\eg}{%
    103102        \@ifnextchar{,}{\EG}%
     
    106105}}{}%
    107106\@ifundefined{ie}{
    108 \newcommand{\IE}{\abbrevFont{i}\abbrevFont{e}}
     107\newcommand{\IE}{\abbrevFont{i}.\abbrevFont{e}.}
    109108\newcommand*{\ie}{%
    110109        \@ifnextchar{,}{\IE}%
     
    144143                _Alignas, _Alignof, __alignof, __alignof__, asm, __asm, __asm__, __attribute, __attribute__,
    145144                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,
    147146                __float80, float80, __float128, float128, forall, ftype, _Generic, _Imaginary, __imag, __imag__,
    148147                inline, __inline, __inline__, __int128, int128, __label__, monitor, mutex, _Noreturn, one_t, or,
     
    170169literate={-}{\makebox[1ex][c]{\raisebox{0.4ex}{\rule{0.8ex}{0.1ex}}}}1 {^}{\raisebox{0.6ex}{$\scriptstyle\land\,$}}1
    171170        {~}{\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,
    173172moredelim=**[is][\color{red}]{`}{`},
    174173}% lstset
     
    217216\author[1]{Thierry Delisle}
    218217\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
    226225
    227226\abstract[Summary]{
    228227\CFA is a modern, polymorphic, \emph{non-object-oriented} extension of the C programming language.
    229228This 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.
     229These features are created from scratch as ISO C lacks concurrency, relying largely on pthreads.
    231230Coroutines and lightweight (user) threads are introduced into the language.
    232231In addition, monitors are added as a high-level mechanism for mutual exclusion and synchronization.
     
    256255Examples of high-level approaches are task based~\cite{TBB}, message passing~\cite{Erlang,MPI}, and implicit threading~\cite{OpenMP}.
    257256
    258 This paper uses the following terminology.
     257This paper used the following terminology.
    259258A \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.
     259Multiple simultaneous threads gives rise to \newterm{concurrency}, which requires locking to ensure safe communication and access to shared data.
    261260% Correspondingly, concurrency is defined as the concepts and challenges that occur when multiple independent (sharing memory, timing dependencies, \etc) concurrent threads are introduced.
    262261\newterm{Locking}, and by extension locks, are defined as a mechanism to prevent progress of threads to provide safety.
    263262\newterm{Parallelism} is running multiple threads simultaneously.
    264263Parallelism 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.
     264As such, parallelism is only observable in differences in performance, which is observed through differences in timing.
    266265
    267266Hence, 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}.
     267While these two concepts are often combined, they are in fact distinct, requiring different tools~\cite[\S~2]{Buhr05a}.
    269268Concurrency tools handle synchronization and mutual exclusion, while parallelism tools handle performance, cost and resource utilization.
    270269
     
    279278
    280279The 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.
     282It is a non-object-oriented system-language, meaning most of the major abstractions have either no runtime overhead or can be opted out easily.
    285283Like C, the basics of \CFA revolve around structures and routines, which are thin abstractions over machine code.
    286284The 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 represent
     285Interestingly, 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
    288286values''~\cite[3.15]{C11}}, most importantly construction and destruction of objects.
     287Most of the following code examples can be found on the \CFA website~\cite{Cforall}.
    289288
    290289
     
    294293In 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:
    295294\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}$
     295int x, *p1 = &x, **p2 = &p1, ***p3 = &p2,
     296        &r1 = x,    &&r2 = r1,   &&&r3 = r2;
     297***p3 = 3;                                                      $\C{// change x}$
     298r3    = 3;                                                      $\C{// change x, ***r3}$
     299**p3  = ...;                                            $\C{// change p1}$
     300*p3   = ...;                                            $\C{// change p2}$
     301int y, z, & ar[3] = {x, y, z};          $\C{// initialize array of references}$
     302typeof( ar[1]) p;                                       $\C{// is int, referenced object type}$
     303typeof(&ar[1]) q;                                       $\C{// is int \&, reference type}$
     304sizeof( ar[1]) == sizeof(int);          $\C{// is true, referenced object size}$
     305sizeof(&ar[1]) == sizeof(int *);        $\C{// is true, reference size}$
    310306\end{cfa}
    311307The 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.
     
    630626\end{lrbox}
    631627\subfloat[3 States, internal variables]{\label{f:Coroutine3States}\usebox\myboxA}
    632 \qquad\qquad
     628\qquad
    633629\subfloat[1 State, internal variables]{\label{f:Coroutine1State}\usebox\myboxB}
    634630\caption{\CFA Coroutine Fibonacci Implementations}
     
    657653
    658654\begin{figure}
    659 \begin{cfa}[xleftmargin=4\parindentlnth]
     655\centering
     656\begin{cfa}
    660657`coroutine` Format {
    661658        char ch;                                                                $\C{// used for communication}$
Note: See TracChangeset for help on using the changeset viewer.