Changeset 638


Ignore:
Timestamp:
Jul 18, 2019, 6:48:08 PM (3 years ago)
Author:
alain
Message:

Fix a bug in the FFT work function (wrong upriv buffer allocation).

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/fs/fatfs.h

    r629 r638  
    171171
    172172/*****************************************************************************************
    173  * This structure defines a FATFS specific context (extension to VFS context).
     173 * This structure defines a FATFS specific context extension to the VFS context.
    174174 * This fatfs context is replicated in all clusters.
    175175 *
  • trunk/kernel/syscalls/shared_include/shared_pthread.h

    r604 r638  
    9898/*******************************************************************************************
    9999 * These typedef and enum define the shared informations related to POSIX barriers.
    100  * The following struct is NOT used in the current implementation or the POSIX barrier
    101  * that is based on a - non scalable - single shared variable.
    102  * It can be used by another implementation, based on a distributed quadtree implemented
    103  * in user space, and relying on a busy waiting policy.
     100 * The following struct is only used in the QDT implementation or the POSIX barrier.
    104101 ******************************************************************************************/
    105102
  • trunk/libs/libalmosmkh/almosmkh.c

    r637 r638  
    3434
    3535#define  DEBUG_REMOTE_MALLOC     0
    36 #define  DEBUG_PTHREAD_PARALLEL  1
     36#define  DEBUG_PTHREAD_PARALLEL  0
    3737 
    3838//////////////////////////////////////////////////////////////////////////////////////
  • trunk/params-hard.mk

    r637 r638  
    22
    33ARCH      = /Users/alain/soc/tsar-trunk-svn-2013/platforms/tsar_generic_iob
    4 X_SIZE    = 2
    5 Y_SIZE    = 2
    6 NB_PROCS  = 2
     4X_SIZE    = 1
     5Y_SIZE    = 1
     6NB_PROCS  = 1
    77NB_TTYS   = 2
    88IOC_TYPE  = IOC_BDV
  • trunk/user/fft/fft.c

    r637 r638  
    9797#define CHECK                   0               
    9898#define DEBUG_MAIN              1               // trace main() function (detailed if odd)
    99 #define DEBUG_WORK              1               // trace work() function (detailed if odd)
     99#define DEBUG_WORK              0               // trace work() function (detailed if odd)
    100100#define DEBUG_FFT1D             0               // trace FFT1D() function (detailed if odd)
    101101#define DEBUG_ROW               0               // trace FFTRow() function (detailed if odd)
     
    548548#endif
    549549
    550     // core 0 allocate memory from the local cluster
     550    // thread on core 0 allocates memory from the local cluster
    551551    // for the distributed data[], trans[], twid[] buffers
    552     // and for the private upriv[] buffer
    553552    if( lid == 0 )
    554553    {
    555         unsigned int data_size  = (N / nclusters) * 2 * sizeof(double);
     554        unsigned int data_size = (N / nclusters) * 2 * sizeof(double);
    556555        unsigned int coefs_size = (rootN - 1) * 2 * sizeof(double); 
    557556
    558         data[cid]   = (double *)malloc( data_size );
    559         trans[cid]  = (double *)malloc( data_size );
    560         twid[cid]   = (double *)malloc( data_size );
    561 
    562         upriv       = (double *)malloc( coefs_size );
    563     }
    564 
    565     // BARRIER
     557        data[cid] = (double *)malloc( data_size );
     558        if( data[cid] == NULL )
     559        {
     560            printf("\n[fft_error] in work : cannot allocate data[%d] buffer\n", cid );
     561            pthread_barrier_wait( parent_barrier );
     562            pthread_exit( NULL );
     563        }
     564       
     565        trans[cid] = (double *)malloc( data_size );
     566        if( trans[cid] == NULL )
     567        {
     568            printf("\n[fft_error] in work : cannot allocate trans[%d] buffer\n", cid );
     569            pthread_barrier_wait( parent_barrier );
     570            pthread_exit( NULL );
     571        }
     572       
     573        twid[cid] = (double *)malloc( data_size );
     574        if( twid[cid] == NULL )
     575        {
     576            printf("\n[fft_error] in work : cannot allocate twid[%d] buffer\n", cid );
     577            pthread_barrier_wait( parent_barrier );
     578            pthread_exit( NULL );
     579        }
     580    }
     581
     582    // BARRIER to wait distributed buffers allocation
    566583    get_cycle( &barrier_start );
    567584    pthread_barrier_wait( &barrier );
     
    570587
    571588#if DEBUG_WORK
    572 printf("\n[fft] %s : thread %d exit first barrier / cycle %d\n",
     589printf("\n[fft] %s : thread %d exit barrier for buffer allocation / cycle %d\n",
    573590__FUNCTION__, tid, (unsigned int)barrier_stop );
    574591#endif
    575592
    576     // all threads initialize data[] local array
     593    // all threads contribute to data[] local array initialisation
    577594    InitD( data , MODE , tid );
    578595
    579     // all threads initialize twid[] local array
     596    // all threads contribute to data[] local array initialisation
    580597    InitT( twid , tid );
    581598   
    582     // all threads initialise private upriv[] array
    583     InitU( upriv );
    584 
    585     // BARRIER
     599    // BARRIER to wait distributed buffers initialisation
    586600    get_cycle( &barrier_start );
    587601    pthread_barrier_wait( &barrier );
     
    590604
    591605#if DEBUG_WORK
    592 printf("\n[fft] %s : thread %d exit second barrier / cycle %d\n",
     606printf("\n[fft] %s : thread %d exit barrier for buffer initialisation / cycle %d\n",
    593607__FUNCTION__, tid, (unsigned int)barrier_stop );
    594608#endif
    595609
    596     // compute first and last rows handled by the thread
     610    // all threads allocate memory from the local cluster
     611    // for the private upriv[] buffer
     612    upriv = (double *)malloc( (rootN - 1) * 2 * sizeof(double) );
     613    if( upriv == NULL )
     614    {
     615        printf("\n[fft_error] in work : cannot allocate trans[%d] buffer\n", cid );
     616        pthread_barrier_wait( parent_barrier );
     617        pthread_exit( NULL );
     618    }
     619
     620    // all threads initialise the private upriv[] array
     621    InitU( upriv );
     622
     623    // all threads compute first and last rows handled by the thread
    597624    MyFirst = rootN * tid / nthreads;
    598625    MyLast  = rootN * (tid + 1) / nthreads;
    599626
    600     // perform forward FFT
     627    // all threads perform forward FFT
    601628    FFT1D( 1 , data , trans , upriv , twid , tid , MyFirst , MyLast );
    602629
     
    808835    unsigned int    base;
    809836    unsigned int    n1;
    810     double  phi;
     837    double          phi;
    811838
    812839    for (q = 0 ; ((unsigned int)(1 << q) < N) ; q++)
  • trunk/user/ksh/ksh.c

    r637 r638  
    12031203
    12041204
    1205 /* 2. second direct command
     1205// 2. second direct command
    12061206if( sem_wait( &semaphore ) )
    12071207{
     
    12161216strcpy( cmd , "load bin/user/fft.elf" );
    12171217execute( cmd );
    1218 */
     1218//
    12191219
    12201220
Note: See TracChangeset for help on using the changeset viewer.