Changeset a51c0c0


Ignore:
Timestamp:
May 25, 2020, 5:38:15 PM (4 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
c1dfa4e
Parents:
089ee6b
Message:

formatting, change buffer remove to not block for empty buffer so worker spins

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/executor.cfa

    r089ee6b ra51c0c0  
    44// buffer.
    55
     6#include <thread.hfa>
    67#include <containers/list.hfa>
    7 #include <thread.hfa>
    8 //#include <malloc.h>                                                                           // trace
    98
    109forall( dtype T | $dlistable(T, T) ) {
     
    2221        T * remove( Buffer(T) & mutex buf ) with(buf) {
    2322                dlist( T, T ) * qptr = &queue;                                  // workaround https://cforall.uwaterloo.ca/trac/ticket/166
    24                 if ( (*qptr)`is_empty ) wait( delay );                  // no request to process ? => wait
     23                // if ( (*qptr)`is_empty ) wait( delay );                       // no request to process ? => wait
     24          if ( (*qptr)`is_empty ) return 0p;                            // no request to process ? => wait
    2525                return &pop_first( *qptr );
    2626        } // remove
    27 
    28 //      void ?{}( Buffer(T) & ) {}
    29 //      void ^?{}( Buffer(T) & mutex ) {}
    3027} // forall
    3128
     
    7471        unsigned int nprocessors, nworkers, nrqueues;           // number of processors/threads/request queues
    7572        bool sepClus;                                                                           // use same or separate cluster for executor
     73        unsigned int next;                                                                      // demultiplexed across worker buffers
    7674}; // Executor
    77 
    78 static thread_local unsigned int next;                                  // demultiplexed across worker buffers
    7975
    8076unsigned int tickets( Executor & ex ) with(ex) {
     
    109105        ex{ nprocessors, nprocessors, nprocessors, sepClus };
    110106}
    111 void ?{}( Executor & ex ) {                                                             // special for current cluster
     107void ?{}( Executor & ex ) {                                                             // special for current cluster, no processors added
    112108        ex{ 0, active_cluster()->nprocessors, false };
    113109}
     
    131127        free( workers );
    132128//      adelete( nrqueues, requests );
    133         for ( i; nrqueues ) ^?{}( requests[i] );
     129        for ( i; nrqueues ) ^?{}( requests[i] );                        // FIX ME: problem with resolver
    134130        free( requests );
    135131        free( processors );
     
    145141int counter = 0;
    146142
    147 void workie( void ) {
     143void work( void ) {
    148144        __atomic_add_fetch( &counter, 1, __ATOMIC_SEQ_CST );
    149 //      fprintf( stderr, "workie\n" );
     145        // fprintf( stderr, "workie\n" );
    150146}
    151147
     
    155151        processor p[7];
    156152        {
    157                 printf( "%d\n", active_cluster()->nprocessors );
    158153                Executor exector;
    159154                for ( i; times ) {
    160                         send( exector, workie );
    161                         if ( i % 100 == 0 ) {
    162 //                        fprintf( stderr, "%d\n", i );
    163                                 yield();
    164                         }
     155                        send( exector, work );
     156                        if ( i % 100 == 0 ) yield();
    165157                } // for
    166158        }
Note: See TracChangeset for help on using the changeset viewer.