Changeset 393 for soft/giet_vm


Ignore:
Timestamp:
Aug 11, 2014, 9:29:28 PM (10 years ago)
Author:
alain
Message:

Cosmetic

File:
1 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/transpose/main.c

    r383 r393  
    1414//
    1515// For each image the application makes a self test (checksum for each line).
    16 // The actual display on the frame buffer is optional (controled by DISPLAY_OK define)
     16// The actual display on the frame buffer depends on frame buffer availability.
    1717///////////////////////////////////////////////////////////////////////////////////////////////
    1818
     
    2626#define FILE_PATHNAME       "misc/images.raw"   // file pathname on disk
    2727#define NB_CLUSTERS         (X_SIZE * Y_SIZE)   // number of clusters
    28 #define INSTRUMENTATION_OK  1                   // display statistics on TTY when non zero
     28#define INSTRUMENTATION_OK  0                   // display statistics on TTY when non zero
    2929
    3030///////////////////////////////////////////////////////
     
    6464    unsigned int l;                                                // line index for loops
    6565    unsigned int p;                                                // pixel index for loops
     66    unsigned int c;                                                // cluster index for loops
    6667
    6768    unsigned int proc_id    = giet_procid();                       // global processor id
    6869    unsigned int lpid       = proc_id % NB_PROCS_MAX;              // local processor id
    69     unsigned int cluster_xy = proc_id / NB_PROCS_MAX;              // cluster index (8 bits format)
     70    unsigned int cluster_xy = proc_id / NB_PROCS_MAX;              // 8 bits format
    7071    unsigned int x          = cluster_xy >> Y_WIDTH;               // x coordinate
    7172    unsigned int y          = cluster_xy & ((1<<Y_WIDTH)-1);       // y coordinate
     
    7576    unsigned int image      = 0;                                   // image counter
    7677
    77     unsigned int nclusters  = X_SIZE * Y_SIZE;                     // clusters with procs
    78     unsigned int cluster_id = (x * Y_SIZE) + y;                    // "continuous" cluster index   
    79     unsigned int ntasks     = nclusters * NB_PROCS_MAX;            // number of tasks
     78    unsigned int cluster_id = (x * Y_SIZE) + y;                    // "continuous" index   
     79    unsigned int ntasks     = NB_CLUSTERS * NB_PROCS_MAX;          // number of tasks
    8080    unsigned int task_id    = (cluster_id * NB_PROCS_MAX) + lpid;  // "continuous" task index
    8181
    82     // processor [0,0,0] makes parameters checking and barriers initialization
     82    // processor [0,0,0] makes nitialisation
     83    // It includes parameters checking, barriers initialization,
     84    // distributed buffers allocation, and file open
    8385    if ( proc_id == 0 )
    8486    {
     87        // Parameters checking
    8588        if ((NB_PROCS_MAX != 1) && (NB_PROCS_MAX != 2) && (NB_PROCS_MAX != 4))
    8689        {
    8790            giet_exit("[TRANSPOSE ERROR] NB_PROCS_MAX must be 1, 2 or 4");
    8891        }
    89         if ((nclusters != 1) && (nclusters != 2) && (nclusters != 4) && (nclusters != 8) &&
    90             (nclusters != 16) && (nclusters != 32) )
    91         {
    92             giet_exit("[TRANSPOSE ERROR] number of clusters must be 2,4,8,16,32");
     92        if ((NB_CLUSTERS != 1) && (NB_CLUSTERS != 2) && (NB_CLUSTERS != 4) &&
     93            (NB_CLUSTERS != 8) && (NB_CLUSTERS != 16) && (NB_CLUSTERS != 32) )
     94        {
     95            giet_exit("[TRANSPOSE ERROR] number of clusters must be 1,2,4,8,16,32");
    9396        }
    9497        if ( ntasks > NN )
     
    97100        }
    98101
     102        giet_shr_printf("\n[TRANSPOSE] Processor[0,0,0] starts at cycle %d\n"
     103                        " - x_size    = %d\n"
     104                        " - y_size    = %d\n"
     105                        " - nprocs    = %d\n"
     106                        " - nclusters = %d\n"
     107                        " - ntasks    = %d\n",
     108                        giet_proctime(), X_SIZE, Y_SIZE, NB_PROCS_MAX, NB_CLUSTERS, ntasks );
     109
     110        // Barrier initialisation
    99111        barrier_init( &barrier, ntasks );
    100112
    101         giet_shr_printf("\n[TRANSPOSE] Proc [%d,%d,%d] completes barrier init at cycle %d\n",
    102                         x, y, lpid, giet_proctime() );
    103 
    104         giet_shr_printf(" - x_size    = %d\n", X_SIZE );
    105         giet_shr_printf(" - y_size    = %d\n", Y_SIZE );
    106         giet_shr_printf(" - y_size    = %d\n", Y_SIZE );
    107         giet_shr_printf(" - nprocs    = %d\n", NB_PROCS_MAX );
    108         giet_shr_printf(" - nclusters = %d\n", nclusters );
    109         giet_shr_printf(" - ntasks    = %d\n", ntasks );
    110 
     113        giet_shr_printf("\n[TRANSPOSE] Proc [0,0,0] completes barrier init at cycle %d\n",
     114                        giet_proctime() );
     115
     116        // Distributed buffers allocation
     117        // The buffers containing one image are distributed in clusters
     118        // (one buf_in and one buf_out per cluster).
     119        // Each buffer contains (NN*NN / NB_CLUSTERS) bytes.
     120        for ( c = 0 ; c < NB_CLUSTERS ; c++ )
     121        {
     122            unsigned int rx = c / Y_SIZE;
     123            unsigned int ry = c % Y_SIZE;
     124
     125            buf_in[c]  = remote_malloc( npixels/NB_CLUSTERS, rx, ry );
     126            buf_out[c] = remote_malloc( npixels/NB_CLUSTERS, rx, ry );
     127
     128            giet_shr_printf("\n[TRANSPOSE] Proc [0,0,0] completes buffer allocation"
     129                            " for cluster[%d,%d] at cycle %d\n"
     130                            " - buf_in  = %x\n"
     131                            " - buf_out = %x\n",
     132                            rx, ry, giet_proctime(),
     133                            (unsigned int)buf_in[c],
     134                            (unsigned int)buf_out[c] );
     135        }
     136
     137        // open file containing images
     138        file = giet_fat_open( "misc/images.raw", 0);
     139
     140        if (file < 0)
     141        {
     142            giet_shr_printf("\n[TRANSPOSE ERROR] Processor[%d,%d,%d]"
     143                            " cannot open file misc/images.raw",
     144                            x, y, lpid );
     145            giet_exit(" open() failure");
     146        }
     147        else
     148        {
     149            giet_shr_printf("\n[TRANSPOSE] Processor[0,0,0] open file misc/images.raw\n");
     150        }
    111151        init_ok = 0;
    112152    }
     
    116156    }
    117157   
    118     // The buffers containing the images are distributed in clusters
    119     // (one buf_in and one buf_out per cluster).
    120     // Each buffer contains (NN*NN / nclusters) bytes.
    121     // They are allocated in the cluster[x,y] heap by processor[x,y,0]
    122     if ( lpid == 0 )
    123     {
    124         // get heap vaddr in cluster[0,0]
    125         unsigned int heap_base;         
    126         giet_vobj_get_vbase( "transpose", "trsp_heap_0_0", &heap_base );
    127  
    128         // allocate buffers in cluster[x,y]
    129         buf_in[cluster_id]  = remote_malloc( npixels/NB_CLUSTERS, x, y);
    130         buf_out[cluster_id] = remote_malloc( npixels/NB_CLUSTERS, x, y);
    131 
    132         giet_shr_printf("\n[TRANSPOSE] Proc [%d,%d,%d] completes buffer allocation at cycle %d\n"
    133                         " - buf_in  = %x\n"
    134                         " - buf_out = %x\n",
    135                         x, y, 0, giet_proctime(),
    136                         (unsigned int)buf_in[cluster_id],
    137                         (unsigned int)buf_out[cluster_id] );
    138 
    139         // open file containing images
    140         file = giet_fat_open( "misc/images.raw", 0);
    141 
    142         if (file < 0)
    143         {
    144             giet_shr_printf("[TRANSPOSE ERROR] Processor[%d,%d,%d]"
    145                             " cannot open file misc/images.raw",
    146                             x, y, lpid );
    147             giet_exit(" open() failure");
    148         }
    149         else
    150         {
    151             giet_shr_printf("\n[TRANSPOSE] Processor[%d,%d,%d]"
    152                             " open file misc/images.raw\n",
    153                             x, y, lpid );
    154         }
    155     }
    156158
    157159    /////////////////////////
    158     barrier_wait( &barrier );
    159 
    160160    // Main loop (on images)
    161161    while (image < NB_IMAGES)
    162162    {
    163         // pseudo parallel load from disk to buf_in buffer : nblocks/nclusters blocks
     163        // pseudo parallel load from disk to buf_in buffer : nblocks/NB_CLUSTERS blocks
    164164        // only task running on processor with (lpid == 0) does it
    165165
     
    170170            giet_fat_read( file,
    171171                           buf_in[cluster_id],
    172                            (nblocks / nclusters),
    173                            ((image*nblocks) + ((nblocks*cluster_id)/nclusters)) );
     172                           (nblocks / NB_CLUSTERS),
     173                           ((image*nblocks) + ((nblocks*cluster_id)/NB_CLUSTERS)) );
    174174
    175175            giet_shr_printf("\n[TRANSPOSE] Proc [%d,%d,0] completes load"
     
    192192
    193193        unsigned int nlt   = NN / ntasks;      // number of lines per task
    194         unsigned int nlc   = NN / nclusters;   // number of lines per cluster
     194        unsigned int nlc   = NN / NB_CLUSTERS;   // number of lines per cluster
    195195
    196196        unsigned int src_cluster;
     
    325325            unsigned int max_disp_ended = 0;
    326326
    327             for (cc = 0; cc < nclusters; cc++)
     327            for (cc = 0; cc < NB_CLUSTERS; cc++)
    328328            {
    329329                for (pp = 0; pp < NB_PROCS_MAX; pp++)
     
    371371        image++;
    372372
    373         //////////////////////////////////////////////////
    374         // all tasks must wait instrumentation completion
    375         //////////////////////////////////////////////////
     373        /////////////////////////
    376374        barrier_wait( &barrier );
    377375
Note: See TracChangeset for help on using the changeset viewer.