Changes in / [c19ca4b:dbae916]


Ignore:
Files:
5 added
9 edited

Legend:

Unmodified
Added
Removed
  • doc/theses/colby_parsons_MMAth/benchmarks/actors/plotData.py

    rc19ca4b rdbae916  
    169169                    else:
    170170                        plt.ylim(0, None)
     171                    plt.xticks(procs)
    171172                    ax.legend(names)
    172173                    # fig.savefig("plots/" + machineName + name + ".png")
  • libcfa/src/Makefile.am

    rc19ca4b rdbae916  
    4848        math.hfa \
    4949        time_t.hfa \
     50    virtual_dtor.hfa \
    5051        bits/algorithm.hfa \
    5152        bits/align.hfa \
     
    6869        vec/vec2.hfa \
    6970        vec/vec3.hfa \
    70         vec/vec4.hfa
     71        vec/vec4.hfa 
    7172
    7273inst_headers_src = \
  • libcfa/src/concurrency/actor.hfa

    rc19ca4b rdbae916  
    55#include <kernel.hfa>
    66#include <iofwd.hfa>
     7#include <virtual_dtor.hfa>
    78
    89#ifdef __CFA_DEBUG__
     
    357358    if ( seperate_clus ) delete( cluster );
    358359
    359     #ifdef STATS
     360    #ifdef STATS // print formatted stats
    360361    printf("    Actor System Stats:\n");
    361362    printf("\tActors Created:\t\t\t\t%lu\n\tMessages Sent:\t\t\t\t%lu\n", __num_actors_stats, __all_processed);
     
    388389static executor * __actor_executor_ = 0p;
    389390static bool __actor_executor_passed = false;            // was an executor passed to start_actor_system
    390 static size_t __num_actors_ = 0;                                // number of actor objects in system
     391static size_t __num_actors_ = 0;                                        // number of actor objects in system
    391392static struct thread$ * __actor_executor_thd = 0p;              // used to wake executor after actors finish
    392393struct actor {
    393     size_t ticket;                              // executor-queue handle
     394    size_t ticket;                                          // executor-queue handle
    394395    Allocation allocation_;                                         // allocation action
     396    inline virtual_dtor;
    395397};
    396398
     
    406408    #endif
    407409}
    408 static inline void ^?{}( actor & this ) {}
    409410
    410411static inline void check_actor( actor & this ) {
     
    430431struct message {
    431432    Allocation allocation_;                     // allocation action
     433    inline virtual_dtor;
    432434};
    433435
    434 static inline void ?{}( message & this ) { this.allocation_ = Nodelete; }
     436static inline void ?{}( message & this ) {
     437    this.allocation_ = Nodelete;
     438}
    435439static inline void ?{}( message & this, Allocation allocation ) {
    436440    memcpy( &this.allocation_, &allocation, sizeof(allocation) ); // optimization to elide ctor
    437441    verifyf( this.allocation_ != Finished, "The Finished Allocation status is not supported for message types.\n");
    438442}
    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); )
     443static 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); )
    441445}
    442446
    443447static inline void check_message( message & this ) {
    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;
     448    switch ( this.allocation_ ) {                                               // analyze message status
     449        case Nodelete: CFA_DEBUG(this.allocation_ = Finished); break;
    453450        case Delete: delete( &this ); break;
    454451        case Destroy: ^?{}(this); break;
     
    456453    } // switch
    457454}
    458 static inline void set_allocation( message & this, Allocation state ) { this.allocation_ = state; }
     455static inline void set_allocation( message & this, Allocation state ) {
     456    this.allocation_ = state;
     457}
    459458
    460459static inline void deliver_request( request & this ) {
     
    688687Allocation receive( actor & this, __DestroyMsg & msg ) { return Destroy; }
    689688Allocation receive( actor & this, __FinishedMsg & msg ) { return Finished; }
     689
  • src/Concurrency/Actors.cpp

    rc19ca4b rdbae916  
    4545    // finds and sets a ptr to the actor, message, and request structs, which are needed in the next pass
    4646    void previsit( const StructDecl * 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
     47        if ( !decl->body ) return;
     48        if ( decl->name == "actor" ) {
     49            actorStructDecls.insert( decl ); // skip inserting fwd decl
    5250            *actorDecl = decl;
    53         }
    54         if( decl->name == "message" ) {
    55             if ( msgDecl ) messageStructDecls.insert( decl ); // skip inserting fwd decl
     51        } else if( decl->name == "message" ) {
     52            messageStructDecls.insert( decl ); // skip inserting fwd decl
    5653            *msgDecl = decl;
    57         }
    58         if( decl->name == "request" ) *requestDecl = decl;
     54        } else if( decl->name == "request" ) *requestDecl = decl;
     55        else {
     56            GuardValue(insideStruct);
     57            insideStruct = true;
     58            parentDecl = mutate( decl );
     59        }
    5960        }
    6061
     
    7071    }
    7172
    72     // this collects the valid actor and message struct decl pts
     73    // this collects the derived actor and message struct decl ptrs
    7374    void postvisit( const StructInstType * node ) {
    7475        if ( ! *actorDecl || ! *msgDecl ) return;
    7576        if ( insideStruct && !namedDecl ) {
    76             if ( node->aggr() == *actorDecl ) {
     77            auto actorIter = actorStructDecls.find( node->aggr() );   
     78            if ( actorIter != actorStructDecls.end() ) {
    7779                actorStructDecls.insert( parentDecl );
    78             } else if ( node->aggr() == *msgDecl ) {
     80                return;
     81            }
     82            auto messageIter = messageStructDecls.find( node->aggr() );
     83            if ( messageIter != messageStructDecls.end() ) {
    7984                messageStructDecls.insert( parentDecl );
    8085            }
     
    186191};
    187192
    188 struct GenReceiveDecls : public ast::WithDeclsToAdd<> {
     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)
     196struct GenFuncsCreateTables : public ast::WithDeclsToAdd<> {
    189197    unordered_set<const StructDecl *> & actorStructDecls;
    190198    unordered_set<const StructDecl *>  & messageStructDecls;
     
    195203    FwdDeclTable & forwardDecls;
    196204
     205    // generates the operator for actor message sends
    197206        void postvisit( const FunctionDecl * decl ) {
    198207        // return if not of the form receive( param1, param2 ) or if it is a forward decl
     
    213222        auto messageIter = messageStructDecls.find( arg2InstType->aggr() );
    214223        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 
    220224            //////////////////////////////////////////////////////////////////////
    221225            // The following generates this send message operator routine for all receive(derived_actor &, derived_msg &) functions
     
    347351            // forward decls to resolve use before decl problem for '|' routines
    348352            forwardDecls.insertDecl( *actorIter, *messageIter , ast::deepCopy( sendOperatorFunction ) );
    349             // forwardDecls.push_back( ast::deepCopy( sendOperatorFunction ) );
    350353
    351354            sendOperatorFunction->stmts = sendBody;
     
    355358
    356359  public:
    357     GenReceiveDecls( unordered_set<const StructDecl *> & actorStructDecls, unordered_set<const StructDecl *> & messageStructDecls,
     360    GenFuncsCreateTables( unordered_set<const StructDecl *> & actorStructDecls, unordered_set<const StructDecl *> & messageStructDecls,
    358361        const StructDecl ** requestDecl, const EnumDecl ** allocationDecl, const StructDecl ** actorDecl, const StructDecl ** msgDecl,
    359362        FwdDeclTable & forwardDecls ) : actorStructDecls(actorStructDecls), messageStructDecls(messageStructDecls),
     
    361364};
    362365
    363 struct GenFwdDecls : public ast::WithDeclsToAdd<> {
     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
     369struct FwdDeclOperator : public ast::WithDeclsToAdd<> {
    364370    unordered_set<const StructDecl *> & actorStructDecls;
    365371    unordered_set<const StructDecl *>  & messageStructDecls;
    366372    FwdDeclTable & forwardDecls;
    367373
     374    // handles forward declaring the message operator
    368375    void postvisit( const StructDecl * decl ) {
    369376        list<FunctionDecl *> toAddAfter;
     
    392399
    393400  public:
    394     GenFwdDecls( unordered_set<const StructDecl *> & actorStructDecls, unordered_set<const StructDecl *> & messageStructDecls,
    395         FwdDeclTable & forwardDecls ) : actorStructDecls(actorStructDecls), messageStructDecls(messageStructDecls),
    396         forwardDecls(forwardDecls) {}
     401    FwdDeclOperator( unordered_set<const StructDecl *> & actorStructDecls, unordered_set<const StructDecl *> & messageStructDecls,
     402        FwdDeclTable & forwardDecls ) : actorStructDecls(actorStructDecls), messageStructDecls(messageStructDecls), forwardDecls(forwardDecls) {}
    397403};
    398404
     
    420426    Pass<CollectactorStructDecls>::run( translationUnit, actorStructDecls, messageStructDecls, requestDecl,
    421427        allocationDecl, actorDecl, msgDecl );
    422        
     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
    423433    // second pass locates all receive() routines that overload the generic receive fn
    424434    // it then generates the appropriate operator '|' send routines for the receive routines
    425     Pass<GenReceiveDecls>::run( translationUnit, actorStructDecls, messageStructDecls, requestDecl,
     435    Pass<GenFuncsCreateTables>::run( translationUnit, actorStructDecls, messageStructDecls, requestDecl,
    426436        allocationDecl, actorDecl, msgDecl, forwardDecls );
    427437
    428438    // The third pass forward declares operator '|' send routines
    429     Pass<GenFwdDecls>::run( translationUnit, actorStructDecls, messageStructDecls, forwardDecls );
     439    Pass<FwdDeclOperator>::run( translationUnit, actorStructDecls, messageStructDecls, forwardDecls );
    430440}
    431441
  • src/Concurrency/Actors.hpp

    rc19ca4b rdbae916  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // Keywords.h -- Implement concurrency constructs from their keywords.
     7// Actors.hpp -- Implement concurrency constructs from their keywords.
    88//
    99// Author           : Colby Parsons
  • src/Virtual/module.mk

    rc19ca4b rdbae916  
    1919        Virtual/ExpandCasts.h \
    2020        Virtual/Tables.cc \
    21         Virtual/Tables.h
     21        Virtual/Tables.h \
     22        Virtual/VirtualDtor.cpp \
     23        Virtual/VirtualDtor.hpp
  • src/main.cc

    rc19ca4b rdbae916  
    8282#include "Validate/VerifyCtorDtorAssign.hpp" // for verifyCtorDtorAssign
    8383#include "Virtual/ExpandCasts.h"            // for expandCasts
     84#include "Virtual/VirtualDtor.hpp"           // for implementVirtDtors
    8485
    8586static void NewPass( const char * const name ) {
     
    341342
    342343                PASS( "Implement Actors", Concurrency::implementActors( transUnit ) );
     344        PASS( "Implement Virtual Destructors", Virtual::implementVirtDtors(transUnit) );
     345       
    343346                PASS( "Implement Mutex", Concurrency::implementMutex( transUnit ) );
    344347                PASS( "Implement Thread Start", Concurrency::implementThreadStarter( transUnit ) );
  • tests/concurrent/actors/executor.cfa

    rc19ca4b rdbae916  
    1515};
    1616void ?{}( d_actor & this ) with(this) {
    17     ((actor &)this){};
    1817    id = ids++;
    1918    gstart = (&this + (id / Set * Set - id)); // remember group-start array-element
  • tests/concurrent/actors/poison.cfa

    rc19ca4b rdbae916  
    55#include <stdio.h>
    66
    7 struct Server { inline actor; };
     7struct Server { int val; inline actor; };
     8
     9void ?{}( Server & this ) { this.val = 999; }
     10void ^?{}( Server & this ) { this.val = 777; }
    811
    912int main() {
     
    1215    sout | "Finished";
    1316    {
    14     start_actor_system();
    15     Server s[10];
    16     for ( i; 10 ) {
    17         s[i] << FinishedMsg;
    18     }
    19     stop_actor_system();
     17        start_actor_system();
     18        Server s[10];
     19        for ( i; 10 ) {
     20            s[i] << FinishedMsg;
     21        }
     22        stop_actor_system();
    2023    }
    2124
    2225    sout | "Delete";
    2326    {
    24     start_actor_system();
    25     for ( i; 10 ) {
    26         Server * s = alloc();
    27         (*s){};
    28         (*s) << DeleteMsg;
    29     }
    30     stop_actor_system();
     27        start_actor_system();
     28        for ( i; 10 ) {
     29            Server * s = alloc();
     30            (*s){};
     31            (*s) << DeleteMsg;
     32        }
     33        stop_actor_system();
    3134    }
    3235
    3336    sout | "Destroy";
    3437    {
    35     start_actor_system();
    36     Server s[10];
    37     for ( i; 10 ) {
    38         s[i] << DestroyMsg;
    39     }
    40     stop_actor_system();
     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.";
    4146    }
    4247
Note: See TracChangeset for help on using the changeset viewer.