# Changeset e58e423

Ignore:
Timestamp:
Oct 29, 2021, 5:24:56 PM (8 months ago)
Branches:
enum, forall-pointer-decay, master
Children:
a7026b4
Parents:
42b7fa5 (diff), 8e48fca4 (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

Files:
1 deleted
13 edited

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

 r42b7fa5 \end{itemize} The new features added to uHeapLmmm (incl. @malloc_size@ routine) The new features added to uHeapLmmm (incl. @malloc\_size@ routine) \CFA alloc interface with examples. \begin{itemize} \item 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. \subsubsection void * aalloc( size_t dim, size_t elemSize ) \subsubsection void * aalloc( size\_t dim, size\_t elemSize ) 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. \paragraph{Usage} aalloc takes two parameters. \begin{itemize} \item 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. \subsubsection void * resize( void * oaddr, size_t size ) \subsubsection void * resize( void * oaddr, size\_t size ) 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. \paragraph{Usage} resize takes two parameters. \begin{itemize} \item 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. \subsubsection void * resize( void * oaddr, size_t nalign, size_t size ) \subsubsection void * resize( void * oaddr, size\_t nalign, size\_t size ) 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. \paragraph{Usage} This resize takes three parameters. It takes an additional parameter of nalign as compared to the above resize (FIX ME: cite above resize). \begin{itemize} \item It returns an object with the size and alignment given in the parameters. On failure, it returns a NULL pointer. \subsubsection void * amemalign( size_t alignment, size_t dim, size_t elemSize ) \subsubsection void * amemalign( size\_t alignment, size\_t dim, size\_t elemSize ) 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. \paragraph{Usage} amemalign takes three parameters. \begin{itemize} \item 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. \subsubsection void * cmemalign( size_t alignment, size_t dim, size_t elemSize ) \subsubsection void * cmemalign( size\_t alignment, size\_t dim, size\_t elemSize ) 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. \paragraph{Usage} cmemalign takes three parameters. \begin{itemize} \item 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. \subsubsection size_t malloc_alignment( void * addr ) 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. \paragraph{Usage} malloc_alignment takes one parameters. \subsubsection size\_t malloc\_alignment( void * addr ) 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. \paragraph{Usage} malloc\_alignment takes one parameters. \begin{itemize} \item addr: the address of the currently allocated dynamic object. \end{itemize} malloc_alignment returns the alignment of the given dynamic object. On failure, it return the value of default alignment of the uHeapLmmm allocator. \subsubsection bool malloc_zero_fill( void * addr ) 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. \paragraph{Usage} malloc_zero_fill takes one parameters. malloc\_alignment returns the alignment of the given dynamic object. On failure, it return the value of default alignment of the uHeapLmmm allocator. \subsubsection bool malloc\_zero\_fill( void * addr ) 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. \paragraph{Usage} malloc\_zero\_fill takes one parameters. \begin{itemize} \item addr: the address of the currently allocated dynamic object. \end{itemize} malloc_zero_fill returns true if the dynamic object was initially zero filled and return false otherwise. On failure, it returns false. \subsubsection size_t malloc_size( void * addr ) 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. \paragraph{Usage} malloc_size takes one parameters. malloc\_zero\_fill returns true if the dynamic object was initially zero filled and return false otherwise. On failure, it returns false. \subsubsection size\_t malloc\_size( void * addr ) 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. \paragraph{Usage} malloc\_size takes one parameters. \begin{itemize} \item addr: the address of the currently allocated dynamic object. \end{itemize} malloc_size returns the allocation size of the given dynamic object. On failure, it return zero. \subsubsection void * realloc( void * oaddr, size_t nalign, size_t size ) malloc\_size returns the allocation size of the given dynamic object. On failure, it return zero. \subsubsection void * realloc( void * oaddr, size\_t nalign, size\_t size ) 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. \paragraph{Usage} This realloc takes three parameters. It takes an additional parameter of nalign as compared to the default realloc. \begin{itemize} \item It returns a dynamic object of the size of type T. On failure, it return NULL pointer. \subsubsection T * aalloc( size_t dim ) \subsubsection T * aalloc( size\_t dim ) 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. \paragraph{Usage} aalloc takes one parameters. \begin{itemize} \item 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. \subsubsection T * calloc( size_t dim ) \subsubsection T * calloc( size\_t dim ) 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. \paragraph{Usage} This calloc takes one parameter. \begin{itemize} \item 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. \subsubsection T * resize( T * ptr, size_t size ) \subsubsection T * resize( T * ptr, size\_t size ) 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. \paragraph{Usage} This resize takes two parameters. \begin{itemize} \item 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. \subsubsection T * realloc( T * ptr, size_t size ) \subsubsection T * realloc( T * ptr, size\_t size ) 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. \paragraph{Usage} This realloc takes two parameters. \begin{itemize} \item 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. \subsubsection T * memalign( size_t align ) \subsubsection T * memalign( size\_t align ) 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. \paragraph{Usage} memalign takes one parameters. \begin{itemize} \item It returns a dynamic object of the size of type T that is aligned to given parameter align. On failure, it return NULL pointer. \subsubsection T * amemalign( size_t align, size_t dim ) \subsubsection T * amemalign( size\_t align, size\_t dim ) 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. \paragraph{Usage} amemalign takes two parameters. \begin{itemize} \item 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. \subsubsection T * cmemalign( size_t align, size_t dim  ) \subsubsection T * cmemalign( size\_t align, size\_t dim  ) 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. \paragraph{Usage} cmemalign takes two parameters. \begin{itemize} \item 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. \subsubsection T * aligned_alloc( size_t align ) 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. \paragraph{Usage} This aligned_alloc takes one parameter. \subsubsection T * aligned\_alloc( size\_t align ) 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. \paragraph{Usage} This aligned\_alloc takes one parameter. \begin{itemize} \item It returns a dynamic object of the size of type T that is aligned to the given parameter. On failure, it return NULL pointer. \subsubsection int posix_memalign( T ** ptr, size_t align ) 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. \paragraph{Usage} This posix_memalign takes two parameter. \subsubsection int posix\_memalign( T ** ptr, size\_t align ) 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. \paragraph{Usage} This posix\_memalign takes two parameter. \begin{itemize} \item align: required alignment of the dynamic object. \end{itemize} 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. 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. \subsection{Alloc Interface} \subsection Alloc Interface 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. This interface helps programmers in three major ways. \begin{itemize} \item 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. It represents the required number of members in the array allocation as in CFA's aalloc (FIX ME: cite aalloc). This parameter should be of type size_t. This parameter should be of type size\_t. Example: int a = alloc( 5 ) \paragraph{Align} 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. 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. Example: int b = alloc( 5 , 64align ) 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. Three types of parameters can be passed using `fill. \begin{itemize} \item

• ## doc/theses/mubeen_zulfiqar_MMath/benchmarks.tex

 r42b7fa5 *** FIX ME: Insert a figure of above benchmark with description \paragrpah{Relevant Knobs} \paragraph{Relevant Knobs} *** FIX ME: Insert Relevant Knobs

• ## doc/theses/mubeen_zulfiqar_MMath/performance.tex

 r42b7fa5 tc               &             &  \\ \end{tabularx} (FIX ME: complete table) %(FIX ME: complete table) \section{Experiment Environment}
• ## doc/theses/mubeen_zulfiqar_MMath/uw-ethesis.bib

 r42b7fa5 address =       "Reading, Massachusetts" } @article{wasik.thesis, author        = "Ayelet Wasik", title         = "Features of A Multi-Threaded Memory Alloator", publisher     = "University of Waterloo", year          = "2008" }
• ## doc/theses/mubeen_zulfiqar_MMath/uw-ethesis.tex

 r42b7fa5 \usepackage{graphicx} \usepackage{comment} % Removes large sections of the document. \usepackage{tabularx} % Hyperlinks make it very easy to navigate an electronic document. % Tip: Putting each sentence on a new line is a way to simplify later editing. %---------------------------------------------------------------------- \begin{sloppypar} \input{intro} \input{background} \input{performance} \input{conclusion} \end{sloppypar} %----------------------------------------------------------------------
• ## libcfa/src/concurrency/mutex_stmt.hfa

 r42b7fa5 #include "bits/algorithm.hfa" #include #include "invoke.h" #include "stdlib.hfa" #include #include "bits/defs.hfa" //-----------------------------------------------------------------------------
• ## src/CodeGen/FixMain.cc

 r42b7fa5 #include                   // for operator<< #include "AST/Decl.hpp" #include "AST/Type.hpp" #include "Common/PassVisitor.h" #include "Common/SemanticError.h"  // for SemanticError #include "CodeGen/GenType.h"       // for GenType namespace CodeGen { namespace { struct FindMainCore { FunctionDecl * main_signature = nullptr; void previsit( FunctionDecl * decl ) { if ( FixMain::isMain( decl ) ) { if ( main_signature ) { SemanticError( decl, "Multiple definition of main routine\n" ); } main_signature = decl; } } }; } bool FixMain::replace_main = false; std::unique_ptr FixMain::main_signature = nullptr; template } void FixMain::registerMain(FunctionDecl* functionDecl) { if(main_signature) { SemanticError(functionDecl, "Multiple definition of main routine\n"); } main_signature.reset( functionDecl->clone() ); } void FixMain::fix( std::list< Declaration * > & translationUnit, std::ostream &os, const char* bootloader_filename ) { PassVisitor< FindMainCore > main_finder; acceptAll( translationUnit, main_finder ); FunctionDecl * main_signature = main_finder.pass.main_signature; void FixMain::fix(std::ostream &os, const char* bootloader_filename) { if( main_signature ) { os << "static inline int invoke_main(int argc, char* argv[], char* envp[]) { (void)argc; (void)argv; (void)envp; return "; main_signature->mangleName = SymTab::Mangler::mangle(main_signature.get()); main_signature->mangleName = SymTab::Mangler::mangle(main_signature); os << main_signature->get_scopedMangleName() << "("; } } namespace { ObjectDecl * signedIntObj() { return new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr ); } ObjectDecl * charStarObj() { return new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), new PointerType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::Char ) ) ), nullptr ); } std::string create_mangled_main_function_name( FunctionType * function_type ) { std::unique_ptr decl( new FunctionDecl( "main", Type::StorageClasses(), LinkageSpec::Cforall, function_type, nullptr ) ); return SymTab::Mangler::mangle( decl.get() ); } std::string mangled_0_argument_main() { FunctionType* main_type = new FunctionType( Type::Qualifiers(), true ); main_type->get_returnVals().push_back( signedIntObj() ); return create_mangled_main_function_name( main_type ); } std::string mangled_2_argument_main() { FunctionType* main_type = new FunctionType( Type::Qualifiers(), false ); main_type->get_returnVals().push_back( signedIntObj() ); main_type->get_parameters().push_back( signedIntObj() ); main_type->get_parameters().push_back( charStarObj() ); return create_mangled_main_function_name( main_type ); } bool is_main( const std::string & mangled_name ) { // This breaks if you move it out of the function. static const std::string mangled_mains[] = { mangled_0_argument_main(), mangled_2_argument_main(), //mangled_3_argument_main(), }; for ( auto main_name : mangled_mains ) { if ( main_name == mangled_name ) return true; } return false; } } // namespace bool FixMain::isMain( FunctionDecl * decl ) { if ( std::string("main") != decl->name ) { return false; } return is_main( SymTab::Mangler::mangle( decl, true, true ) ); } bool FixMain::isMain( const ast::FunctionDecl * decl ) { if ( std::string("main") != decl->name ) { return false; } return is_main( Mangle::mangle( decl, Mangle::Type ) ); } };