Changeset 641 for trunk/user
- Timestamp:
- Oct 10, 2019, 1:42:04 PM (5 years ago)
- Location:
- trunk/user
- Files:
-
- 2 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", -
trunk/user/ksh/ksh.c
r640 r641 123 123 124 124 #if DEBUG_CMD_CAT 125 snprintf( string , 128 , "[ksh] enter %s" , __FUNCTION__);125 snprintf( string , 128 , "[ksh] %s enters" , __FUNCTION__); 126 126 display_string( string ); 127 127 #endif … … 138 138 139 139 #if DEBUG_CMD_CAT 140 snprintf( string , 128 , "[ksh] in%s : after strcpy" , __FUNCTION__ );140 snprintf( string , 128 , "[ksh] %s : after strcpy" , __FUNCTION__ ); 141 141 display_string( string ); 142 142 #endif … … 180 180 181 181 #if DEBUG_CMD_CAT 182 snprintf( string , 128 , "[ksh] %s : size = %d", __FUNCTION__, size ); 182 snprintf( string , 128 , "[ksh] %s : size = %d", 183 __FUNCTION__, size ); 183 184 display_string( string ); 184 185 #endif … … 206 207 207 208 #if DEBUG_CMD_CAT 208 snprintf( string , 128 , "[ksh] %s : maped file %d to buffer %x", __FUNCTION__, fd , buf ); 209 snprintf( string , 128 , "[ksh] %s : mapped file %d to buffer %x", 210 __FUNCTION__, fd , buf ); 209 211 display_string( string ); 210 212 #endif … … 213 215 write( 1 , buf , size ); 214 216 215 // unmap t e file217 // unmap the file 216 218 if( munmap( buf , size ) ) 217 219 { … … 220 222 221 223 #if DEBUG_CMD_CAT 222 snprintf( string , 128 , "[ksh] %s : unmaped file %d from buffer %x", __FUNCTION__, fd , buf ); 224 snprintf( string , 128 , "[ksh] %s : unmapped file %d from buffer %x", 225 __FUNCTION__, fd , buf ); 223 226 display_string( string ); 224 227 #endif … … 852 855 853 856 #if DEBUG_CMD_LS 854 snprintf( string , 128 , "[ksh] %s : directory <%s> open / DIR %x \n",857 snprintf( string , 128 , "[ksh] %s : directory <%s> open / DIR %x", 855 858 __FUNCTION__, pathname , dir ); 856 859 display_string( string ); … … 875 878 876 879 #if DEBUG_CMD_LS 877 snprintf( string , 128 , "[ksh] %s : directory <%s> closed \n",880 snprintf( string , 128 , "[ksh] %s : directory <%s> closed", 878 881 __FUNCTION__, pathname ); 879 882 display_string( string ); … … 1020 1023 sem_post( &semaphore ); 1021 1024 1022 } // end_cmd_rm() 1025 } // end cmd_rm() 1026 1027 /////////////////////////////////////////////// 1028 static void cmd_stat( int argc , char **argv ) 1029 { 1030 struct stat st; 1031 unsigned int size; 1032 1033 if (argc != 2) 1034 { 1035 printf(" usage: %s pathname\n", argv[0]); 1036 } 1037 else 1038 { 1039 strcpy( pathname , argv[1] ); 1040 1041 if ( stat( pathname , &st ) ) 1042 { 1043 printf(" error: cannot stat <%s>\n", argv[2] ); 1044 } 1045 else 1046 { 1047 // get file size 1048 size = st.st_size; 1049 1050 // print file stat info 1051 printf(" <%s> : %d bytes\n", pathname, size ); 1052 } 1053 } 1054 1055 // release semaphore to get next command 1056 sem_post( &semaphore ); 1057 1058 } // end cmd_stat() 1023 1059 1024 1060 /////////////////////////////////////////////// … … 1103 1139 { "rm", "remove a file from file system", cmd_rm }, 1104 1140 { "rmdir", "remove a directory from file system", cmd_rmdir }, 1141 { "stat", "print infos on a given file", cmd_stat }, 1105 1142 { "trace", "activate trace for a given core", cmd_trace }, 1106 1143 { "untrace", "desactivate trace for a given core", cmd_untrace }, … … 1149 1186 1150 1187 #if DEBUG_EXECUTE 1151 snprintf( string , 128 , "\n[ksh] in %s : argc = %d / arg0 = %s / arg1 = %s \n",1188 snprintf( string , 128 , "\n[ksh] in %s : argc = %d / arg0 = %s / arg1 = %s", 1152 1189 __FUNCTION__ , argc , argv[0], argv[1] ); 1153 1190 #endif … … 1187 1224 char cmd[CMD_MAX_SIZE]; // buffer for one command 1188 1225 1189 /* 1. first direct command 1226 1227 1228 // 1. first direct command 1190 1229 if( sem_wait( &semaphore ) ) 1191 1230 { … … 1195 1234 else 1196 1235 { 1197 printf("\n[ksh] load bin/user/sort.elf\n"); 1236 strcpy( cmd , "load bin/user/fft.elf" ); 1237 printf("[ksh] %s\n", cmd ); 1238 execute( cmd ); 1198 1239 } 1199 1200 strcpy( cmd , "load bin/user/sort.elf" ); 1201 execute( cmd ); 1202 */ 1203 1204 1205 1206 // 2. second direct command 1240 // 1241 1242 1243 1244 /* 2. second direct command 1207 1245 if( sem_wait( &semaphore ) ) 1208 1246 { … … 1212 1250 else 1213 1251 { 1214 printf("\n[ksh] load bin/user/fft.elf\n"); 1252 strcpy( cmd , "cat home/p_fft_dqt_16384_1_2" ); 1253 printf("[ksh] %s\n", cmd ); 1254 execute( cmd ); 1215 1255 } 1216 1217 strcpy( cmd , "load bin/user/fft.elf" ); 1218 execute( cmd ); 1219 // 1220 1256 */ 1221 1257 1222 1258 … … 1253 1289 { 1254 1290 // initialize command buffer 1255 // memset( cmd , 0x20 , sizeof(cmd) ); // TODO useful ?1256 1291 count = 0; 1257 1292 state = NORMAL; … … 1459 1494 1460 1495 #if DEBUG_MAIN 1461 snprintf( string , 128 , "\n[ksh] main thread started on core[%x,%d] \n", cxy , lid );1496 snprintf( string , 128 , "\n[ksh] main thread started on core[%x,%d]", cxy , lid ); 1462 1497 display_string( string ); 1463 1498 #endif … … 1471 1506 1472 1507 #if DEBUG_MAIN 1473 snprintf( string , 128 , "\n[ksh] main initialized semaphore \n" );1508 snprintf( string , 128 , "\n[ksh] main initialized semaphore" ); 1474 1509 display_string( string ); 1475 1510 #endif … … 1485 1520 NULL ); 1486 1521 #if DEBUG_MAIN 1487 snprintf( string , 128 , "\n[ksh] main thread launched interactive thread %x \n", trdid );1522 snprintf( string , 128 , "\n[ksh] main thread launched interactive thread %x", trdid ); 1488 1523 display_string( string ); 1489 1524 #endif
Note: See TracChangeset
for help on using the changeset viewer.