Changeset 641 for trunk/user/fft
- Timestamp:
- Oct 10, 2019, 1:42:04 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/user/fft/fft.c
r640 r641 92 92 // parameters 93 93 94 #define DEFAULT_M 1 4// 16384 data points94 #define DEFAULT_M 16 // 16384 data points 95 95 #define USE_DQT_BARRIER 1 // use DDT barrier if non zero 96 96 #define MODE COSIN // DATA array initialisation mode … … 135 135 136 136 // instrumentation counters 137 unsigned int pgfault_nr[THREADS_MAX]; // total number of page faults (per thread) 138 unsigned int pgfault_cost[THREADS_MAX]; // total page faults cost (per thread) 139 unsigned int pgfault_max[THREADS_MAX]; // max page faults cost (per thread) 137 140 unsigned int parallel_time[THREADS_MAX]; // total computation time (per thread) 138 141 unsigned int sync_time[THREADS_MAX]; // cumulated waiting time in barriers (per thread) … … 458 461 } 459 462 460 // get instrumentation results for each thread 463 // initializes global (all threads) instrumentation values 464 unsigned int time_para = parallel_time[0]; 465 unsigned int time_sync = sync_time[0]; 466 unsigned int pgfaults_nr = 0; 467 unsigned int pgfaults_cost = 0; 468 unsigned int pgfaults_max = pgfault_max[0]; 469 470 // loop on threads to compute global instrumentation results 461 471 for (tid = 0 ; tid < nthreads ; tid++) 462 472 { 463 snprintf( string , 256 , "- tid %d : Sequencial %d / Parallel %d / Barrier %d\n", 464 tid, init_time, parallel_time[tid], sync_time[tid] ); 473 snprintf( string , 256 , 474 "- tid %d : Seq %d / Para %d / Sync %d / Pgfaults %d ( cost %d / max %d )\n", 475 tid, init_time, parallel_time[tid], sync_time[tid], 476 pgfault_nr[tid], (pgfault_cost[tid] / pgfault_nr[tid]) , pgfault_max[tid] ); 465 477 466 478 // save to instrumentation file … … 468 480 if( ret < 0 ) 469 481 { 470 printf("\n[fft error] cannot write thread %dto file <%s>\n", tid, path );482 printf("\n[fft error] cannot save thread %d results to file <%s>\n", tid, path ); 471 483 printf("%s", string ); 472 484 exit(0); 473 485 } 474 } 475 476 // compute min/max values 477 unsigned int min_para = parallel_time[0]; 478 unsigned int max_para = parallel_time[0]; 479 unsigned int min_sync = sync_time[0]; 480 unsigned int max_sync = sync_time[0]; 481 482 for (tid = 0 ; tid < nthreads ; tid++) 483 { 484 if (parallel_time[tid] > max_para) max_para = parallel_time[tid]; 485 if (parallel_time[tid] < min_para) min_para = parallel_time[tid]; 486 if (sync_time[tid] > max_sync) max_sync = sync_time[tid]; 487 if (sync_time[tid] < min_sync) min_sync = sync_time[tid]; 488 } 489 490 // display MIN/MAX values on terminal and save to file 491 snprintf( string , 256 , "\n Sequencial Parallel Barrier\n" 492 "MIN : %d\t | %d\t | %d\t (cycles)\n" 493 "MAX : %d\t | %d\t | %d\t (cycles)\n", 494 (int)init_time, (int)min_para, (int)min_sync, 495 (int)init_time, (int)max_para, (int)max_sync ); 486 487 // compute global values 488 if (parallel_time[tid] > time_para) time_para = parallel_time[tid]; 489 if (sync_time[tid] > time_sync) time_sync = sync_time[tid]; 490 pgfaults_nr += pgfault_nr[tid]; 491 pgfaults_cost += pgfault_cost[tid]; 492 if (pgfault_max[tid] > pgfaults_max) pgfaults_max = pgfault_max[tid]; 493 } 494 495 // display global values on terminal and save to file 496 snprintf( string , 256 , 497 "\nSeq %d / Para %d / Sync %d / Pgfaults %d ( cost %d / max %d )\n", 498 init_time, time_para, time_sync, pgfaults_nr, (pgfaults_cost / pgfaults_nr), pgfaults_max ); 499 496 500 printf("%s", string ); 501 502 // save global values to file 497 503 ret = fprintf( f , "%s", string ); 504 498 505 if( ret < 0 ) 499 506 { 500 printf("\n[fft error] cannot write MIN/MAX to file <%s>\n", path ); 507 printf("\n[fft error] cannot save global results to file <%s>\n", path ); 508 exit(0); 509 } 510 511 // close instrumentation file 512 ret = fclose( f ); 513 514 if( ret < 0 ) 515 { 516 printf("\n[fft error] cannot close file <%s>\n", path ); 501 517 exit(0); 502 518 } … … 504 520 #if DEBUG_MAIN 505 521 get_cycle( &debug_cycle ); 506 printf("\n[fft] main close file<%s> at cycle %d\n",522 printf("\n[fft] main exit <%s> at cycle %d\n", 507 523 path, (unsigned int)debug_cycle ); 508 524 #endif … … 645 661 get_cycle( ¶llel_stop ); 646 662 647 // register parallel time 663 // register parallel time in instrumentation counters 648 664 parallel_time[tid] = (unsigned int)(parallel_stop - parallel_start); 649 665 666 // get work thread info for page faults 667 thread_info_t info; 668 get_thread_info( &info ); 669 670 // register page faults in instrumentation counters 671 pgfault_nr[tid] = info.false_pgfault_nr + 672 info.local_pgfault_nr + 673 info.global_pgfault_nr; 674 pgfault_cost[tid] = info.false_pgfault_cost + 675 info.local_pgfault_cost + 676 info.global_pgfault_cost; 677 pgfault_max[tid] = info.false_pgfault_max + 678 info.local_pgfault_max + 679 info.global_pgfault_max; 650 680 #if DEBUG_WORK 651 681 printf("\n[fft] %s : thread %d completes fft / p_start %d / p_stop %d\n",
Note: See TracChangeset
for help on using the changeset viewer.