Changeset efdd18c for libcfa/src
- Timestamp:
- Mar 30, 2023, 3:49:10 PM (19 months ago)
- Branches:
- ADT, ast-experimental, master
- Children:
- a45e21c
- Parents:
- 9319a23
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/actor.hfa
r9319a23 refdd18c 35 35 36 36 // show stats 37 // #define STATS37 // #define ACTOR_STATS 38 38 39 39 // forward decls … … 122 122 copy_queue * c_queue; // current queue 123 123 volatile bool being_processed; // flag to prevent concurrent processing 124 #ifdef STATS124 #ifdef ACTOR_STATS 125 125 unsigned int id; 126 126 size_t missed; // transfers skipped due to being_processed flag being up … … 132 132 c_queue = owned_queue; 133 133 being_processed = false; 134 #ifdef STATS134 #ifdef ACTOR_STATS 135 135 id = i; 136 136 missed = 0; … … 153 153 // check if queue is being processed elsewhere 154 154 if ( unlikely( being_processed ) ) { 155 #ifdef STATS155 #ifdef ACTOR_STATS 156 156 missed++; 157 157 #endif … … 175 175 struct worker_info { 176 176 volatile unsigned long long stamp; 177 #ifdef STATS177 #ifdef ACTOR_STATS 178 178 size_t stolen_from, try_steal, stolen, failed_swaps, msgs_stolen; 179 179 unsigned long long processed; … … 182 182 }; 183 183 static inline void ?{}( worker_info & this ) { 184 #ifdef STATS184 #ifdef ACTOR_STATS 185 185 this.stolen_from = 0; 186 186 this.try_steal = 0; // attempts to steal … … 194 194 } 195 195 196 // #ifdef STATS196 // #ifdef ACTOR_STATS 197 197 // unsigned int * stolen_arr; 198 198 // unsigned int * replaced_queue; … … 206 206 }; 207 207 208 #ifdef STATS208 #ifdef ACTOR_STATS 209 209 // aggregate counters for statistics 210 210 size_t __total_tries = 0, __total_stolen = 0, __total_workers, __all_gulps = 0, … … 235 235 }; // executor 236 236 237 // #ifdef STATS237 // #ifdef ACTOR_STATS 238 238 // __spinlock_t out_lock; 239 239 // #endif 240 240 static inline void ^?{}( worker & mutex this ) with(this) { 241 #ifdef STATS241 #ifdef ACTOR_STATS 242 242 __atomic_add_fetch(&__all_gulps, executor_->w_infos[id].gulps,__ATOMIC_SEQ_CST); 243 243 __atomic_add_fetch(&__all_processed, executor_->w_infos[id].processed,__ATOMIC_SEQ_CST); … … 276 276 no_steal = true; 277 277 278 #ifdef STATS278 #ifdef ACTOR_STATS 279 279 // stolen_arr = aalloc( nrqueues ); 280 280 // replaced_queue = aalloc( nrqueues ); … … 341 341 } // for 342 342 343 #ifdef STATS343 #ifdef ACTOR_STATS 344 344 size_t misses = 0; 345 345 for ( i; nrqueues ) { … … 358 358 if ( seperate_clus ) delete( cluster ); 359 359 360 #ifdef STATS // print formatted stats360 #ifdef ACTOR_STATS // print formatted stats 361 361 printf(" Actor System Stats:\n"); 362 362 printf("\tActors Created:\t\t\t\t%lu\n\tMessages Sent:\t\t\t\t%lu\n", __num_actors_stats, __all_processed); … … 404 404 ticket = __get_next_ticket( *__actor_executor_ ); 405 405 __atomic_fetch_add( &__num_actors_, 1, __ATOMIC_RELAXED ); 406 #ifdef STATS406 #ifdef ACTOR_STATS 407 407 __atomic_fetch_add( &__num_actors_stats, 1, __ATOMIC_SEQ_CST ); 408 408 #endif … … 513 513 continue; 514 514 515 #ifdef STATS515 #ifdef ACTOR_STATS 516 516 curr_steal_queue = try_swap_queues( this, i + vic_start, swap_idx ); 517 517 if ( curr_steal_queue ) { … … 526 526 #else 527 527 curr_steal_queue = try_swap_queues( this, i + vic_start, swap_idx ); 528 #endif // STATS528 #endif // ACTOR_STATS 529 529 530 530 return; … … 558 558 559 559 void main( worker & this ) with(this) { 560 // #ifdef STATS560 // #ifdef ACTOR_STATS 561 561 // for ( i; executor_->nrqueues ) { 562 562 // replaced_queue[i] = 0; … … 587 587 } 588 588 transfer( *curr_work_queue, ¤t_queue ); 589 #ifdef STATS589 #ifdef ACTOR_STATS 590 590 executor_->w_infos[id].gulps++; 591 #endif // STATS591 #endif // ACTOR_STATS 592 592 #ifdef __STEAL 593 593 if ( isEmpty( *current_queue ) ) { … … 599 599 __atomic_store_n( &executor_->w_infos[id].stamp, rdtscl(), __ATOMIC_RELAXED ); 600 600 601 #ifdef STATS601 #ifdef ACTOR_STATS 602 602 executor_->w_infos[id].try_steal++; 603 #endif // STATS603 #endif // ACTOR_STATS 604 604 605 605 steal_work( this, start + prng( range ) ); … … 608 608 #endif // __STEAL 609 609 while ( ! isEmpty( *current_queue ) ) { 610 #ifdef STATS610 #ifdef ACTOR_STATS 611 611 executor_->w_infos[id].processed++; 612 612 #endif … … 636 636 637 637 static inline void __reset_stats() { 638 #ifdef STATS638 #ifdef ACTOR_STATS 639 639 __total_tries = 0; 640 640 __total_stolen = 0;
Note: See TracChangeset
for help on using the changeset viewer.