source: soft/giet_vm/convol/main.c @ 402

Last change on this file since 402 was 402, checked in by alain, 10 years ago

supporting X_SIZE = 16 and Y_SIZE = 16

File size: 24.8 KB
Line 
1////////////////////////////////////////////////////////////////////////////////////////////
2// File   : main.c   (for convol application)
3// Date   : june 2014
4// author : Alain Greiner
5//
6// The "convol" application implements a 2D convolution product. 
7////////////////////////////////////////////////////////////////////////////////////////////
8
9#include "hard_config.h"
10#include "stdio.h"
11#include "stdlib.h"
12#include "barrier.h"
13#include "malloc.h"
14
15#define USE_SBT_BARRIER            1
16#define VERBOSE                    0
17#define SUPER_VERBOSE              0
18
19#define INITIAL_DISPLAY_ENABLE     0
20#define FINAL_DISPLAY_ENABLE       1
21
22#define NB_CLUSTERS                (X_SIZE * Y_SIZE)
23#define PIXEL_SIZE                 2
24#define NL                         1024
25#define NP                         1024
26#define NB_PIXELS                  (NP * NL)
27#define FRAME_SIZE                 (NB_PIXELS * PIXEL_SIZE)
28
29#define TA(c,l,p)  (A[c][((NP) * (l)) + (p)])
30#define TB(c,p,l)  (B[c][((NL) * (p)) + (l)])
31#define TC(c,l,p)  (C[c][((NP) * (l)) + (p)])
32#define TD(c,l,p)  (D[c][((NP) * (l)) + (p)])
33#define TZ(c,l,p)  (Z[c][((NP) * (l)) + (p)])
34
35#define max(x,y) ((x) > (y) ? (x) : (y))
36#define min(x,y) ((x) < (y) ? (x) : (y))
37
38// global instrumentation counters (cluster_id, lpid]
39
40unsigned int START[NB_CLUSTERS][NB_PROCS_MAX];
41unsigned int H_BEG[NB_CLUSTERS][NB_PROCS_MAX];
42unsigned int H_END[NB_CLUSTERS][NB_PROCS_MAX];
43unsigned int V_BEG[NB_CLUSTERS][NB_PROCS_MAX];
44unsigned int V_END[NB_CLUSTERS][NB_PROCS_MAX];
45unsigned int D_BEG[NB_CLUSTERS][NB_PROCS_MAX];
46unsigned int D_END[NB_CLUSTERS][NB_PROCS_MAX];
47
48// global synchronization barrier
49
50#if USE_SBT_BARRIER
51giet_sbt_barrier_t  barrier;
52#else
53giet_barrier_t      barrier;
54#endif
55
56volatile unsigned int barrier_init_ok    = 0;
57volatile unsigned int load_image_ok      = 0;
58volatile unsigned int instrumentation_ok = 0;
59
60// global pointers on distributed buffers in all clusters
61unsigned short * GA[NB_CLUSTERS];
62int *            GB[NB_CLUSTERS];
63int *            GC[NB_CLUSTERS];
64int *            GD[NB_CLUSTERS];
65unsigned char *  GZ[NB_CLUSTERS];
66
67///////////////////////////////////////////
68__attribute__ ((constructor)) void main()
69///////////////////////////////////////////
70{
71    //////////////////////////////////
72    // convolution kernel parameters
73    // The content of this section is
74    // Philips proprietary information.
75    ///////////////////////////////////
76
77    int   vnorm  = 115;
78    int   vf[35] = { 1, 1, 2, 2, 2,
79                     2, 3, 3, 3, 4,
80                     4, 4, 4, 5, 5,
81                     5, 5, 5, 5, 5,
82                     5, 5, 4, 4, 4,
83                     4, 3, 3, 3, 2,
84                     2, 2, 2, 1, 1 };
85
86    int hrange = 100;
87    int hnorm  = 201;
88
89    unsigned int date = 0;
90
91    int c; // cluster index for loops
92    int l; // line index for loops
93    int p; // pixel index for loops
94    int z; // vertical filter index for loops
95
96    int          file        = 0;                             // file descriptor
97    unsigned int pid         = giet_procid();                 // processor id
98    unsigned int nprocs      = NB_PROCS_MAX;                  // procs per cluster
99    unsigned int nclusters   = NB_CLUSTERS;                   // number of clusters
100    unsigned int lpid        = pid % nprocs;                  // local task id
101    unsigned int cluster_xy  = pid / nprocs;                  // cluster index
102    unsigned int x           = cluster_xy >> Y_WIDTH;         // x coordinate
103    unsigned int y           = cluster_xy & ((1<<Y_WIDTH)-1); // y coordinate
104    unsigned int cluster_id  = (x * Y_SIZE) + y;              // continuous cluster index
105    unsigned int task_id     = (cluster_id * nprocs) + lpid;  // continuous task index
106    unsigned int ntasks      = nclusters * nprocs;            // number of tasks
107    unsigned int npixels     = NB_PIXELS;                     // pixels per frame
108    unsigned int frame_size  = FRAME_SIZE;                    // total size (bytes)
109    unsigned int nblocks     = frame_size / 512;              // number of blocks per frame
110
111    unsigned int lines_per_task     = NL / ntasks;            // lines per task
112    unsigned int lines_per_cluster  = NL / nclusters;         // lines per cluster
113    unsigned int pixels_per_task    = NP / ntasks;            // columns per task
114    unsigned int pixels_per_cluster = NP / nclusters;         // columns per cluster
115
116    int first, last;
117
118    date = giet_proctime();
119    START[cluster_id][lpid] = date;
120
121#if VERBOSE
122giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] starts at cycle %d\n", x,y,lpid, date );
123#endif
124
125     // parameters checking
126   
127    if ((nprocs != 1) && (nprocs != 2) && (nprocs != 4))
128        giet_exit( "[CONVOL ERROR] NB_PROCS_MAX must be 1, 2 or 4\n");
129
130    if ((X_SIZE!=1) && (X_SIZE!=2) && (X_SIZE!=4) && (X_SIZE!=8) && (X_SIZE!=16))
131        giet_exit( "[CONVOL ERROR] X_SIZE must be 1, 2, 4, 8, 16\n");
132       
133    if ((Y_SIZE!=1) && (Y_SIZE!=2) && (Y_SIZE!=4) && (Y_SIZE!=8) && (Y_SIZE!=16))
134        giet_exit( "[CONVOL ERROR] Y_SIZE must be 1, 2, 4, 8, 16\n");
135
136    if ( NL % nclusters != 0 )
137        giet_exit( "[CONVOL ERROR] NB_CLUSTERS must be a divider of NL");
138
139    if ( NP % nclusters != 0 )
140        giet_exit( "[CONVOL ERROR] NB_CLUSTERS must be a divider of NP");
141
142   
143    ///////////////////////////////////////////////////////////////////
144    // task[0][0][0] makes barrier initialisation
145    ///////////////////////////////////////////////////////////////////
146   
147    if ( pid == 0 )
148    {
149        giet_shr_printf("\n[CONVOL] task[0,0,0] starts barrier init at cycle %d\n" 
150                        "- NB_CLUSTERS     = %d\n"
151                        "- NB_LOCAL_PROCS  = %d\n" 
152                        "- NB_TASKS        = %d\n" 
153                        "- NB_PIXELS       = %x\n"           
154                        "- FRAME_SIZE      = %x\n"             
155                        "- NB_BLOCKS       = %x\n",
156                        giet_proctime(), nclusters, nprocs, ntasks, 
157                        npixels, frame_size, nblocks );
158#if USE_SBT_BARRIER
159        sbt_barrier_init( &barrier, ntasks );
160#else
161        barrier_init( &barrier, ntasks );
162#endif
163
164        giet_shr_printf( "\n[CONVOL] task[0,0,0] completes barrier init at cycle %d\n",
165                         giet_proctime() );
166
167        barrier_init_ok = 1;
168    }
169    else 
170    {
171        while ( barrier_init_ok == 0 );
172    }
173
174    ///////////////////////////////////////////////////////////////////
175    // All task[x][y][0] allocate the global buffers in cluster(x,y)
176    // These buffers mut be sector-aligned.
177    ///////////////////////////////////////////////////////////////////
178    if ( lpid == 0 )
179    {
180
181#if VERBOSE
182giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] enters malloc at cycle %d\n", x,y,lpid, date );
183#endif
184
185        GA[cluster_id] = remote_malloc( (FRAME_SIZE/nclusters)   , x , y );
186        GB[cluster_id] = remote_malloc( (FRAME_SIZE/nclusters)*2 , x , y );
187        GC[cluster_id] = remote_malloc( (FRAME_SIZE/nclusters)*2 , x , y );
188        GD[cluster_id] = remote_malloc( (FRAME_SIZE/nclusters)*2 , x , y );
189        GZ[cluster_id] = remote_malloc( (FRAME_SIZE/nclusters)/2 , x , y );
190       
191#if VERBOSE
192giet_shr_printf( "\n[CONVOL]  Shared Buffer Virtual Addresses in cluster(%d,%d)\n"
193                 "### GA = %x\n"
194                 "### GB = %x\n"               
195                 "### GC = %x\n"               
196                 "### GD = %x\n"               
197                 "### GZ = %x\n",
198                 x, y,
199                 GA[cluster_id],
200                 GB[cluster_id],
201                 GC[cluster_id],
202                 GD[cluster_id],
203                 GZ[cluster_id] );
204#endif
205    }
206
207    ///////////////////////////////
208    #if USE_SBT_BARRIER
209    sbt_barrier_wait( &barrier );
210    #else
211    barrier_wait( &barrier );
212    #endif
213
214    ///////////////////////////////////////////////////////////////////
215    // All tasks initialise in their private stack a copy of the
216    // arrays of pointers on the shared, distributed buffers.
217    ///////////////////////////////////////////////////////////////////
218
219    unsigned short * A[NB_CLUSTERS];
220    int *            B[NB_CLUSTERS];
221    int *            C[NB_CLUSTERS];
222    int *            D[NB_CLUSTERS];
223    unsigned char *  Z[NB_CLUSTERS];
224
225    for (c = 0; c < nclusters; c++)
226    {
227        A[c] = GA[c];
228        B[c] = GB[c];
229        C[c] = GC[c];
230        D[c] = GD[c];
231        Z[c] = GZ[c];
232    }
233
234    ///////////////////////////////////////////////////////////////////////////
235    // task[0,0,0] open the file containing image, and load it from disk
236    // to all A[c] buffers (nblocks / nclusters loaded in each cluster).
237    // Other tasks are waiting on the init_ok condition.
238    //////////////////////////////////////////////////////////////////////////
239    if ( pid == 0 )
240    {
241        // open file
242        file = giet_fat_open("misc/philips_image.raw", 0 );
243        if ( file < 0 ) giet_exit( "[CONVOL ERROR] task[0,0,0] cannot open"
244                                   " file misc/philips_image.raw" );
245 
246        giet_shr_printf( "\n[CONVOL] task[0,0,0] open file misc/philips_image.raw"
247                         " at cycle %d\n", giet_proctime() );
248
249        for ( c = 0 ; c < NB_CLUSTERS ; c++ )
250        {
251            giet_shr_printf( "\n[CONVOL] task[0,0,0] starts load "
252                             "for cluster %d at cycle %d\n", c, giet_proctime() );
253
254            giet_fat_read( file,
255                           A[c],
256                           nblocks/nclusters,
257                           (nblocks/nclusters)*c );
258
259            giet_shr_printf( "\n[CONVOL] task[0,0,0] completes load "
260                             "for cluster %d at cycle %d\n", c, giet_proctime() );
261        }
262        load_image_ok = 1;
263    }
264    else
265    {
266        while ( load_image_ok == 0 );
267    }
268
269    /////////////////////////////////////////////////////////////////////////////
270    // Optionnal parallel display of the initial image stored in A[c] buffers.
271    // Eah task displays (NL/ntasks) lines. (one byte per pixel).
272    /////////////////////////////////////////////////////////////////////////////
273
274    if ( INITIAL_DISPLAY_ENABLE )
275    {
276
277#if VERBOSE
278giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] starts initial display"
279                 " at cycle %d\n",
280                 x, y, lpid, giet_proctime() );
281#endif
282
283        unsigned int line;
284        unsigned int offset = lines_per_task * lpid;
285
286        for ( l = 0 ; l < lines_per_task ; l++ )
287        {
288            line = offset + l;
289
290            for ( p = 0 ; p < NP ; p++ )
291            {
292                TZ(cluster_id, line, p) = (unsigned char)(TA(cluster_id, line, p) >> 8);
293            }
294
295            giet_fb_sync_write( NP*(l + (task_id * lines_per_task) ), 
296                                &TZ(cluster_id, line, 0), 
297                                NP);
298        }
299
300#if VERBOSE
301giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] completes initial display"
302                 " at cycle %d\n",
303                 x, y, lpid, giet_proctime() );
304#endif
305
306        ////////////////////////////
307        #if USE_SBT_BARRIER
308        sbt_barrier_wait( &barrier );
309        #else
310        barrier_wait( &barrier );
311        #endif
312
313    }
314
315    ////////////////////////////////////////////////////////
316    // parallel horizontal filter :
317    // B <= transpose(FH(A))
318    // D <= A - FH(A)
319    // Each task computes (NL/ntasks) lines
320    // The image must be extended :
321    // if (z<0)    TA(cluster_id,l,z) == TA(cluster_id,l,0)
322    // if (z>NP-1) TA(cluster_id,l,z) == TA(cluster_id,l,NP-1)
323    ////////////////////////////////////////////////////////
324
325    date  = giet_proctime();
326    H_BEG[cluster_id][lpid] = date;
327
328#if VERBOSE
329giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] starts horizontal filter"
330                 " at cycle %d\n",
331                 x, y, lpid, date );
332#else
333if ( pid == 0 ) giet_shr_printf( "\n[CONVOL] task[0,0,0] starts horizontal filter"
334                                 " at cycle %d\n", date );
335#endif
336
337    // l = absolute line index / p = absolute pixel index 
338    // first & last define which lines are handled by a given task
339
340    first = task_id * lines_per_task;
341    last  = first + lines_per_task;
342
343    for (l = first; l < last; l++)
344    {
345        // src_c and src_l are the cluster index and the line index for A & D
346        int src_c = l / lines_per_cluster;
347        int src_l = l % lines_per_cluster;
348
349        // We use the specific values of the horizontal ep-filter for optimisation:
350        // sum(p) = sum(p-1) + TA[p+hrange] - TA[p-hrange-1]
351        // To minimize the number of tests, the loop on pixels is split in three domains
352
353        int sum_p = (hrange + 2) * TA(src_c, src_l, 0);
354        for (z = 1; z < hrange; z++)
355        {
356            sum_p = sum_p + TA(src_c, src_l, z);
357        }
358
359        // first domain : from 0 to hrange
360        for (p = 0; p < hrange + 1; p++)
361        {
362            // dst_c and dst_p are the cluster index and the pixel index for B
363            int dst_c = p / pixels_per_cluster;
364            int dst_p = p % pixels_per_cluster;
365            sum_p = sum_p + (int) TA(src_c, src_l, p + hrange) - (int) TA(src_c, src_l, 0);
366            TB(dst_c, dst_p, l) = sum_p / hnorm;
367            TD(src_c, src_l, p) = (int) TA(src_c, src_l, p) - sum_p / hnorm;
368        }
369        // second domain : from (hrange+1) to (NP-hrange-1)
370        for (p = hrange + 1; p < NP - hrange; p++)
371        {
372            // dst_c and dst_p are the cluster index and the pixel index for B
373            int dst_c = p / pixels_per_cluster;
374            int dst_p = p % pixels_per_cluster;
375            sum_p = sum_p + (int) TA(src_c, src_l, p + hrange) 
376                          - (int) TA(src_c, src_l, p - hrange - 1);
377            TB(dst_c, dst_p, l) = sum_p / hnorm;
378            TD(src_c, src_l, p) = (int) TA(src_c, src_l, p) - sum_p / hnorm;
379        }
380        // third domain : from (NP-hrange) to (NP-1)
381        for (p = NP - hrange; p < NP; p++)
382        {
383            // dst_c and dst_p are the cluster index and the pixel index for B
384            int dst_c = p / pixels_per_cluster;
385            int dst_p = p % pixels_per_cluster;
386            sum_p = sum_p + (int) TA(src_c, src_l, NP - 1) 
387                          - (int) TA(src_c, src_l, p - hrange - 1);
388            TB(dst_c, dst_p, l) = sum_p / hnorm;
389            TD(src_c, src_l, p) = (int) TA(src_c, src_l, p) - sum_p / hnorm;
390        }
391
392#if SUPER_VERBOSE
393giet_shr_printf(" - line %d computed at cycle %d\n", l, giet_proctime() );
394#endif   
395
396    }
397
398    date  = giet_proctime();
399    H_END[cluster_id][lpid] = date;
400
401#if VERBOSE
402giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] completes horizontal filter"
403                 " at cycle %d\n",
404                 x, y, lpid, date );
405#else
406if ( pid == 0 ) giet_shr_printf( "\n[CONVOL] task[0,0,0] completes horizontal filter"
407                                 " at cycle %d\n", date );
408#endif
409
410    /////////////////////////////
411    #if USE_SBT_BARRIER
412    sbt_barrier_wait( &barrier );
413    #else
414    barrier_wait( &barrier );
415    #endif
416
417
418    ///////////////////////////////////////////////////////////////
419    // parallel vertical filter :
420    // C <= transpose(FV(B))
421    // Each task computes (NP/ntasks) columns
422    // The image must be extended :
423    // if (l<0)    TB(cluster_id,p,l) == TB(cluster_id,p,0)
424    // if (l>NL-1)   TB(cluster_id,p,l) == TB(cluster_id,p,NL-1)
425    ///////////////////////////////////////////////////////////////
426
427    date  = giet_proctime();
428    V_BEG[cluster_id][lpid] = date;
429
430#if VERBOSE
431giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] starts vertical filter"
432                 " at cycle %d\n",
433                 x, y, lpid, date );
434#else
435if ( pid == 0 ) giet_shr_printf( "\n[CONVOL] task[0,0,0] starts vertical filter"
436                                 " at cycle %d\n", date );
437#endif
438
439    // l = absolute line index / p = absolute pixel index
440    // first & last define which pixels are handled by a given task
441
442    first = task_id * pixels_per_task;
443    last  = first + pixels_per_task;
444
445    for (p = first; p < last; p++)
446    {
447        // src_c and src_p are the cluster index and the pixel index for B
448        int src_c = p / pixels_per_cluster;
449        int src_p = p % pixels_per_cluster;
450
451        int sum_l;
452
453        // We use the specific values of the vertical ep-filter
454        // To minimize the number of tests, the NL lines are split in three domains
455
456        // first domain : explicit computation for the first 18 values
457        for (l = 0; l < 18; l++)
458        {
459            // dst_c and dst_l are the cluster index and the line index for C
460            int dst_c = l / lines_per_cluster;
461            int dst_l = l % lines_per_cluster;
462
463            for (z = 0, sum_l = 0; z < 35; z++)
464            {
465                sum_l = sum_l + vf[z] * TB(src_c, src_p, max(l - 17 + z,0) );
466            }
467            TC(dst_c, dst_l, p) = sum_l / vnorm;
468        }
469        // second domain
470        for (l = 18; l < NL - 17; l++)
471        {
472            // dst_c and dst_l are the cluster index and the line index for C
473            int dst_c = l / lines_per_cluster;
474            int dst_l = l % lines_per_cluster;
475
476            sum_l = sum_l + TB(src_c, src_p, l + 4)
477                  + TB(src_c, src_p, l + 8)
478                  + TB(src_c, src_p, l + 11)
479                  + TB(src_c, src_p, l + 15)
480                  + TB(src_c, src_p, l + 17)
481                  - TB(src_c, src_p, l - 5)
482                  - TB(src_c, src_p, l - 9)
483                  - TB(src_c, src_p, l - 12)
484                  - TB(src_c, src_p, l - 16)
485                  - TB(src_c, src_p, l - 18);
486
487            TC(dst_c, dst_l, p) = sum_l / vnorm;
488        }
489        // third domain
490        for (l = NL - 17; l < NL; l++)
491        {
492            // dst_c and dst_l are the cluster index and the line index for C
493            int dst_c = l / lines_per_cluster;
494            int dst_l = l % lines_per_cluster;
495
496            sum_l = sum_l + TB(src_c, src_p, min(l + 4, NL - 1))
497                  + TB(src_c, src_p, min(l + 8, NL - 1))
498                  + TB(src_c, src_p, min(l + 11, NL - 1))
499                  + TB(src_c, src_p, min(l + 15, NL - 1))
500                  + TB(src_c, src_p, min(l + 17, NL - 1))
501                  - TB(src_c, src_p, l - 5)
502                  - TB(src_c, src_p, l - 9)
503                  - TB(src_c, src_p, l - 12)
504                  - TB(src_c, src_p, l - 16)
505                  - TB(src_c, src_p, l - 18);
506
507            TC(dst_c, dst_l, p) = sum_l / vnorm;
508        }
509
510#if SUPER_VERBOSE
511giet_shr_printf(" - column %d computed at cycle %d\n", p, giet_proctime());
512#endif
513
514    }
515
516    date  = giet_proctime();
517    V_END[cluster_id][lpid] = date;
518
519#if VERBOSE
520giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] completes vertical filter"
521                 " at cycle %d\n",
522                 x, y, lpid, date );
523#else
524if ( pid == 0 ) giet_shr_printf( "\n[CONVOL] task[0,0,0] completes vertical filter"
525                                 " at cycle %d\n", date );
526#endif
527
528    ////////////////////////////
529    #if USE_SBT_BARRIER
530    sbt_barrier_wait( &barrier );
531    #else
532    barrier_wait( &barrier );
533    #endif
534
535    ////////////////////////////////////////////////////////////////
536    // Optional parallel display of the final image Z <= D + C
537    // Eah task displays (NL/ntasks) lines. (one byte per pixel).
538    ////////////////////////////////////////////////////////////////
539
540    if ( FINAL_DISPLAY_ENABLE )
541    {
542        date  = giet_proctime();
543        D_BEG[cluster_id][lpid] = date;
544
545#if VERBOSE
546giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] starts final display"
547                 " at cycle %d\n",
548                 x, y, lpid, date);
549#else
550if ( pid == 0 ) giet_shr_printf( "\n[CONVOL] task[0,0,0] starts final display"
551                                 " at cycle %d\n", date );
552#endif
553
554        unsigned int line;
555        unsigned int offset = lines_per_task * lpid;
556
557        for ( l = 0 ; l < lines_per_task ; l++ )
558        {
559            line = offset + l;
560
561            for ( p = 0 ; p < NP ; p++ )
562            {
563                TZ(cluster_id, line, p) = 
564                   (unsigned char)( (TD(cluster_id, line, p) + 
565                                     TC(cluster_id, line, p) ) >> 8 );
566            }
567
568            giet_fb_sync_write( NP*(l + (task_id * lines_per_task) ), 
569                                &TZ(cluster_id, line, 0), 
570                                NP);
571        }
572
573        date  = giet_proctime();
574        D_END[cluster_id][lpid] = date;
575
576#if VERBOSE
577giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] completes final display"
578                 " at cycle %d\n",
579                 x, y, lpid, date);
580#else
581if ( pid == 0 ) giet_shr_printf( "\n[CONVOL] task[0,0,0] completes final display"
582                                 " at cycle %d\n", date );
583#endif
584     
585    //////////////////////////////
586    #if USE_SBT_BARRIER
587    sbt_barrier_wait( &barrier );
588    #else
589    barrier_wait( &barrier );
590    #endif
591
592    }
593
594    /////////////////////////////////////////////////////////
595    // Task[0,0,0] makes the instrumentation
596    /////////////////////////////////////////////////////////
597
598    if ( pid == 0 )
599    {
600        date  = giet_proctime();
601        giet_shr_printf("\n[CONVOL] task[0,0,0] starts instrumentation"
602                        " at cycle %d\n\n", date );
603
604        int cc, pp;
605
606        unsigned int min_start = 0xFFFFFFFF;
607        unsigned int max_start = 0;
608
609        unsigned int min_h_beg = 0xFFFFFFFF;
610        unsigned int max_h_beg = 0;
611
612        unsigned int min_h_end = 0xFFFFFFFF;
613        unsigned int max_h_end = 0;
614
615        unsigned int min_v_beg = 0xFFFFFFFF;
616        unsigned int max_v_beg = 0;
617
618        unsigned int min_v_end = 0xFFFFFFFF;
619        unsigned int max_v_end = 0;
620
621        unsigned int min_d_beg = 0xFFFFFFFF;
622        unsigned int max_d_beg = 0;
623
624        unsigned int min_d_end = 0xFFFFFFFF;
625        unsigned int max_d_end = 0;
626
627        for (cc = 0; cc < nclusters; cc++)
628        {
629            for (pp = 0; pp < nprocs; pp++ )
630            {
631                if (START[cc][pp] < min_start) min_start = START[cc][pp];
632                if (START[cc][pp] > max_start) max_start = START[cc][pp];
633
634                if (H_BEG[cc][pp] < min_h_beg) min_h_beg = H_BEG[cc][pp];
635                if (H_BEG[cc][pp] > max_h_beg) max_h_beg = H_BEG[cc][pp];
636
637                if (H_END[cc][pp] < min_h_end) min_h_end = H_END[cc][pp];
638                if (H_END[cc][pp] > max_h_end) max_h_end = H_END[cc][pp];
639
640                if (V_BEG[cc][pp] < min_v_beg) min_v_beg = V_BEG[cc][pp];
641                if (V_BEG[cc][pp] > max_v_beg) max_v_beg = V_BEG[cc][pp];
642
643                if (V_END[cc][pp] < min_v_end) min_v_end = V_END[cc][pp];
644                if (V_END[cc][pp] > max_v_end) max_v_end = V_END[cc][pp];
645
646                if (D_BEG[cc][pp] < min_d_beg) min_d_beg = D_BEG[cc][pp];
647                if (D_BEG[cc][pp] > max_d_beg) max_d_beg = D_BEG[cc][pp];
648
649                if (D_END[cc][pp] < min_d_end) min_d_end = D_END[cc][pp];
650                if (D_END[cc][pp] > max_d_end) max_d_end = D_END[cc][pp];
651            }
652        }
653
654        giet_shr_printf(" - START : min = %d / max = %d / med = %d / delta = %d\n",
655               min_start, max_start, (min_start+max_start)/2, max_start-min_start);
656
657        giet_shr_printf(" - H_BEG : min = %d / max = %d / med = %d / delta = %d\n",
658               min_h_beg, max_h_beg, (min_h_beg+max_h_beg)/2, max_h_beg-min_h_beg);
659
660        giet_shr_printf(" - H_END : min = %d / max = %d / med = %d / delta = %d\n",
661               min_h_end, max_h_end, (min_h_end+max_h_end)/2, max_h_end-min_h_end);
662
663        giet_shr_printf(" - V_BEG : min = %d / max = %d / med = %d / delta = %d\n",
664               min_v_beg, max_v_beg, (min_v_beg+max_v_beg)/2, max_v_beg-min_v_beg);
665
666        giet_shr_printf(" - V_END : min = %d / max = %d / med = %d / delta = %d\n",
667               min_v_end, max_v_end, (min_v_end+max_v_end)/2, max_v_end-min_v_end);
668
669        giet_shr_printf(" - D_BEG : min = %d / max = %d / med = %d / delta = %d\n",
670               min_d_beg, max_d_beg, (min_d_beg+max_d_beg)/2, max_d_beg-min_d_beg);
671
672        giet_shr_printf(" - D_END : min = %d / max = %d / med = %d / delta = %d\n",
673               min_d_end, max_d_end, (min_d_end+max_d_end)/2, max_d_end-min_d_end);
674
675        giet_shr_printf( "\n General Scenario (Kcycles for each step)\n" );
676        giet_shr_printf( " - BOOT OS           = %d\n", (min_start            )/1000 );
677        giet_shr_printf( " - LOAD IMAGE        = %d\n", (min_h_beg - min_start)/1000 );
678        giet_shr_printf( " - H_FILTER          = %d\n", (max_h_end - min_h_beg)/1000 );
679        giet_shr_printf( " - BARRIER HORI/VERT = %d\n", (min_v_beg - max_h_end)/1000 );
680        giet_shr_printf( " - V_FILTER          = %d\n", (max_v_end - min_v_beg)/1000 );
681        giet_shr_printf( " - BARRIER VERT/DISP = %d\n", (min_d_beg - max_v_end)/1000 );
682        giet_shr_printf( " - DISPLAY           = %d\n", (max_d_end - min_d_beg)/1000 );
683
684        instrumentation_ok = 1;
685    }
686    else
687    {
688        while ( instrumentation_ok == 0 );
689    }
690
691    giet_exit( "completed");
692
693} // end main()
694
695// Local Variables:
696// tab-width: 3
697// c-basic-offset: 3
698// c-file-offsets:((innamespace . 0)(inline-open . 0))
699// indent-tabs-mode: nil
700// End:
701
702// vim: filetype=cpp:expandtab:shiftwidth=3:tabstop=3:softtabstop=3
703
704
Note: See TracBrowser for help on using the repository browser.