Changeset a51c0c0
- Timestamp:
- May 25, 2020, 5:38:15 PM (5 years ago)
- 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
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/executor.cfa
r089ee6b ra51c0c0 4 4 // buffer. 5 5 6 #include <thread.hfa> 6 7 #include <containers/list.hfa> 7 #include <thread.hfa>8 //#include <malloc.h> // trace9 8 10 9 forall( dtype T | $dlistable(T, T) ) { … … 22 21 T * remove( Buffer(T) & mutex buf ) with(buf) { 23 22 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 25 25 return &pop_first( *qptr ); 26 26 } // remove 27 28 // void ?{}( Buffer(T) & ) {}29 // void ^?{}( Buffer(T) & mutex ) {}30 27 } // forall 31 28 … … 74 71 unsigned int nprocessors, nworkers, nrqueues; // number of processors/threads/request queues 75 72 bool sepClus; // use same or separate cluster for executor 73 unsigned int next; // demultiplexed across worker buffers 76 74 }; // Executor 77 78 static thread_local unsigned int next; // demultiplexed across worker buffers79 75 80 76 unsigned int tickets( Executor & ex ) with(ex) { … … 109 105 ex{ nprocessors, nprocessors, nprocessors, sepClus }; 110 106 } 111 void ?{}( Executor & ex ) { // special for current cluster 107 void ?{}( Executor & ex ) { // special for current cluster, no processors added 112 108 ex{ 0, active_cluster()->nprocessors, false }; 113 109 } … … 131 127 free( workers ); 132 128 // adelete( nrqueues, requests ); 133 for ( i; nrqueues ) ^?{}( requests[i] ); 129 for ( i; nrqueues ) ^?{}( requests[i] ); // FIX ME: problem with resolver 134 130 free( requests ); 135 131 free( processors ); … … 145 141 int counter = 0; 146 142 147 void work ie( void ) {143 void work( void ) { 148 144 __atomic_add_fetch( &counter, 1, __ATOMIC_SEQ_CST ); 149 //fprintf( stderr, "workie\n" );145 // fprintf( stderr, "workie\n" ); 150 146 } 151 147 … … 155 151 processor p[7]; 156 152 { 157 printf( "%d\n", active_cluster()->nprocessors );158 153 Executor exector; 159 154 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(); 165 157 } // for 166 158 }
Note: See TracChangeset
for help on using the changeset viewer.