#include "stdio.h" #define NL 128 #define NP 128 #define NB_IMAGES 2 #define BLOCK_SIZE 128 #define PRINTF if(local_id == 0) tty_printf /////////////////////////////////////////// // tricks to read parameters from ldscript /////////////////////////////////////////// struct plaf; extern struct plaf seg_heap_base; extern struct plaf NB_PROCS; extern struct plaf NB_CLUSTERS; ///////////// void main() { unsigned int image = 0; unsigned int date = 0; unsigned int delta = 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 nprocs = (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%nprocs; // local processor id unsigned int cluster_id = proc_id/nprocs; // local processor id unsigned int base = (unsigned int)&seg_heap_base; // base address for shared buffers unsigned int increment = (0x80000000 / nclusters) * 2; // cluster increment unsigned int ntasks = nclusters * nprocs; // number of tasks unsigned int nblocks = (NP*NL) / BLOCK_SIZE; // number of blocks per image PRINTF("\n *** Entering main at cycle %d ***\n\n", proctime()); // parameters checking if( (nprocs != 1) && (nprocs != 2) && (nprocs != 4) ) { PRINTF("NB_PROCS 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) ) { PRINTF("NB_CLUSTERS must be a power of 2 between 1 and 128\n"); exit(); } if( ntasks > 128 ) { PRINTF("NB_PROCS * NB_CLUSTERS cannot be larger than 128 4\n"); exit(); } if( proc_id >= ntasks ) { PRINTF("processor id %d larger than NB_CLUSTERS*NB_PROCS\n", proc_id); } // Arrays of pointers on the shared, distributed buffers // containing the images (sized for the worst case : 128 clusters) unsigned char* A[128]; unsigned char* B[128]; // shared buffers address definition // from the seg_heap_base and segment_increment // values defined in the ldscript file. // These arrays of pointers are identical and // replicated in the stack of each task for( c=0 ; c