Changes in / [dbae916:c19ca4b]
- Files:
-
- 5 deleted
- 9 edited
-
doc/theses/colby_parsons_MMAth/benchmarks/actors/plotData.py (modified) (1 diff)
-
libcfa/src/Makefile.am (modified) (2 diffs)
-
libcfa/src/concurrency/actor.hfa (modified) (7 diffs)
-
libcfa/src/virtual_dtor.hfa (deleted)
-
src/Concurrency/Actors.cpp (modified) (10 diffs)
-
src/Concurrency/Actors.hpp (modified) (1 diff)
-
src/Virtual/VirtualDtor.cpp (deleted)
-
src/Virtual/VirtualDtor.hpp (deleted)
-
src/Virtual/module.mk (modified) (1 diff)
-
src/main.cc (modified) (2 diffs)
-
tests/concurrent/actors/.expect/inherit.txt (deleted)
-
tests/concurrent/actors/executor.cfa (modified) (1 diff)
-
tests/concurrent/actors/inherit.cfa (deleted)
-
tests/concurrent/actors/poison.cfa (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/colby_parsons_MMAth/benchmarks/actors/plotData.py
rdbae916 rc19ca4b 169 169 else: 170 170 plt.ylim(0, None) 171 plt.xticks(procs)172 171 ax.legend(names) 173 172 # fig.savefig("plots/" + machineName + name + ".png") -
libcfa/src/Makefile.am
rdbae916 rc19ca4b 48 48 math.hfa \ 49 49 time_t.hfa \ 50 virtual_dtor.hfa \51 50 bits/algorithm.hfa \ 52 51 bits/align.hfa \ … … 69 68 vec/vec2.hfa \ 70 69 vec/vec3.hfa \ 71 vec/vec4.hfa 70 vec/vec4.hfa 72 71 73 72 inst_headers_src = \ -
libcfa/src/concurrency/actor.hfa
rdbae916 rc19ca4b 5 5 #include <kernel.hfa> 6 6 #include <iofwd.hfa> 7 #include <virtual_dtor.hfa>8 7 9 8 #ifdef __CFA_DEBUG__ … … 358 357 if ( seperate_clus ) delete( cluster ); 359 358 360 #ifdef STATS // print formatted stats359 #ifdef STATS 361 360 printf(" Actor System Stats:\n"); 362 361 printf("\tActors Created:\t\t\t\t%lu\n\tMessages Sent:\t\t\t\t%lu\n", __num_actors_stats, __all_processed); … … 389 388 static executor * __actor_executor_ = 0p; 390 389 static bool __actor_executor_passed = false; // was an executor passed to start_actor_system 391 static size_t __num_actors_ = 0; // number of actor objects in system390 static size_t __num_actors_ = 0; // number of actor objects in system 392 391 static struct thread$ * __actor_executor_thd = 0p; // used to wake executor after actors finish 393 392 struct actor { 394 size_t ticket; // executor-queue handle393 size_t ticket; // executor-queue handle 395 394 Allocation allocation_; // allocation action 396 inline virtual_dtor;397 395 }; 398 396 … … 408 406 #endif 409 407 } 408 static inline void ^?{}( actor & this ) {} 410 409 411 410 static inline void check_actor( actor & this ) { … … 431 430 struct message { 432 431 Allocation allocation_; // allocation action 433 inline virtual_dtor;434 432 }; 435 433 436 static inline void ?{}( message & this ) { 437 this.allocation_ = Nodelete; 438 } 434 static inline void ?{}( message & this ) { this.allocation_ = Nodelete; } 439 435 static inline void ?{}( message & this, Allocation allocation ) { 440 436 memcpy( &this.allocation_, &allocation, sizeof(allocation) ); // optimization to elide ctor 441 437 verifyf( this.allocation_ != Finished, "The Finished Allocation status is not supported for message types.\n"); 442 438 } 443 static inline void ^?{}( message & this ) with(this){444 CFA_DEBUG( if ( allocation_ == Nodelete ) printf("A message at location %p was allocated but never sent.\n", &this); )439 static inline void ^?{}( message & this ) { 440 CFA_DEBUG( if ( this.allocation_ == Nodelete ) printf("A message at location %p was allocated but never sent.\n", &this); ) 445 441 } 446 442 447 443 static inline void check_message( message & this ) { 448 switch ( this.allocation_ ) { // analyze message status 449 case Nodelete: CFA_DEBUG(this.allocation_ = Finished); break; 444 #ifdef __CFA_DEBUG__ 445 Allocation temp = this.allocation_; 446 this.allocation_ = Finished; 447 switch ( temp ) 448 #else 449 switch ( this.allocation_ ) 450 #endif 451 { // analyze message status 452 case Nodelete: break; 450 453 case Delete: delete( &this ); break; 451 454 case Destroy: ^?{}(this); break; … … 453 456 } // switch 454 457 } 455 static inline void set_allocation( message & this, Allocation state ) { 456 this.allocation_ = state; 457 } 458 static inline void set_allocation( message & this, Allocation state ) { this.allocation_ = state; } 458 459 459 460 static inline void deliver_request( request & this ) { … … 687 688 Allocation receive( actor & this, __DestroyMsg & msg ) { return Destroy; } 688 689 Allocation receive( actor & this, __FinishedMsg & msg ) { return Finished; } 689 -
src/Concurrency/Actors.cpp
rdbae916 rc19ca4b 45 45 // finds and sets a ptr to the actor, message, and request structs, which are needed in the next pass 46 46 void previsit( const StructDecl * decl ) { 47 if ( !decl->body ) return; 48 if ( decl->name == "actor" ) { 49 actorStructDecls.insert( decl ); // skip inserting fwd decl 47 GuardValue(insideStruct); 48 insideStruct = true; 49 parentDecl = mutate( decl ); 50 if( decl->name == "actor" ) { 51 if ( actorDecl ) actorStructDecls.insert( decl ); // skip inserting fwd decl 50 52 *actorDecl = decl; 51 } else if( decl->name == "message" ) { 52 messageStructDecls.insert( decl ); // skip inserting fwd decl 53 } 54 if( decl->name == "message" ) { 55 if ( msgDecl ) messageStructDecls.insert( decl ); // skip inserting fwd decl 53 56 *msgDecl = decl; 54 } else if( decl->name == "request" ) *requestDecl = decl; 55 else { 56 GuardValue(insideStruct); 57 insideStruct = true; 58 parentDecl = mutate( decl ); 59 } 57 } 58 if( decl->name == "request" ) *requestDecl = decl; 60 59 } 61 60 … … 71 70 } 72 71 73 // this collects the derived actor and message struct decl ptrs72 // this collects the valid actor and message struct decl pts 74 73 void postvisit( const StructInstType * node ) { 75 74 if ( ! *actorDecl || ! *msgDecl ) return; 76 75 if ( insideStruct && !namedDecl ) { 77 auto actorIter = actorStructDecls.find( node->aggr() ); 78 if ( actorIter != actorStructDecls.end() ) { 76 if ( node->aggr() == *actorDecl ) { 79 77 actorStructDecls.insert( parentDecl ); 80 return; 81 } 82 auto messageIter = messageStructDecls.find( node->aggr() ); 83 if ( messageIter != messageStructDecls.end() ) { 78 } else if ( node->aggr() == *msgDecl ) { 84 79 messageStructDecls.insert( parentDecl ); 85 80 } … … 191 186 }; 192 187 193 // generates the definitions of send operators for actors 194 // collects data needed for next pass that does the circular defn resolution 195 // for message send operators (via table above) 196 struct GenFuncsCreateTables : public ast::WithDeclsToAdd<> { 188 struct GenReceiveDecls : public ast::WithDeclsToAdd<> { 197 189 unordered_set<const StructDecl *> & actorStructDecls; 198 190 unordered_set<const StructDecl *> & messageStructDecls; … … 203 195 FwdDeclTable & forwardDecls; 204 196 205 // generates the operator for actor message sends206 197 void postvisit( const FunctionDecl * decl ) { 207 198 // return if not of the form receive( param1, param2 ) or if it is a forward decl … … 222 213 auto messageIter = messageStructDecls.find( arg2InstType->aggr() ); 223 214 if ( actorIter != actorStructDecls.end() && messageIter != messageStructDecls.end() ) { 215 216 // check that we have found all the decls we need from <actor.hfa> 217 if ( !*allocationDecl || !*requestDecl ) 218 SemanticError( decl->location, "using actors requires a header, add #include <actor.hfa>\n" ); 219 224 220 ////////////////////////////////////////////////////////////////////// 225 221 // The following generates this send message operator routine for all receive(derived_actor &, derived_msg &) functions … … 351 347 // forward decls to resolve use before decl problem for '|' routines 352 348 forwardDecls.insertDecl( *actorIter, *messageIter , ast::deepCopy( sendOperatorFunction ) ); 349 // forwardDecls.push_back( ast::deepCopy( sendOperatorFunction ) ); 353 350 354 351 sendOperatorFunction->stmts = sendBody; … … 358 355 359 356 public: 360 Gen FuncsCreateTables( unordered_set<const StructDecl *> & actorStructDecls, unordered_set<const StructDecl *> & messageStructDecls,357 GenReceiveDecls( unordered_set<const StructDecl *> & actorStructDecls, unordered_set<const StructDecl *> & messageStructDecls, 361 358 const StructDecl ** requestDecl, const EnumDecl ** allocationDecl, const StructDecl ** actorDecl, const StructDecl ** msgDecl, 362 359 FwdDeclTable & forwardDecls ) : actorStructDecls(actorStructDecls), messageStructDecls(messageStructDecls), … … 364 361 }; 365 362 366 367 // separate pass is needed since this pass resolves circular defn issues 368 // generates the forward declarations of the send operator for actor routines 369 struct FwdDeclOperator : public ast::WithDeclsToAdd<> { 363 struct GenFwdDecls : public ast::WithDeclsToAdd<> { 370 364 unordered_set<const StructDecl *> & actorStructDecls; 371 365 unordered_set<const StructDecl *> & messageStructDecls; 372 366 FwdDeclTable & forwardDecls; 373 367 374 // handles forward declaring the message operator375 368 void postvisit( const StructDecl * decl ) { 376 369 list<FunctionDecl *> toAddAfter; … … 399 392 400 393 public: 401 FwdDeclOperator( unordered_set<const StructDecl *> & actorStructDecls, unordered_set<const StructDecl *> & messageStructDecls, 402 FwdDeclTable & forwardDecls ) : actorStructDecls(actorStructDecls), messageStructDecls(messageStructDecls), forwardDecls(forwardDecls) {} 394 GenFwdDecls( unordered_set<const StructDecl *> & actorStructDecls, unordered_set<const StructDecl *> & messageStructDecls, 395 FwdDeclTable & forwardDecls ) : actorStructDecls(actorStructDecls), messageStructDecls(messageStructDecls), 396 forwardDecls(forwardDecls) {} 403 397 }; 404 398 … … 426 420 Pass<CollectactorStructDecls>::run( translationUnit, actorStructDecls, messageStructDecls, requestDecl, 427 421 allocationDecl, actorDecl, msgDecl ); 428 429 // check that we have found all the decls we need from <actor.hfa>, if not no need to run the rest of this pass 430 if ( !allocationDeclPtr || !requestDeclPtr || !actorDeclPtr || !msgDeclPtr ) 431 return; 432 422 433 423 // second pass locates all receive() routines that overload the generic receive fn 434 424 // it then generates the appropriate operator '|' send routines for the receive routines 435 Pass<Gen FuncsCreateTables>::run( translationUnit, actorStructDecls, messageStructDecls, requestDecl,425 Pass<GenReceiveDecls>::run( translationUnit, actorStructDecls, messageStructDecls, requestDecl, 436 426 allocationDecl, actorDecl, msgDecl, forwardDecls ); 437 427 438 428 // The third pass forward declares operator '|' send routines 439 Pass< FwdDeclOperator>::run( translationUnit, actorStructDecls, messageStructDecls, forwardDecls );429 Pass<GenFwdDecls>::run( translationUnit, actorStructDecls, messageStructDecls, forwardDecls ); 440 430 } 441 431 -
src/Concurrency/Actors.hpp
rdbae916 rc19ca4b 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Actors.hpp-- Implement concurrency constructs from their keywords.7 // Keywords.h -- Implement concurrency constructs from their keywords. 8 8 // 9 9 // Author : Colby Parsons -
src/Virtual/module.mk
rdbae916 rc19ca4b 19 19 Virtual/ExpandCasts.h \ 20 20 Virtual/Tables.cc \ 21 Virtual/Tables.h \ 22 Virtual/VirtualDtor.cpp \ 23 Virtual/VirtualDtor.hpp 21 Virtual/Tables.h -
src/main.cc
rdbae916 rc19ca4b 82 82 #include "Validate/VerifyCtorDtorAssign.hpp" // for verifyCtorDtorAssign 83 83 #include "Virtual/ExpandCasts.h" // for expandCasts 84 #include "Virtual/VirtualDtor.hpp" // for implementVirtDtors85 84 86 85 static void NewPass( const char * const name ) { … … 342 341 343 342 PASS( "Implement Actors", Concurrency::implementActors( transUnit ) ); 344 PASS( "Implement Virtual Destructors", Virtual::implementVirtDtors(transUnit) );345 346 343 PASS( "Implement Mutex", Concurrency::implementMutex( transUnit ) ); 347 344 PASS( "Implement Thread Start", Concurrency::implementThreadStarter( transUnit ) ); -
tests/concurrent/actors/executor.cfa
rdbae916 rc19ca4b 15 15 }; 16 16 void ?{}( d_actor & this ) with(this) { 17 ((actor &)this){}; 17 18 id = ids++; 18 19 gstart = (&this + (id / Set * Set - id)); // remember group-start array-element -
tests/concurrent/actors/poison.cfa
rdbae916 rc19ca4b 5 5 #include <stdio.h> 6 6 7 struct Server { int val; inline actor; }; 8 9 void ?{}( Server & this ) { this.val = 999; } 10 void ^?{}( Server & this ) { this.val = 777; } 7 struct Server { inline actor; }; 11 8 12 9 int main() { … … 15 12 sout | "Finished"; 16 13 { 17 start_actor_system();18 Server s[10];19 for ( i; 10 ) {20 s[i] << FinishedMsg;21 }22 stop_actor_system();14 start_actor_system(); 15 Server s[10]; 16 for ( i; 10 ) { 17 s[i] << FinishedMsg; 18 } 19 stop_actor_system(); 23 20 } 24 21 25 22 sout | "Delete"; 26 23 { 27 start_actor_system();28 for ( i; 10 ) {29 Server * s = alloc();30 (*s){};31 (*s) << DeleteMsg;32 }33 stop_actor_system();24 start_actor_system(); 25 for ( i; 10 ) { 26 Server * s = alloc(); 27 (*s){}; 28 (*s) << DeleteMsg; 29 } 30 stop_actor_system(); 34 31 } 35 32 36 33 sout | "Destroy"; 37 34 { 38 start_actor_system(); 39 Server s[10]; 40 for ( i; 10 ) 41 s[i] << DestroyMsg; 42 stop_actor_system(); 43 for ( i; 10 ) 44 if (s[i].val != 777) 45 sout | "Error: dtor not called correctly."; 35 start_actor_system(); 36 Server s[10]; 37 for ( i; 10 ) { 38 s[i] << DestroyMsg; 39 } 40 stop_actor_system(); 46 41 } 47 42
Note:
See TracChangeset
for help on using the changeset viewer.