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

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

Modify the convol application to use the remote_malloc library,
and to support both the simple barrier and the SBT barrier.

File size: 24.6 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 "remote_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))
131        giet_exit( "[CONVOL ERROR] X_SIZE must be 1, 2, 4, 8\n");
132       
133    if ((Y_SIZE!=1) && (Y_SIZE!=2) && (Y_SIZE!=4) && (Y_SIZE!=8))
134        giet_exit( "[CONVOL ERROR] X_SIZE must be 1, 2, 4, 8\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)   , 9 , x , y );
186        GB[cluster_id] = remote_malloc( (FRAME_SIZE/nclusters)*2 , 9 , x , y );
187        GC[cluster_id] = remote_malloc( (FRAME_SIZE/nclusters)*2 , 9 , x , y );
188        GD[cluster_id] = remote_malloc( (FRAME_SIZE/nclusters)*2 , 9 , x , y );
189        GZ[cluster_id] = remote_malloc( (FRAME_SIZE/nclusters)/2 , 9 , 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#if USE_SBT_BARRIER
208        sbt_barrier_wait( &barrier );
209#else
210        barrier_wait( &barrier );
211#endif
212
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#if USE_SBT_BARRIER
307        sbt_barrier_wait( &barrier );
308#else
309        barrier_wait( &barrier );
310#endif
311
312    }
313
314    ////////////////////////////////////////////////////////
315    // parallel horizontal filter :
316    // B <= transpose(FH(A))
317    // D <= A - FH(A)
318    // Each task computes (NL/ntasks) lines
319    // The image must be extended :
320    // if (z<0)    TA(cluster_id,l,z) == TA(cluster_id,l,0)
321    // if (z>NP-1) TA(cluster_id,l,z) == TA(cluster_id,l,NP-1)
322    ////////////////////////////////////////////////////////
323
324    date  = giet_proctime();
325    H_BEG[cluster_id][lpid] = date;
326
327#if VERBOSE
328giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] starts horizontal filter"
329                 " at cycle %d\n",
330                 x, y, lpid, date );
331#else
332if ( pid == 0 ) giet_shr_printf( "\n[CONVOL] task[0,0,0] starts horizontal filter"
333                                 " at cycle %d\n", date );
334#endif
335
336    // l = absolute line index / p = absolute pixel index 
337    // first & last define which lines are handled by a given task
338
339    first = task_id * lines_per_task;
340    last  = first + lines_per_task;
341
342    for (l = first; l < last; l++)
343    {
344        // src_c and src_l are the cluster index and the line index for A & D
345        int src_c = l / lines_per_cluster;
346        int src_l = l % lines_per_cluster;
347
348        // We use the specific values of the horizontal ep-filter for optimisation:
349        // sum(p) = sum(p-1) + TA[p+hrange] - TA[p-hrange-1]
350        // To minimize the number of tests, the loop on pixels is split in three domains
351
352        int sum_p = (hrange + 2) * TA(src_c, src_l, 0);
353        for (z = 1; z < hrange; z++)
354        {
355            sum_p = sum_p + TA(src_c, src_l, z);
356        }
357
358        // first domain : from 0 to hrange
359        for (p = 0; p < hrange + 1; p++)
360        {
361            // dst_c and dst_p are the cluster index and the pixel index for B
362            int dst_c = p / pixels_per_cluster;
363            int dst_p = p % pixels_per_cluster;
364            sum_p = sum_p + (int) TA(src_c, src_l, p + hrange) - (int) TA(src_c, src_l, 0);
365            TB(dst_c, dst_p, l) = sum_p / hnorm;
366            TD(src_c, src_l, p) = (int) TA(src_c, src_l, p) - sum_p / hnorm;
367        }
368        // second domain : from (hrange+1) to (NP-hrange-1)
369        for (p = hrange + 1; p < NP - hrange; p++)
370        {
371            // dst_c and dst_p are the cluster index and the pixel index for B
372            int dst_c = p / pixels_per_cluster;
373            int dst_p = p % pixels_per_cluster;
374            sum_p = sum_p + (int) TA(src_c, src_l, p + hrange) 
375                          - (int) TA(src_c, src_l, p - hrange - 1);
376            TB(dst_c, dst_p, l) = sum_p / hnorm;
377            TD(src_c, src_l, p) = (int) TA(src_c, src_l, p) - sum_p / hnorm;
378        }
379        // third domain : from (NP-hrange) to (NP-1)
380        for (p = NP - hrange; p < NP; p++)
381        {
382            // dst_c and dst_p are the cluster index and the pixel index for B
383            int dst_c = p / pixels_per_cluster;
384            int dst_p = p % pixels_per_cluster;
385            sum_p = sum_p + (int) TA(src_c, src_l, NP - 1) 
386                          - (int) TA(src_c, src_l, p - hrange - 1);
387            TB(dst_c, dst_p, l) = sum_p / hnorm;
388            TD(src_c, src_l, p) = (int) TA(src_c, src_l, p) - sum_p / hnorm;
389        }
390
391#if SUPER_VERBOSE
392giet_shr_printf(" - line %d computed at cycle %d\n", l, giet_proctime() );
393#endif   
394
395    }
396
397    date  = giet_proctime();
398    H_END[cluster_id][lpid] = date;
399
400#if VERBOSE
401giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] completes horizontal filter"
402                 " at cycle %d\n",
403                 x, y, lpid, date );
404#else
405if ( pid == 0 ) giet_shr_printf( "\n[CONVOL] task[0,0,0] completes horizontal filter"
406                                 " at cycle %d\n", date );
407#endif
408
409#if USE_SBT_BARRIER
410        sbt_barrier_wait( &barrier );
411#else
412        barrier_wait( &barrier );
413#endif
414
415
416    ///////////////////////////////////////////////////////////////
417    // parallel vertical filter :
418    // C <= transpose(FV(B))
419    // Each task computes (NP/ntasks) columns
420    // The image must be extended :
421    // if (l<0)    TB(cluster_id,p,l) == TB(cluster_id,p,0)
422    // if (l>NL-1)   TB(cluster_id,p,l) == TB(cluster_id,p,NL-1)
423    ///////////////////////////////////////////////////////////////
424
425    date  = giet_proctime();
426    V_BEG[cluster_id][lpid] = date;
427
428#if VERBOSE
429giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] starts vertical filter"
430                 " at cycle %d\n",
431                 x, y, lpid, date );
432#else
433if ( pid == 0 ) giet_shr_printf( "\n[CONVOL] task[0,0,0] starts vertical filter"
434                                 " at cycle %d\n", date );
435#endif
436
437    // l = absolute line index / p = absolute pixel index
438    // first & last define which pixels are handled by a given task
439
440    first = task_id * pixels_per_task;
441    last  = first + pixels_per_task;
442
443    for (p = first; p < last; p++)
444    {
445        // src_c and src_p are the cluster index and the pixel index for B
446        int src_c = p / pixels_per_cluster;
447        int src_p = p % pixels_per_cluster;
448
449        int sum_l;
450
451        // We use the specific values of the vertical ep-filter
452        // To minimize the number of tests, the NL lines are split in three domains
453
454        // first domain : explicit computation for the first 18 values
455        for (l = 0; l < 18; l++)
456        {
457            // dst_c and dst_l are the cluster index and the line index for C
458            int dst_c = l / lines_per_cluster;
459            int dst_l = l % lines_per_cluster;
460
461            for (z = 0, sum_l = 0; z < 35; z++)
462            {
463                sum_l = sum_l + vf[z] * TB(src_c, src_p, max(l - 17 + z,0) );
464            }
465            TC(dst_c, dst_l, p) = sum_l / vnorm;
466        }
467        // second domain
468        for (l = 18; l < NL - 17; l++)
469        {
470            // dst_c and dst_l are the cluster index and the line index for C
471            int dst_c = l / lines_per_cluster;
472            int dst_l = l % lines_per_cluster;
473
474            sum_l = sum_l + TB(src_c, src_p, l + 4)
475                  + TB(src_c, src_p, l + 8)
476                  + TB(src_c, src_p, l + 11)
477                  + TB(src_c, src_p, l + 15)
478                  + TB(src_c, src_p, l + 17)
479                  - TB(src_c, src_p, l - 5)
480                  - TB(src_c, src_p, l - 9)
481                  - TB(src_c, src_p, l - 12)
482                  - TB(src_c, src_p, l - 16)
483                  - TB(src_c, src_p, l - 18);
484
485            TC(dst_c, dst_l, p) = sum_l / vnorm;
486        }
487        // third domain
488        for (l = NL - 17; l < NL; l++)
489        {
490            // dst_c and dst_l are the cluster index and the line index for C
491            int dst_c = l / lines_per_cluster;
492            int dst_l = l % lines_per_cluster;
493
494            sum_l = sum_l + TB(src_c, src_p, min(l + 4, NL - 1))
495                  + TB(src_c, src_p, min(l + 8, NL - 1))
496                  + TB(src_c, src_p, min(l + 11, NL - 1))
497                  + TB(src_c, src_p, min(l + 15, NL - 1))
498                  + TB(src_c, src_p, min(l + 17, NL - 1))
499                  - TB(src_c, src_p, l - 5)
500                  - TB(src_c, src_p, l - 9)
501                  - TB(src_c, src_p, l - 12)
502                  - TB(src_c, src_p, l - 16)
503                  - TB(src_c, src_p, l - 18);
504
505            TC(dst_c, dst_l, p) = sum_l / vnorm;
506        }
507
508#if SUPER_VERBOSE
509giet_shr_printf(" - column %d computed at cycle %d\n", p, giet_proctime());
510#endif
511
512    }
513
514    date  = giet_proctime();
515    V_END[cluster_id][lpid] = date;
516
517#if VERBOSE
518giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] completes vertical filter"
519                 " at cycle %d\n",
520                 x, y, lpid, date );
521#else
522if ( pid == 0 ) giet_shr_printf( "\n[CONVOL] task[0,0,0] completes vertical filter"
523                                 " at cycle %d\n", date );
524#endif
525
526#if USE_SBT_BARRIER
527        sbt_barrier_wait( &barrier );
528#else
529        barrier_wait( &barrier );
530#endif
531
532    ////////////////////////////////////////////////////////////////
533    // Optional parallel display of the final image Z <= D + C
534    // Eah task displays (NL/ntasks) lines. (one byte per pixel).
535    ////////////////////////////////////////////////////////////////
536
537    if ( FINAL_DISPLAY_ENABLE )
538    {
539        date  = giet_proctime();
540        D_BEG[cluster_id][lpid] = date;
541
542#if VERBOSE
543giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] starts final display"
544                 " at cycle %d\n",
545                 x, y, lpid, date);
546#else
547if ( pid == 0 ) giet_shr_printf( "\n[CONVOL] task[0,0,0] starts final display"
548                                 " at cycle %d\n", date );
549#endif
550
551        unsigned int line;
552        unsigned int offset = lines_per_task * lpid;
553
554        for ( l = 0 ; l < lines_per_task ; l++ )
555        {
556            line = offset + l;
557
558            for ( p = 0 ; p < NP ; p++ )
559            {
560                TZ(cluster_id, line, p) = 
561                   (unsigned char)( (TD(cluster_id, line, p) + 
562                                     TC(cluster_id, line, p) ) >> 8 );
563            }
564
565            giet_fb_sync_write( NP*(l + (task_id * lines_per_task) ), 
566                                &TZ(cluster_id, line, 0), 
567                                NP);
568        }
569
570        date  = giet_proctime();
571        D_END[cluster_id][lpid] = date;
572
573#if VERBOSE
574giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] completes final display"
575                 " at cycle %d\n",
576                 x, y, lpid, date);
577#else
578if ( pid == 0 ) giet_shr_printf( "\n[CONVOL] task[0,0,0] completes final display"
579                                 " at cycle %d\n", date );
580#endif
581     
582#if USE_SBT_BARRIER
583        sbt_barrier_wait( &barrier );
584#else
585        barrier_wait( &barrier );
586#endif
587
588    }
589
590    /////////////////////////////////////////////////////////
591    // Task[0,0,0] makes the instrumentation
592    /////////////////////////////////////////////////////////
593
594    if ( pid == 0 )
595    {
596        date  = giet_proctime();
597        giet_shr_printf("\n[CONVOL] task[0,0,0] starts instrumentation"
598                        " at cycle %d\n\n", date );
599
600        int cc, pp;
601
602        unsigned int min_start = 0xFFFFFFFF;
603        unsigned int max_start = 0;
604
605        unsigned int min_h_beg = 0xFFFFFFFF;
606        unsigned int max_h_beg = 0;
607
608        unsigned int min_h_end = 0xFFFFFFFF;
609        unsigned int max_h_end = 0;
610
611        unsigned int min_v_beg = 0xFFFFFFFF;
612        unsigned int max_v_beg = 0;
613
614        unsigned int min_v_end = 0xFFFFFFFF;
615        unsigned int max_v_end = 0;
616
617        unsigned int min_d_beg = 0xFFFFFFFF;
618        unsigned int max_d_beg = 0;
619
620        unsigned int min_d_end = 0xFFFFFFFF;
621        unsigned int max_d_end = 0;
622
623        for (cc = 0; cc < nclusters; cc++)
624        {
625            for (pp = 0; pp < nprocs; pp++ )
626            {
627                if (START[cc][pp] < min_start) min_start = START[cc][pp];
628                if (START[cc][pp] > max_start) max_start = START[cc][pp];
629
630                if (H_BEG[cc][pp] < min_h_beg) min_h_beg = H_BEG[cc][pp];
631                if (H_BEG[cc][pp] > max_h_beg) max_h_beg = H_BEG[cc][pp];
632
633                if (H_END[cc][pp] < min_h_end) min_h_end = H_END[cc][pp];
634                if (H_END[cc][pp] > max_h_end) max_h_end = H_END[cc][pp];
635
636                if (V_BEG[cc][pp] < min_v_beg) min_v_beg = V_BEG[cc][pp];
637                if (V_BEG[cc][pp] > max_v_beg) max_v_beg = V_BEG[cc][pp];
638
639                if (V_END[cc][pp] < min_v_end) min_v_end = V_END[cc][pp];
640                if (V_END[cc][pp] > max_v_end) max_v_end = V_END[cc][pp];
641
642                if (D_BEG[cc][pp] < min_d_beg) min_d_beg = D_BEG[cc][pp];
643                if (D_BEG[cc][pp] > max_d_beg) max_d_beg = D_BEG[cc][pp];
644
645                if (D_END[cc][pp] < min_d_end) min_d_end = D_END[cc][pp];
646                if (D_END[cc][pp] > max_d_end) max_d_end = D_END[cc][pp];
647            }
648        }
649
650        giet_shr_printf(" - START : min = %d / max = %d / med = %d / delta = %d\n",
651               min_start, max_start, (min_start+max_start)/2, max_start-min_start);
652
653        giet_shr_printf(" - H_BEG : min = %d / max = %d / med = %d / delta = %d\n",
654               min_h_beg, max_h_beg, (min_h_beg+max_h_beg)/2, max_h_beg-min_h_beg);
655
656        giet_shr_printf(" - H_END : min = %d / max = %d / med = %d / delta = %d\n",
657               min_h_end, max_h_end, (min_h_end+max_h_end)/2, max_h_end-min_h_end);
658
659        giet_shr_printf(" - V_BEG : min = %d / max = %d / med = %d / delta = %d\n",
660               min_v_beg, max_v_beg, (min_v_beg+max_v_beg)/2, max_v_beg-min_v_beg);
661
662        giet_shr_printf(" - V_END : min = %d / max = %d / med = %d / delta = %d\n",
663               min_v_end, max_v_end, (min_v_end+max_v_end)/2, max_v_end-min_v_end);
664
665        giet_shr_printf(" - D_BEG : min = %d / max = %d / med = %d / delta = %d\n",
666               min_d_beg, max_d_beg, (min_d_beg+max_d_beg)/2, max_d_beg-min_d_beg);
667
668        giet_shr_printf(" - D_END : min = %d / max = %d / med = %d / delta = %d\n",
669               min_d_end, max_d_end, (min_d_end+max_d_end)/2, max_d_end-min_d_end);
670
671        giet_shr_printf( "\n General Scenario (Kcycles for each step)\n" );
672        giet_shr_printf( " - BOOT OS           = %d\n", (min_start            )/1000 );
673        giet_shr_printf( " - LOAD IMAGE        = %d\n", (min_h_beg - min_start)/1000 );
674        giet_shr_printf( " - H_FILTER          = %d\n", (max_h_end - min_h_beg)/1000 );
675        giet_shr_printf( " - BARRIER HORI/VERT = %d\n", (min_v_beg - max_h_end)/1000 );
676        giet_shr_printf( " - V_FILTER          = %d\n", (max_v_end - min_v_beg)/1000 );
677        giet_shr_printf( " - BARRIER VERT/DISP = %d\n", (min_d_beg - max_v_end)/1000 );
678        giet_shr_printf( " - DISPLAY           = %d\n", (max_d_end - min_d_beg)/1000 );
679
680        instrumentation_ok = 1;
681    }
682    else
683    {
684        while ( instrumentation_ok == 0 );
685    }
686
687    giet_exit( "completed");
688
689} // end main()
690
691// Local Variables:
692// tab-width: 3
693// c-basic-offset: 3
694// c-file-offsets:((innamespace . 0)(inline-open . 0))
695// indent-tabs-mode: nil
696// End:
697
698// vim: filetype=cpp:expandtab:shiftwidth=3:tabstop=3:softtabstop=3
699
700
Note: See TracBrowser for help on using the repository browser.