Changeset 574 for trunk/user/fft/fft.c


Ignore:
Timestamp:
Oct 5, 2018, 12:26:30 AM (6 years ago)
Author:
alain
Message:

Cosmetic.

File:
1 edited

Legend:

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

    r503 r574  
    4646//
    4747// Several configuration parameters can be defined below:
    48 //  - VERBOSE : Print out complex data points arrays.
    49 //  - CHECK : Perform both FFT and inverse FFT to check output/input.
    50 //  - DEBUG : Display intermediate results
     48//  - PRINT_ARRAY : Print out complex data points arrays.
     49//  - CHECK       : Perform both FFT and inverse FFT to check output/input.
     50//  - DEBUG_MAIN  : Display intermediate results in main()
     51//  - DEBUG_FFT1D : Display intermediate results in FFT1D()
     52//  - DEBUG_ROW  :
    5153//
    5254// Regarding final instrumentation:
     
    8587
    8688#define DEFAULT_M               6
    87 #define VERBOSE                 0
     89#define MODE                    COSIN
    8890#define CHECK                   0
    89 #define DEBUG_MAIN              1
    90 #define DEBUG_FFT1D             1
    91 #define DEBUG_ONCE              0
    92 #define MODE                    COSIN
     91#define DEBUG_MAIN              0               // trace main() function (detailed if odd)
     92#define DEBUG_FFT1D             0               // trace FFT1D() function (detailed if odd)
     93#define DEBUG_ROW               0               // trace FFTRow() function (detailed if odd)
     94#define PRINT_ARRAY             0
    9395
    9496// macro to swap two variables
     
    178180              unsigned int offset_x );
    179181
    180 void FFT1DOnce( int          direction,
     182void FFTRow( int          direction,
    181183                double     * u,
    182184                double    ** x,
     
    298300    }
    299301
     302printf("\n[FFT] complete remote_malloc\n");
     303
    300304    // arrays initialisation
    301305    InitX( data , MODE );
     
    303307    InitT( twid );
    304308
     309printf("\n[FFT] complete init arrays\n");
     310
    305311#if CHECK
    306312ck1 = CheckSum();
    307313#endif
    308314
    309 #if VERBOSE
     315#if PRINT_ARRAY
    310316printf("\nData values / base = %x\n", &data[0][0] );
    311317PrintArray( data , N );
     
    373379    get_cycle( &start_exec_cycle );
    374380    init_time = (long)(start_exec_cycle - start_init_cycle);
    375     printf("\n[FFT] enter parallel execution / cycle %d\n", (long)start_exec_cycle );
     381    printf("\n[FFT] main enter parallel execution\n");
    376382   
    377383    // main execute itself the slave() function
     
    391397                {
    392398#if DEBUG_MAIN
    393 printf("\n[FFT] before join for thread %x\n", trdid[tid] );
    394 #endif
    395 
     399printf("\n[FFT] main join thread %x\n", trdid[tid] );
     400#endif
    396401                    if( pthread_join( trdid[tid] , NULL ) )
    397402                    {
     
    400405                    }
    401406
    402 #if DEBUG_MAIN
    403 printf("\n[FFT] after join for thread %x\n", trdid[tid] );
    404 #endif
    405407                }
    406408            }
     
    412414    printf("\n[FFT] complete parallel execution / cycle %d\n", (long)end_exec_cycle );
    413415
    414 #if VERBOSE
     416#if PRINT_ARRAY
    415417printf("\nData values after FFT:\n");
    416418PrintArray( data , N );
     
    525527
    526528#if CHECK
    527 
    528529get_cycle( &barrier_start );
    529530pthread_barrier_wait( &barrier );
     
    533534
    534535FFT1D( -1 , data , trans , upriv , twid , MyNum , MyFirst , MyLast );
    535 
    536536#endif
    537537
     
    541541
    542542    // exit if MyNum != 0
    543     if( MyNum ) exit( 0 );
     543    if( MyNum ) pthread_exit( 0 );
    544544
    545545}  // end slave()
     
    753753// 3) it transpose (rootN/nthreads) columns from tmp to x.
    754754// 4) it make (rootN/nthreads) FFT on the x rows.
    755 // It calls the FFT1DOnce() 2*(rootN/nthreads) times to perform the in place FFT
     755// It calls the FFTRow() 2*(rootN/nthreads) times to perform the in place FFT
    756756// on the rootN points contained in a row.
    757757////////////////////////////////////////////////////////////////////////////////////////
     
    769769    unsigned long long barrier_stop;
    770770
     771#if DEBUG_FFT1D
     772printf("\n[FFT] %s : thread %x enter / first %d / last %d\n",
     773__FUNCTION__, MyNum, MyFirst, MyLast );
     774#endif
     775
    771776    // transpose (rootN/nthreads) rows from x to tmp
    772777    Transpose( x , tmp , MyFirst , MyLast );
    773778
    774 #if DEBUG_FFT1D
    775 printf("\n[FFT] %s : thread %x after first transpose\n", __FUNCTION__, MyNum);
    776 if( VERBOSE ) PrintArray( tmp , N );
     779#if( DEBUG_FFT1D & 1 )
     780unsigned long long cycle;
     781get_cycle( &cycle );
     782printf("\n[FFT] %s : thread %x after first transpose / cycle %d\n",
     783__FUNCTION__, MyNum, (unsigned int)cycle );
     784if( PRINT_ARRAY ) PrintArray( tmp , N );
    777785#endif
    778786
     
    781789    pthread_barrier_wait( &barrier );
    782790    get_cycle( &barrier_stop );
    783 
    784791    sync_time[MyNum] = (long)(barrier_stop - barrier_start);
     792
     793#if( DEBUG_FFT1D & 1 )
     794get_cycle( &cycle );
     795printf("\n[FFT] %s : thread %x exit barrier after first transpose / cycle %d\n",
     796__FUNCTION__, MyNum, (unsigned int)cycle );
     797#endif
    785798
    786799    // do FFTs on rows of tmp (i.e. columns of x) and apply twiddle factor
    787800    for (j = MyFirst; j < MyLast; j++)
    788801    {
    789 printf("@@@  before FFT1Once / j = %d\n", j );
    790         FFT1DOnce( direction , upriv , tmp , j * rootN );
    791 printf("@@@  after  FFT1Once / j = %d\n", j );
     802        FFTRow( direction , upriv , tmp , j * rootN );
     803
    792804        TwiddleOneCol( direction , j , twid , tmp , j * rootN );
    793 printf("@@@  after  Twiddle  / j = %d\n", j );
    794805    } 
    795806
    796 #if DEBUG_FFT1D
     807#if( DEBUG_FFT1D & 1 )
    797808printf("\n[FFT] %s : thread %x after first twiddle\n", __FUNCTION__, MyNum);
    798 if( VERBOSE ) PrintArray( tmp , N );
     809if( PRINT_ARRAY ) PrintArray( tmp , N );
    799810#endif
    800811
     
    804815    get_cycle( &barrier_stop );
    805816
     817#if( DEBUG_FFT1D & 1 )
     818printf("\n[FFT] %s : thread %x exit barrier after first twiddle\n", __FUNCTION__, MyNum);
     819#endif
     820
    806821    sync_time[MyNum] += (long)(barrier_stop - barrier_start);
    807822
     
    809824    Transpose( tmp , x , MyFirst , MyLast );
    810825
    811 #if DEBUG_FFT1D
     826#if( DEBUG_FFT1D & 1 )
    812827printf("\n[FFT] %s : thread %x after second transpose\n", __FUNCTION__, MyNum);
    813 if( VERBOSE ) PrintArray( x , N );
     828if( PRINT_ARRAY ) PrintArray( x , N );
    814829#endif
    815830
     
    819834    get_cycle( &barrier_stop );
    820835
     836#if( DEBUG_FFT1D & 1 )
     837printf("\n[FFT] %s : thread %x exit barrier after second transpose\n", __FUNCTION__, MyNum);
     838#endif
     839
    821840    sync_time[MyNum] += (long)(barrier_stop - barrier_start);
    822841
     
    824843    for (j = MyFirst; j < MyLast; j++)
    825844    {
    826         FFT1DOnce( direction , upriv , x , j * rootN );
     845        FFTRow( direction , upriv , x , j * rootN );
    827846        if (direction == -1) Scale( x , j * rootN );
    828847    }
    829848
    830 #if DEBUG_FFT1D
     849#if( DEBUG_FFT1D & 1 )
    831850printf("\n[FFT] %s : thread %x after FFT on rows\n", __FUNCTION__, MyNum);
    832 if( VERBOSE ) PrintArray( x , N );
     851if( PRINT_ARRAY ) PrintArray( x , N );
    833852#endif
    834853
     
    838857    get_cycle( &barrier_stop );
    839858
     859#if( DEBUG_FFT1D & 1 )
     860printf("\n[FFT] %s : thread %x exit barrier after FFT on rows\n", __FUNCTION__, MyNum);
     861#endif
    840862    sync_time[MyNum] += (long)(barrier_stop - barrier_start);
    841863
     
    843865    Transpose( x , tmp , MyFirst , MyLast );
    844866
    845 #if DEBUG_FFT1D
     867#if( DEBUG_FFT1D & 1 )
    846868printf("\n[FFT] %s : thread %x after third transpose\n", __FUNCTION__, MyNum);
    847 if( VERBOSE ) PrintArray( x , N );
     869if( PRINT_ARRAY ) PrintArray( x , N );
    848870#endif
    849871
     
    853875    get_cycle( &barrier_stop );
    854876
     877#if( DEBUG_FFT1D & 1 )
     878printf("\n[FFT] %s : thread %x exit barrier after third transpose\n", __FUNCTION__, MyNum);
     879#endif
     880
     881    sync_time[MyNum] += (long)(barrier_stop - barrier_start);
    855882    sync_time[MyNum] += (long)(barrier_stop - barrier_start);
    856883
     
    859886
    860887#if DEBUG_FFT1D
    861 printf("\n[FFT] %s : thread %x after final copy\n", __FUNCTION__, MyNum);
    862 if( VERBOSE ) PrintArray( x , N );
     888printf("\n[FFT] %s : thread %x completed\n", __FUNCTION__, MyNum);
     889if( PRINT_ARRAY ) PrintArray( x , N );
    863890#endif
    864891
     
    10171044// (i.e. rootN points) of the x[nclusters][points_per_cluster] array.
    10181045/////////////////////////////////////////////////////////////////////////////
    1019 void FFT1DOnce( int            direction,  // 1 direct / -1 inverse
     1046void FFTRow( int            direction,  // 1 direct / -1 inverse
    10201047                double       * u,          // private coefs array
    10211048                double      ** x,          // array of pointers on distributed buffers
     
    10491076    unsigned int     c_offset_2;    // offset for second butterfly input
    10501077
    1051 #if DEBUG_ONCE
     1078#if DEBUG_ROW
    10521079unsigned int p;
    1053 printf("\n@@@ FFT ROW data in / %d points / offset = %d\n",
    1054                 rootN , offset_x );
     1080printf("\n[FFT] ROW data in / %d points / offset = %d\n", rootN , offset_x );
     1081
    10551082for ( p = 0 ; p < rootN ; p++ )
    10561083{
     
    10661093    Reverse( x , offset_x ); 
    10671094
    1068 #if DEBUG_ONCE
    1069 printf("\n@@@ FFT ROW data after reverse\n");
     1095#if DEBUG_ROW
     1096printf("\n[FFT] ROW data after reverse / %d points / offset = %d\n", rootN , offset_x );
     1097
    10701098for ( p = 0 ; p < rootN ; p++ )
    10711099{
     
    10901118            offset_x2  = offset_x + (k * L + Lstar);    // index second point
    10911119
    1092 #if DEBUG_ONCE
    1093 printf("\n ### q = %d / k = %d / x1 = %d / x2 = %d\n",
    1094                  q , k , offset_x1 , offset_x2 );
     1120#if (DEBUG_ROW & 1)
     1121printf("\n ### q = %d / k = %d / x1 = %d / x2 = %d\n", q , k , offset_x1 , offset_x2 );
    10951122#endif
    10961123            // makes all in-place butterfly(s) for subset
     
    11131140                d2_c        = x[c_id_2][2*c_offset_2+1];
    11141141
    1115 #if DEBUG_ONCE
     1142#if (DEBUG_ROW & 1)
    11161143printf("\n ### d1_in = (%f , %f) / d2_in = (%f , %f) / coef = (%f , %f)\n",
    11171144                d1_r , d1_c , d2_r , d2_c , omega_r , omega_c);
     
    11291156                x[c_id_2][2*c_offset_2+1] = d1_c - tau_c;
    11301157
    1131 #if DEBUG_ONCE
     1158#if (DEBUG_ROW & 1)
    11321159printf("\n ### d1_out = (%f , %f) / d2_out = (%f , %f)\n",
    11331160                d1_r + tau_r , d1_c + tau_c , d2_r - tau_r , d2_c - tau_c );
     
    11371164    }
    11381165
    1139 #if DEBUG_ONCE
    1140 printf("\n@@@ FFT ROW data out\n");
     1166#if DEBUG_ROW
     1167printf("\n[FFT] ROW data out / %d points / offset = %d\n", rootN , offset_x );
    11411168for ( p = 0 ; p < rootN ; p++ )
    11421169{
     
    11491176#endif
    11501177
    1151 }  // end FFT1DOnce()
     1178}  // end FFTRow()
    11521179
    11531180///////////////////////////////////////
Note: See TracChangeset for help on using the changeset viewer.