Changeset 41b8ea4 for doc/theses


Ignore:
Timestamp:
Oct 7, 2020, 5:10:45 PM (5 years ago)
Author:
Fangren Yu <f37yu@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum, stuck-waitfor-destruct
Children:
490fb92e, 69c5c00
Parents:
2fb35df (diff), 848439f (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.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc into master

Location:
doc/theses
Files:
6 added
1 deleted
3 edited
1 moved

Legend:

Unmodified
Added
Removed
  • doc/theses/fangren_yu_COOP_S20/Makefile

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

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

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

    r2fb35df r41b8ea4  
    1 #pragma once
    2 
    31#include <pthread.h>
    42#include <errno.h>
     
    5654#undef CHECKED
    5755
    58 #if defined(__cforall) || defined(__cpluplus)
     56//--------------------
     57// Basic types
     58struct pthread_runner_t {
     59        pthread_t handle;
     60        __bin_sem_t sem;
     61};
     62typedef pthread_runner_t * thread_t;
     63
     64static_assert(sizeof(thread_t) == sizeof(void*), "thread_t musst be of same size as void*");
     65
    5966extern "C" {
    60 #endif
    61         //--------------------
    62         // Basic types
    63         struct pthread_runner_t {
    64                 pthread_t handle;
    65                 __bin_sem_t sem;
    66         };
    67         typedef pthread_runner_t * thread_t;
    68 
    6967        //--------------------
    7068        // Basic thread support
     
    9896        //--------------------
    9997        // Basic kernel features
    100         void thrdlib_setproccnt( int ) {
    101 
    102         }
    103 
    104 
    105 #if defined(__cforall) || defined(__cpluplus)
     98        void thrdlib_init( int ) {}
    10699}
    107 #endif
Note: See TracChangeset for help on using the changeset viewer.