Changes in / [f57668a:c352893]
- Location:
- src
- Files:
-
- 9 added
- 6 deleted
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
rf57668a rc352893 262 262 } // if 263 263 } else { 264 output << typeDecl->typeString() << " " << typeDecl->get_name(); 264 output << typeDecl->genTypeString() << " " << typeDecl->get_name(); 265 if ( typeDecl->get_kind() != TypeDecl::Any && typeDecl->get_sized() ) { 266 output << " | sized(" << typeDecl->get_name() << ")"; 267 } 265 268 if ( ! typeDecl->get_assertions().empty() ) { 266 269 output << " | { "; … … 769 772 void CodeGenerator::visit( ExprStmt * exprStmt ) { 770 773 assert( exprStmt ); 771 // cast the top-level expression to void to reduce gcc warnings. 772 Expression * expr = new CastExpr( exprStmt->get_expr() ); 774 Expression * expr = exprStmt->get_expr(); 775 if ( genC ) { 776 // cast the top-level expression to void to reduce gcc warnings. 777 expr = new CastExpr( expr ); 778 } 773 779 expr->accept( *this ); 774 780 output << ";"; -
src/CodeGen/Generate.cc
rf57668a rc352893 22 22 #include "SynTree/Declaration.h" 23 23 #include "CodeGenerator.h" 24 #include "Tuples/Tuples.h" 24 #include "GenType.h" 25 #include "SynTree/SynTree.h" 26 #include "SynTree/Type.h" 27 #include "SynTree/BaseSyntaxNode.h" 28 // #include "Tuples/Tuples.h" 25 29 26 30 using namespace std; … … 39 43 } // for 40 44 } 45 46 void generate( BaseSyntaxNode * node, std::ostream & os ) { 47 if ( Type * type = dynamic_cast< Type * >( node ) ) { 48 os << CodeGen::genPrettyType( type, "" ); 49 } else { 50 CodeGen::CodeGenerator cgv( os, true, false ); 51 node->accept( cgv ); 52 } 53 os << std::endl; 54 } 41 55 } // namespace CodeGen 42 56 -
src/CodeGen/Generate.h
rf57668a rc352893 25 25 /// Generates code. doIntrinsics determines if intrinsic functions are printed, pretty formats output nicely (e.g., uses unmangled names, etc.), generateC is true when the output must consist only of C code (allows some assertions, etc.) 26 26 void generate( std::list< Declaration* > translationUnit, std::ostream &os, bool doIntrinsics, bool pretty, bool generateC = false ); 27 28 /// Generate code for a single node -- helpful for debugging in gdb 29 void generate( BaseSyntaxNode * node, std::ostream & os ); 27 30 } // namespace CodeGen 28 31 -
src/Concurrency/Keywords.cc
rf57668a rc352893 246 246 //============================================================================================= 247 247 void ConcurrentSueKeyword::visit(StructDecl * decl) { 248 Visitor::visit(decl); 248 249 if( decl->get_name() == type_name ) { 249 250 assert( !type_decl ); … … 385 386 //============================================================================================= 386 387 void MutexKeyword::visit(FunctionDecl* decl) { 388 Visitor::visit(decl); 389 387 390 std::list<DeclarationWithType*> mutexArgs = findMutexArgs( decl ); 388 391 if( mutexArgs.empty() ) return; … … 402 405 403 406 void MutexKeyword::visit(StructDecl* decl) { 407 Visitor::visit(decl); 408 404 409 if( decl->get_name() == "monitor_desc" ) { 405 410 assert( !monitor_decl ); … … 504 509 //============================================================================================= 505 510 void ThreadStarter::visit(FunctionDecl * decl) { 511 Visitor::visit(decl); 512 506 513 if( ! InitTweak::isConstructor(decl->get_name()) ) return; 507 514 -
src/GenPoly/PolyMutator.cc
rf57668a rc352893 50 50 51 51 Statement * PolyMutator::mutateStatement( Statement *stmt ) { 52 // don't want statements from outer CompoundStmts to be added to this CompoundStmt 53 ValueGuard< std::list< Statement* > > oldStmtsToAdd( stmtsToAdd ); 54 ValueGuard< std::list< Statement* > > oldStmtsToAddAfter( stmtsToAddAfter ); 55 ValueGuard< TypeSubstitution * > oldEnv( env ); 56 stmtsToAdd.clear(); 57 stmtsToAddAfter.clear(); 58 52 59 Statement *newStmt = maybeMutate( stmt, *this ); 53 60 if ( ! stmtsToAdd.empty() || ! stmtsToAddAfter.empty() ) { … … 83 90 84 91 Statement * PolyMutator::mutate(IfStmt *ifStmt) { 92 ifStmt->set_condition( mutateExpression( ifStmt->get_condition() ) ); 85 93 ifStmt->set_thenPart( mutateStatement( ifStmt->get_thenPart() ) ); 86 94 ifStmt->set_elsePart( mutateStatement( ifStmt->get_elsePart() ) ); 87 ifStmt->set_condition( mutateExpression( ifStmt->get_condition() ) );88 95 return ifStmt; 89 96 } 90 97 91 98 Statement * PolyMutator::mutate(WhileStmt *whileStmt) { 99 whileStmt->set_condition( mutateExpression( whileStmt->get_condition() ) ); 92 100 whileStmt->set_body( mutateStatement( whileStmt->get_body() ) ); 93 whileStmt->set_condition( mutateExpression( whileStmt->get_condition() ) );94 101 return whileStmt; 95 102 } 96 103 97 104 Statement * PolyMutator::mutate(ForStmt *forStmt) { 98 forStmt->set_body( mutateStatement( forStmt->get_body() ) );99 105 mutateAll( forStmt->get_initialization(), *this ); 100 106 forStmt->set_condition( mutateExpression( forStmt->get_condition() ) ); 101 107 forStmt->set_increment( mutateExpression( forStmt->get_increment() ) ); 108 forStmt->set_body( mutateStatement( forStmt->get_body() ) ); 102 109 return forStmt; 103 110 } 104 111 105 112 Statement * PolyMutator::mutate(SwitchStmt *switchStmt) { 113 switchStmt->set_condition( mutateExpression( switchStmt->get_condition() ) ); 106 114 mutateStatementList( switchStmt->get_statements() ); 107 switchStmt->set_condition( mutateExpression( switchStmt->get_condition() ) );108 115 return switchStmt; 109 116 } 110 117 111 118 Statement * PolyMutator::mutate(CaseStmt *caseStmt) { 119 caseStmt->set_condition( mutateExpression( caseStmt->get_condition() ) ); 112 120 mutateStatementList( caseStmt->get_statements() ); 113 caseStmt->set_condition( mutateExpression( caseStmt->get_condition() ) );114 121 return caseStmt; 115 122 } -
src/ResolvExpr/AlternativeFinder.cc
rf57668a rc352893 766 766 } // if 767 767 } // for 768 // function may return struct or union value, in which case we need to add alternatives for implicit conversions to each of the anonymous members 768 769 candidates.clear(); 770 candidates.splice( candidates.end(), alternatives ); 771 772 findMinCost( candidates.begin(), candidates.end(), std::back_inserter( alternatives ) ); 773 774 // function may return struct or union value, in which case we need to add alternatives for implicit 775 // conversions to each of the anonymous members, must happen after findMinCost since anon conversions 776 // are never the cheapest expression 769 777 for ( const Alternative & alt : alternatives ) { 770 778 addAnonConversions( alt ); 771 779 } 772 773 candidates.clear();774 candidates.splice( candidates.end(), alternatives );775 776 findMinCost( candidates.begin(), candidates.end(), std::back_inserter( alternatives ) );777 780 778 781 if ( alternatives.empty() && targetType && ! targetType->isVoid() ) { -
src/SynTree/BaseSyntaxNode.h
rf57668a rc352893 18 18 19 19 #include "Common/utility.h" 20 #include "Visitor.h" 20 21 21 22 class BaseSyntaxNode { 22 23 public: 23 24 CodeLocation location; 25 26 virtual void accept( Visitor & v ) = 0; // temporary -- needs to be here so that BaseSyntaxNode is polymorphic and can be dynamic_cast 24 27 }; 25 28 -
src/SynTree/Declaration.h
rf57668a rc352893 204 204 205 205 virtual std::string typeString() const; 206 virtual std::string genTypeString() const; 206 207 207 208 virtual TypeDecl *clone() const { return new TypeDecl( *this ); } -
src/SynTree/SynTree.h
rf57668a rc352893 21 21 #include <map> 22 22 #include <iostream> 23 24 class BaseSyntaxNode; 23 25 24 26 class Declaration; -
src/SynTree/TypeDecl.cc
rf57668a rc352893 29 29 } 30 30 31 std::string TypeDecl::genTypeString() const { 32 static const std::string kindNames[] = { "otype", "dtype", "ftype", "ttype" }; 33 return kindNames[ kind ]; 34 } 35 31 36 std::ostream & operator<<( std::ostream & os, const TypeDecl::Data & data ) { 32 37 return os << data.kind << ", " << data.isComplete; -
src/benchmark/CorCtxSwitch.c
rf57668a rc352893 3 3 #include <thread> 4 4 5 #include <unistd.h> // sysconf 6 #include <sys/times.h> // times 7 #include <time.h> 8 9 inline unsigned long long int Time() { 10 timespec ts; 11 clock_gettime( 12 #if defined( __linux__ ) 13 CLOCK_THREAD_CPUTIME_ID, 14 #elif defined( __freebsd__ ) 15 CLOCK_PROF, 16 #elif defined( __solaris__ ) 17 CLOCK_HIGHRES, 18 #else 19 #error uC++ : internal error, unsupported architecture 20 #endif 21 &ts ); 22 return 1000000000LL * ts.tv_sec + ts.tv_nsec; 23 } // Time 5 #include "bench.h" 24 6 25 7 coroutine GreatSuspender {}; … … 42 24 } 43 25 44 #ifndef N45 #define N 10000000046 #endif47 48 26 int main() { 49 27 const unsigned int NoOfTimes = N; -
src/benchmark/Makefile.am
rf57668a rc352893 44 44 @rm -f ./a.out 45 45 46 sched-int: 47 ${CC} ${AM_CFLAGS} ${CFLAGS} ${ccflags} @CFA_FLAGS@ -nodebug -lrt -DN=10000000 SchedInt.c 48 @for number in 1 2 3 4 5 6 7 8 9 10; do \ 49 ./a.out ; \ 50 done 51 @rm -f ./a.out 52 53 monitor: 54 ${CC} ${AM_CFLAGS} ${CFLAGS} ${ccflags} @CFA_FLAGS@ -nodebug -lrt -DN=10000000 Monitor.c 55 @for number in 1 2 3 4 5 6 7 8 9 10; do \ 56 ./a.out ; \ 57 done 58 @rm -f ./a.out 59 46 60 csv-data: 47 61 @${CC} ${AM_CFLAGS} ${CFLAGS} ${ccflags} @CFA_FLAGS@ -nodebug -lrt -quiet -DN=10000000 csv-data.c -
src/benchmark/Makefile.in
rf57668a rc352893 492 492 @rm -f ./a.out 493 493 494 sched-int: 495 ${CC} ${AM_CFLAGS} ${CFLAGS} ${ccflags} @CFA_FLAGS@ -nodebug -lrt -DN=10000000 SchedInt.c 496 @for number in 1 2 3 4 5 6 7 8 9 10; do \ 497 ./a.out ; \ 498 done 499 @rm -f ./a.out 500 501 monitor: 502 ${CC} ${AM_CFLAGS} ${CFLAGS} ${ccflags} @CFA_FLAGS@ -nodebug -lrt -DN=10000000 Monitor.c 503 @for number in 1 2 3 4 5 6 7 8 9 10; do \ 504 ./a.out ; \ 505 done 506 @rm -f ./a.out 507 494 508 csv-data: 495 509 @${CC} ${AM_CFLAGS} ${CFLAGS} ${ccflags} @CFA_FLAGS@ -nodebug -lrt -quiet -DN=10000000 csv-data.c -
src/benchmark/ThrdCtxSwitch.c
rf57668a rc352893 3 3 #include <thread> 4 4 5 #include <unistd.h> // sysconf 6 #include <sys/times.h> // times 7 #include <time.h> 8 9 inline unsigned long long int Time() { 10 timespec ts; 11 clock_gettime( 12 #if defined( __linux__ ) 13 CLOCK_THREAD_CPUTIME_ID, 14 #elif defined( __freebsd__ ) 15 CLOCK_PROF, 16 #elif defined( __solaris__ ) 17 CLOCK_HIGHRES, 18 #else 19 #error uC++ : internal error, unsupported architecture 20 #endif 21 &ts ); 22 return 1000000000LL * ts.tv_sec + ts.tv_nsec; 23 } // Time 24 25 #ifndef N 26 #define N 100000000 27 #endif 5 #include "bench.h" 28 6 29 7 int main() { -
src/benchmark/bench.c
rf57668a rc352893 4 4 #include <thread> 5 5 6 #include <unistd.h> // sysconf 7 #include <sys/times.h> // times 8 #include <time.h> 9 10 inline unsigned long long int Time() { 11 timespec ts; 12 clock_gettime( 13 #if defined( __linux__ ) 14 CLOCK_THREAD_CPUTIME_ID, 15 #elif defined( __freebsd__ ) 16 CLOCK_PROF, 17 #elif defined( __solaris__ ) 18 CLOCK_HIGHRES, 19 #else 20 #error uC++ : internal error, unsupported architecture 21 #endif 22 &ts ); 23 return 1000000000LL * ts.tv_sec + ts.tv_nsec; 24 } // Time 6 #include "bench.h" 25 7 26 8 //======================================= -
src/benchmark/csv-data.c
rf57668a rc352893 1 1 #include <fstream> 2 #include <monitor> 2 3 #include <stdlib> 3 4 #include <thread> 4 5 5 extern "C" { 6 #include <unistd.h> // sysconf 7 #include <sys/times.h> // times 8 #include <time.h> 9 } 10 11 inline unsigned long long int Time() { 12 timespec ts; 13 clock_gettime( 14 #if defined( __linux__ ) 15 CLOCK_THREAD_CPUTIME_ID, 16 #elif defined( __freebsd__ ) 17 CLOCK_PROF, 18 #elif defined( __solaris__ ) 19 CLOCK_HIGHRES, 20 #else 21 #error uC++ : internal error, unsupported architecture 22 #endif 23 &ts ); 24 return 1000000000LL * ts.tv_sec + ts.tv_nsec; 25 } // Time 6 #include "bench.h" 26 7 27 8 coroutine GreatSuspender {}; … … 48 29 #endif 49 30 50 51 31 //----------------------------------------------------------------------------- 32 // coroutine context switch 52 33 long long int measure_coroutine() { 53 34 const unsigned int NoOfTimes = N; … … 67 48 } 68 49 50 //----------------------------------------------------------------------------- 51 // thread context switch 69 52 long long int measure_thread() { 70 53 const unsigned int NoOfTimes = N; … … 80 63 } 81 64 65 //----------------------------------------------------------------------------- 66 // single monitor entry 67 monitor mon_t {}; 68 void dummy( mon_t * mutex m ) {} 69 70 long long int measure_1_monitor_entry() { 71 const unsigned int NoOfTimes = N; 72 long long int StartTime, EndTime; 73 mon_t mon; 74 75 StartTime = Time(); 76 for ( volatile unsigned int i = 0; i < NoOfTimes; i += 1 ) { 77 dummy( &mon ); 78 } 79 EndTime = Time(); 80 81 return ( EndTime - StartTime ) / NoOfTimes; 82 } 83 84 //----------------------------------------------------------------------------- 85 // multi monitor entry 86 void dummy( mon_t * mutex m1, mon_t * mutex m2 ) {} 87 88 long long int measure_2_monitor_entry() { 89 const unsigned int NoOfTimes = N; 90 long long int StartTime, EndTime; 91 mon_t mon1, mon2; 92 93 StartTime = Time(); 94 for ( volatile unsigned int i = 0; i < NoOfTimes; i += 1 ) { 95 dummy( &mon1, &mon2 ); 96 } 97 EndTime = Time(); 98 99 return ( EndTime - StartTime ) / NoOfTimes; 100 } 101 102 //----------------------------------------------------------------------------- 103 // single internal sched entry 104 mon_t mon1; 105 106 condition cond1a; 107 condition cond1b; 108 109 thread thrd1a { long long int * out; }; 110 thread thrd1b {}; 111 112 void ?{}( thrd1a * this, long long int * out ) { 113 this->out = out; 114 } 115 116 void side1A( mon_t * mutex a, long long int * out ) { 117 long long int StartTime, EndTime; 118 119 StartTime = Time(); 120 for( int i = 0;; i++ ) { 121 signal(&cond1a); 122 if( i > N ) break; 123 wait(&cond1b); 124 } 125 EndTime = Time(); 126 127 *out = ( EndTime - StartTime ) / N; 128 } 129 130 void side1B( mon_t * mutex a ) { 131 for( int i = 0;; i++ ) { 132 signal(&cond1b); 133 if( i > N ) break; 134 wait(&cond1a); 135 } 136 } 137 138 void main( thrd1a * this ) { side1A( &mon1, this->out ); } 139 void main( thrd1b * this ) { side1B( &mon1 ); } 140 141 long long int measure_1_sched_int() { 142 long long int t; 143 { 144 thrd1a a = { &t }; 145 thrd1b b; 146 } 147 return t; 148 } 149 150 //----------------------------------------------------------------------------- 151 // multi internal sched entry 152 mon_t mon2; 153 154 condition cond2a; 155 condition cond2b; 156 157 thread thrd2a { long long int * out; }; 158 thread thrd2b {}; 159 160 void ?{}( thrd2a * this, long long int * out ) { 161 this->out = out; 162 } 163 164 void side2A( mon_t * mutex a, mon_t * mutex b, long long int * out ) { 165 long long int StartTime, EndTime; 166 167 StartTime = Time(); 168 for( int i = 0;; i++ ) { 169 signal(&cond2a); 170 if( i > N ) break; 171 wait(&cond2b); 172 } 173 EndTime = Time(); 174 175 *out = ( EndTime - StartTime ) / N; 176 } 177 178 void side2B( mon_t * mutex a, mon_t * mutex b ) { 179 for( int i = 0;; i++ ) { 180 signal(&cond2b); 181 if( i > N ) break; 182 wait(&cond2a); 183 } 184 } 185 186 void main( thrd2a * this ) { side2A( &mon1, &mon2, this->out ); } 187 void main( thrd2b * this ) { side2B( &mon1, &mon2 ); } 188 189 long long int measure_2_sched_int() { 190 long long int t; 191 { 192 thrd2a a = { &t }; 193 thrd2b b; 194 } 195 return t; 196 } 197 198 //----------------------------------------------------------------------------- 199 // main loop 82 200 int main() 83 201 { 84 sout | time(NULL) | ',' | measure_coroutine() | ',' | measure_thread() | endl; 85 } 202 sout | time(NULL) | ','; 203 sout | measure_coroutine() | ','; 204 sout | measure_thread() | ','; 205 sout | measure_1_monitor_entry() | ','; 206 sout | measure_2_monitor_entry() | ','; 207 sout | measure_1_sched_int() | ','; 208 sout | measure_2_sched_int() | endl; 209 } -
src/libcfa/concurrency/thread.c
rf57668a rc352893 40 40 this->next = NULL; 41 41 42 this->current_monitors = NULL;43 this->current_monitor_count = 0;42 this->current_monitors = &this->mon; 43 this->current_monitor_count = 1; 44 44 } 45 45 -
src/tests/Makefile.am
rf57668a rc352893 22 22 concurrent=yes 23 23 quick_test+= coroutine thread monitor 24 concurrent_test=coroutine thread monitor multi-monitor sched-int sched-int-multi sched-int-multi2sched-ext sched-ext-multi preempt24 concurrent_test=coroutine thread monitor multi-monitor sched-int-disjoint sched-int-barge sched-int-wait sched-ext sched-ext-multi preempt 25 25 else 26 26 concurrent=no -
src/tests/Makefile.in
rf57668a rc352893 230 230 @BUILD_CONCURRENCY_TRUE@concurrent = yes 231 231 @BUILD_CONCURRENCY_FALSE@concurrent_test = 232 @BUILD_CONCURRENCY_TRUE@concurrent_test = coroutine thread monitor multi-monitor sched-int sched-int-multi sched-int-multi2sched-ext sched-ext-multi preempt232 @BUILD_CONCURRENCY_TRUE@concurrent_test = coroutine thread monitor multi-monitor sched-int-disjoint sched-int-barge sched-int-wait sched-ext sched-ext-multi preempt 233 233 234 234 # applies to both programs
Note: See TracChangeset
for help on using the changeset viewer.