Changes in / [e58e423:42b7fa5f]
- Files:
-
- 1 added
- 13 edited
-
doc/theses/mubeen_zulfiqar_MMath/allocator.tex (modified) (21 diffs)
-
doc/theses/mubeen_zulfiqar_MMath/background.tex (modified) (1 diff)
-
doc/theses/mubeen_zulfiqar_MMath/benchmarks.tex (modified) (1 diff)
-
doc/theses/mubeen_zulfiqar_MMath/intro.tex (modified) (2 diffs)
-
doc/theses/mubeen_zulfiqar_MMath/performance.tex (modified) (1 diff)
-
doc/theses/mubeen_zulfiqar_MMath/thesis.tex (added)
-
doc/theses/mubeen_zulfiqar_MMath/uw-ethesis.bib (modified) (1 diff)
-
doc/theses/mubeen_zulfiqar_MMath/uw-ethesis.tex (modified) (3 diffs)
-
libcfa/src/concurrency/mutex_stmt.hfa (modified) (1 diff)
-
src/CodeGen/FixMain.cc (modified) (4 diffs)
-
src/CodeGen/FixMain.h (modified) (2 diffs)
-
src/CodeGen/FixNames.cc (modified) (6 diffs)
-
src/CodeGen/FixNames.h (modified) (2 diffs)
-
src/main.cc (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/mubeen_zulfiqar_MMath/allocator.tex
re58e423 r42b7fa5f 24 24 \end{itemize} 25 25 26 The new features added to uHeapLmmm (incl. @malloc \_size@ routine)26 The new features added to uHeapLmmm (incl. @malloc_size@ routine) 27 27 \CFA alloc interface with examples. 28 29 28 \begin{itemize} 30 29 \item … … 118 117 We 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. 119 118 120 \subsubsection void * aalloc( size \_t dim, size\_t elemSize )119 \subsubsection void * aalloc( size_t dim, size_t elemSize ) 121 120 aalloc 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. 122 121 \paragraph{Usage} 123 122 aalloc takes two parameters. 124 125 123 \begin{itemize} 126 124 \item … … 131 129 It 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. 132 130 133 \subsubsection void * resize( void * oaddr, size \_t size )131 \subsubsection void * resize( void * oaddr, size_t size ) 134 132 resize 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. 135 133 \paragraph{Usage} 136 134 resize takes two parameters. 137 138 135 \begin{itemize} 139 136 \item … … 144 141 It 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. 145 142 146 \subsubsection void * resize( void * oaddr, size \_t nalign, size\_t size )143 \subsubsection void * resize( void * oaddr, size_t nalign, size_t size ) 147 144 This 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. 148 145 \paragraph{Usage} 149 146 This resize takes three parameters. It takes an additional parameter of nalign as compared to the above resize (FIX ME: cite above resize). 150 151 147 \begin{itemize} 152 148 \item … … 159 155 It returns an object with the size and alignment given in the parameters. On failure, it returns a NULL pointer. 160 156 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 ) 162 158 amemalign 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. 163 159 \paragraph{Usage} 164 160 amemalign takes three parameters. 165 166 161 \begin{itemize} 167 162 \item … … 174 169 It 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. 175 170 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 ) 177 172 cmemalign 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. 178 173 \paragraph{Usage} 179 174 cmemalign takes three parameters. 180 181 175 \begin{itemize} 182 176 \item … … 189 183 It 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. 190 184 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 ) 186 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. 187 \paragraph{Usage} 188 malloc_alignment takes one parameters. 196 189 \begin{itemize} 197 190 \item 198 191 addr: the address of the currently allocated dynamic object. 199 192 \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 193 malloc_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 ) 196 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. 197 \paragraph{Usage} 198 malloc_zero_fill takes one parameters. 207 199 \begin{itemize} 208 200 \item 209 201 addr: the address of the currently allocated dynamic object. 210 202 \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 203 malloc_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 ) 206 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. 207 \paragraph{Usage} 208 malloc_size takes one parameters. 218 209 \begin{itemize} 219 210 \item 220 211 addr: the address of the currently allocated dynamic object. 221 212 \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 )213 malloc_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 ) 225 216 This 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. 226 217 \paragraph{Usage} 227 218 This realloc takes three parameters. It takes an additional parameter of nalign as compared to the default realloc. 228 229 219 \begin{itemize} 230 220 \item … … 247 237 It returns a dynamic object of the size of type T. On failure, it return NULL pointer. 248 238 249 \subsubsection T * aalloc( size \_t dim )239 \subsubsection T * aalloc( size_t dim ) 250 240 This 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. 251 241 \paragraph{Usage} 252 242 aalloc takes one parameters. 253 254 243 \begin{itemize} 255 244 \item … … 258 247 It 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. 259 248 260 \subsubsection T * calloc( size \_t dim )249 \subsubsection T * calloc( size_t dim ) 261 250 This 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. 262 251 \paragraph{Usage} 263 252 This calloc takes one parameter. 264 265 253 \begin{itemize} 266 254 \item … … 269 257 It 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. 270 258 271 \subsubsection T * resize( T * ptr, size \_t size )259 \subsubsection T * resize( T * ptr, size_t size ) 272 260 This 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. 273 261 \paragraph{Usage} 274 262 This resize takes two parameters. 275 276 263 \begin{itemize} 277 264 \item … … 282 269 It 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. 283 270 284 \subsubsection T * realloc( T * ptr, size \_t size )271 \subsubsection T * realloc( T * ptr, size_t size ) 285 272 This 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. 286 273 \paragraph{Usage} 287 274 This realloc takes two parameters. 288 289 275 \begin{itemize} 290 276 \item … … 295 281 It 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. 296 282 297 \subsubsection T * memalign( size \_t align )283 \subsubsection T * memalign( size_t align ) 298 284 This 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. 299 285 \paragraph{Usage} 300 286 memalign takes one parameters. 301 302 287 \begin{itemize} 303 288 \item … … 306 291 It returns a dynamic object of the size of type T that is aligned to given parameter align. On failure, it return NULL pointer. 307 292 308 \subsubsection T * amemalign( size \_t align, size\_t dim )293 \subsubsection T * amemalign( size_t align, size_t dim ) 309 294 This 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. 310 295 \paragraph{Usage} 311 296 amemalign takes two parameters. 312 313 297 \begin{itemize} 314 298 \item … … 319 303 It 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. 320 304 321 \subsubsection T * cmemalign( size \_t align, size\_t dim )305 \subsubsection T * cmemalign( size_t align, size_t dim ) 322 306 This 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. 323 307 \paragraph{Usage} 324 308 cmemalign takes two parameters. 325 326 309 \begin{itemize} 327 310 \item … … 332 315 It 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. 333 316 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 ) 318 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. 319 \paragraph{Usage} 320 This aligned_alloc takes one parameter. 339 321 \begin{itemize} 340 322 \item … … 343 325 It returns a dynamic object of the size of type T that is aligned to the given parameter. On failure, it return NULL pointer. 344 326 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 ) 328 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. 329 \paragraph{Usage} 330 This posix_memalign takes two parameter. 350 331 \begin{itemize} 351 332 \item … … 354 335 align: required alignment of the dynamic object. 355 336 \end{itemize} 356 357 337 It 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. 358 338 … … 369 349 It 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. 370 350 371 \subsection Alloc Interface351 \subsection{Alloc Interface} 372 352 In 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. 373 353 This interface helps programmers in three major ways. 374 375 354 \begin{itemize} 376 355 \item … … 392 371 This 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. 393 372 It 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.373 This parameter should be of type size_t. 395 374 396 375 Example: int a = alloc( 5 ) … … 398 377 399 378 \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.379 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. 401 380 402 381 Example: int b = alloc( 5 , 64`align ) … … 406 385 This 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. 407 386 Three types of parameters can be passed using `fill. 408 409 387 \begin{itemize} 410 388 \item -
doc/theses/mubeen_zulfiqar_MMath/background.tex
re58e423 r42b7fa5f 23 23 ==================== 24 24 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 149 149 *** FIX ME: Insert a figure of above benchmark with description 150 150 151 \paragr aph{Relevant Knobs}151 \paragrpah{Relevant Knobs} 152 152 *** FIX ME: Insert Relevant Knobs 153 153 -
doc/theses/mubeen_zulfiqar_MMath/intro.tex
re58e423 r42b7fa5f 47 47 \begin{itemize} 48 48 \item 49 aligned \_alloc49 aligned_alloc 50 50 \item 51 malloc \_usable\_size51 malloc_usable_size 52 52 \item 53 53 memalign 54 54 \item 55 posix \_memalign55 posix_memalign 56 56 \item 57 57 pvalloc … … 61 61 62 62 With 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} 67 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. 68 69 \paragraph{dlmalloc} 70 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) 71 72 \paragraph{hoard} 73 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) 74 75 \paragraph{jemalloc} 76 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. 77 78 \paragraph{ptmalloc} 79 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. 80 81 \paragraph{rpmalloc} 82 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. 83 84 \paragraph{tbb malloc} 85 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. 86 87 \paragraph{tc malloc} 88 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. 89 90 \subsection{Benchmarks} 91 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. 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. 63 101 64 102 \section{Research Objectives} -
doc/theses/mubeen_zulfiqar_MMath/performance.tex
re58e423 r42b7fa5f 44 44 tc & & \\ 45 45 \end{tabularx} 46 47 %(FIX ME: complete table) 46 (FIX ME: complete table) 48 47 49 48 \section{Experiment Environment} -
doc/theses/mubeen_zulfiqar_MMath/uw-ethesis.bib
re58e423 r42b7fa5f 27 27 address = "Reading, Massachusetts" 28 28 } 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 84 84 \usepackage{graphicx} 85 85 \usepackage{comment} % Removes large sections of the document. 86 \usepackage{tabularx}87 86 88 87 % Hyperlinks make it very easy to navigate an electronic document. … … 192 191 % Tip: Putting each sentence on a new line is a way to simplify later editing. 193 192 %---------------------------------------------------------------------- 194 \begin{sloppypar}195 196 193 \input{intro} 197 194 \input{background} … … 200 197 \input{performance} 201 198 \input{conclusion} 202 203 \end{sloppypar}204 199 205 200 %---------------------------------------------------------------------- -
libcfa/src/concurrency/mutex_stmt.hfa
re58e423 r42b7fa5f 1 1 #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> 3 6 4 7 //----------------------------------------------------------------------------- -
src/CodeGen/FixMain.cc
re58e423 r42b7fa5f 22 22 #include <string> // for operator<< 23 23 24 #include "AST/Decl.hpp"25 #include "AST/Type.hpp"26 #include "Common/PassVisitor.h"27 24 #include "Common/SemanticError.h" // for SemanticError 28 25 #include "CodeGen/GenType.h" // for GenType … … 32 29 33 30 namespace 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 52 31 bool FixMain::replace_main = false; 32 std::unique_ptr<FunctionDecl> FixMain::main_signature = nullptr; 53 33 54 34 template<typename container> … … 57 37 } 58 38 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 } 64 46 47 void FixMain::fix(std::ostream &os, const char* bootloader_filename) { 65 48 if( main_signature ) { 66 49 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()); 68 51 69 52 os << main_signature->get_scopedMangleName() << "("; … … 82 65 } 83 66 } 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 } // namespace138 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 153 67 }; -
src/CodeGen/FixMain.h
re58e423 r42b7fa5f 9 9 // Author : Thierry Delisle 10 10 // Created On : Thr Jan 12 14:11:09 2017 11 // Last Modified By : Andrew Beach12 // Last Modified On : Fri Oct 29 16:20:00 202113 // Update Count : 811 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Feb 16 03:24:32 2020 13 // Update Count : 5 14 14 // 15 15 … … 18 18 #include <iosfwd> 19 19 #include <memory> 20 #include <list>21 20 22 21 #include "SynTree/LinkageSpec.h" 23 22 24 class Declaration;25 23 class FunctionDecl; 26 namespace ast {27 class FunctionDecl;28 }29 24 30 25 namespace 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 } 31 35 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); 37 37 38 static inline void setReplaceMain(bool val) { 39 replace_main = val; 40 } 38 static void fix(std::ostream &os, const char* bootloader_filename); 41 39 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 }; 52 44 } // namespace CodeGen -
src/CodeGen/FixNames.cc
re58e423 r42b7fa5f 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Fri Oct 29 15:49:00 202113 // Update Count : 2 311 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Dec 13 23:39:14 2019 13 // Update Count : 21 14 14 // 15 15 … … 19 19 #include <string> // for string, operator!=, operator== 20 20 21 #include "AST/Chain.hpp"22 #include "AST/Expr.hpp"23 #include "AST/Pass.hpp"24 21 #include "Common/PassVisitor.h" 25 22 #include "Common/SemanticError.h" // for SemanticError … … 49 46 }; 50 47 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 51 97 void fixNames( std::list< Declaration* > & translationUnit ) { 52 98 PassVisitor<FixNames> fixer; … … 72 118 fixDWT( functionDecl ); 73 119 74 if ( FixMain::isMain( functionDecl )) {120 if(is_main( SymTab::Mangler::mangle(functionDecl, true, true) )) { 75 121 int nargs = functionDecl->get_functionType()->get_parameters().size(); 76 122 if( !(nargs == 0 || nargs == 2 || nargs == 3) ) { … … 78 124 } 79 125 functionDecl->get_statements()->get_kids().push_back( new ReturnStmt( new ConstantExpr( Constant::from_int( 0 ) ) ) ); 126 CodeGen::FixMain::registerMain( functionDecl ); 80 127 } 81 128 } … … 85 132 GuardAction( [this](){ scopeLevel--; } ); 86 133 } 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_mangled94 && 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 139 134 } // namespace CodeGen 140 135 -
src/CodeGen/FixNames.h
re58e423 r42b7fa5f 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Tue Oct 26 13:47:00 202113 // Update Count : 411 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jul 21 22:17:33 2017 13 // Update Count : 3 14 14 // 15 15 … … 19 19 20 20 class Declaration; 21 namespace ast {22 struct TranslationUnit;23 }24 21 25 22 namespace CodeGen { 26 23 /// mangles object and function names 27 24 void fixNames( std::list< Declaration* > & translationUnit ); 28 void fixNames( ast::TranslationUnit & translationUnit );29 25 } // namespace CodeGen 30 26 -
src/main.cc
re58e423 r42b7fa5f 10 10 // Created On : Fri May 15 23:12:02 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Fri Oct 2 9 16:34:00 202113 // Update Count : 65 512 // Last Modified On : Fri Oct 22 16:06:00 2021 13 // Update Count : 653 14 14 // 15 15 … … 335 335 PASS( "Translate Throws", ControlStruct::translateThrows( translationUnit ) ); 336 336 PASS( "Fix Labels", ControlStruct::fixLabels( translationUnit ) ); 337 PASS( "Fix Names", CodeGen::fixNames( translationUnit ) ); 337 338 338 339 CodeTools::fillLocations( translationUnit ); … … 347 348 forceFillCodeLocations( transUnit ); 348 349 349 PASS( "Fix Names", CodeGen::fixNames( transUnit ) );350 350 PASS( "Gen Init", InitTweak::genInit( transUnit ) ); 351 351 PASS( "Expand Member Tuples" , Tuples::expandMemberTuples( transUnit ) ); … … 383 383 translationUnit = convert( move( transUnit ) ); 384 384 } else { 385 PASS( "Fix Names", CodeGen::fixNames( translationUnit ) );386 385 PASS( "Gen Init", InitTweak::genInit( translationUnit ) ); 387 386 PASS( "Expand Member Tuples" , Tuples::expandMemberTuples( translationUnit ) ); … … 472 471 PASS( "Code Gen", CodeGen::generate( translationUnit, *output, ! genproto, prettycodegenp, true, linemarks ) ); 473 472 474 CodeGen::FixMain::fix( translationUnit, *output, 475 (PreludeDirector + "/bootloader.c").c_str() ); 473 CodeGen::FixMain::fix( *output, (PreludeDirector + "/bootloader.c").c_str() ); 476 474 if ( output != &cout ) { 477 475 delete output;
Note:
See TracChangeset
for help on using the changeset viewer.