Ignore:
Timestamp:
Jul 27, 2015, 8:40:45 PM (9 years ago)
Author:
alain
Message:

Introduce support for the "shared" argument in the giet_tty_alloc() system call,
and replace the giet_shr_printf() system call by giet_tty_printf().

File:
1 edited

Legend:

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

    r589 r669  
    11///////////////////////////////////////////////////////////////////////////////////////
    2 // File   : main.c   (for convol application)
     2// File   : main.c   (convol application)
    33// Date   : june 2014
    44// author : Alain Greiner
     
    2222
    2323#define USE_SQT_BARRIER            1
    24 #define VERBOSE                    0
     24#define VERBOSE                    1
    2525#define SUPER_VERBOSE              0
    2626
     
    4949#define max(x,y) ((x) > (y) ? (x) : (y))
    5050#define min(x,y) ((x) < (y) ? (x) : (y))
     51
     52// macro to use a shared TTY
     53#define printf(...)     lock_acquire( &tty_lock ); \
     54                        giet_tty_printf(__VA_ARGS__);  \
     55                        lock_release( &tty_lock )
    5156
    5257// global instrumentation counters (cluster_id, lpid]
     
    6065unsigned int D_END[CLUSTERS_MAX][PROCS_MAX];
    6166
    62 // global synchronization barrier
     67// global synchronization barriers
    6368
    6469#if USE_SQT_BARRIER
     
    7176volatile unsigned int load_image_ok      = 0;
    7277volatile unsigned int instrumentation_ok = 0;
     78
     79// lock protecting access to shared TTY
     80user_lock_t         tty_lock;
    7381
    7482// global pointers on distributed buffers in all clusters
     
    138146    START[cluster_id][lpid] = date;
    139147
    140 #if VERBOSE
    141 giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] starts at cycle %d\n", x,y,lpid, date );
    142 #endif
    143 
    144148     // parameters checking
    145149   
     
    161165   
    162166    ///////////////////////////////////////////////////////////////////
    163     // task[0][0][0] makes barrier initialisation
     167    // task[0][0][0] makes various initialisations
    164168    ///////////////////////////////////////////////////////////////////
    165169   
    166170    if ( (x==0) && (y==0) && (lpid==0) )
    167171    {
    168         giet_shr_printf("\n[CONVOL] task[0,0,0] starts barrier init at cycle %d\n"
    169                         "- CLUSTERS   = %d\n"
    170                         "- PROCS      = %d\n"
    171                         "- TASKS      = %d\n"
    172                         "- LINES/TASK = %d\n",
    173                         giet_proctime(), nclusters, nprocs, ntasks, lines_per_task );
     172        // get a shared TTY
     173        giet_tty_alloc( 1 );
     174
     175        // initializes TTY lock
     176        lock_init( &tty_lock );
     177
     178        // initializes the distributed heap[x,y]
     179        unsigned int cx;
     180        unsigned int cy;
     181        for ( cx = 0 ; cx < x_size ; cx++ )
     182        {
     183            for ( cy = 0 ; cy < y_size ; cy++ )
     184            {
     185                heap_init( cx , cy );
     186            }
     187        }
     188
    174189#if USE_SQT_BARRIER
    175190        sqt_barrier_init( &barrier, x_size , y_size , nprocs );
     
    178193#endif
    179194
    180         giet_shr_printf( "\n[CONVOL] task[0,0,0] completes barrier init at cycle %d\n",
    181                          giet_proctime() );
     195        printf("\n[CONVOL] task[0,0,0] completes initialisation at cycle %d\n"
     196               "- CLUSTERS   = %d\n"
     197               "- PROCS      = %d\n"
     198               "- TASKS      = %d\n"
     199               "- LINES/TASK = %d\n",
     200               giet_proctime(), nclusters, nprocs, ntasks, lines_per_task );
    182201
    183202        barrier_init_ok = 1;
     
    196215
    197216#if VERBOSE
    198 giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] enters malloc at cycle %d\n",
     217printf( "\n[CONVOL] task[%d,%d,%d] enters malloc at cycle %d\n",
    199218                 x,y,lpid, date );
    200219#endif
     
    207226       
    208227#if VERBOSE
    209 giet_shr_printf( "\n[CONVOL]  Shared Buffer Virtual Addresses in cluster(%d,%d)\n"
    210                  "### GA = %x\n"
    211                  "### GB = %x\n"               
    212                  "### GC = %x\n"               
    213                  "### GD = %x\n"               
    214                  "### GZ = %x\n",
    215                  x, y,
    216                  GA[cluster_id],
    217                  GB[cluster_id],
    218                  GC[cluster_id],
    219                  GD[cluster_id],
    220                  GZ[cluster_id] );
     228printf( "\n[CONVOL]  Shared Buffer Virtual Addresses in cluster(%d,%d)\n"
     229        "### GA = %x\n"
     230        "### GB = %x\n"               
     231        "### GC = %x\n"               
     232        "### GD = %x\n"               
     233        "### GZ = %x\n",
     234        x, y,
     235        GA[cluster_id],
     236        GB[cluster_id],
     237        GC[cluster_id],
     238        GD[cluster_id],
     239        GZ[cluster_id] );
    221240#endif
    222241    }
     
    257276    {
    258277        // open file
    259         file = giet_fat_open( "misc/philips_image.raw" , 0 );
     278        file = giet_fat_open( "/misc/philips_1024.raw" , 0 );
    260279        if ( file < 0 ) giet_exit( "[CONVOL ERROR] task[0,0,0] cannot open"
    261                                    " file misc/philips_image.raw" );
     280                                   " file /misc/philips_1024.raw" );
    262281 
    263         giet_shr_printf( "\n[CONVOL] task[0,0,0] open file misc/philips_image.raw"
    264                          " at cycle %d\n", giet_proctime() );
     282        printf( "\n[CONVOL] task[0,0,0] open file /misc/philips_1024.raw"
     283                " at cycle %d\n", giet_proctime() );
    265284
    266285        for ( c = 0 ; c < nclusters ; c++ )
    267286        {
    268             giet_shr_printf( "\n[CONVOL] task[0,0,0] starts load "
    269                              "for cluster %d at cycle %d\n", c, giet_proctime() );
     287            printf( "\n[CONVOL] task[0,0,0] starts load "
     288                    "for cluster %d at cycle %d\n", c, giet_proctime() );
    270289
    271290            giet_fat_lseek( file,
     
    277296                           frame_size/nclusters );
    278297
    279             giet_shr_printf( "\n[CONVOL] task[0,0,0] completes load "
    280                              "for cluster %d at cycle %d\n", c, giet_proctime() );
     298            printf( "\n[CONVOL] task[0,0,0] completes load "
     299                    "for cluster %d at cycle %d\n", c, giet_proctime() );
    281300        }
    282301        load_image_ok = 1;
     
    296315
    297316#if VERBOSE
    298 giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] starts initial display"
    299                  " at cycle %d\n",
    300                  x, y, lpid, giet_proctime() );
     317printf( "\n[CONVOL] task[%d,%d,%d] starts initial display"
     318        " at cycle %d\n",
     319        x, y, lpid, giet_proctime() );
    301320#endif
    302321
     
    319338
    320339#if VERBOSE
    321 giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] completes initial display"
    322                  " at cycle %d\n",
    323                  x, y, lpid, giet_proctime() );
     340printf( "\n[CONVOL] task[%d,%d,%d] completes initial display"
     341        " at cycle %d\n",
     342        x, y, lpid, giet_proctime() );
    324343#endif
    325344
     
    347366
    348367#if VERBOSE
    349 giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] starts horizontal filter"
    350                  " at cycle %d\n",
    351                  x, y, lpid, date );
     368printf( "\n[CONVOL] task[%d,%d,%d] starts horizontal filter"
     369        " at cycle %d\n",
     370        x, y, lpid, date );
    352371#else
    353372if ( (x==0) && (y==0) && (lpid==0) )
    354 giet_shr_printf( "\n[CONVOL] task[0,0,0] starts horizontal filter"
    355                  " at cycle %d\n", date );
     373printf( "\n[CONVOL] task[0,0,0] starts horizontal filter"
     374        " at cycle %d\n", date );
    356375#endif
    357376
     
    412431
    413432#if SUPER_VERBOSE
    414 giet_shr_printf(" - line %d computed at cycle %d\n", l, giet_proctime() );
     433printf(" - line %d computed at cycle %d\n", l, giet_proctime() );
    415434#endif   
    416435
     
    421440
    422441#if VERBOSE
    423 giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] completes horizontal filter"
    424                  " at cycle %d\n",
    425                  x, y, lpid, date );
     442printf( "\n[CONVOL] task[%d,%d,%d] completes horizontal filter"
     443        " at cycle %d\n",
     444        x, y, lpid, date );
    426445#else
    427446if ( (x==0) && (y==0) && (lpid==0) )
    428 giet_shr_printf( "\n[CONVOL] task[0,0,0] completes horizontal filter"
    429                  " at cycle %d\n", date );
     447printf( "\n[CONVOL] task[0,0,0] completes horizontal filter"
     448        " at cycle %d\n", date );
    430449#endif
    431450
     
    451470
    452471#if VERBOSE
    453 giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] starts vertical filter"
    454                  " at cycle %d\n",
    455                  x, y, lpid, date );
     472printf( "\n[CONVOL] task[%d,%d,%d] starts vertical filter"
     473        " at cycle %d\n",
     474        x, y, lpid, date );
    456475#else
    457476if ( (x==0) && (y==0) && (lpid==0) )
    458 giet_shr_printf( "\n[CONVOL] task[0,0,0] starts vertical filter"
    459                  " at cycle %d\n", date );
     477printf( "\n[CONVOL] task[0,0,0] starts vertical filter"
     478        " at cycle %d\n", date );
    460479#endif
    461480
     
    532551
    533552#if SUPER_VERBOSE
    534 giet_shr_printf(" - column %d computed at cycle %d\n", p, giet_proctime());
     553printf(" - column %d computed at cycle %d\n", p, giet_proctime());
    535554#endif
    536555
     
    541560
    542561#if VERBOSE
    543 giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] completes vertical filter"
    544                  " at cycle %d\n",
    545                  x, y, lpid, date );
     562printf( "\n[CONVOL] task[%d,%d,%d] completes vertical filter"
     563        " at cycle %d\n",
     564        x, y, lpid, date );
    546565#else
    547566if ( (x==0) && (y==0) && (lpid==0) )
    548 giet_shr_printf( "\n[CONVOL] task[0,0,0] completes vertical filter"
    549                  " at cycle %d\n", date );
     567printf( "\n[CONVOL] task[0,0,0] completes vertical filter"
     568        " at cycle %d\n", date );
    550569#endif
    551570
     
    568587
    569588#if VERBOSE
    570 giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] starts final display"
    571                  " at cycle %d\n",
    572                  x, y, lpid, date);
     589printf( "\n[CONVOL] task[%d,%d,%d] starts final display"
     590        " at cycle %d\n",
     591        x, y, lpid, date);
    573592#else
    574593if ( (x==0) && (y==0) && (lpid==0) )
    575 giet_shr_printf( "\n[CONVOL] task[0,0,0] starts final display"
    576                  " at cycle %d\n", date );
     594printf( "\n[CONVOL] task[0,0,0] starts final display"
     595        " at cycle %d\n", date );
    577596#endif
    578597
     
    600619
    601620#if VERBOSE
    602 giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] completes final display"
    603                  " at cycle %d\n",
    604                  x, y, lpid, date);
     621printf( "\n[CONVOL] task[%d,%d,%d] completes final display"
     622        " at cycle %d\n",
     623        x, y, lpid, date);
    605624#else
    606625if ( (x==0) && (y==0) && (lpid==0) )
    607 giet_shr_printf( "\n[CONVOL] task[0,0,0] completes final display"
    608                  " at cycle %d\n", date );
     626printf( "\n[CONVOL] task[0,0,0] completes final display"
     627        " at cycle %d\n", date );
    609628#endif
    610629     
     
    625644    {
    626645        date  = giet_proctime();
    627         giet_shr_printf("\n[CONVOL] task[0,0,0] starts instrumentation"
    628                         " at cycle %d\n\n", date );
     646        printf("\n[CONVOL] task[0,0,0] starts instrumentation"
     647               " at cycle %d\n\n", date );
    629648
    630649        int cc, pp;
     
    678697        }
    679698
    680         giet_shr_printf(" - START : min = %d / max = %d / med = %d / delta = %d\n",
     699        printf(" - START : min = %d / max = %d / med = %d / delta = %d\n",
    681700               min_start, max_start, (min_start+max_start)/2, max_start-min_start);
    682701
    683         giet_shr_printf(" - H_BEG : min = %d / max = %d / med = %d / delta = %d\n",
     702        printf(" - H_BEG : min = %d / max = %d / med = %d / delta = %d\n",
    684703               min_h_beg, max_h_beg, (min_h_beg+max_h_beg)/2, max_h_beg-min_h_beg);
    685704
    686         giet_shr_printf(" - H_END : min = %d / max = %d / med = %d / delta = %d\n",
     705        printf(" - H_END : min = %d / max = %d / med = %d / delta = %d\n",
    687706               min_h_end, max_h_end, (min_h_end+max_h_end)/2, max_h_end-min_h_end);
    688707
    689         giet_shr_printf(" - V_BEG : min = %d / max = %d / med = %d / delta = %d\n",
     708        printf(" - V_BEG : min = %d / max = %d / med = %d / delta = %d\n",
    690709               min_v_beg, max_v_beg, (min_v_beg+max_v_beg)/2, max_v_beg-min_v_beg);
    691710
    692         giet_shr_printf(" - V_END : min = %d / max = %d / med = %d / delta = %d\n",
     711        printf(" - V_END : min = %d / max = %d / med = %d / delta = %d\n",
    693712               min_v_end, max_v_end, (min_v_end+max_v_end)/2, max_v_end-min_v_end);
    694713
    695         giet_shr_printf(" - D_BEG : min = %d / max = %d / med = %d / delta = %d\n",
     714        printf(" - D_BEG : min = %d / max = %d / med = %d / delta = %d\n",
    696715               min_d_beg, max_d_beg, (min_d_beg+max_d_beg)/2, max_d_beg-min_d_beg);
    697716
    698         giet_shr_printf(" - D_END : min = %d / max = %d / med = %d / delta = %d\n",
     717        printf(" - D_END : min = %d / max = %d / med = %d / delta = %d\n",
    699718               min_d_end, max_d_end, (min_d_end+max_d_end)/2, max_d_end-min_d_end);
    700719
    701         giet_shr_printf( "\n General Scenario (Kcycles for each step)\n" );
    702         giet_shr_printf( " - BOOT OS           = %d\n", (min_start            )/1000 );
    703         giet_shr_printf( " - LOAD IMAGE        = %d\n", (min_h_beg - min_start)/1000 );
    704         giet_shr_printf( " - H_FILTER          = %d\n", (max_h_end - min_h_beg)/1000 );
    705         giet_shr_printf( " - BARRIER HORI/VERT = %d\n", (min_v_beg - max_h_end)/1000 );
    706         giet_shr_printf( " - V_FILTER          = %d\n", (max_v_end - min_v_beg)/1000 );
    707         giet_shr_printf( " - BARRIER VERT/DISP = %d\n", (min_d_beg - max_v_end)/1000 );
    708         giet_shr_printf( " - DISPLAY           = %d\n", (max_d_end - min_d_beg)/1000 );
     720        printf( "\n General Scenario (Kcycles for each step)\n" );
     721        printf( " - BOOT OS           = %d\n", (min_start            )/1000 );
     722        printf( " - LOAD IMAGE        = %d\n", (min_h_beg - min_start)/1000 );
     723        printf( " - H_FILTER          = %d\n", (max_h_end - min_h_beg)/1000 );
     724        printf( " - BARRIER HORI/VERT = %d\n", (min_v_beg - max_h_end)/1000 );
     725        printf( " - V_FILTER          = %d\n", (max_v_end - min_v_beg)/1000 );
     726        printf( " - BARRIER VERT/DISP = %d\n", (min_d_beg - max_v_end)/1000 );
     727        printf( " - DISPLAY           = %d\n", (max_d_end - min_d_beg)/1000 );
    709728
    710729        instrumentation_ok = 1;
Note: See TracChangeset for help on using the changeset viewer.