Changeset 574 for trunk/user


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

Cosmetic.

Location:
trunk/user
Files:
6 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///////////////////////////////////////
  • trunk/user/init/Makefile

    r445 r574  
    1616           -I$(LIBPTHREAD_INCLUDE)  \
    1717           -I$(LIBALMOSMKH_INCLUDE) \
    18            -I$(SHARED_INCLUDE)
     18           -I$(SHARED_INCLUDE)      \
     19           -I$(HAL_INCLUDE)
    1920
    2021compile : dirs build/init.elf
    2122
    2223build/init.elf : $(OBJS) init.ld
    23         $(LD) -o $@ -T init.ld $(OBJS) -L$(LIBC) -L$(LIBPTHREAD) -L$(LIBALMOSMKH) -lc -lpthread -lalmosmkh -lpthread -lc
     24        $(LD) -o $@ -T init.ld $(OBJS) -L$(LIBC) -L$(LIBPTHREAD) -L$(LIBALMOSMKH) \
     25        -lc -lpthread -lalmosmkh -lpthread -lc
    2426        $(DU) -D $@ > $@.txt
    2527
  • trunk/user/init/init.c

    r528 r574  
    1818#include <pthread.h>
    1919#include <almosmkh.h>
     20#include <hal_macros.h>
    2021#include <sys/wait.h>
    2122
    2223#define DEBUG_PROCESS_INIT    0
    2324
    24 // TODO make the cxy computation portable
    25 // and avoid this TSAR specific define [AG]
    26 
    27 #define CXY_FROM_XY( x , y )  ((x<<4) + y)
    28 
    2925// TODO improve the get_config() syscall to return nb_txt_channels
    3026// and avoid the hard_config include [AG]
    3127
    32 //////////
     28// TODO introduce a communication channel between INIT and KSH
     29// to allow KSH to signal INIT the exec completion.
     30
     31////////////////
    3332int main( void )
    3433{
     
    3938    int           status;        // used by the wait syscall
    4039    char          string[64];    // log messages on kernel TXT0
     40
     41#if DEBUG_PROCESS_INIT
     42display_string("[INIT] process enters");
     43#endif
    4144
    4245    // check number of TXT channels
     
    105108    for( x = 0 ; x < x_size ; x++ )
    106109    {
    107         for( y = 0 ; y < y_size - 1 ; y++ )
    108         {
    109             cxy = CXY_FROM_XY( x , y );
     110        cxy = HAL_CXY_FROM_XY( x , y );
     111        display_cluster_processes( cxy );
     112        for( lid = 0 ; lid < ncores ; lid++ )
     113        {
    110114            display_cluster_processes( cxy );
    111             for( lid = 0 ; lid < ncores ; lid++ )
    112             {
    113                 display_sched( cxy , lid );
    114             }
    115115        }
    116116    }
     
    180180            for( y = 0 ; y < y_size ; y++ )
    181181            {
    182                 cxy = CXY_FROM_XY( x , y );
     182                cxy = HAL_CXY_FROM_XY( x , y );
    183183                display_cluster_processes( cxy );
    184184                for( lid = 0 ; lid < ncores ; lid++ )
  • trunk/user/ksh/ksh.c

    r503 r574  
    88// This user KSH process contains two POSIX threads:
    99// - the "main" thread contains the infinite loop implementing
    10 //   the children processes termination monitoring, using the wait syscall.
     10//   the children processes termination monitoring, using the wait() syscall.
    1111// - the "interactive" thread contains the infinite loop implementing the command
    1212//   interpreter attached to the TXT terminal, and handling one KSH command
     
    4949#define LOG_DEPTH      (32)     // max number of registered commands
    5050#define MAX_ARGS           (32)     // max number of arguments in a command
    51 #define FIFO_SIZE      (1024)   // FIFO depth for recursive ls
    52 
    53 #define KSH_DEBUG           0
     51
     52#define MAIN_DEBUG          0
    5453#define CMD_LOAD_DEBUG      0
    5554
     
    821820}  // end parse()
    822821
    823 /////////////////////////
     822///////////////////////////////
    824823static void interactive( void )
    825824{
     
    831830        unsigned int   state;                   // escape sequence state
    832831
    833 /* This can be used to remove interactive mode
    834 
    835 for( i=1 ; 1 ; i += 2)
     832/* This can be used to simplify debug, as it avoids interactive mode
     833
     834for( i=1 ; 1 ; i++ )
    836835{
    837836    if( sem_wait( &semaphore ) )
     
    842841    else
    843842    {
    844         printf("\n[ksh] %d for sort\n", i );
    845     }
    846     strcpy( buf , "load /bin/user/sort.elf" );
    847     parse( buf );
    848 
    849     if( sem_wait( &semaphore ) )
    850     {
    851         printf("\n[ksh error] cannot found semafore\n" );
    852         exit( 1 );
    853     }
    854     else
    855     {
    856         printf("\n[ksh] %d for fft\n", i+1 );
     843        printf("\n[ksh] %d for fft\n", i );
    857844    }
    858845    strcpy( buf , "load /bin/user/fft.elf" );
     
    10471034}  // end interactive()
    10481035
    1049 //////////
     1036////////////////
    10501037int main( void )
    10511038{
     
    10671054    get_core( &cxy , &lid );
    10681055
    1069     // initializes the semaphore used to unblock the interactive thread
     1056#if MAIN_DEBUG
     1057printf("\n[ksh] main started on core[%x,%d]\n", cxy , lid );
     1058#endif
     1059   
     1060    // initializes the semaphore used to synchronize with interactive thread
    10701061    if ( sem_init( &semaphore , 0 , 1 ) )
    10711062    {
     
    10741065    }
    10751066
     1067#if MAIN_DEBUG
     1068printf("\n[ksh] main initialized semaphore\n" );
     1069#endif
     1070   
    10761071    // initialize interactive thread attributes
    10771072    attr.attributes = PT_ATTR_DETACH | PT_ATTR_CLUSTER_DEFINED;
     
    10831078                    &interactive,   // entry function
    10841079                    NULL );
     1080#if MAIN_DEBUG
     1081printf("\n[ksh] main launched interactive thread => wait children termination\n" );
     1082#endif
    10851083   
    10861084    // enter infinite loop monitoring children processes termination
     
    10901088        child_pid = wait( &status );
    10911089
    1092 #if KSH_DEBUG
    1093 if( WIFEXITED  (status) ) printf("\n[KSH] child process %x exited\n" , child_pid );
    1094 if( WIFSIGNALED(status) ) printf("\n[KSH] child process %x killed\n" , child_pid );
    1095 if( WIFSTOPPED (status) ) printf("\n[KSH] child process %x stopped\n", child_pid );
     1090#if MAIN_DEBUG
     1091if( WIFEXITED  (status) ) printf("\n[ksh] child process %x exit\n"  , child_pid );
     1092if( WIFSIGNALED(status) ) printf("\n[ksh] child process %x killed\n" , child_pid );
     1093if( WIFSTOPPED (status) ) printf("\n[ksh] child process %x stopped\n", child_pid );
    10961094#endif
    10971095
  • trunk/user/pgcd/pgcd.c

    r475 r574  
    1212#include <almosmkh.h>
    1313
    14 ///////////
     14/////////////////
    1515void main( void )
    1616{
  • trunk/user/sort/sort.c

    r504 r574  
    204204
    205205
    206 ///////////
     206/////////////////
    207207void main( void )
    208208{
     
    296296
    297297                // set thread attributes for all threads
    298                 attr[thread_uid].attributes = PT_ATTR_CLUSTER_DEFINED | PT_ATTR_CORE_DEFINED;
     298                attr[thread_uid].attributes = PT_ATTR_DETACH          |
     299                                              PT_ATTR_CLUSTER_DEFINED |
     300                                              PT_ATTR_CORE_DEFINED;
    299301                attr[thread_uid].cxy        = HAL_CXY_FROM_XY( x , y );
    300302                attr[thread_uid].lid        = lid;
Note: See TracChangeset for help on using the changeset viewer.