Index: trunk/softs/soft_transpose_giet/main.c
===================================================================
--- trunk/softs/soft_transpose_giet/main.c	(revision 620)
+++ trunk/softs/soft_transpose_giet/main.c	(revision 629)
@@ -1,217 +1,269 @@
 
+#include "hard_config.h"
 #include "stdio.h"
 #include "limits.h"
 #include "../giet_tsar/block_device.h"
 
-#define NL              512
-#define NP              512
-#define NB_IMAGES       1
-#define NB_CLUSTER_MAX  256
-
-#define PRINTF(...)      ({ if (proc_id == 0) { tty_printf(__VA_ARGS__); } })
-
-//#define DISPLAY_ONLY
-
-///////////////////////////////////////////
+#define NL              128
+#define NP              128
+#define NB_IMAGES       5
+
+#define PRINTF(...)      ({ if (lpid == 0) { _tty_printf(__VA_ARGS__); } })
+
+#define DISPLAY_OK
+
 // tricks to read parameters from ldscript
-///////////////////////////////////////////
-
-struct plaf;
-
-extern struct plouf seg_ioc_base;
+extern struct plaf seg_ioc_base;
 extern struct plaf seg_heap_base;
-extern struct plaf NB_PROCS;
-extern struct plaf NB_CLUSTERS;
+
+// global variables stored in seg_data (cluster 0)
+
+// instrumentation counters for each processor
+unsigned int LOAD_START[256][4];
+unsigned int LOAD_END  [256][4];
+unsigned int TRSP_START[256][4];
+unsigned int TRSP_END  [256][4];
+unsigned int DISP_START[256][4];
+unsigned int DISP_END  [256][4];
+
+// checksum variables
+unsigned check_line_before[NL];
+unsigned check_line_after[NL];
 
 /////////////
-void main(){
-   unsigned int frame = 0;
-   unsigned int date  = 0;
-
-   unsigned int c; // cluster index for loops
-   unsigned int l; // line index for loops
-   unsigned int p; // pixel index for loops
-
-   unsigned int proc_id       = procid();                      // processor id
-   unsigned int nlocal_procs  = (unsigned int) &NB_PROCS;      // number of processors per cluster
-   unsigned int nclusters     = (unsigned int) &NB_CLUSTERS;   // number of clusters
-   unsigned int local_id      = proc_id % nlocal_procs;        // local processor id
-   unsigned int cluster_id    = proc_id / nlocal_procs;        // cluster id
-   unsigned int base          = (unsigned int) &seg_heap_base; // base address for shared buffers
-   unsigned int increment     = 0x80000000 / nclusters * 2;    // cluster increment
-   unsigned int nglobal_procs = nclusters * nlocal_procs;      // number of tasks
-   unsigned int npixels       = NP * NL;                       // number of pixel per frame
-   
-   unsigned int * ioc_address = (unsigned int *) &seg_ioc_base;
-   unsigned int block_size    = ioc_address[BLOCK_DEVICE_BLOCK_SIZE];
-   unsigned int nblocks       = npixels / block_size;   // number of blocks per frame
-
-   PRINTF("\n *** Entering main at cycle %d ***\n\n", proctime());
+void main()
+{
+    unsigned int image = 0;
+
+    unsigned int l;                                             // line index for loops
+    unsigned int p;                                             // pixel index for loops
+
+    unsigned int * ioc_address = (unsigned int *) &seg_ioc_base;
+    unsigned int block_size    = ioc_address[BLOCK_DEVICE_BLOCK_SIZE];
+
+    unsigned int proc_id     = _procid();                       // processor id
+    unsigned int nclusters   = X_SIZE*Y_SIZE;                   // number of clusters
+    unsigned int lpid        = proc_id % NB_PROCS_MAX;          // local processor id
+    unsigned int cluster_xy  = proc_id / NB_PROCS_MAX;          // cluster index (8 bits format)
+    unsigned int x           = cluster_xy >> Y_WIDTH;           // x coordinate
+    unsigned int y           = cluster_xy & ((1<<Y_WIDTH)-1);   // y coordinate
+    unsigned int ntasks      = nclusters * NB_PROCS_MAX;        // number of tasks
+    unsigned int npixels     = NP * NL;                         // number of pixel per image
+    unsigned int nblocks     = npixels / block_size;            // number of blocks per image
+
+    // task_id is a "continuous" index for the the task running on processor (x,y,lpid)
+    unsigned int task_id = (((x * Y_SIZE) + y) * NB_PROCS_MAX) + lpid;
+
+    // cluster_id is a "continuous" index for cluster(x,y)
+    unsigned int cluster_id  = (x * Y_SIZE) + y;               
+
+    PRINTF("\n *** Proc 0 in cluster [%d,%d] enters main at cycle %d ***\n\n", 
+           x, y, _proctime());
 
    //  parameters checking
-   if ((nlocal_procs != 1) && (nlocal_procs != 2) && (nlocal_procs != 4)){
-      PRINTF("NB_PROCS must be 1, 2 or 4\n");
-      exit(1);
+   if ((NB_PROCS_MAX != 1) && (NB_PROCS_MAX != 2) && (NB_PROCS_MAX != 4))
+   {
+      PRINTF("NB_PROCS_MAX must be 1, 2 or 4\n");
+      _exit();
    }
    if ((nclusters != 1) && (nclusters != 2) && (nclusters != 4) && (nclusters != 8) &&
          (nclusters != 16) && (nclusters != 32) && (nclusters != 64) && (nclusters != 128) &&
-         (nclusters != 256)){
+         (nclusters != 256))
+   {
       PRINTF("NB_CLUSTERS must be a power of 1 between 1 and 256\n");
-      exit(1);
+      _exit();
    }
-   if (nglobal_procs > 1024){
-      PRINTF("NB_PROCS * NB_CLUSTERS cannot be larger than 1024\n");
-      exit(1);
-   }
-   if (proc_id >= nglobal_procs){
-      PRINTF("processor id %d larger than NB_CLUSTERS*NB_PROCS\n", proc_id);
-      exit(1);
-   }
-
-   // Arrays of pointers on the shared, distributed buffers containing the frames 
-   // These arrays are indexed by the cluster index (sized for the worst case : 256 clusters)
-   unsigned char * A[NB_CLUSTER_MAX];
-   unsigned char * B[NB_CLUSTER_MAX];
-
-   // Arrays of pointers on the instrumentation arrays
-   // These arrays are indexed by the cluster index (sized for the worst case : 256 clusters)
-   // each pointer points on the base adress of an array of NPROCS unsigned int
-   unsigned int * LOAD_START[NB_CLUSTER_MAX];
-   unsigned int * LOAD_END[NB_CLUSTER_MAX];
-   unsigned int * TRSP_START[NB_CLUSTER_MAX];
-   unsigned int * TRSP_END[NB_CLUSTER_MAX];
-   unsigned int * DISP_START[NB_CLUSTER_MAX];
-   unsigned int * DISP_END[NB_CLUSTER_MAX];
-
-   // shared buffers address definition 
-   // from the seg_heap_base and increment depending on the cluster index
-   // These arrays of pointers are identical and replicated in the stack of each task 
-   for (c = 0; c < nclusters; c++){
-      A[c]          = (unsigned char *) (base                                  + increment * c);
-      B[c]          = (unsigned char *) (base +     npixels                    + increment * c);
-      LOAD_START[c] = (unsigned int *)  (base + 2 * npixels                    + increment * c);
-      LOAD_END[c]   = (unsigned int *)  (base + 2 * npixels +     nlocal_procs + increment * c);
-      TRSP_START[c] = (unsigned int *)  (base + 2 * npixels + 2 * nlocal_procs + increment * c);
-      TRSP_END[c]   = (unsigned int *)  (base + 2 * npixels + 3 * nlocal_procs + increment * c);
-      DISP_START[c] = (unsigned int *)  (base + 2 * npixels + 4 * nlocal_procs + increment * c);
-      DISP_END[c]   = (unsigned int *)  (base + 2 * npixels + 5 * nlocal_procs + increment * c);
-   }
+
+   // pointers on the distributed buffers containing the images, 
+   // allocated in the heap segment: each buffer contains 256 Kbytes
+   unsigned char* buf_in  = (unsigned char*)&seg_heap_base;
+   unsigned char* buf_out = buf_in + 0x00100000;
 
    PRINTF("NB_CLUSTERS     = %d\n", nclusters); 
-   PRINTF("NB_LOCAL_PROCS  = %d\n", nlocal_procs); 
-   PRINTF("NB_GLOBAL_PROCS = %d\n", nglobal_procs);
+   PRINTF("NB_LOCAL_PROCS  = %d\n", NB_PROCS_MAX); 
+   PRINTF("NB_TASKS        = %d\n", ntasks);
    PRINTF("NB_PIXELS       = %d\n", npixels);
    PRINTF("BLOCK_SIZE      = %d\n", block_size);
    PRINTF("NB_BLOCKS       = %d\n\n", nblocks);
 
-
-   PRINTF("*** Starting barrier init at cycle %d ***\n", proctime());
+   PRINTF("*** Proc 0 in cluster [%d,%d] starts barrier init at cycle %d\n", 
+          x, y, _proctime());
 
    //  barriers initialization
-   barrier_init(0, nglobal_procs);
-   barrier_init(1, nglobal_procs);
-   barrier_init(2, nglobal_procs);
-
-   PRINTF("*** Completing barrier init at cycle %d ***\n", proctime());
-
-   // Main loop (on frames)
-   while (frame < NB_IMAGES){
-      // pseudo parallel load from disk to A[c] buffer : nblocks/nclusters blocks
-      // only task running on processor with (local_id == 0) does it
-
-      if (local_id == 0){
-         int p;
-
-         date = proctime();
-         PRINTF("\n*** Starting load for frame %d at cycle %d\n", frame, date);
+   _barrier_init(0, ntasks);
+   _barrier_init(1, ntasks);
+   _barrier_init(2, ntasks);
+   _barrier_init(3, ntasks);
+
+   PRINTF("*** Proc 0 in cluster [%d,%d] completes barrier init at cycle %d\n",
+          x, y, _proctime());
+
+   // Main loop (on images)
+   while (image < NB_IMAGES)
+   {
+      // pseudo parallel load from disk to buf_in buffer : nblocks/nclusters blocks
+      // only task running on processor with (lpid == 0) does it
+
+      LOAD_START[cluster_id][lpid] = _proctime();
+
+      if (lpid == 0)
+      {
+         _ioc_read( ((image * nblocks) + ((nblocks * cluster_id) / nclusters)), 
+                    buf_in,
+                    (nblocks / nclusters),
+                    cluster_xy );
+
+         PRINTF("\n*** Proc 0 in cluster [%d,%d] starts load for image %d at cycle %d\n",
+                x, y, image, _proctime() );
+
+         _ioc_completed();
+
+         PRINTF("*** Proc 0 in cluster [%d,%d] completes load for image %d at cycle %d\n",
+                x, y, image, _proctime() );
+      }
+
+      LOAD_END[cluster_id][lpid] = _proctime();
+
+      _barrier_wait(0);
+
+      // parallel transpose from buf_in to buf_out buffers
+      // each processor makes the transposition for (NL/ntasks) lines
+      // (p,l) are the pixel coordinates in the source image
+
+      PRINTF("\n*** proc 0 in cluster [%d,%d] starts transpose for image %d at cycle %d\n", 
+             x, y, image, _proctime());
+
+      TRSP_START[cluster_id][lpid] = _proctime();
+
+      unsigned int nlt   = NL / ntasks;                // number of lines per processor
+      unsigned int first = task_id * nlt;              // first line index
+      unsigned int last  = first + nlt;                // last line index
+      unsigned int nlines_clusters = NL / nclusters;   // number of lines per cluster
+      unsigned int npix_clusters   = NP / nclusters;   // number of pixels per cluster
+
+      unsigned int src_cluster;
+      unsigned int src_index;
+      unsigned int dst_cluster;
+      unsigned int dst_index;
+
+      unsigned int word;
+
+      for (l = first; l < last; l++)
+      {
+         PRINTF("    - processing line %d\n", l);
+
+         check_line_before[l] = 0;
          
-         for (p = 0; p < nlocal_procs; p++){
-            LOAD_START[cluster_id][p] = date;
-         }
-         if (ioc_read(frame * nblocks + nblocks * cluster_id / nclusters, A[cluster_id], nblocks / nclusters)){
-            PRINTF("echec ioc_read\n");
-            exit();
-         }
-         if (ioc_completed()){
-            PRINTF("echec ioc_completed\n");
-            exit();
-         }
-
-         date = proctime();
-         PRINTF("*** Completing load for frame %d at cycle %d\n", frame, date);
-         for (p = 0; p < nlocal_procs; p++){
-            LOAD_END[cluster_id][p] = date;
+         // in each iteration we read one word an write four bytes
+         for (p = 0 ; p < NP ; p = p+4)
+         {
+            // read one word, with extended address from local buffer
+            src_cluster = cluster_xy;
+            src_index   = (l % nlines_clusters) * NP + p;
+            word = _word_extended_read( src_cluster, 
+                                        (unsigned int)&buf_in[src_index] );
+
+            unsigned char byte0 = (unsigned char)( word      & 0x000000FF);
+            unsigned char byte1 = (unsigned char)((word>>8)  & 0x000000FF);
+            unsigned char byte2 = (unsigned char)((word>>16) & 0x000000FF);
+            unsigned char byte3 = (unsigned char)((word>>24) & 0x000000FF);
+
+            // compute checksum
+            check_line_before[l] = check_line_before[l] + byte0 + byte1 + byte2 + byte3;
+
+            // write four bytes with extended address to four remote buffers
+            dst_cluster = (((p / npix_clusters) / Y_SIZE) << Y_WIDTH) + 
+                           ((p / npix_clusters) % Y_SIZE);
+            dst_index   = (p % npix_clusters) * NL + l;
+            _byte_extended_write( dst_cluster, 
+                                  (unsigned int)&buf_out[dst_index], 
+                                  byte0 );
+
+            dst_cluster = ((((p+1) / npix_clusters) / Y_SIZE) << Y_WIDTH) + 
+                           (((p+1) / npix_clusters) % Y_SIZE);
+            dst_index   = ((p+1) % npix_clusters) * NL + l;
+            _byte_extended_write( dst_cluster, 
+                                  (unsigned int)&buf_out[dst_index], 
+                                  byte1 );
+
+            dst_cluster = ((((p+2) / npix_clusters) / Y_SIZE) << Y_WIDTH) + 
+                           (((p+2) / npix_clusters) % Y_SIZE);
+            dst_index   = ((p+2) % npix_clusters) * NL + l;
+            _byte_extended_write( dst_cluster, 
+                                  (unsigned int)&buf_out[dst_index], 
+                                  byte2 );
+
+            dst_cluster = ((((p+3) / npix_clusters) / Y_SIZE) << Y_WIDTH) + 
+                           (((p+3) / npix_clusters) % Y_SIZE);
+            dst_index   = ((p+3) % npix_clusters) * NL + l;
+            _byte_extended_write( dst_cluster, 
+                                  (unsigned int)&buf_out[dst_index], 
+                                  byte3 );
          }
       }
 
-      barrier_wait(0);
-
-      // parallel transpose from A to B buffers
-      // each processor makes the transposition for (NL/nglobal_procs) lines
-      // (p,l) are the (x,y) pixel coordinates in the source frame
-
-#ifndef DISPLAY_ONLY
-      date = proctime();
-      PRINTF("\n*** Starting transpose for frame %d at cycle %d\n", frame, date);
-      TRSP_START[cluster_id][local_id] = date;
-
-      unsigned int nlt   = NL / nglobal_procs; // Nombre de ligne Ã  traiter par processeur
-      unsigned int first = proc_id * nlt;      // Index de la premiÃšre ligne Ã  traiter pour le proc courant (celui qui exÃ©cute le code)
-      unsigned int last  = first + nlt;        // Index de la derniÃšre ligne
-      unsigned int nlines_clusters = NL / nclusters; // Nombre de lignes Ã  traiter par cluster
-      unsigned int npix_clusters   = NP / nclusters; // Nombre de pixels par ligne Ã  traiter par cluster
-
-      for (l = first; l < last; l++){
-         PRINTF("    - processing line %d\n", l);
-         for (p = 0; p < NP; p++){
-            unsigned int source_index   = (l % nlines_clusters) * NP + p;
-            unsigned int dest_cluster   = p / npix_clusters;
-            unsigned int dest_index     = (p % npix_clusters) * NL + l;
-            B[dest_cluster][dest_index] = A[cluster_id][source_index];
+      PRINTF("*** proc 0 in cluster [%d,%d] complete transpose for image %d at cycle %d\n", 
+             x, y, image, _proctime() );
+
+      TRSP_END[cluster_id][lpid] = _proctime();
+
+      _barrier_wait(1);
+
+      // optional parallel display from local buf_out to frame buffer
+
+#ifdef DISPLAY_OK
+
+      PRINTF("\n*** proc 0 in cluster [%d,%d] starts display for image %d at cycle %d\n", 
+             x, y, image, _proctime() );
+
+      DISP_START[cluster_id][lpid] = _proctime();
+
+      unsigned int npxt = npixels / ntasks;   // number of pixels per task
+      unsigned int buffer = (unsigned int)buf_out + npxt*lpid;
+
+      _fb_sync_write( npxt * task_id, buffer, npxt, cluster_xy );
+
+      PRINTF("*** Proc 0 in cluster [%d,%d] completes display for image %d at cycle %d\n",
+             x, y, image, _proctime() );
+
+      DISP_END[cluster_id][lpid] = _proctime();
+
+      _barrier_wait(2);
+
+#endif
+
+      // Instrumentation and checksum (done by processor 0 in cluster 0)
+      if (proc_id == 0)
+      { 
+         PRINTF("\n*** Proc [0,0,0] starts checks for image %d at cycle %d\n\n",
+                  image, _proctime() );
+
+         unsigned int success = 1;
+
+         for ( l = 0 ; l < NL ; l++ )
+         {
+            check_line_after[l] = 0;
+
+            for ( p = 0 ; p < NP ; p++ )
+            {
+               // read one byte in remote buffer
+               src_cluster = (((p / npix_clusters) / Y_SIZE) << Y_WIDTH) +
+                             ((p / npix_clusters) % Y_SIZE);
+               src_index   = (p % npix_clusters) * NL + l;
+
+               unsigned char byte = _byte_extended_read( src_cluster,
+                                                         (unsigned int)&buf_out[src_index] );
+
+               check_line_after[l] = check_line_after[l] + byte;
+            }
+
+            PRINTF(" - l = %d / before = %d / after = %d \n",
+                   l, check_line_before[l], check_line_after[l] );
+
+            if ( check_line_before[l] != check_line_after[l] ) success = 0;
          }
-      }
-
-      date = proctime();
-      PRINTF("*** Completing transpose for frame %d at cycle %d\n", frame, date);
-      TRSP_END[cluster_id][local_id] = date;
-      barrier_wait(1);
-#endif
-
-      // parallel display from B[c] to frame buffer 
-      // each processor uses its private dma to display NL*NP/nglobal_procs pixels
-
-      date = proctime();
-      PRINTF("\n*** Starting display for frame %d at cycle %d\n", frame, date);
-      DISP_START[cluster_id][local_id] = date;
-
-      unsigned int npxt = npixels / nglobal_procs;   // number of pixels per proc
-
-#ifndef DISPLAY_ONLY
-      if (fb_write(npxt * proc_id, B[cluster_id] + npxt * local_id, npxt)){
-         PRINTF("[%d]: echec fb_sync_write\n", proc_id);
-         exit();
-      }
-#else
-      if (fb_write(npxt * proc_id, A[cluster_id] + npxt * local_id, npxt)){
-         PRINTF("[%d]: echec fb_sync_write\n", proc_id);
-         exit();
-      }
-#endif
-
-      if (fb_completed()){
-         PRINTF("[%d]: echec fb_completed\n", proc_id);
-         exit();
-      }
-
-      date = proctime();
-      PRINTF("*** Completing display for frame %d at cycle %d\n", frame, date);
-      DISP_END[cluster_id][local_id] = date;
-
-      barrier_wait(2);
-
-      // Instrumentation (done by processor 0 in cluster 0)
-      if (local_id == 0){ 
-         date = proctime();
-         PRINTF("\n*** Starting Instrumentation for frame %d at cycle %d\n\n", frame, date);
+
+         if ( success ) PRINTF("\n*** proc [0,0,0] : CHECKSUM OK \n\n");
+         else           PRINTF("\n*** proc [0,0,0] : CHECKSUM KO \n\n");
 
          int cc, pp;
@@ -229,71 +281,56 @@
          unsigned int max_disp_ended = 0;
 
-         for (cc = 0; cc < nclusters; cc++){
-            for (pp = 0; pp < nlocal_procs; pp++){
-               if (LOAD_START[cc][pp] < min_load_start){
-                  min_load_start = LOAD_START[cc][pp];
-               }
-               if (LOAD_START[cc][pp] > max_load_start){
-                  max_load_start = LOAD_START[cc][pp];
-               }
-               if (LOAD_END[cc][pp] < min_load_ended){
-                  min_load_ended = LOAD_END[cc][pp];
-               }
-               if (LOAD_END[cc][pp] > max_load_ended){
-                  max_load_ended = LOAD_END[cc][pp];
-               }
-
-               if (TRSP_START[cc][pp] < min_trsp_start){
-                  min_trsp_start = TRSP_START[cc][pp];
-               }
-               if (TRSP_START[cc][pp] > max_trsp_start){
-                  max_trsp_start = TRSP_START[cc][pp];
-               }
-               if (TRSP_END[cc][pp] < min_trsp_ended){
-                  min_trsp_ended = TRSP_END[cc][pp];
-               }
-               if (TRSP_END[cc][pp] > max_trsp_ended){
-                  max_trsp_ended = TRSP_END[cc][pp];
-               }
-
-               if (DISP_START[cc][pp] < min_disp_start){
-                  min_disp_start = DISP_START[cc][pp];
-               }
-               if (DISP_START[cc][pp] > max_disp_start){
-                  max_disp_start = DISP_START[cc][pp];
-               }
-               if (DISP_END[cc][pp] < min_disp_ended){
-                  min_disp_ended = DISP_END[cc][pp];
-               }
-               if (DISP_END[cc][pp] > max_disp_ended){
-                  max_disp_ended = DISP_END[cc][pp];
-               }
+         for (cc = 0; cc < nclusters; cc++)
+         {
+            for (pp = 0; pp < NB_PROCS_MAX; pp++)
+            {
+               if (LOAD_START[cc][pp] < min_load_start)  min_load_start = LOAD_START[cc][pp];
+               if (LOAD_START[cc][pp] > max_load_start)  max_load_start = LOAD_START[cc][pp];
+               if (LOAD_END[cc][pp]   < min_load_ended)  min_load_ended = LOAD_END[cc][pp]; 
+               if (LOAD_END[cc][pp]   > max_load_ended)  max_load_ended = LOAD_END[cc][pp];
+               if (TRSP_START[cc][pp] < min_trsp_start)  min_trsp_start = TRSP_START[cc][pp];
+               if (TRSP_START[cc][pp] > max_trsp_start)  max_trsp_start = TRSP_START[cc][pp];
+               if (TRSP_END[cc][pp]   < min_trsp_ended)  min_trsp_ended = TRSP_END[cc][pp];
+               if (TRSP_END[cc][pp]   > max_trsp_ended)  max_trsp_ended = TRSP_END[cc][pp];
+               if (DISP_START[cc][pp] < min_disp_start)  min_disp_start = DISP_START[cc][pp];
+               if (DISP_START[cc][pp] > max_disp_start)  max_disp_start = DISP_START[cc][pp];
+               if (DISP_END[cc][pp]   < min_disp_ended)  min_disp_ended = DISP_END[cc][pp];
+               if (DISP_END[cc][pp]   > max_disp_ended)  max_disp_ended = DISP_END[cc][pp];
             }
          }
 
          PRINTF(" - LOAD_START : min = %d / max = %d / med = %d / delta = %d\n",
-               min_load_start, max_load_start, (min_load_start+max_load_start)/2, max_load_start-min_load_start); 
+               min_load_start, max_load_start, (min_load_start+max_load_start)/2, 
+               max_load_start-min_load_start); 
+
          PRINTF(" - LOAD_END   : min = %d / max = %d / med = %d / delta = %d\n",
-               min_load_ended, max_load_ended, (min_load_ended+max_load_ended)/2, max_load_ended-min_load_ended); 
+               min_load_ended, max_load_ended, (min_load_ended+max_load_ended)/2, 
+               max_load_ended-min_load_ended); 
 
          PRINTF(" - TRSP_START : min = %d / max = %d / med = %d / delta = %d\n",
-               min_trsp_start, max_trsp_start, (min_trsp_start+max_trsp_start)/2, max_trsp_start-min_trsp_start); 
+               min_trsp_start, max_trsp_start, (min_trsp_start+max_trsp_start)/2, 
+               max_trsp_start-min_trsp_start); 
+
          PRINTF(" - TRSP_END   : min = %d / max = %d / med = %d / delta = %d\n",
-               min_trsp_ended, max_trsp_ended, (min_trsp_ended+max_trsp_ended)/2, max_trsp_ended-min_trsp_ended); 
+               min_trsp_ended, max_trsp_ended, (min_trsp_ended+max_trsp_ended)/2, 
+               max_trsp_ended-min_trsp_ended); 
 
          PRINTF(" - DISP_START : min = %d / max = %d / med = %d / delta = %d\n",
-               min_disp_start, max_disp_start, (min_disp_start+max_disp_start)/2, max_disp_start-min_disp_start); 
+               min_disp_start, max_disp_start, (min_disp_start+max_disp_start)/2, 
+               max_disp_start-min_disp_start); 
+
          PRINTF(" - DISP_END   : min = %d / max = %d / med = %d / delta = %d\n",
-               min_disp_ended, max_disp_ended, (min_disp_ended+max_disp_ended)/2, max_disp_ended-min_disp_ended); 
-
-         PRINTF(" - BARRIER TRSP/DISP = %d\n", min_disp_start - max_trsp_ended);
+               min_disp_ended, max_disp_ended, (min_disp_ended+max_disp_ended)/2, 
+               max_disp_ended-min_disp_ended); 
       }
-      frame++;
-
-   } // end while frame      
-
-   PRINTF("*** End of main ***\n");
-
-   while(1);
+
+      image++;
+
+      _barrier_wait( 3 );
+   } // end while image      
+
+
+   _exit();
+
 } // end main()
 
