Changes in / [e58e423:42b7fa5f]


Ignore:
Files:
1 added
13 edited

Legend:

Unmodified
Added
Removed
  • doc/theses/mubeen_zulfiqar_MMath/allocator.tex

    re58e423 r42b7fa5f  
    2424\end{itemize}
    2525
    26 The new features added to uHeapLmmm (incl. @malloc\_size@ routine)
     26The new features added to uHeapLmmm (incl. @malloc_size@ routine)
    2727\CFA alloc interface with examples.
    28 
    2928\begin{itemize}
    3029\item
     
    118117We added a few more features and routines to the allocator's C interface that can make the allocator more usable to the programmers. THese features will programmer more control on the dynamic memory allocation.
    119118
    120 \subsubsection void * aalloc( size\_t dim, size\_t elemSize )
     119\subsubsection void * aalloc( size_t dim, size_t elemSize )
    121120aalloc is an extension of malloc. It allows programmer to allocate a dynamic array of objects without calculating the total size of array explicitly. The only alternate of this routine in the other allocators is calloc but calloc also fills the dynamic memory with 0 which makes it slower for a programmer who only wants to dynamically allocate an array of objects without filling it with 0.
    122121\paragraph{Usage}
    123122aalloc takes two parameters.
    124 
    125123\begin{itemize}
    126124\item
     
    131129It returns address of dynamic object allocatoed on heap that can contain dim number of objects of the size elemSize. On failure, it returns NULL pointer.
    132130
    133 \subsubsection void * resize( void * oaddr, size\_t size )
     131\subsubsection void * resize( void * oaddr, size_t size )
    134132resize is an extension of relloc. It allows programmer to reuse a cuurently allocated dynamic object with a new size requirement. Its alternate in the other allocators is realloc but relloc also copy the data in old object to the new object which makes it slower for the programmer who only wants to reuse an old dynamic object for a new size requirement but does not want to preserve the data in the old object to the new object.
    135133\paragraph{Usage}
    136134resize takes two parameters.
    137 
    138135\begin{itemize}
    139136\item
     
    144141It returns an object that is of the size given but it does not preserve the data in the old object. On failure, it returns NULL pointer.
    145142
    146 \subsubsection void * resize( void * oaddr, size\_t nalign, size\_t size )
     143\subsubsection void * resize( void * oaddr, size_t nalign, size_t size )
    147144This resize is an extension of the above resize (FIX ME: cite above resize). In addition to resizing the size of of an old object, it can also realign the old object to a new alignment requirement.
    148145\paragraph{Usage}
    149146This resize takes three parameters. It takes an additional parameter of nalign as compared to the above resize (FIX ME: cite above resize).
    150 
    151147\begin{itemize}
    152148\item
     
    159155It returns an object with the size and alignment given in the parameters. On failure, it returns a NULL pointer.
    160156
    161 \subsubsection void * amemalign( size\_t alignment, size\_t dim, size\_t elemSize )
     157\subsubsection void * amemalign( size_t alignment, size_t dim, size_t elemSize )
    162158amemalign is a hybrid of memalign and aalloc. It allows programmer to allocate an aligned dynamic array of objects without calculating the total size of the array explicitly. It frees the programmer from calculating the total size of the array.
    163159\paragraph{Usage}
    164160amemalign takes three parameters.
    165 
    166161\begin{itemize}
    167162\item
     
    174169It returns a dynamic array of objects that has the capacity to contain dim number of objects of the size of elemSize. The returned dynamic array is aligned to the given alignment. On failure, it returns NULL pointer.
    175170
    176 \subsubsection void * cmemalign( size\_t alignment, size\_t dim, size\_t elemSize )
     171\subsubsection void * cmemalign( size_t alignment, size_t dim, size_t elemSize )
    177172cmemalign is a hybrid of amemalign and calloc. It allows programmer to allocate an aligned dynamic array of objects that is 0 filled. The current way to do this in other allocators is to allocate an aligned object with memalign and then fill it with 0 explicitly. This routine provides both features of aligning and 0 filling, implicitly.
    178173\paragraph{Usage}
    179174cmemalign takes three parameters.
    180 
    181175\begin{itemize}
    182176\item
     
    189183It returns a dynamic array of objects that has the capacity to contain dim number of objects of the size of elemSize. The returned dynamic array is aligned to the given alignment and is 0 filled. On failure, it returns NULL pointer.
    190184
    191 \subsubsection size\_t malloc\_alignment( void * addr )
    192 malloc\_alignment returns the alignment of a currently allocated dynamic object. It allows the programmer in memory management and personal bookkeeping. It helps the programmer in verofying the alignment of a dynamic object especially in a scenerio similar to prudcer-consumer where a producer allocates a dynamic object and the consumer needs to assure that the dynamic object was allocated with the required alignment.
    193 \paragraph{Usage}
    194 malloc\_alignment takes one parameters.
    195 
     185\subsubsection size_t malloc_alignment( void * addr )
     186malloc_alignment returns the alignment of a currently allocated dynamic object. It allows the programmer in memory management and personal bookkeeping. It helps the programmer in verofying the alignment of a dynamic object especially in a scenerio similar to prudcer-consumer where a producer allocates a dynamic object and the consumer needs to assure that the dynamic object was allocated with the required alignment.
     187\paragraph{Usage}
     188malloc_alignment takes one parameters.
    196189\begin{itemize}
    197190\item
    198191addr: the address of the currently allocated dynamic object.
    199192\end{itemize}
    200 malloc\_alignment returns the alignment of the given dynamic object. On failure, it return the value of default alignment of the uHeapLmmm allocator.
    201 
    202 \subsubsection bool malloc\_zero\_fill( void * addr )
    203 malloc\_zero\_fill returns whether a currently allocated dynamic object was initially zero filled at the time of allocation. It allows the programmer in memory management and personal bookkeeping. It helps the programmer in verifying the zero filled property of a dynamic object especially in a scenerio similar to prudcer-consumer where a producer allocates a dynamic object and the consumer needs to assure that the dynamic object was zero filled at the time of allocation.
    204 \paragraph{Usage}
    205 malloc\_zero\_fill takes one parameters.
    206 
     193malloc_alignment returns the alignment of the given dynamic object. On failure, it return the value of default alignment of the uHeapLmmm allocator.
     194
     195\subsubsection bool malloc_zero_fill( void * addr )
     196malloc_zero_fill returns whether a currently allocated dynamic object was initially zero filled at the time of allocation. It allows the programmer in memory management and personal bookkeeping. It helps the programmer in verifying the zero filled property of a dynamic object especially in a scenerio similar to prudcer-consumer where a producer allocates a dynamic object and the consumer needs to assure that the dynamic object was zero filled at the time of allocation.
     197\paragraph{Usage}
     198malloc_zero_fill takes one parameters.
    207199\begin{itemize}
    208200\item
    209201addr: the address of the currently allocated dynamic object.
    210202\end{itemize}
    211 malloc\_zero\_fill returns true if the dynamic object was initially zero filled and return false otherwise. On failure, it returns false.
    212 
    213 \subsubsection size\_t malloc\_size( void * addr )
    214 malloc\_size returns the allocation size of a currently allocated dynamic object. It allows the programmer in memory management and personal bookkeeping. It helps the programmer in verofying the alignment of a dynamic object especially in a scenerio similar to prudcer-consumer where a producer allocates a dynamic object and the consumer needs to assure that the dynamic object was allocated with the required size. Its current alternate in the other allocators is malloc\_usable\_size. But, malloc\_size is different from malloc\_usable\_size as malloc\_usabe\_size returns the total data capacity of dynamic object including the extra space at the end of the dynamic object. On the other hand, malloc\_size returns the size that was given to the allocator at the allocation of the dynamic object. This size is updated when an object is realloced, resized, or passed through a similar allocator routine.
    215 \paragraph{Usage}
    216 malloc\_size takes one parameters.
    217 
     203malloc_zero_fill returns true if the dynamic object was initially zero filled and return false otherwise. On failure, it returns false.
     204
     205\subsubsection size_t malloc_size( void * addr )
     206malloc_size returns the allocation size of a currently allocated dynamic object. It allows the programmer in memory management and personal bookkeeping. It helps the programmer in verofying the alignment of a dynamic object especially in a scenerio similar to prudcer-consumer where a producer allocates a dynamic object and the consumer needs to assure that the dynamic object was allocated with the required size. Its current alternate in the other allocators is malloc_usable_size. But, malloc_size is different from malloc_usable_size as malloc_usabe_size returns the total data capacity of dynamic object including the extra space at the end of the dynamic object. On the other hand, malloc_size returns the size that was given to the allocator at the allocation of the dynamic object. This size is updated when an object is realloced, resized, or passed through a similar allocator routine.
     207\paragraph{Usage}
     208malloc_size takes one parameters.
    218209\begin{itemize}
    219210\item
    220211addr: the address of the currently allocated dynamic object.
    221212\end{itemize}
    222 malloc\_size returns the allocation size of the given dynamic object. On failure, it return zero.
    223 
    224 \subsubsection void * realloc( void * oaddr, size\_t nalign, size\_t size )
     213malloc_size returns the allocation size of the given dynamic object. On failure, it return zero.
     214
     215\subsubsection void * realloc( void * oaddr, size_t nalign, size_t size )
    225216This realloc is an extension of the default realloc (FIX ME: cite default realloc). In addition to reallocating an old object and preserving the data in old object, it can also realign the old object to a new alignment requirement.
    226217\paragraph{Usage}
    227218This realloc takes three parameters. It takes an additional parameter of nalign as compared to the default realloc.
    228 
    229219\begin{itemize}
    230220\item
     
    247237It returns a dynamic object of the size of type T. On failure, it return NULL pointer.
    248238
    249 \subsubsection T * aalloc( size\_t dim )
     239\subsubsection T * aalloc( size_t dim )
    250240This aalloc is a simplified polymorphic form of above aalloc (FIX ME: cite aalloc). It takes one parameter as compared to the above aalloc that takes two parameters.
    251241\paragraph{Usage}
    252242aalloc takes one parameters.
    253 
    254243\begin{itemize}
    255244\item
     
    258247It returns a dynamic object that has the capacity to contain dim number of objects, each of the size of type T. On failure, it return NULL pointer.
    259248
    260 \subsubsection T * calloc( size\_t dim )
     249\subsubsection T * calloc( size_t dim )
    261250This calloc is a simplified polymorphic form of defualt calloc (FIX ME: cite calloc). It takes one parameter as compared to the default calloc that takes two parameters.
    262251\paragraph{Usage}
    263252This calloc takes one parameter.
    264 
    265253\begin{itemize}
    266254\item
     
    269257It returns a dynamic object that has the capacity to contain dim number of objects, each of the size of type T. On failure, it return NULL pointer.
    270258
    271 \subsubsection T * resize( T * ptr, size\_t size )
     259\subsubsection T * resize( T * ptr, size_t size )
    272260This resize is a simplified polymorphic form of above resize (FIX ME: cite resize with alignment). It takes two parameters as compared to the above resize that takes three parameters. It frees the programmer from explicitly mentioning the alignment of the allocation as CFA provides gives allocator the liberty to get the alignment of the returned type.
    273261\paragraph{Usage}
    274262This resize takes two parameters.
    275 
    276263\begin{itemize}
    277264\item
     
    282269It returns a dynamic object of the size given in paramters. The returned object is aligned to the alignemtn of type T. On failure, it return NULL pointer.
    283270
    284 \subsubsection T * realloc( T * ptr, size\_t size )
     271\subsubsection T * realloc( T * ptr, size_t size )
    285272This realloc is a simplified polymorphic form of defualt realloc (FIX ME: cite realloc with align). It takes two parameters as compared to the above realloc that takes three parameters. It frees the programmer from explicitly mentioning the alignment of the allocation as CFA provides gives allocator the liberty to get the alignment of the returned type.
    286273\paragraph{Usage}
    287274This realloc takes two parameters.
    288 
    289275\begin{itemize}
    290276\item
     
    295281It returns a dynamic object of the size given in paramters that preserves the data in the given object. The returned object is aligned to the alignemtn of type T. On failure, it return NULL pointer.
    296282
    297 \subsubsection T * memalign( size\_t align )
     283\subsubsection T * memalign( size_t align )
    298284This memalign is a simplified polymorphic form of defualt memalign (FIX ME: cite memalign). It takes one parameters as compared to the default memalign that takes two parameters.
    299285\paragraph{Usage}
    300286memalign takes one parameters.
    301 
    302287\begin{itemize}
    303288\item
     
    306291It returns a dynamic object of the size of type T that is aligned to given parameter align. On failure, it return NULL pointer.
    307292
    308 \subsubsection T * amemalign( size\_t align, size\_t dim )
     293\subsubsection T * amemalign( size_t align, size_t dim )
    309294This amemalign is a simplified polymorphic form of above amemalign (FIX ME: cite amemalign). It takes two parameter as compared to the above amemalign that takes three parameters.
    310295\paragraph{Usage}
    311296amemalign takes two parameters.
    312 
    313297\begin{itemize}
    314298\item
     
    319303It returns a dynamic object that has the capacity to contain dim number of objects, each of the size of type T. The returned object is aligned to the given parameter align. On failure, it return NULL pointer.
    320304
    321 \subsubsection T * cmemalign( size\_t align, size\_t dim  )
     305\subsubsection T * cmemalign( size_t align, size_t dim  )
    322306This cmemalign is a simplified polymorphic form of above cmemalign (FIX ME: cite cmemalign). It takes two parameter as compared to the above cmemalign that takes three parameters.
    323307\paragraph{Usage}
    324308cmemalign takes two parameters.
    325 
    326309\begin{itemize}
    327310\item
     
    332315It returns a dynamic object that has the capacity to contain dim number of objects, each of the size of type T. The returned object is aligned to the given parameter align and is zero filled. On failure, it return NULL pointer.
    333316
    334 \subsubsection T * aligned\_alloc( size\_t align )
    335 This aligned\_alloc is a simplified polymorphic form of defualt aligned\_alloc (FIX ME: cite aligned\_alloc). It takes one parameter as compared to the default aligned\_alloc that takes two parameters.
    336 \paragraph{Usage}
    337 This aligned\_alloc takes one parameter.
    338 
     317\subsubsection T * aligned_alloc( size_t align )
     318This aligned_alloc is a simplified polymorphic form of defualt aligned_alloc (FIX ME: cite aligned_alloc). It takes one parameter as compared to the default aligned_alloc that takes two parameters.
     319\paragraph{Usage}
     320This aligned_alloc takes one parameter.
    339321\begin{itemize}
    340322\item
     
    343325It returns a dynamic object of the size of type T that is aligned to the given parameter. On failure, it return NULL pointer.
    344326
    345 \subsubsection int posix\_memalign( T ** ptr, size\_t align )
    346 This posix\_memalign is a simplified polymorphic form of defualt posix\_memalign (FIX ME: cite posix\_memalign). It takes two parameters as compared to the default posix\_memalign that takes three parameters.
    347 \paragraph{Usage}
    348 This posix\_memalign takes two parameter.
    349 
     327\subsubsection int posix_memalign( T ** ptr, size_t align )
     328This posix_memalign is a simplified polymorphic form of defualt posix_memalign (FIX ME: cite posix_memalign). It takes two parameters as compared to the default posix_memalign that takes three parameters.
     329\paragraph{Usage}
     330This posix_memalign takes two parameter.
    350331\begin{itemize}
    351332\item
     
    354335align: required alignment of the dynamic object.
    355336\end{itemize}
    356 
    357337It stores address of the dynamic object of the size of type T in given parameter ptr. This object is aligned to the given parameter. On failure, it return NULL pointer.
    358338
     
    369349It returns a dynamic object of the size that is calcutaed by rouding the size of type T. The returned object is also aligned to the page size. On failure, it return NULL pointer.
    370350
    371 \subsection Alloc Interface
     351\subsection{Alloc Interface}
    372352In addition to improve allocator interface both for CFA and our standalone allocator uHeapLmmm in C. We also added a new alloc interface in CFA that increases usability of dynamic memory allocation.
    373353This interface helps programmers in three major ways.
    374 
    375354\begin{itemize}
    376355\item
     
    392371This is the only parameter in the alloc routine that has a fixed-position and it is also the only parameter that does not use a backtick function. It has to be passed at the first position to alloc call in-case of an array allocation of objects of type T.
    393372It represents the required number of members in the array allocation as in CFA's aalloc (FIX ME: cite aalloc).
    394 This parameter should be of type size\_t.
     373This parameter should be of type size_t.
    395374
    396375Example: int a = alloc( 5 )
     
    398377
    399378\paragraph{Align}
    400 This parameter is position-free and uses a backtick routine align (`align). The parameter passed with `align should be of type size\_t. If the alignment parameter is not a power of two or is less than the default alignment of the allocator (that can be found out using routine libAlign in CFA) then the passed alignment parameter will be rejected and the default alignment will be used.
     379This parameter is position-free and uses a backtick routine align (`align). The parameter passed with `align should be of type size_t. If the alignment parameter is not a power of two or is less than the default alignment of the allocator (that can be found out using routine libAlign in CFA) then the passed alignment parameter will be rejected and the default alignment will be used.
    401380
    402381Example: int b = alloc( 5 , 64`align )
     
    406385This parameter is position-free and uses a backtick routine fill (`fill). In case of realloc, only the extra space after copying the data in the old object will be filled with given parameter.
    407386Three types of parameters can be passed using `fill.
    408 
    409387\begin{itemize}
    410388\item
  • doc/theses/mubeen_zulfiqar_MMath/background.tex

    re58e423 r42b7fa5f  
    2323====================
    2424
    25 \section{Background}
    26 
    27 % FIXME: cite wasik
    28 \cite{wasik.thesis}
    29 
    30 \subsection{Memory Allocation}
    31 With dynamic allocation being an important feature of C, there are many standalone memory allocators that have been designed for different purposes. For this thesis, we chose 7 of the most popular and widely used memory allocators.
    32 
    33 \paragraph{dlmalloc}
    34 dlmalloc (FIX ME: cite allocator) is a thread-safe allocator that is single threaded and single heap. dlmalloc maintains free-lists of different sizes to store freed dynamic memory. (FIX ME: cite wasik)
    35 
    36 \paragraph{hoard}
    37 Hoard (FIX ME: cite allocator) is a thread-safe allocator that is multi-threaded and using a heap layer framework. It has per-thred heaps that have thread-local free-lists, and a gloabl shared heap. (FIX ME: cite wasik)
    38 
    39 \paragraph{jemalloc}
    40 jemalloc (FIX ME: cite allocator) is a thread-safe allocator that uses multiple arenas. Each thread is assigned an arena. Each arena has chunks that contain contagious memory regions of same size. An arena has multiple chunks that contain regions of multiple sizes.
    41 
    42 \paragraph{ptmalloc}
    43 ptmalloc (FIX ME: cite allocator) is a modification of dlmalloc. It is a thread-safe multi-threaded memory allocator that uses multiple heaps. ptmalloc heap has similar design to dlmalloc's heap.
    44 
    45 \paragraph{rpmalloc}
    46 rpmalloc (FIX ME: cite allocator) is a thread-safe allocator that is multi-threaded and uses per-thread heap. Each heap has multiple size-classes and each size-calss contains memory regions of the relevant size.
    47 
    48 \paragraph{tbb malloc}
    49 tbb malloc (FIX ME: cite allocator) is a thread-safe allocator that is multi-threaded and uses private heap for each thread. Each private-heap has multiple bins of different sizes. Each bin contains free regions of the same size.
    50 
    51 \paragraph{tc malloc}
    52 tcmalloc (FIX ME: cite allocator) is a thread-safe allocator. It uses per-thread cache to store free objects that prevents contention on shared resources in multi-threaded application. A central free-list is used to refill per-thread cache when it gets empty.
    53 
    54 \subsection{Benchmarks}
    55 There are multiple benchmarks that are built individually and evaluate different aspects of a memory allocator. But, there is not standard set of benchamrks that can be used to evaluate multiple aspects of memory allocators.
    56 
    57 \paragraph{threadtest}
    58 (FIX ME: cite benchmark and hoard) Each thread repeatedly allocates and then deallocates 100,000 objects. Runtime of the benchmark evaluates its efficiency.
    59 
    60 \paragraph{shbench}
    61 (FIX ME: cite benchmark and hoard) Each thread allocates and randomly frees a number of random-sized objects. It is a stress test that also uses runtime to determine efficiency of the allocator.
    62 
    63 \paragraph{larson}
    64 (FIX ME: cite benchmark and hoard) Larson simulates a server environment. Multiple threads are created where each thread allocator and free a number of objects within a size range. Some objects are passed from threads to the child threads to free. It caluculates memory operations per second as an indicator of memory allocator's performance.
     25\cite{Wasik08}
  • doc/theses/mubeen_zulfiqar_MMath/benchmarks.tex

    re58e423 r42b7fa5f  
    149149*** FIX ME: Insert a figure of above benchmark with description
    150150
    151 \paragraph{Relevant Knobs}
     151\paragrpah{Relevant Knobs}
    152152*** FIX ME: Insert Relevant Knobs
    153153
  • doc/theses/mubeen_zulfiqar_MMath/intro.tex

    re58e423 r42b7fa5f  
    4747\begin{itemize}
    4848\item
    49 aligned\_alloc
     49aligned_alloc
    5050\item
    51 malloc\_usable\_size
     51malloc_usable_size
    5252\item
    5353memalign
    5454\item
    55 posix\_memalign
     55posix_memalign
    5656\item
    5757pvalloc
     
    6161
    6262With the rise of concurrent applications, memory allocators should be able to fulfill dynamic memory requests from multiple threads in parallel without causing contention on shared resources. There needs to be a set of a standard benchmarks that can be used to evaluate an allocator's performance in different scenerios.
     63
     64\section{Background}
     65
     66\subsection{Memory Allocation}
     67With dynamic allocation being an important feature of C, there are many standalone memory allocators that have been designed for different purposes. For this thesis, we chose 7 of the most popular and widely used memory allocators.
     68
     69\paragraph{dlmalloc}
     70dlmalloc (FIX ME: cite allocator) is a thread-safe allocator that is single threaded and single heap. dlmalloc maintains free-lists of different sizes to store freed dynamic memory. (FIX ME: cite wasik)
     71
     72\paragraph{hoard}
     73Hoard (FIX ME: cite allocator) is a thread-safe allocator that is multi-threaded and using a heap layer framework. It has per-thred heaps that have thread-local free-lists, and a gloabl shared heap. (FIX ME: cite wasik)
     74
     75\paragraph{jemalloc}
     76jemalloc (FIX ME: cite allocator) is a thread-safe allocator that uses multiple arenas. Each thread is assigned an arena. Each arena has chunks that contain contagious memory regions of same size. An arena has multiple chunks that contain regions of multiple sizes.
     77
     78\paragraph{ptmalloc}
     79ptmalloc (FIX ME: cite allocator) is a modification of dlmalloc. It is a thread-safe multi-threaded memory allocator that uses multiple heaps. ptmalloc heap has similar design to dlmalloc's heap.
     80
     81\paragraph{rpmalloc}
     82rpmalloc (FIX ME: cite allocator) is a thread-safe allocator that is multi-threaded and uses per-thread heap. Each heap has multiple size-classes and each size-calss contains memory regions of the relevant size.
     83
     84\paragraph{tbb malloc}
     85tbb malloc (FIX ME: cite allocator) is a thread-safe allocator that is multi-threaded and uses private heap for each thread. Each private-heap has multiple bins of different sizes. Each bin contains free regions of the same size.
     86
     87\paragraph{tc malloc}
     88tcmalloc (FIX ME: cite allocator) is a thread-safe allocator. It uses per-thread cache to store free objects that prevents contention on shared resources in multi-threaded application. A central free-list is used to refill per-thread cache when it gets empty.
     89
     90\subsection{Benchmarks}
     91There are multiple benchmarks that are built individually and evaluate different aspects of a memory allocator. But, there is not standard set of benchamrks that can be used to evaluate multiple aspects of memory allocators.
     92
     93\paragraph{threadtest}
     94(FIX ME: cite benchmark and hoard) Each thread repeatedly allocates and then deallocates 100,000 objects. Runtime of the benchmark evaluates its efficiency.
     95
     96\paragraph{shbench}
     97(FIX ME: cite benchmark and hoard) Each thread allocates and randomly frees a number of random-sized objects. It is a stress test that also uses runtime to determine efficiency of the allocator.
     98
     99\paragraph{larson}
     100(FIX ME: cite benchmark and hoard) Larson simulates a server environment. Multiple threads are created where each thread allocator and free a number of objects within a size range. Some objects are passed from threads to the child threads to free. It caluculates memory operations per second as an indicator of memory allocator's performance.
    63101
    64102\section{Research Objectives}
  • doc/theses/mubeen_zulfiqar_MMath/performance.tex

    re58e423 r42b7fa5f  
    4444tc               &             &  \\
    4545\end{tabularx}
    46 
    47 %(FIX ME: complete table)
     46(FIX ME: complete table)
    4847
    4948\section{Experiment Environment}
  • doc/theses/mubeen_zulfiqar_MMath/uw-ethesis.bib

    re58e423 r42b7fa5f  
    2727        address =       "Reading, Massachusetts"
    2828}
    29 
    30 @article{wasik.thesis,
    31     author        = "Ayelet Wasik",
    32     title         = "Features of A Multi-Threaded Memory Alloator",
    33     publisher     = "University of Waterloo",
    34     year          = "2008"
    35 }
  • doc/theses/mubeen_zulfiqar_MMath/uw-ethesis.tex

    re58e423 r42b7fa5f  
    8484\usepackage{graphicx}
    8585\usepackage{comment} % Removes large sections of the document.
    86 \usepackage{tabularx}
    8786
    8887% Hyperlinks make it very easy to navigate an electronic document.
     
    192191% Tip: Putting each sentence on a new line is a way to simplify later editing.
    193192%----------------------------------------------------------------------
    194 \begin{sloppypar}
    195 
    196193\input{intro}
    197194\input{background}
     
    200197\input{performance}
    201198\input{conclusion}
    202 
    203 \end{sloppypar}
    204199
    205200%----------------------------------------------------------------------
  • libcfa/src/concurrency/mutex_stmt.hfa

    re58e423 r42b7fa5f  
    11#include "bits/algorithm.hfa"
    2 #include "bits/defs.hfa"
     2#include <assert.h>
     3#include "invoke.h"
     4#include "stdlib.hfa"
     5#include <stdio.h>
    36
    47//-----------------------------------------------------------------------------
  • src/CodeGen/FixMain.cc

    re58e423 r42b7fa5f  
    2222#include <string>                  // for operator<<
    2323
    24 #include "AST/Decl.hpp"
    25 #include "AST/Type.hpp"
    26 #include "Common/PassVisitor.h"
    2724#include "Common/SemanticError.h"  // for SemanticError
    2825#include "CodeGen/GenType.h"       // for GenType
     
    3229
    3330namespace CodeGen {
    34 
    35 namespace {
    36 
    37 struct FindMainCore {
    38         FunctionDecl * main_signature = nullptr;
    39 
    40         void previsit( FunctionDecl * decl ) {
    41                 if ( FixMain::isMain( decl ) ) {
    42                         if ( main_signature ) {
    43                                 SemanticError( decl, "Multiple definition of main routine\n" );
    44                         }
    45                         main_signature = decl;
    46                 }
    47         }
    48 };
    49 
    50 }
    51 
    5231        bool FixMain::replace_main = false;
     32        std::unique_ptr<FunctionDecl> FixMain::main_signature = nullptr;
    5333
    5434        template<typename container>
     
    5737        }
    5838
    59         void FixMain::fix( std::list< Declaration * > & translationUnit,
    60                         std::ostream &os, const char* bootloader_filename ) {
    61                 PassVisitor< FindMainCore > main_finder;
    62                 acceptAll( translationUnit, main_finder );
    63                 FunctionDecl * main_signature = main_finder.pass.main_signature;
     39        void FixMain::registerMain(FunctionDecl* functionDecl)
     40        {
     41                if(main_signature) {
     42                        SemanticError(functionDecl, "Multiple definition of main routine\n");
     43                }
     44                main_signature.reset( functionDecl->clone() );
     45        }
    6446
     47        void FixMain::fix(std::ostream &os, const char* bootloader_filename) {
    6548                if( main_signature ) {
    6649                        os << "static inline int invoke_main(int argc, char* argv[], char* envp[]) { (void)argc; (void)argv; (void)envp; return ";
    67                         main_signature->mangleName = SymTab::Mangler::mangle(main_signature);
     50                        main_signature->mangleName = SymTab::Mangler::mangle(main_signature.get());
    6851
    6952                        os << main_signature->get_scopedMangleName() << "(";
     
    8265                }
    8366        }
    84 
    85 namespace {
    86 
    87 ObjectDecl * signedIntObj() {
    88         return new ObjectDecl(
    89                 "", Type::StorageClasses(), LinkageSpec::Cforall, 0,
    90                 new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr );
    91 }
    92 
    93 ObjectDecl * charStarObj() {
    94         return new ObjectDecl(
    95                 "", Type::StorageClasses(), LinkageSpec::Cforall, 0,
    96                 new PointerType( Type::Qualifiers(),
    97                         new PointerType( Type::Qualifiers(),
    98                                 new BasicType( Type::Qualifiers(), BasicType::Char ) ) ),
    99                 nullptr );
    100 }
    101 
    102 std::string create_mangled_main_function_name( FunctionType * function_type ) {
    103         std::unique_ptr<FunctionDecl> decl( new FunctionDecl(
    104                 "main", Type::StorageClasses(), LinkageSpec::Cforall,
    105                 function_type, nullptr ) );
    106         return SymTab::Mangler::mangle( decl.get() );
    107 }
    108 
    109 std::string mangled_0_argument_main() {
    110         FunctionType* main_type = new FunctionType( Type::Qualifiers(), true );
    111         main_type->get_returnVals().push_back( signedIntObj() );
    112         return create_mangled_main_function_name( main_type );
    113 }
    114 
    115 std::string mangled_2_argument_main() {
    116         FunctionType* main_type = new FunctionType( Type::Qualifiers(), false );
    117         main_type->get_returnVals().push_back( signedIntObj() );
    118         main_type->get_parameters().push_back( signedIntObj() );
    119         main_type->get_parameters().push_back( charStarObj() );
    120         return create_mangled_main_function_name( main_type );
    121 }
    122 
    123 bool is_main( const std::string & mangled_name ) {
    124         // This breaks if you move it out of the function.
    125         static const std::string mangled_mains[] = {
    126                 mangled_0_argument_main(),
    127                 mangled_2_argument_main(),
    128                 //mangled_3_argument_main(),
    129         };
    130 
    131         for ( auto main_name : mangled_mains ) {
    132                 if ( main_name == mangled_name ) return true;
    133         }
    134         return false;
    135 }
    136 
    137 } // namespace
    138 
    139 bool FixMain::isMain( FunctionDecl * decl ) {
    140         if ( std::string("main") != decl->name ) {
    141                 return false;
    142         }
    143         return is_main( SymTab::Mangler::mangle( decl, true, true ) );
    144 }
    145 
    146 bool FixMain::isMain( const ast::FunctionDecl * decl ) {
    147         if ( std::string("main") != decl->name ) {
    148                 return false;
    149         }
    150         return is_main( Mangle::mangle( decl, Mangle::Type ) );
    151 }
    152 
    15367};
  • src/CodeGen/FixMain.h

    re58e423 r42b7fa5f  
    99// Author           : Thierry Delisle
    1010// Created On       : Thr Jan 12 14:11:09 2017
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Fri Oct 29 16:20:00 2021
    13 // Update Count     : 8
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Sun Feb 16 03:24:32 2020
     13// Update Count     : 5
    1414//
    1515
     
    1818#include <iosfwd>
    1919#include <memory>
    20 #include <list>
    2120
    2221#include "SynTree/LinkageSpec.h"
    2322
    24 class Declaration;
    2523class FunctionDecl;
    26 namespace ast {
    27         class FunctionDecl;
    28 }
    2924
    3025namespace CodeGen {
     26        class FixMain {
     27          public :
     28                static inline LinkageSpec::Spec mainLinkage() {
     29                        return replace_main ? LinkageSpec::Cforall : LinkageSpec::C;
     30                }
     31               
     32                static inline void setReplaceMain(bool val) {
     33                        replace_main = val;
     34                }
    3135
    32 class FixMain {
    33 public :
    34         static inline LinkageSpec::Spec mainLinkage() {
    35                 return replace_main ? LinkageSpec::Cforall : LinkageSpec::C;
    36         }
     36                static void registerMain(FunctionDecl* val);
    3737
    38         static inline void setReplaceMain(bool val) {
    39                 replace_main = val;
    40         }
     38                static void fix(std::ostream &os, const char* bootloader_filename);
    4139
    42         static bool isMain(FunctionDecl* decl);
    43         static bool isMain(const ast::FunctionDecl * decl);
    44 
    45         static void fix( std::list< Declaration * > & decls,
    46                         std::ostream &os, const char* bootloader_filename );
    47 
    48 private:
    49         static bool replace_main;
    50 };
    51 
     40          private:
     41                static bool replace_main;
     42                static std::unique_ptr<FunctionDecl> main_signature;
     43        };
    5244} // namespace CodeGen
  • src/CodeGen/FixNames.cc

    re58e423 r42b7fa5f  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Fri Oct 29 15:49:00 2021
    13 // Update Count     : 23
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Fri Dec 13 23:39:14 2019
     13// Update Count     : 21
    1414//
    1515
     
    1919#include <string>                  // for string, operator!=, operator==
    2020
    21 #include "AST/Chain.hpp"
    22 #include "AST/Expr.hpp"
    23 #include "AST/Pass.hpp"
    2421#include "Common/PassVisitor.h"
    2522#include "Common/SemanticError.h"  // for SemanticError
     
    4946        };
    5047
     48        std::string mangle_main() {
     49                FunctionType* main_type;
     50                std::unique_ptr<FunctionDecl> mainDecl { new FunctionDecl( "main", Type::StorageClasses(), LinkageSpec::Cforall,
     51                                                                                                                                   main_type = new FunctionType( Type::Qualifiers(), true ), nullptr )
     52                                };
     53                main_type->get_returnVals().push_back(
     54                        new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr )
     55                );
     56
     57                auto && name = SymTab::Mangler::mangle( mainDecl.get() );
     58                // std::cerr << name << std::endl;
     59                return std::move(name);
     60        }
     61        std::string mangle_main_args() {
     62                FunctionType* main_type;
     63                std::unique_ptr<FunctionDecl> mainDecl { new FunctionDecl( "main", Type::StorageClasses(), LinkageSpec::Cforall,
     64                                                                                                                                   main_type = new FunctionType( Type::Qualifiers(), false ), nullptr )
     65                                };
     66                main_type->get_returnVals().push_back(
     67                        new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr )
     68                );
     69
     70                main_type->get_parameters().push_back(
     71                        new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr )
     72                );
     73
     74                main_type->get_parameters().push_back(
     75                        new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, 0,
     76                        new PointerType( Type::Qualifiers(), new PointerType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::Char ) ) ),
     77                        nullptr )
     78                );
     79
     80                auto&& name = SymTab::Mangler::mangle( mainDecl.get() );
     81                // std::cerr << name << std::endl;
     82                return std::move(name);
     83        }
     84
     85        bool is_main(const std::string& name) {
     86                static std::string mains[] = {
     87                        mangle_main(),
     88                        mangle_main_args()
     89                };
     90
     91                for(const auto& m : mains) {
     92                        if( name == m ) return true;
     93                }
     94                return false;
     95        }
     96
    5197        void fixNames( std::list< Declaration* > & translationUnit ) {
    5298                PassVisitor<FixNames> fixer;
     
    72118                fixDWT( functionDecl );
    73119
    74                 if ( FixMain::isMain( functionDecl ) ) {
     120                if(is_main( SymTab::Mangler::mangle(functionDecl, true, true) )) {
    75121                        int nargs = functionDecl->get_functionType()->get_parameters().size();
    76122                        if( !(nargs == 0 || nargs == 2 || nargs == 3) ) {
     
    78124                        }
    79125                        functionDecl->get_statements()->get_kids().push_back( new ReturnStmt( new ConstantExpr( Constant::from_int( 0 ) ) ) );
     126                        CodeGen::FixMain::registerMain( functionDecl );
    80127                }
    81128        }
     
    85132                GuardAction( [this](){ scopeLevel--; } );
    86133        }
    87 
    88 /// Does work with the main function and scopeLevels.
    89 class FixNames_new : public ast::WithGuards {
    90         int scopeLevel = 1;
    91 
    92         bool shouldSetScopeLevel( const ast::DeclWithType * dwt ) {
    93                 return !dwt->name.empty() && dwt->linkage.is_mangled
    94                         && dwt->scopeLevel != scopeLevel;
    95         }
    96 public:
    97         const ast::ObjectDecl *postvisit( const ast::ObjectDecl *objectDecl ) {
    98                 if ( shouldSetScopeLevel( objectDecl ) ) {
    99                         return ast::mutate_field( objectDecl, &ast::ObjectDecl::scopeLevel, scopeLevel );
    100                 }
    101                 return objectDecl;
    102         }
    103 
    104         const ast::FunctionDecl *postvisit( const ast::FunctionDecl *functionDecl ) {
    105                 // This store is used to ensure a maximum of one call to mutate.
    106                 ast::FunctionDecl * mutDecl = nullptr;
    107 
    108                 if ( shouldSetScopeLevel( functionDecl ) ) {
    109                         mutDecl = ast::mutate( functionDecl );
    110                         mutDecl->scopeLevel = scopeLevel;
    111                 }
    112 
    113                 if ( FixMain::isMain( functionDecl ) ) {
    114                         if ( !mutDecl ) { mutDecl = ast::mutate( functionDecl ); }
    115 
    116                         int nargs = mutDecl->params.size();
    117                         if ( 0 != nargs && 2 != nargs && 3 != nargs ) {
    118                                 SemanticError( functionDecl, "Main expected to have 0, 2 or 3 arguments\n" );
    119                         }
    120                         ast::chain_mutate( mutDecl->stmts )->kids.push_back(
    121                                 new ast::ReturnStmt(
    122                                         mutDecl->location,
    123                                         ast::ConstantExpr::from_int( mutDecl->location, 0 )
    124                                 )
    125                         );
    126                 }
    127                 return mutDecl ? mutDecl : functionDecl;
    128         }
    129 
    130         void previsit( const ast::CompoundStmt * ) {
    131                 GuardValue( scopeLevel ) += 1;
    132         }
    133 };
    134 
    135 void fixNames( ast::TranslationUnit & translationUnit ) {
    136         ast::Pass<FixNames_new>::run( translationUnit );
    137 }
    138 
    139134} // namespace CodeGen
    140135
  • src/CodeGen/FixNames.h

    re58e423 r42b7fa5f  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Tue Oct 26 13:47:00 2021
    13 // Update Count     : 4
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Fri Jul 21 22:17:33 2017
     13// Update Count     : 3
    1414//
    1515
     
    1919
    2020class Declaration;
    21 namespace ast {
    22         struct TranslationUnit;
    23 }
    2421
    2522namespace CodeGen {
    2623        /// mangles object and function names
    2724        void fixNames( std::list< Declaration* > & translationUnit );
    28         void fixNames( ast::TranslationUnit & translationUnit );
    2925} // namespace CodeGen
    3026
  • src/main.cc

    re58e423 r42b7fa5f  
    1010// Created On       : Fri May 15 23:12:02 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Fri Oct 29 16:34:00 2021
    13 // Update Count     : 655
     12// Last Modified On : Fri Oct 22 16:06:00 2021
     13// Update Count     : 653
    1414//
    1515
     
    335335                PASS( "Translate Throws", ControlStruct::translateThrows( translationUnit ) );
    336336                PASS( "Fix Labels", ControlStruct::fixLabels( translationUnit ) );
     337                PASS( "Fix Names", CodeGen::fixNames( translationUnit ) );
    337338
    338339                CodeTools::fillLocations( translationUnit );
     
    347348                        forceFillCodeLocations( transUnit );
    348349
    349                         PASS( "Fix Names", CodeGen::fixNames( transUnit ) );
    350350                        PASS( "Gen Init", InitTweak::genInit( transUnit ) );
    351351                        PASS( "Expand Member Tuples" , Tuples::expandMemberTuples( transUnit ) );
     
    383383                        translationUnit = convert( move( transUnit ) );
    384384                } else {
    385                         PASS( "Fix Names", CodeGen::fixNames( translationUnit ) );
    386385                        PASS( "Gen Init", InitTweak::genInit( translationUnit ) );
    387386                        PASS( "Expand Member Tuples" , Tuples::expandMemberTuples( translationUnit ) );
     
    472471                PASS( "Code Gen", CodeGen::generate( translationUnit, *output, ! genproto, prettycodegenp, true, linemarks ) );
    473472
    474                 CodeGen::FixMain::fix( translationUnit, *output,
    475                                 (PreludeDirector + "/bootloader.c").c_str() );
     473                CodeGen::FixMain::fix( *output, (PreludeDirector + "/bootloader.c").c_str() );
    476474                if ( output != &cout ) {
    477475                        delete output;
Note: See TracChangeset for help on using the changeset viewer.