Ignore:
Timestamp:
Jun 29, 2014, 1:23:18 PM (10 years ago)
Author:
alain
Message:

Introduce distribution of page tables, kernel code, and user code
in the convol application.

File:
1 edited

Legend:

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

    r345 r353  
    99#include "hard_config.h"
    1010#include "stdio.h"
     11#include "stdlib.h"
    1112#include "barrier.h"
    1213
    13 #define VERBOSE                    1
    14 
    15 #define INITIAL_DISPLAY_ENABLE     1
     14#define VERBOSE                    0
     15#define SUPER_VERBOSE              0
     16
     17#define INITIAL_DISPLAY_ENABLE     0
    1618#define FINAL_DISPLAY_ENABLE       1
    1719
    18 #define NB_CLUSTERS_MAX            (X_SIZE * Y_SIZE)
     20#define NB_CLUSTERS                (X_SIZE * Y_SIZE)
    1921#define PIXEL_SIZE                 2
    2022#define NL                         1024
     
    3335
    3436// instrumentation counters indexed by (cluster_id, lpid]
    35 unsigned int START[NB_CLUSTERS_MAX][NB_PROCS_MAX];
    36 unsigned int H_BEG[NB_CLUSTERS_MAX][NB_PROCS_MAX];
    37 unsigned int H_END[NB_CLUSTERS_MAX][NB_PROCS_MAX];
    38 unsigned int V_BEG[NB_CLUSTERS_MAX][NB_PROCS_MAX];
    39 unsigned int V_END[NB_CLUSTERS_MAX][NB_PROCS_MAX];
    40 unsigned int D_BEG[NB_CLUSTERS_MAX][NB_PROCS_MAX];
    41 unsigned int D_END[NB_CLUSTERS_MAX][NB_PROCS_MAX];
     37unsigned int START[NB_CLUSTERS][NB_PROCS_MAX];
     38unsigned int H_BEG[NB_CLUSTERS][NB_PROCS_MAX];
     39unsigned int H_END[NB_CLUSTERS][NB_PROCS_MAX];
     40unsigned int V_BEG[NB_CLUSTERS][NB_PROCS_MAX];
     41unsigned int V_END[NB_CLUSTERS][NB_PROCS_MAX];
     42unsigned int D_BEG[NB_CLUSTERS][NB_PROCS_MAX];
     43unsigned int D_END[NB_CLUSTERS][NB_PROCS_MAX];
    4244
    4345// synchronization barriers
     
    5052volatile unsigned int exit_ok = 0;
    5153
    52 //////////////////////////////////////////////////////
    53 // Required by GCC when initializing an array
    54 //////////////////////////////////////////////////////
    55 static void *memcpy( void *        _dst,
    56                      const void *  _src,
    57                      unsigned int  size )
    58 {
    59     unsigned int         *dst = _dst;
    60     const unsigned int   *src = _src;
    61 
    62     if (! ((unsigned int)dst & 3) && ! ((unsigned int)src & 3))
    63     {
    64         while (size > 3)
    65         {
    66             *dst++ = *src++;
    67             size -= 4;
    68         }
    69     }
    70 
    71     unsigned char *cdst = (unsigned char*)dst;
    72     unsigned char *csrc = (unsigned char*)src;
    73 
    74     while ( size-- )
    75     {
    76         *cdst++ = *csrc++;
    77     }
    78     return _dst;
    79 }
    8054
    8155///////////////////////////////////////////
     
    10882    int z; // vertical filter index for loops
    10983
    110     int          file;                                        // file descriptor
     84    int          file        = 0;                             // file descriptor
    11185    unsigned int pid         = giet_procid();                 // processor id
    11286    unsigned int nprocs      = NB_PROCS_MAX;                  // procs per cluster
    113     unsigned int nclusters   = NB_CLUSTERS_MAX;               // number of clusters
     87    unsigned int nclusters   = NB_CLUSTERS;               // number of clusters
    11488    unsigned int lpid        = pid % nprocs;                  // local task id
    11589    unsigned int cluster_xy  = pid / nprocs;                  // cluster index
     
    131105
    132106    date = giet_proctime();
    133     giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] starts at cycle %d\n",
    134                      x,y,lpid, date );
    135107    START[cluster_id][lpid] = date;
     108
     109#if VERBOSE
     110giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] starts at cycle %d\n", x,y,lpid, date );
     111#endif
    136112
    137113     // parameters checking
     
    159135    ///////////////////////////////////////////////////////////////////
    160136
    161     unsigned short * A[NB_CLUSTERS_MAX];
    162     int *            B[NB_CLUSTERS_MAX];
    163     int *            C[NB_CLUSTERS_MAX];
    164     int *            D[NB_CLUSTERS_MAX];
    165     unsigned char *  Z[NB_CLUSTERS_MAX];
     137    unsigned short * A[NB_CLUSTERS];
     138    int *            B[NB_CLUSTERS];
     139    int *            C[NB_CLUSTERS];
     140    int *            D[NB_CLUSTERS];
     141    unsigned char *  Z[NB_CLUSTERS];
    166142
    167143    // get heap vaddr in cluster[0,0]
     
    182158        Z[c] = (unsigned char *)  (cluster_offset + (frame_size * 7 / nclusters));
    183159
    184         if ( pid == 0  && VERBOSE )
    185         {
    186             giet_shr_printf( "\n########################################\n"
    187                              "### A[%d] = %x\n"
    188                              "### B[%d] = %x\n"               
    189                              "### C[%d] = %x\n"               
    190                              "### D[%d] = %x\n"               
    191                              "### Z[%d] = %x\n"               
    192                              "########################################\n",
    193                              c,A[c],c,B[c],c,C[c],c,D[c],c,Z[c] );
    194         }
     160#if VERBOSE
     161if ( pid == 0 ) giet_shr_printf( "\n########################################\n"
     162                                 "### A[%d] = %x\n"
     163                                 "### B[%d] = %x\n"               
     164                                 "### C[%d] = %x\n"               
     165                                 "### D[%d] = %x\n"               
     166                                 "### Z[%d] = %x\n"               
     167                                 "########################################\n",
     168                                 c,A[c],c,B[c],c,C[c],c,D[c],c,Z[c] );
     169#endif
    195170    }
    196171
     
    230205                         " at cycle %d\n", giet_proctime() );
    231206
    232         for ( c = 0 ; c < nclusters ; c++ )
    233         {
    234             giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] starts load"
    235                              " for cluster %d at cycle %d\n",
    236                              x, y, lpid, c, giet_proctime() );
    237        
     207        for ( c = 0 ; c < NB_CLUSTERS ; c++ )
     208        {
     209            giet_shr_printf( "\n[CONVOL] task[0,0,0] starts load "
     210                             "for cluster %d at cycle %d\n", c, giet_proctime() );
     211
    238212            giet_fat_read( file,
    239213                           A[c],
     
    241215                           (nblocks/nclusters)*c );
    242216
    243             giet_shr_printf( "[CONVOL] task[%d,%d,%d] completes load"
    244                              " for cluster %d at cycle %d\n",
    245                              x, y, lpid, c, giet_proctime() );
     217            giet_shr_printf( "\n[CONVOL] task[0,0,0] completes load "
     218                             "for cluster %d at cycle %d\n", c, giet_proctime() );
    246219        }
    247220        init_ok = 1;
     
    259232    if ( INITIAL_DISPLAY_ENABLE )
    260233    {
    261         date = giet_proctime();
    262         giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] starts initial display at cycle %d\n",
    263                          x, y, lpid, date);
     234
     235#if VERBOSE
     236giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] starts initial display"
     237                 " at cycle %d\n",
     238                 x, y, lpid, giet_proctime() );
     239#endif
    264240
    265241        unsigned int line;
     
    280256        }
    281257
    282         date = giet_proctime();
    283         giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] completes initial display at cycle %d\n",
    284                          x, y, lpid, date);
     258#if VERBOSE
     259giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] completes initial display"
     260                 " at cycle %d\n",
     261                 x, y, lpid, giet_proctime() );
     262#endif
    285263
    286264        ///////////////////////////
     
    300278
    301279    date  = giet_proctime();
    302     giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] starts horizontal filter at cycle %d\n",
    303             x, y, lpid, date );
    304280    H_BEG[cluster_id][lpid] = date;
     281
     282#if VERBOSE
     283giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] starts horizontal filter"
     284                 " at cycle %d\n",
     285                 x, y, lpid, date );
     286#else
     287if ( pid == 0 ) giet_shr_printf( "\n[CONVOL] task[0,0,0] starts horizontal filter"
     288                                 " at cycle %d\n", date );
     289#endif
    305290
    306291    // l = absolute line index / p = absolute pixel index 
     
    359344        }
    360345
    361         if ( VERBOSE )
    362         {
    363             giet_shr_printf(" - line %d computed at cycle %d\n", l, giet_proctime() );
    364         }
     346#if SUPER_VERBOSE
     347giet_shr_printf(" - line %d computed at cycle %d\n", l, giet_proctime() );
     348#endif   
     349
    365350    }
    366351
    367352    date  = giet_proctime();
    368     giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] completes horizontal filter at cycle %d\n",
    369             x, y, lpid, date );
    370353    H_END[cluster_id][lpid] = date;
     354
     355#if VERBOSE
     356giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] completes horizontal filter"
     357                 " at cycle %d\n",
     358                 x, y, lpid, date );
     359#else
     360if ( pid == 0 ) giet_shr_printf( "\n[CONVOL] task[0,0,0] completes horizontal filter"
     361                                 " at cycle %d\n", date );
     362#endif
    371363
    372364    ///////////////////////////
    373365    barrier_wait( &barrier_2 );
    374366
    375     //////////////////////////////////////////////////////////
     367    ///////////////////////////////////////////////////////////////
    376368    // parallel vertical filter :
    377369    // C <= transpose(FV(B))
     
    380372    // if (l<0)    TB(cluster_id,p,l) == TB(cluster_id,p,0)
    381373    // if (l>NL-1)   TB(cluster_id,p,l) == TB(cluster_id,p,NL-1)
    382     //////////////////////////////////////////////////////////
     374    ///////////////////////////////////////////////////////////////
    383375
    384376    date  = giet_proctime();
    385     giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] starts vertical filter at cycle %d\n",
    386             x, y, lpid, date );
    387377    V_BEG[cluster_id][lpid] = date;
     378
     379#if VERBOSE
     380giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] starts vertical filter"
     381                 " at cycle %d\n",
     382                 x, y, lpid, date );
     383#else
     384if ( pid == 0 ) giet_shr_printf( "\n[CONVOL] task[0,0,0] starts vertical filter"
     385                                 " at cycle %d\n", date );
     386#endif
    388387
    389388    // l = absolute line index / p = absolute pixel index
     
    458457        }
    459458
    460         if ( VERBOSE )
    461         {
    462             giet_shr_printf(" - column %d computed at cycle %d\n", p, giet_proctime());
    463         }
     459#if SUPER_VERBOSE
     460giet_shr_printf(" - column %d computed at cycle %d\n", p, giet_proctime());
     461#endif
     462
    464463    }
    465464
    466465    date  = giet_proctime();
    467     giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] completes vertical filter at cycle %d\n",
    468             x, y, lpid, date );
    469466    V_END[cluster_id][lpid] = date;
     467
     468#if VERBOSE
     469giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] completes vertical filter"
     470                 " at cycle %d\n",
     471                 x, y, lpid, date );
     472#else
     473if ( pid == 0 ) giet_shr_printf( "\n[CONVOL] task[0,0,0] completes vertical filter"
     474                                 " at cycle %d\n", date );
     475#endif
    470476
    471477    ///////////////////////////
     
    480486    {
    481487        date  = giet_proctime();
    482         giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] starts final display at cycle %d\n",
    483                          x, y, lpid, date);
    484488        D_BEG[cluster_id][lpid] = date;
     489
     490#if VERBOSE
     491giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] starts final display"
     492                 " at cycle %d\n",
     493                 x, y, lpid, date);
     494#else
     495if ( pid == 0 ) giet_shr_printf( "\n[CONVOL] task[0,0,0] starts final display"
     496                                 " at cycle %d\n", date );
     497#endif
    485498
    486499        unsigned int line;
     
    504517
    505518        date  = giet_proctime();
    506         giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] completes final display at cycle %d\n",
    507             x, y, lpid, date);
    508519        D_END[cluster_id][lpid] = date;
     520
     521#if VERBOSE
     522giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] completes final display"
     523                 " at cycle %d\n",
     524                 x, y, lpid, date);
     525#else
     526if ( pid == 0 ) giet_shr_printf( "\n[CONVOL] task[0,0,0] completes final display"
     527                                 " at cycle %d\n", date );
     528#endif
    509529     
    510530        ///////////////////////////
     
    519539    {
    520540        date  = giet_proctime();
    521         giet_shr_printf("\n*** Starting Instrumentation at cycle %d\n\n", date);
     541        giet_shr_printf("\n[CONVOL] task[0,0,0] starts instrumentation"
     542                        " at cycle %d\n\n", date );
    522543
    523544        int cc, pp;
     
    577598               min_h_beg, max_h_beg, (min_h_beg+max_h_beg)/2, max_h_beg-min_h_beg);
    578599
    579         giet_shr_printf(" - H_END   : min = %d / max = %d / med = %d / delta = %d\n",
     600        giet_shr_printf(" - H_END : min = %d / max = %d / med = %d / delta = %d\n",
    580601               min_h_end, max_h_end, (min_h_end+max_h_end)/2, max_h_end-min_h_end);
    581602
     
    583604               min_v_beg, max_v_beg, (min_v_beg+max_v_beg)/2, max_v_beg-min_v_beg);
    584605
    585         giet_shr_printf(" - V_END   : min = %d / max = %d / med = %d / delta = %d\n",
     606        giet_shr_printf(" - V_END : min = %d / max = %d / med = %d / delta = %d\n",
    586607               min_v_end, max_v_end, (min_v_end+max_v_end)/2, max_v_end-min_v_end);
    587608
     
    589610               min_d_beg, max_d_beg, (min_d_beg+max_d_beg)/2, max_d_beg-min_d_beg);
    590611
    591         giet_shr_printf(" - D_END   : min = %d / max = %d / med = %d / delta = %d\n",
     612        giet_shr_printf(" - D_END : min = %d / max = %d / med = %d / delta = %d\n",
    592613               min_d_end, max_d_end, (min_d_end+max_d_end)/2, max_d_end-min_d_end);
    593614
    594615        giet_shr_printf( "\n General Scenario (Kcycles for each step)\n" );
    595         giet_shr_printf( " - BOOT OS           = %d\n", min_start );
    596         giet_shr_printf( " - LOAD IMAGE        = %d\n", min_h_beg - min_start);
    597         giet_shr_printf( " - H_FILTER          = %d\n", max_h_end - min_h_beg );
    598         giet_shr_printf( " - BARRIER HORI/VERT = %d\n", min_v_beg - max_h_end);
    599         giet_shr_printf( " - V_FILTER          = %d\n", max_v_end - min_v_beg );
    600         giet_shr_printf( " - BARRIER VERT/DISP = %d\n", min_d_beg - max_v_end);
    601         giet_shr_printf( " - DISPLAY           = %d\n", max_d_end - min_d_beg );
     616        giet_shr_printf( " - BOOT OS           = %d\n", (min_start            )/1000 );
     617        giet_shr_printf( " - LOAD IMAGE        = %d\n", (min_h_beg - min_start)/1000 );
     618        giet_shr_printf( " - H_FILTER          = %d\n", (max_h_end - min_h_beg)/1000 );
     619        giet_shr_printf( " - BARRIER HORI/VERT = %d\n", (min_v_beg - max_h_end)/1000 );
     620        giet_shr_printf( " - V_FILTER          = %d\n", (max_v_end - min_v_beg)/1000 );
     621        giet_shr_printf( " - BARRIER VERT/DISP = %d\n", (min_d_beg - max_v_end)/1000 );
     622        giet_shr_printf( " - DISPLAY           = %d\n", (max_d_end - min_d_beg)/1000 );
    602623
    603624        exit_ok = 1;
Note: See TracChangeset for help on using the changeset viewer.