Index: soft/giet_vm/convol/main.c
===================================================================
--- soft/giet_vm/convol/main.c	(revision 345)
+++ soft/giet_vm/convol/main.c	(revision 353)
@@ -9,12 +9,14 @@
 #include "hard_config.h"
 #include "stdio.h"
+#include "stdlib.h"
 #include "barrier.h"
 
-#define VERBOSE                    1
-
-#define INITIAL_DISPLAY_ENABLE     1
+#define VERBOSE                    0
+#define SUPER_VERBOSE              0
+
+#define INITIAL_DISPLAY_ENABLE     0
 #define FINAL_DISPLAY_ENABLE       1
 
-#define NB_CLUSTERS_MAX            (X_SIZE * Y_SIZE)
+#define NB_CLUSTERS                (X_SIZE * Y_SIZE)
 #define PIXEL_SIZE                 2
 #define NL                         1024
@@ -33,11 +35,11 @@
 
 // instrumentation counters indexed by (cluster_id, lpid]
-unsigned int START[NB_CLUSTERS_MAX][NB_PROCS_MAX];
-unsigned int H_BEG[NB_CLUSTERS_MAX][NB_PROCS_MAX];
-unsigned int H_END[NB_CLUSTERS_MAX][NB_PROCS_MAX];
-unsigned int V_BEG[NB_CLUSTERS_MAX][NB_PROCS_MAX];
-unsigned int V_END[NB_CLUSTERS_MAX][NB_PROCS_MAX];
-unsigned int D_BEG[NB_CLUSTERS_MAX][NB_PROCS_MAX];
-unsigned int D_END[NB_CLUSTERS_MAX][NB_PROCS_MAX];
+unsigned int START[NB_CLUSTERS][NB_PROCS_MAX];
+unsigned int H_BEG[NB_CLUSTERS][NB_PROCS_MAX];
+unsigned int H_END[NB_CLUSTERS][NB_PROCS_MAX];
+unsigned int V_BEG[NB_CLUSTERS][NB_PROCS_MAX];
+unsigned int V_END[NB_CLUSTERS][NB_PROCS_MAX];
+unsigned int D_BEG[NB_CLUSTERS][NB_PROCS_MAX];
+unsigned int D_END[NB_CLUSTERS][NB_PROCS_MAX];
 
 // synchronization barriers
@@ -50,32 +52,4 @@
 volatile unsigned int exit_ok = 0;
 
-//////////////////////////////////////////////////////
-// Required by GCC when initializing an array 
-//////////////////////////////////////////////////////
-static void *memcpy( void *        _dst, 
-                     const void *  _src, 
-                     unsigned int  size )
-{
-    unsigned int         *dst = _dst;
-    const unsigned int   *src = _src;
-
-    if (! ((unsigned int)dst & 3) && ! ((unsigned int)src & 3))
-    {
-        while (size > 3)
-        {
-            *dst++ = *src++;
-            size -= 4;
-        }
-    }
-
-    unsigned char *cdst = (unsigned char*)dst;
-    unsigned char *csrc = (unsigned char*)src;
-
-    while ( size-- )
-    {
-        *cdst++ = *csrc++;
-    }
-    return _dst;
-}
 
 ///////////////////////////////////////////
@@ -108,8 +82,8 @@
     int z; // vertical filter index for loops
 
-    int          file;                                        // file descriptor
+    int          file        = 0;                             // file descriptor
     unsigned int pid         = giet_procid();                 // processor id
     unsigned int nprocs      = NB_PROCS_MAX;                  // procs per cluster
-    unsigned int nclusters   = NB_CLUSTERS_MAX;               // number of clusters
+    unsigned int nclusters   = NB_CLUSTERS;               // number of clusters
     unsigned int lpid        = pid % nprocs;                  // local task id
     unsigned int cluster_xy  = pid / nprocs;                  // cluster index
@@ -131,7 +105,9 @@
 
     date = giet_proctime();
-    giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] starts at cycle %d\n",
-                     x,y,lpid, date );
     START[cluster_id][lpid] = date;
+
+#if VERBOSE
+giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] starts at cycle %d\n", x,y,lpid, date );
+#endif
 
      // parameters checking 
@@ -159,9 +135,9 @@
     ///////////////////////////////////////////////////////////////////
 
-    unsigned short * A[NB_CLUSTERS_MAX];
-    int *            B[NB_CLUSTERS_MAX];
-    int *            C[NB_CLUSTERS_MAX];
-    int *            D[NB_CLUSTERS_MAX];
-    unsigned char *  Z[NB_CLUSTERS_MAX];
+    unsigned short * A[NB_CLUSTERS];
+    int *            B[NB_CLUSTERS];
+    int *            C[NB_CLUSTERS];
+    int *            D[NB_CLUSTERS];
+    unsigned char *  Z[NB_CLUSTERS];
 
     // get heap vaddr in cluster[0,0]
@@ -182,15 +158,14 @@
         Z[c] = (unsigned char *)  (cluster_offset + (frame_size * 7 / nclusters));
 
-        if ( pid == 0  && VERBOSE )
-        {
-            giet_shr_printf( "\n########################################\n"
-                             "### A[%d] = %x\n"
-                             "### B[%d] = %x\n"               
-                             "### C[%d] = %x\n"               
-                             "### D[%d] = %x\n"               
-                             "### Z[%d] = %x\n"               
-                             "########################################\n",
-                             c,A[c],c,B[c],c,C[c],c,D[c],c,Z[c] );
-        }
+#if VERBOSE
+if ( pid == 0 ) giet_shr_printf( "\n########################################\n"
+                                 "### A[%d] = %x\n"
+                                 "### B[%d] = %x\n"               
+                                 "### C[%d] = %x\n"               
+                                 "### D[%d] = %x\n"               
+                                 "### Z[%d] = %x\n"               
+                                 "########################################\n",
+                                 c,A[c],c,B[c],c,C[c],c,D[c],c,Z[c] );
+#endif
     }
 
@@ -230,10 +205,9 @@
                          " at cycle %d\n", giet_proctime() );
 
-        for ( c = 0 ; c < nclusters ; c++ )
-        {
-            giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] starts load"
-                             " for cluster %d at cycle %d\n",
-                             x, y, lpid, c, giet_proctime() );
-        
+        for ( c = 0 ; c < NB_CLUSTERS ; c++ )
+        {
+            giet_shr_printf( "\n[CONVOL] task[0,0,0] starts load "
+                             "for cluster %d at cycle %d\n", c, giet_proctime() );
+
             giet_fat_read( file,
                            A[c],
@@ -241,7 +215,6 @@
                            (nblocks/nclusters)*c );
 
-            giet_shr_printf( "[CONVOL] task[%d,%d,%d] completes load"
-                             " for cluster %d at cycle %d\n",
-                             x, y, lpid, c, giet_proctime() );
+            giet_shr_printf( "\n[CONVOL] task[0,0,0] completes load "
+                             "for cluster %d at cycle %d\n", c, giet_proctime() );
         }
         init_ok = 1;
@@ -259,7 +232,10 @@
     if ( INITIAL_DISPLAY_ENABLE )
     {
-        date = giet_proctime();
-        giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] starts initial display at cycle %d\n",
-                         x, y, lpid, date);
+
+#if VERBOSE
+giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] starts initial display"
+                 " at cycle %d\n",
+                 x, y, lpid, giet_proctime() );
+#endif
 
         unsigned int line;
@@ -280,7 +256,9 @@
         }
 
-        date = giet_proctime();
-        giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] completes initial display at cycle %d\n",
-                         x, y, lpid, date);
+#if VERBOSE 
+giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] completes initial display"
+                 " at cycle %d\n",
+                 x, y, lpid, giet_proctime() );
+#endif
 
         ///////////////////////////
@@ -300,7 +278,14 @@
 
     date  = giet_proctime();
-    giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] starts horizontal filter at cycle %d\n",
-            x, y, lpid, date );
     H_BEG[cluster_id][lpid] = date;
+
+#if VERBOSE 
+giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] starts horizontal filter"
+                 " at cycle %d\n",
+                 x, y, lpid, date );
+#else
+if ( pid == 0 ) giet_shr_printf( "\n[CONVOL] task[0,0,0] starts horizontal filter"
+                                 " at cycle %d\n", date );
+#endif
 
     // l = absolute line index / p = absolute pixel index  
@@ -359,19 +344,26 @@
         }
 
-        if ( VERBOSE )
-        {
-            giet_shr_printf(" - line %d computed at cycle %d\n", l, giet_proctime() );
-        }
+#if SUPER_VERBOSE
+giet_shr_printf(" - line %d computed at cycle %d\n", l, giet_proctime() );
+#endif    
+
     }
 
     date  = giet_proctime();
-    giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] completes horizontal filter at cycle %d\n",
-            x, y, lpid, date );
     H_END[cluster_id][lpid] = date;
+
+#if VERBOSE 
+giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] completes horizontal filter"
+                 " at cycle %d\n",
+                 x, y, lpid, date );
+#else
+if ( pid == 0 ) giet_shr_printf( "\n[CONVOL] task[0,0,0] completes horizontal filter"
+                                 " at cycle %d\n", date );
+#endif
 
     ///////////////////////////
     barrier_wait( &barrier_2 );
 
-    //////////////////////////////////////////////////////////
+    ///////////////////////////////////////////////////////////////
     // parallel vertical filter : 
     // C <= transpose(FV(B))
@@ -380,10 +372,17 @@
     // if (l<0)    TB(cluster_id,p,l) == TB(cluster_id,p,0)
     // if (l>NL-1)   TB(cluster_id,p,l) == TB(cluster_id,p,NL-1)
-    //////////////////////////////////////////////////////////
+    ///////////////////////////////////////////////////////////////
 
     date  = giet_proctime();
-    giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] starts vertical filter at cycle %d\n",
-            x, y, lpid, date );
     V_BEG[cluster_id][lpid] = date;
+
+#if VERBOSE 
+giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] starts vertical filter"
+                 " at cycle %d\n",
+                 x, y, lpid, date );
+#else
+if ( pid == 0 ) giet_shr_printf( "\n[CONVOL] task[0,0,0] starts vertical filter"
+                                 " at cycle %d\n", date );
+#endif
 
     // l = absolute line index / p = absolute pixel index
@@ -458,14 +457,21 @@
         }
 
-        if ( VERBOSE )
-        {
-            giet_shr_printf(" - column %d computed at cycle %d\n", p, giet_proctime());
-        }
+#if SUPER_VERBOSE
+giet_shr_printf(" - column %d computed at cycle %d\n", p, giet_proctime());
+#endif 
+
     }
 
     date  = giet_proctime();
-    giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] completes vertical filter at cycle %d\n",
-            x, y, lpid, date );
     V_END[cluster_id][lpid] = date;
+
+#if VERBOSE 
+giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] completes vertical filter"
+                 " at cycle %d\n",
+                 x, y, lpid, date );
+#else
+if ( pid == 0 ) giet_shr_printf( "\n[CONVOL] task[0,0,0] completes vertical filter"
+                                 " at cycle %d\n", date );
+#endif
 
     ///////////////////////////
@@ -480,7 +486,14 @@
     {
         date  = giet_proctime();
-        giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] starts final display at cycle %d\n",
-                         x, y, lpid, date);
         D_BEG[cluster_id][lpid] = date;
+
+#if VERBOSE
+giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] starts final display"
+                 " at cycle %d\n",
+                 x, y, lpid, date);
+#else
+if ( pid == 0 ) giet_shr_printf( "\n[CONVOL] task[0,0,0] starts final display"
+                                 " at cycle %d\n", date );
+#endif
 
         unsigned int line;
@@ -504,7 +517,14 @@
 
         date  = giet_proctime();
-        giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] completes final display at cycle %d\n",
-            x, y, lpid, date);
         D_END[cluster_id][lpid] = date;
+
+#if VERBOSE
+giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] completes final display"
+                 " at cycle %d\n",
+                 x, y, lpid, date);
+#else
+if ( pid == 0 ) giet_shr_printf( "\n[CONVOL] task[0,0,0] completes final display"
+                                 " at cycle %d\n", date );
+#endif
      
         ///////////////////////////
@@ -519,5 +539,6 @@
     {
         date  = giet_proctime();
-        giet_shr_printf("\n*** Starting Instrumentation at cycle %d\n\n", date);
+        giet_shr_printf("\n[CONVOL] task[0,0,0] starts instrumentation"
+                        " at cycle %d\n\n", date );
 
         int cc, pp;
@@ -577,5 +598,5 @@
                min_h_beg, max_h_beg, (min_h_beg+max_h_beg)/2, max_h_beg-min_h_beg);
 
-        giet_shr_printf(" - H_END   : min = %d / max = %d / med = %d / delta = %d\n",
+        giet_shr_printf(" - H_END : min = %d / max = %d / med = %d / delta = %d\n",
                min_h_end, max_h_end, (min_h_end+max_h_end)/2, max_h_end-min_h_end);
 
@@ -583,5 +604,5 @@
                min_v_beg, max_v_beg, (min_v_beg+max_v_beg)/2, max_v_beg-min_v_beg);
 
-        giet_shr_printf(" - V_END   : min = %d / max = %d / med = %d / delta = %d\n",
+        giet_shr_printf(" - V_END : min = %d / max = %d / med = %d / delta = %d\n",
                min_v_end, max_v_end, (min_v_end+max_v_end)/2, max_v_end-min_v_end);
 
@@ -589,15 +610,15 @@
                min_d_beg, max_d_beg, (min_d_beg+max_d_beg)/2, max_d_beg-min_d_beg);
 
-        giet_shr_printf(" - D_END   : min = %d / max = %d / med = %d / delta = %d\n",
+        giet_shr_printf(" - D_END : min = %d / max = %d / med = %d / delta = %d\n",
                min_d_end, max_d_end, (min_d_end+max_d_end)/2, max_d_end-min_d_end);
 
         giet_shr_printf( "\n General Scenario (Kcycles for each step)\n" );
-        giet_shr_printf( " - BOOT OS           = %d\n", min_start );
-        giet_shr_printf( " - LOAD IMAGE        = %d\n", min_h_beg - min_start);
-        giet_shr_printf( " - H_FILTER          = %d\n", max_h_end - min_h_beg );
-        giet_shr_printf( " - BARRIER HORI/VERT = %d\n", min_v_beg - max_h_end);
-        giet_shr_printf( " - V_FILTER          = %d\n", max_v_end - min_v_beg );
-        giet_shr_printf( " - BARRIER VERT/DISP = %d\n", min_d_beg - max_v_end);
-        giet_shr_printf( " - DISPLAY           = %d\n", max_d_end - min_d_beg );
+        giet_shr_printf( " - BOOT OS           = %d\n", (min_start            )/1000 );
+        giet_shr_printf( " - LOAD IMAGE        = %d\n", (min_h_beg - min_start)/1000 );
+        giet_shr_printf( " - H_FILTER          = %d\n", (max_h_end - min_h_beg)/1000 );
+        giet_shr_printf( " - BARRIER HORI/VERT = %d\n", (min_v_beg - max_h_end)/1000 );
+        giet_shr_printf( " - V_FILTER          = %d\n", (max_v_end - min_v_beg)/1000 );
+        giet_shr_printf( " - BARRIER VERT/DISP = %d\n", (min_d_beg - max_v_end)/1000 );
+        giet_shr_printf( " - DISPLAY           = %d\n", (max_d_end - min_d_beg)/1000 );
 
         exit_ok = 1;
