Changeset 628 for trunk/user


Ignore:
Timestamp:
May 6, 2019, 1:28:01 PM (6 years ago)
Author:
alain
Message:

Introduce teh page_min / page_max mechanism in the fatfs_release_inode()
function, to avoid to scan all pages in FAT mapper.

Location:
trunk/user
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/user/fft/fft.c

    r596 r628  
    2828// - RANDOM   : data points have pseudo random values
    2929//
    30 // This application uses 4 shared data arrays, that are distributed
    31 // in all clusters (one buffer per cluster):
     30// The main parameters for this generic application are the following:     
     31//  - M : N = 2**M = number of data points / M must be an even number.
     32//  - T : nthreads = ncores defined by the hardware / must be power of 2.
     33//
     34// This application uses 4 shared data arrays, that are dynamically
     35// allocated an distributed, using the remote_malloc() function, with
     36// one sub-buffer per cluster:
    3237// - data[N] contains N input data points, with 2 double per point.
    3338// - trans[N] contains N intermediate data points, 2 double per point.
     
    3641// For data, trans, twid, each sub-buffer contains (N/nclusters) points.
    3742// For umain, each sub-buffer contains (rootN/nclusters) points.
    38 //
    39 // The main parameters for this generic application are the following:     
    40 //  - M : N = 2**M = number of data points / M must be an even number.
    41 //  - T : nthreads = ncores defined by the hardware / must be power of 2.
    4243//
    4344// There is one thread per core.
     
    5051//  - DEBUG_MAIN  : Display intermediate results in main()
    5152//  - DEBUG_FFT1D : Display intermediate results in FFT1D()
    52 //  - DEBUG_ROW  :
     53//  - DEBUG_ROW   : Display intermedite results in FFTrow()
    5354//
    5455// Regarding final instrumentation:
     
    8788
    8889#define DEFAULT_M               12              // 4096 data points
    89 #define MODE                    COSIN
    90 #define CHECK                   0
    91 #define DEBUG_MAIN              2               // trace main() function (detailed if odd)
    92 #define DEBUG_SLAVE             2               // trace slave() function (detailed if odd)
    93 #define DEBUG_FFT1D             2               // trace FFT1D() function (detailed if odd)
     90#define USE_DQT_BARRIER         0               // use DDT barrier if non zero
     91#define MODE                    COSIN           // DATA array initialisation mode
     92#define CHECK                   0               
     93#define DEBUG_MAIN              1               // trace main() function (detailed if odd)
     94#define DEBUG_SLAVE             0               // trace slave() function (detailed if odd)
     95#define DEBUG_FFT1D             0               // trace FFT1D() function (detailed if odd)
    9496#define DEBUG_ROW               0               // trace FFTRow() function (detailed if odd)
    9597#define PRINT_ARRAY             0
     
    138140// synchronisation barrier (all threads)
    139141pthread_barrier_t      barrier;
    140 pthread_barrierattr_t  barrierattr;
     142pthread_barrierattr_t  barrier_attr;
    141143
    142144// threads identifiers, attributes, and arguments
     
    213215void main ( void )
    214216{
     217    int                 error;
     218
    215219    unsigned int        main_cxy;          // main thread cluster
    216220    unsigned int        main_x;            // main thread X coordinate
     
    240244    if( get_config( &x_size , &y_size , &ncores ) )
    241245    {
    242         printf("\n[FFT ERROR] cannot get hardware configuration\n");
     246        printf("\n[fft error] cannot get hardware configuration\n");
    243247        exit( 0 );
    244248    }
     
    247251    if( (ncores != 1) && (ncores != 2) && (ncores != 4) )
    248252    {
    249         printf("\n[FFT ERROR] number of cores per cluster must be 1/2/4\n");
     253        printf("\n[fft error] number of cores per cluster must be 1/2/4\n");
    250254        exit( 0 );
    251255    }
     
    254258    if( (x_size != 1) && (x_size != 2) && (x_size != 4) && (x_size != 8) && (x_size != 16) )
    255259    {
    256         printf("\n[FFT ERROR] x_size must be 1/2/4/8/16\n");
     260        printf("\n[fft error] x_size must be 1/2/4/8/16\n");
    257261        exit( 0 );
    258262    }
     
    261265    if( (y_size != 1) && (y_size != 2) && (y_size != 4) && (y_size != 8) && (y_size != 16) )
    262266    {
    263         printf("\n[FFT ERROR] y_size must be 1/2/4/8/16\n");
     267        printf("\n[fft error] y_size must be 1/2/4/8/16\n");
    264268        exit( 0 );
    265269    }
     
    277281    if( rootN < nthreads )
    278282    {
    279         printf("\n[FFT ERROR] sqrt(N) must be larger than T\n");
     283        printf("\n[fft error] sqrt(N) must be larger than T\n");
    280284        exit( 0 );
    281285    }
     
    287291    main_tid = (((main_x * y_size) + main_y) * ncores) + main_lid;
    288292
    289     printf("\n[FFT] starts on core[%x,%d] / %d complex points / %d thread(s) / PID %x\n",
     293    printf("\n[fft] starts on core[%x,%d] / %d complex points / %d thread(s) / PID %x\n",
    290294    main_cxy, main_lid, N, nthreads, getpid() );
    291295
     
    308312    }
    309313
    310     printf("\n[FFT] main completes remote_malloc\n");
     314    printf("\n[fft] main completes remote_malloc\n");
    311315
    312316    // arrays initialisation
     
    315319    InitT( twid );
    316320
    317     printf("\n[FFT] main completes arrays init\n");
     321    printf("\n[fft] main completes arrays init\n");
    318322
    319323#if CHECK
     
    335339
    336340    // initialise barrier
    337     barrierattr.x_size   = x_size;
    338     barrierattr.y_size   = y_size;
    339     barrierattr.nthreads = ncores;
    340     if( pthread_barrier_init( &barrier, &barrierattr , nthreads) )
    341     {
    342         printf("\n[FFT ERROR] cannot initialize barrier\n");
     341    if( USE_DQT_BARRIER )
     342    {
     343        barrier_attr.x_size   = x_size;
     344        barrier_attr.y_size   = y_size;
     345        barrier_attr.nthreads = ncores;
     346        error = pthread_barrier_init( &barrier, &barrier_attr , nthreads );
     347    }
     348    else
     349    {
     350        error = pthread_barrier_init( &barrier, NULL , nthreads );
     351    }
     352
     353    if( error )
     354    {
     355        printf("\n[fft error] cannot initialize barrier\n");
    343356        exit( 0 );
    344357    }
    345358
    346     printf("\n[FFT] main completes barrier init\n");
     359    printf("\n[fft] main completes barrier init\n");
    347360
    348361    // launch other threads to execute the slave() function
     
    377390                                         &args[tid]) ) // pointer on function arguments
    378391                    {
    379                         printf("\n[FFT ERROR] creating thread %x\n", tid );
     392                        printf("\n[fft error] creating thread %x\n", tid );
    380393                        exit( 0 );
    381394                    }
    382 #if DEBUG_MAIN
     395#if (DEBUG_MAIN & 1)
    383396unsigned long long debug_cycle;
    384397get_cycle( &debug_cycle );
    385 printf("\n[FFT] main created thread %x on core[%x,%d] / cycle %d\n",
     398printf("\n[fft] main created thread %d on core[%x,%d] / cycle %d\n",
    386399tid, cxy, lid, (unsigned int)debug_cycle );
    387400#endif
     
    390403        }
    391404    }
     405
    392406
    393407    // register sequencial initalisation completion cycle
     
    395409    init_time = (unsigned int)(end_init_cycle - start_init_cycle);
    396410
    397     printf("\n[FFT] main enters parallel execution\n");
     411    printf("\n[fft] main completes threads creation\n");
    398412   
    399413    // main itself executes the slave() function
     
    414428                    if( pthread_join( trdid[tid] , NULL ) )
    415429                    {
    416                         printf("\n[FFT ERROR] in main thread joining thread %x\n", tid );
     430                        printf("\n[fft error] in main thread joining thread %x\n", tid );
    417431                        exit( 0 );
    418432                    }
    419433                   
    420 #if DEBUG_MAIN
    421 printf("\n[FFT] main thread %d joined thread %d\n", main_tid, tid );
     434#if (DEBUG_MAIN & 1)
     435printf("\n[fft] main thread %d joined thread %d\n", main_tid, tid );
    422436#endif
    423437
     
    441455
    442456    // instrumentation
     457    char name[64];
     458    char path[128];
    443459    char string[256];
    444 
    445     snprintf( string , 256 , "/home/fft_%d_%d_%d_%d", x_size , y_size , ncores , N );
     460    int  ret;
     461
     462    // build file name
     463    if( USE_DQT_BARRIER )
     464    snprintf( name , 64 , "fft_dqt_%d_%d_%d_%d", x_size , y_size , ncores , N );
     465    else
     466    snprintf( name , 64 , "fft_smp_%d_%d_%d_%d", x_size , y_size , ncores , N );
     467
     468    // build pathname
     469    snprintf( path , 128 , "/home/%s", name );
    446470
    447471    // open instrumentation file
    448 //  FILE * f = fopen( string , NULL );
    449 //  if ( f == NULL )
    450 //  {
    451 //      printf("\n[FFT ERROR] cannot open instrumentation file %s\n", string );
    452 //      exit( 0 );
    453 //  }
    454 
    455     snprintf( string , 256 , "\n[FFT] instrumentation : (%dx%dx%d) threads / %d points\n",
    456     x_size, y_size, ncores , N );
    457 
    458     // display on terminal, and save to instrumentation file
    459     printf( "%s" , string );
    460 //  fprintf( f , string );
    461 
     472    FILE * f = fopen( path , NULL );
     473    if ( f == NULL )
     474    {
     475        printf("\n[fft error] cannot open instrumentation file <%s>\n", path );
     476        exit( 0 );
     477    }
     478    printf("\n[fft] file <%s> open\n", path );
     479
     480    // display header on terminal, and save to file
     481    printf("\n----- %s -----\n", name );
     482
     483    ret = fprintf( f , "\n----- %s -----\n", name );
     484    if( ret < 0 )
     485    {
     486        printf("\n[fft error] cannot write header to file <%s>\n", path );
     487        exit(0);
     488    }
     489
     490    // display results for each thread on terminal, and save to file
    462491    for (tid = 0 ; tid < nthreads ; tid++)
    463492    {
    464         snprintf( string , 256 , "\ntid %d : Init %d / Parallel %d / Sync %d\n",
     493        snprintf( string , 256 , "- tid %d : Sequencial %d / Parallel %d / Barrier %d\n",
    465494        tid, init_time, parallel_time[tid], sync_time[tid] );
    466495
    467496        // display on terminal, and save to instrumentation file
    468497        printf("%s" , string );
    469 //      fprintf( f , string );
    470     }
    471 
    472     // close instrumentation file and exit
    473 //  fclose( f );
    474                              
    475 
    476 /*
    477     long min_para = parallel_time[0];
    478     long max_para = parallel_time[0];
    479     long min_sync = sync_time[0];
    480     long max_sync = sync_time[0];
     498        fprintf( f , "%s" , string );
     499        if( ret < 0 )
     500        {
     501            printf("\n[fft error] cannot write thread %d to file <%s>\n", tid, path );
     502            exit(0);
     503        }
     504    }
     505
     506    // display MIN/MAX values on terminal and save to file
     507    unsigned int min_para = parallel_time[0];
     508    unsigned int max_para = parallel_time[0];
     509    unsigned int min_sync = sync_time[0];
     510    unsigned int max_sync = sync_time[0];
    481511
    482512    for (tid = 1 ; tid < nthreads ; tid++)
     
    488518    }
    489519
    490     snprintf( string , 256 , "\n      Init       Parallel   Barrier\n"
     520    snprintf( string , 256 , "\n      Sequencial  Parallel       Barrier\n"
    491521                             "MIN : %d\t | %d\t | %d\t   (cycles)\n"
    492522                             "MAX : %d\t | %d\t | %d\t   (cycles)\n",
    493523                             (int)init_time, (int)min_para, (int)min_sync,
    494524                             (int)init_time, (int)max_para, (int)max_sync );
    495 */
    496 
    497     pthread_exit( NULL );
     525    printf("%s", string );
     526    ret = fprintf( f , "%s", string );
     527    if( ret < 0 )
     528    {
     529        printf("\n[fft error] cannot write MIN/MAX to file <%s>\n", path );
     530        exit(0);
     531    }
     532
     533    // close instrumentation file
     534    ret = fclose( f );
     535    if( ret )
     536    {
     537        printf("\n[fft error] cannot close file <%s>\n", path );
     538        exit(0);
     539    }
     540    printf("\n[sort] file <%s> closed\n", path );
     541
     542    exit( 0 );
    498543
    499544} // end main()
     
    525570
    526571#if DEBUG_SLAVE
    527 printf("\n[FFT] %s : thread %x enter / cycle %d\n",
     572printf("\n[fft] %s : thread %x enter / cycle %d\n",
    528573__FUNCTION__, MyNum, (unsigned int)parallel_start );
    529574#endif
     
    569614
    570615#if DEBUG_SLAVE
    571 printf("\n[FFT] %s : thread %x exit / parallel_time %d / sync_time %d / cycle %d\n",
    572 __FUNCTION__, MyNum, parallel_time[MyNum], sync_time[MyNum], (unsigned int)parallel_stop );
     616printf("\n[fft] %s : thread %x exit / cycle %d\n", __FUNCTION__, MyNum, parallel_stop );
    573617#endif
    574618
     
    805849unsigned long long cycle;
    806850get_cycle( &cycle );
    807 printf("\n[FFT] %s : thread %x enter / first %d / last %d / cycle %d\n",
     851printf("\n[fft] %s : thread %x enter / first %d / last %d / cycle %d\n",
    808852__FUNCTION__, MyNum, MyFirst, MyLast, (unsigned int)cycle );
    809853#endif
     
    814858#if( DEBUG_FFT1D & 1 )
    815859get_cycle( &cycle );
    816 printf("\n[FFT] %s : thread %x after first transpose / cycle %d\n",
     860printf("\n[fft] %s : thread %x after first transpose / cycle %d\n",
    817861__FUNCTION__, MyNum, (unsigned int)cycle );
    818862if( PRINT_ARRAY ) PrintArray( tmp , N );
     
    827871#if( DEBUG_FFT1D & 1 )
    828872get_cycle( &cycle );
    829 printf("\n[FFT] %s : thread %x exit barrier after first transpose / cycle %d\n",
     873printf("\n[fft] %s : thread %x exit barrier after first transpose / cycle %d\n",
    830874__FUNCTION__, MyNum, (unsigned int)cycle );
    831875#endif
     
    840884
    841885#if( DEBUG_FFT1D & 1 )
    842 printf("\n[FFT] %s : thread %x after first twiddle\n", __FUNCTION__, MyNum);
     886printf("\n[fft] %s : thread %x after first twiddle\n", __FUNCTION__, MyNum);
    843887if( PRINT_ARRAY ) PrintArray( tmp , N );
    844888#endif
     
    850894
    851895#if( DEBUG_FFT1D & 1 )
    852 printf("\n[FFT] %s : thread %x exit barrier after first twiddle\n", __FUNCTION__, MyNum);
     896printf("\n[fft] %s : thread %x exit barrier after first twiddle\n", __FUNCTION__, MyNum);
    853897#endif
    854898
     
    859903
    860904#if( DEBUG_FFT1D & 1 )
    861 printf("\n[FFT] %s : thread %x after second transpose\n", __FUNCTION__, MyNum);
     905printf("\n[fft] %s : thread %x after second transpose\n", __FUNCTION__, MyNum);
    862906if( PRINT_ARRAY ) PrintArray( x , N );
    863907#endif
     
    869913
    870914#if( DEBUG_FFT1D & 1 )
    871 printf("\n[FFT] %s : thread %x exit barrier after second transpose\n", __FUNCTION__, MyNum);
     915printf("\n[fft] %s : thread %x exit barrier after second transpose\n", __FUNCTION__, MyNum);
    872916#endif
    873917
     
    882926
    883927#if( DEBUG_FFT1D & 1 )
    884 printf("\n[FFT] %s : thread %x after FFT on rows\n", __FUNCTION__, MyNum);
     928printf("\n[fft] %s : thread %x after FFT on rows\n", __FUNCTION__, MyNum);
    885929if( PRINT_ARRAY ) PrintArray( x , N );
    886930#endif
     
    892936
    893937#if( DEBUG_FFT1D & 1 )
    894 printf("\n[FFT] %s : thread %x exit barrier after FFT on rows\n", __FUNCTION__, MyNum);
     938printf("\n[fft] %s : thread %x exit barrier after FFT on rows\n", __FUNCTION__, MyNum);
    895939#endif
    896940    sync_time[MyNum] += (long)(barrier_stop - barrier_start);
     
    900944
    901945#if( DEBUG_FFT1D & 1 )
    902 printf("\n[FFT] %s : thread %x after third transpose\n", __FUNCTION__, MyNum);
     946printf("\n[fft] %s : thread %x after third transpose\n", __FUNCTION__, MyNum);
    903947if( PRINT_ARRAY ) PrintArray( x , N );
    904948#endif
     
    910954
    911955#if( DEBUG_FFT1D & 1 )
    912 printf("\n[FFT] %s : thread %x exit barrier after third transpose\n", __FUNCTION__, MyNum);
     956printf("\n[fft] %s : thread %x exit barrier after third transpose\n", __FUNCTION__, MyNum);
    913957#endif
    914958
     
    920964
    921965#if DEBUG_FFT1D
    922 printf("\n[FFT] %s : thread %x completed\n", __FUNCTION__, MyNum);
     966printf("\n[fft] %s : thread %x completed\n", __FUNCTION__, MyNum);
    923967if( PRINT_ARRAY ) PrintArray( x , N );
    924968#endif
     
    11111155#if DEBUG_ROW
    11121156unsigned int p;
    1113 printf("\n[FFT] ROW data in / %d points / offset = %d\n", rootN , offset_x );
     1157printf("\n[fft] ROW data in / %d points / offset = %d\n", rootN , offset_x );
    11141158
    11151159for ( p = 0 ; p < rootN ; p++ )
     
    11271171
    11281172#if DEBUG_ROW
    1129 printf("\n[FFT] ROW data after reverse / %d points / offset = %d\n", rootN , offset_x );
     1173printf("\n[fft] ROW data after reverse / %d points / offset = %d\n", rootN , offset_x );
    11301174
    11311175for ( p = 0 ; p < rootN ; p++ )
     
    11981242
    11991243#if DEBUG_ROW
    1200 printf("\n[FFT] ROW data out / %d points / offset = %d\n", rootN , offset_x );
     1244printf("\n[fft] ROW data out / %d points / offset = %d\n", rootN , offset_x );
    12011245for ( p = 0 ; p < rootN ; p++ )
    12021246{
  • trunk/user/ksh/ksh.c

    r626 r628  
    11781178#endif
    11791179
    1180 /*
    1181 // Lauch one or several commands without interactive mode
    1182 
    1183 // 1. first command
     1180
     1181/* 1. first direct command
    11841182if( sem_wait( &semaphore ) )
    11851183{
     
    11891187else
    11901188{
    1191     printf("\n[ksh] display fat 0 32\n");
     1189    printf("\n[ksh] load bin/user/sort.elf\n");
    11921190}
    11931191
    1194 strcpy( cmd , "display fat 0 32" );
     1192strcpy( cmd , "load bin/user/sort.elf" );
    11951193execute( cmd );
    1196 
    1197 // 2. second command
     1194*/
     1195
     1196
     1197
     1198/* 2. second direct command
    11981199if( sem_wait( &semaphore ) )
    11991200{
     
    12031204else
    12041205{
    1205     printf("\n[ksh] load bin/user/pgcd.elf\n");
     1206    printf("\n[ksh] rm home/fft_1_2_1_4096\n");
    12061207}
    12071208
    1208 strcpy( cmd , "load bin/user/pgcd.elf" );
     1209strcpy( cmd , "rm home/fft_1_2_1_4096" );
    12091210execute( cmd );
    1210 
    1211 // end non-interactive mode
    12121211*/
     1212
     1213
    12131214
    12141215        enum fsm_states
  • trunk/user/sort/sort.c

    r627 r628  
    2929#include <hal_macros.h>
    3030
    31 #define ARRAY_LENGTH        4096       // number of items
     31#define ARRAY_LENGTH        1024       // number of items
    3232#define MAX_THREADS         1024       // 16 * 16 * 4
    3333
     
    3535#define DISPLAY_ARRAY       0          // display items values before and after
    3636#define DEBUG_MAIN          1          // trace main function
    37 #define DEBUG_SORT          0          // trace sort function
     37#define DEBUG_SORT          1          // trace sort function
    3838#define INTERACTIVE_MODE    0          // activate idbg() during instrumentation
    3939#define CHECK_RESULT        0          // for debug
     
    337337
    338338#if DEBUG_MAIN
    339 printf("\n[sort] main completes barrier init\n");
     339if( USE_DQT_BARRIER ) printf("\n[sort] main completes DQT barrier init\n");
     340else                  printf("\n[sort] main completes simple barrier init\n");
    340341#endif
    341342
Note: See TracChangeset for help on using the changeset viewer.