[158] | 1 | #include "stdio.h" |
---|
| 2 | |
---|
| 3 | //////////////////////////////////// |
---|
| 4 | // Image parameters |
---|
| 5 | |
---|
| 6 | #define PIXEL_SIZE 2 |
---|
| 7 | #define NL 1024 |
---|
| 8 | #define NP 1024 |
---|
| 9 | #define BLOCK_SIZE 1024 |
---|
| 10 | |
---|
| 11 | #define PRINTF if(lid==0) tty_printf |
---|
| 12 | |
---|
| 13 | #define TA(c,l,p) (A[c][((NP)*(l))+(p)]) |
---|
| 14 | #define TB(c,p,l) (B[c][((NL)*(p))+(l)]) |
---|
| 15 | #define TC(c,l,p) (C[c][((NP)*(l))+(p)]) |
---|
| 16 | #define TD(c,l,p) (D[c][((NP)*(l))+(p)]) |
---|
| 17 | #define TZ(c,l,p) (Z[c][((NP)*(l))+(p)]) |
---|
| 18 | |
---|
| 19 | #define max(x,y) ((x) > (y) ? (x) : (y)) |
---|
| 20 | #define min(x,y) ((x) < (y) ? (x) : (y)) |
---|
| 21 | |
---|
| 22 | /////////////////////////////////////////// |
---|
| 23 | // tricks to read parameters from ldscript |
---|
| 24 | /////////////////////////////////////////// |
---|
| 25 | |
---|
| 26 | struct plaf; |
---|
| 27 | |
---|
| 28 | extern struct plaf seg_heap_base; |
---|
| 29 | extern struct plaf NB_PROCS; |
---|
| 30 | extern struct plaf NB_CLUSTERS; |
---|
| 31 | |
---|
| 32 | ///////////// |
---|
| 33 | void main() |
---|
| 34 | { |
---|
| 35 | |
---|
| 36 | ////////////////////////////////// |
---|
| 37 | // convolution kernel parameters |
---|
| 38 | // The content of this section is |
---|
| 39 | // Philips proprietary information. |
---|
| 40 | /////////////////////////////////// |
---|
| 41 | |
---|
| 42 | int vnorm = 115; |
---|
| 43 | int vf[35]; |
---|
| 44 | vf[0] = 1; |
---|
| 45 | vf[1] = 1; |
---|
| 46 | vf[2] = 2; |
---|
| 47 | vf[3] = 2; |
---|
| 48 | vf[4] = 2; |
---|
| 49 | vf[5] = 2; |
---|
| 50 | vf[6] = 3; |
---|
| 51 | vf[7] = 3; |
---|
| 52 | vf[8] = 3; |
---|
| 53 | vf[9] = 4; |
---|
| 54 | vf[10] = 4; |
---|
| 55 | vf[11] = 4; |
---|
| 56 | vf[12] = 4; |
---|
| 57 | vf[13] = 5; |
---|
| 58 | vf[14] = 5; |
---|
| 59 | vf[15] = 5; |
---|
| 60 | vf[16] = 5; |
---|
| 61 | vf[17] = 5; |
---|
| 62 | vf[18] = 5; |
---|
| 63 | vf[19] = 5; |
---|
| 64 | vf[20] = 5; |
---|
| 65 | vf[21] = 5; |
---|
| 66 | vf[22] = 4; |
---|
| 67 | vf[23] = 4; |
---|
| 68 | vf[24] = 4; |
---|
| 69 | vf[25] = 4; |
---|
| 70 | vf[26] = 3; |
---|
| 71 | vf[27] = 3; |
---|
| 72 | vf[28] = 3; |
---|
| 73 | vf[29] = 2; |
---|
| 74 | vf[30] = 2; |
---|
| 75 | vf[31] = 2; |
---|
| 76 | vf[32] = 2; |
---|
| 77 | vf[33] = 1; |
---|
| 78 | vf[34] = 1; |
---|
| 79 | |
---|
| 80 | int hrange = 100; |
---|
| 81 | int hnorm = 201; |
---|
| 82 | |
---|
| 83 | unsigned int date = 0; |
---|
| 84 | unsigned int delta = 0; |
---|
| 85 | |
---|
| 86 | int c; // cluster index for loops |
---|
| 87 | int l; // line index for loops |
---|
| 88 | int p; // pixel index for loops |
---|
| 89 | int x; // filter index for loops |
---|
| 90 | |
---|
| 91 | int pid = procid(); // processor id |
---|
| 92 | int nprocs = (int)&NB_PROCS; // number of processors per cluster |
---|
| 93 | int nclusters = (int)&NB_CLUSTERS; // number of clusters |
---|
| 94 | int lid = pid%nprocs; // local task id |
---|
| 95 | int cid = pid/nprocs; // cluster task id |
---|
| 96 | int base = (unsigned int)&seg_heap_base; // base address for shared buffers |
---|
| 97 | int increment = (0x80000000 / nclusters) * 2; // cluster increment |
---|
| 98 | int ntasks = nclusters * nprocs; // number of tasks |
---|
| 99 | int nblocks = (NP*NL*PIXEL_SIZE)/BLOCK_SIZE; // number of blocks per image |
---|
| 100 | |
---|
| 101 | int lines_per_task = NL/ntasks; // number of lines per task |
---|
| 102 | int lines_per_cluster = NL/nclusters; // number of lines per cluster |
---|
| 103 | int pixels_per_task = NP/ntasks; // number of columns per task |
---|
| 104 | int pixels_per_cluster = NP/nclusters; // number of columns per cluster |
---|
| 105 | |
---|
| 106 | int first, last; |
---|
| 107 | |
---|
| 108 | PRINTF("\n*** Processor %d entering main at cycle %d ***\n\n", pid, proctime()); |
---|
| 109 | |
---|
| 110 | ////////////////////////// |
---|
| 111 | // parameters checking |
---|
| 112 | if( (nprocs != 1) && (nprocs != 2) && (nprocs != 4) ) |
---|
| 113 | { |
---|
| 114 | PRINTF("NB_PROCS must be 1, 2 or 4\n"); |
---|
| 115 | while(1); |
---|
| 116 | } |
---|
| 117 | if( (nclusters != 4) && (nclusters != 8) && (nclusters != 16) && |
---|
| 118 | (nclusters != 32) && (nclusters != 64) && (nclusters !=128) && (nclusters != 256) ) |
---|
| 119 | { |
---|
| 120 | PRINTF("NB_CLUSTERS must be a power of 2 between 4 and 256\n"); |
---|
| 121 | while(1); |
---|
| 122 | } |
---|
| 123 | if( pid >= ntasks ) |
---|
| 124 | { |
---|
| 125 | PRINTF("processor id %d larger than NB_CLUSTERS*NB_PROCS\n", pid); |
---|
| 126 | while(1); |
---|
| 127 | } |
---|
| 128 | if ( NL % nclusters != 0 ) |
---|
| 129 | { |
---|
| 130 | PRINTF("NB_CLUSTERS must be a divider of NL"); |
---|
| 131 | while(1); |
---|
| 132 | } |
---|
| 133 | if( NP % nclusters != 0 ) |
---|
| 134 | { |
---|
| 135 | PRINTF("NB_CLUSTERS must be a divider of NP"); |
---|
| 136 | while(1); |
---|
| 137 | } |
---|
| 138 | |
---|
| 139 | ////////////////////////////////////////////////////////////////// |
---|
| 140 | // Arrays of pointers on the shared, distributed buffers |
---|
| 141 | // containing the images (sized for the worst case : 256 clusters) |
---|
| 142 | unsigned short* A[256]; |
---|
| 143 | int* B[256]; |
---|
| 144 | int* C[256]; |
---|
| 145 | int* D[256]; |
---|
| 146 | unsigned char* Z[256]; |
---|
| 147 | |
---|
[170] | 148 | // Arrays of pointers on the instrumentation arrays |
---|
| 149 | // These arrays are indexed by the cluster index (sized for the worst case : 256 clusters) |
---|
| 150 | // each pointer points on the base adress of an array of 4 (NPROCS max) unsigned int |
---|
| 151 | unsigned int* LOAD_START[256]; |
---|
| 152 | unsigned int* LOAD_ENDED[256]; |
---|
| 153 | unsigned int* VERT_START[256]; |
---|
| 154 | unsigned int* VERT_ENDED[256]; |
---|
| 155 | unsigned int* HORI_START[256]; |
---|
| 156 | unsigned int* HORI_ENDED[256]; |
---|
| 157 | unsigned int* DISP_START[256]; |
---|
| 158 | unsigned int* DISP_ENDED[256]; |
---|
| 159 | |
---|
[158] | 160 | // The shared, distributed buffers addresses are computed |
---|
| 161 | // from the seg_heap_base value defined in the ldscript file |
---|
| 162 | // and from the cluster increment = 4Gbytes/nclusters. |
---|
| 163 | // These arrays of pointers are identical and |
---|
| 164 | // replicated in the stack of each task |
---|
| 165 | for( c=0 ; c<nclusters ; c++) |
---|
| 166 | { |
---|
[170] | 167 | A[c] = (unsigned short*) (base + increment*c); |
---|
| 168 | Z[c] = (unsigned char*) (base + 2*NP*NL/nclusters + increment*c); |
---|
| 169 | B[c] = (int*) (base + 4*NP*NL/nclusters + increment*c); |
---|
| 170 | C[c] = (int*) (base + 8*NP*NL/nclusters + increment*c); |
---|
| 171 | D[c] = (int*) (base + 12*NP*NL/nclusters + increment*c); |
---|
| 172 | |
---|
| 173 | LOAD_START[c] = (unsigned int*) (base + 3*NL*NP/nclusters + increment*c); |
---|
| 174 | LOAD_ENDED[c] = (unsigned int*) (base + 3*NL*NP/nclusters + 16 + increment*c); |
---|
| 175 | VERT_START[c] = (unsigned int*) (base + 3*NL*NP/nclusters + 32 + increment*c); |
---|
| 176 | VERT_ENDED[c] = (unsigned int*) (base + 3*NL*NP/nclusters + 48 + increment*c); |
---|
| 177 | HORI_START[c] = (unsigned int*) (base + 3*NL*NP/nclusters + 64 + increment*c); |
---|
| 178 | HORI_ENDED[c] = (unsigned int*) (base + 3*NL*NP/nclusters + 80 + increment*c); |
---|
| 179 | DISP_START[c] = (unsigned int*) (base + 3*NL*NP/nclusters + 96 + increment*c); |
---|
| 180 | DISP_ENDED[c] = (unsigned int*) (base + 3*NL*NP/nclusters + 112 + increment*c); |
---|
[158] | 181 | } |
---|
| 182 | |
---|
| 183 | PRINTF("NCLUSTERS = %d\n", nclusters); |
---|
| 184 | PRINTF("NPROCS = %d\n\n", nprocs); |
---|
| 185 | |
---|
| 186 | PRINTF("*** Starting barrier init at cycle %d ***\n", proctime()); |
---|
| 187 | |
---|
| 188 | // barriers initialization |
---|
| 189 | barrier_init(0, ntasks); |
---|
| 190 | barrier_init(1, ntasks); |
---|
| 191 | barrier_init(2, ntasks); |
---|
[170] | 192 | barrier_init(3, ntasks); |
---|
[158] | 193 | |
---|
| 194 | PRINTF("*** Completing barrier init at cycle %d ***\n", proctime()); |
---|
| 195 | |
---|
| 196 | //////////////////////////////////////////////////////// |
---|
| 197 | // pseudo parallel load from disk to A[c] buffers |
---|
| 198 | // only task running on processor with (lid==0) does it |
---|
| 199 | // nblocks/nclusters are loaded in each cluster |
---|
| 200 | |
---|
| 201 | if ( lid == 0 ) |
---|
| 202 | { |
---|
[170] | 203 | int p; |
---|
[158] | 204 | delta = proctime() - date; |
---|
| 205 | date = date + delta; |
---|
| 206 | PRINTF("\n*** Starting load at cycle %d (%d)\n", date, delta); |
---|
[170] | 207 | for ( p=0 ; p<nprocs ; p++ ) LOAD_START[cid][p] = date; |
---|
[158] | 208 | |
---|
| 209 | if( ioc_read(nblocks*cid/nclusters, |
---|
| 210 | A[cid] , |
---|
| 211 | nblocks/nclusters) ) |
---|
| 212 | { |
---|
| 213 | PRINTF("echec ioc_read\n"); |
---|
| 214 | while(1); |
---|
| 215 | } |
---|
| 216 | if ( ioc_completed() ) |
---|
| 217 | { |
---|
| 218 | PRINTF("echec ioc_completed\n"); |
---|
| 219 | while(1); |
---|
| 220 | } |
---|
| 221 | |
---|
| 222 | delta = proctime() - date; |
---|
| 223 | date = date + delta; |
---|
| 224 | PRINTF("*** Completing load at cycle %d (%d)\n", date, delta); |
---|
[170] | 225 | for ( p=0 ; p<nprocs ; p++ ) LOAD_ENDED[cid][p] = date; |
---|
[158] | 226 | } |
---|
| 227 | |
---|
| 228 | barrier_wait(0); |
---|
| 229 | |
---|
| 230 | ////////////////////////////////////////////////////////// |
---|
| 231 | // parallel horizontal filter : |
---|
[159] | 232 | // B <= transpose(FH(A)) |
---|
| 233 | // D <= A - FH(A) |
---|
[158] | 234 | // Each task computes (NL/ntasks) lines |
---|
| 235 | // The image must be extended : |
---|
| 236 | // if (z<0) TA(cid,l,z) == TA(cid,l,0) |
---|
| 237 | // if (z>NP-1) TA(cid,l,z) == TA(cid,l,NP-1) |
---|
| 238 | |
---|
| 239 | delta = proctime() - date; |
---|
| 240 | date = date + delta; |
---|
| 241 | PRINTF("\n*** Starting horizontal filter at cycle %d (%d)\n", date, delta); |
---|
[170] | 242 | HORI_START[cid][lid] = date; |
---|
[158] | 243 | |
---|
| 244 | // l = absolute line index / p = absolute pixel index |
---|
| 245 | // first & last define which lines are handled by a given task(cid,lid) |
---|
| 246 | |
---|
| 247 | first = (cid*nprocs + lid)*lines_per_task; |
---|
| 248 | last = first + lines_per_task; |
---|
| 249 | |
---|
| 250 | for ( l=first ; l<last ; l++) |
---|
| 251 | { |
---|
| 252 | // src_c and src_l are the cluster index and the line index for A & D |
---|
| 253 | int src_c = l/lines_per_cluster; |
---|
| 254 | int src_l = l%lines_per_cluster; |
---|
| 255 | |
---|
| 256 | // We use the spécific values of the horizontal ep-filter for optimisation: |
---|
| 257 | // sum(p) = sum(p-1) + TA[p+hrange] - TA[p-hrange-1] |
---|
| 258 | // To minimize the number of tests, the loop on pixels is split in three domains |
---|
| 259 | |
---|
[159] | 260 | int sum_p = (hrange+2)*TA(src_c, src_l, 0); |
---|
| 261 | for ( x = 1 ; x < hrange ; x++) sum_p = sum_p + TA(src_c, src_l, x); |
---|
[158] | 262 | |
---|
| 263 | // first domain : from 0 to hrange |
---|
| 264 | for ( p=0 ; p<hrange+1 ; p++) |
---|
| 265 | { |
---|
| 266 | // dst_c and dst_p are the cluster index and the pixel index for B |
---|
| 267 | int dst_c = p/pixels_per_cluster; |
---|
| 268 | int dst_p = p%pixels_per_cluster; |
---|
[159] | 269 | sum_p = sum_p + (int)TA(src_c, src_l, p+hrange) - (int)TA(src_c, src_l, 0); |
---|
| 270 | TB(dst_c, dst_p, l) = sum_p/hnorm; |
---|
| 271 | TD(src_c, src_l, p) = (int)TA(src_c, src_l, p) - sum_p/hnorm; |
---|
[158] | 272 | } |
---|
| 273 | // second domain : from (hrange+1) to (NP-hrange-1) |
---|
| 274 | for ( p = hrange+1 ; p < NP-hrange ; p++) |
---|
| 275 | { |
---|
| 276 | // dst_c and dst_p are the cluster index and the pixel index for B |
---|
| 277 | int dst_c = p/pixels_per_cluster; |
---|
| 278 | int dst_p = p%pixels_per_cluster; |
---|
[159] | 279 | sum_p = sum_p + (int)TA(src_c, src_l, p+hrange) - (int)TA(src_c, src_l, p-hrange-1); |
---|
| 280 | TB(dst_c, dst_p, l) = sum_p/hnorm; |
---|
| 281 | TD(src_c, src_l, p) = (int)TA(src_c, src_l, p) - sum_p/hnorm; |
---|
[158] | 282 | } |
---|
| 283 | // third domain : from (NP-hrange) to (NP-1) |
---|
| 284 | for ( p = NP-hrange ; p < NP ; p++) |
---|
| 285 | { |
---|
| 286 | // dst_c and dst_p are the cluster index and the pixel index for B |
---|
| 287 | int dst_c = p/pixels_per_cluster; |
---|
| 288 | int dst_p = p%pixels_per_cluster; |
---|
[159] | 289 | sum_p = sum_p + (int)TA(src_c, src_l, NP-1) - (int)TA(src_c, src_l, p-hrange-1); |
---|
| 290 | TB(dst_c, dst_p, l) = sum_p/hnorm; |
---|
| 291 | TD(src_c, src_l, p) = (int)TA(src_c, src_l, p) - sum_p/hnorm; |
---|
[158] | 292 | } |
---|
| 293 | |
---|
| 294 | PRINTF(" - line %d computed at cycle %d\n", l, proctime()); |
---|
| 295 | } |
---|
| 296 | |
---|
| 297 | delta = proctime() - date; |
---|
| 298 | date = date + delta; |
---|
| 299 | PRINTF("*** Completing horizontal filter at cycle %d (%d)\n", date, delta); |
---|
[170] | 300 | HORI_ENDED[cid][lid] = date; |
---|
[158] | 301 | |
---|
| 302 | barrier_wait(1); |
---|
| 303 | |
---|
| 304 | ////////////////////////////////////////////////////////// |
---|
| 305 | // parallel vertical filter : |
---|
| 306 | // C <= transpose(FV(B)) |
---|
| 307 | // Each task computes (NP/ntasks) columns |
---|
| 308 | // The image must be extended : |
---|
| 309 | // if (l<0) TB(cid,p,x) == TB(cid,p,0) |
---|
| 310 | // if (l>NL-1) TB(cid,p,x) == TB(cid,p,NL-1) |
---|
| 311 | |
---|
| 312 | delta = proctime() - date; |
---|
| 313 | date = date + delta; |
---|
| 314 | PRINTF("\n*** starting vertical filter at cycle %d (%d)\n", date, delta); |
---|
[170] | 315 | VERT_START[cid][lid] = date; |
---|
[158] | 316 | |
---|
| 317 | // l = absolute line index / p = absolute pixel index |
---|
| 318 | // first & last define which pixels are handled by a given task(cid,lid) |
---|
| 319 | |
---|
| 320 | first = (cid*nprocs + lid)*pixels_per_task; |
---|
| 321 | last = first + pixels_per_task; |
---|
| 322 | |
---|
| 323 | for ( p=first ; p<last ; p++) |
---|
| 324 | { |
---|
| 325 | // src_c and src_p are the cluster index and the pixel index for B |
---|
| 326 | int src_c = p/pixels_per_cluster; |
---|
| 327 | int src_p = p%pixels_per_cluster; |
---|
| 328 | |
---|
[159] | 329 | int sum_l; |
---|
[158] | 330 | |
---|
| 331 | // We use the specific values of the vertical ep-filter |
---|
| 332 | // To minimize the number of tests, the NL lines are split in three domains |
---|
| 333 | |
---|
[159] | 334 | // first domain : explicit computation for the first 18 values |
---|
| 335 | for ( l=0 ; l<18 ; l++) |
---|
[158] | 336 | { |
---|
| 337 | // dst_c and dst_l are the cluster index and the line index for C |
---|
| 338 | int dst_c = l/lines_per_cluster; |
---|
| 339 | int dst_l = l%lines_per_cluster; |
---|
| 340 | |
---|
[159] | 341 | for ( x=0, sum_l=0 ; x<35 ; x++ ) |
---|
[158] | 342 | { |
---|
[159] | 343 | sum_l = sum_l + vf[x] * TB(src_c, src_p, max(l-17+x,0) ); |
---|
[158] | 344 | } |
---|
[159] | 345 | TC(dst_c, dst_l, p) = sum_l/vnorm; |
---|
[158] | 346 | } |
---|
| 347 | // second domain |
---|
[159] | 348 | for ( l = 18 ; l < NL-17 ; l++ ) |
---|
[158] | 349 | { |
---|
| 350 | // dst_c and dst_l are the cluster index and the line index for C |
---|
| 351 | int dst_c = l/lines_per_cluster; |
---|
| 352 | int dst_l = l%lines_per_cluster; |
---|
| 353 | |
---|
[159] | 354 | sum_l = sum_l + TB(src_c, src_p, l+4) |
---|
| 355 | + TB(src_c, src_p, l+8) |
---|
| 356 | + TB(src_c, src_p, l+11) |
---|
| 357 | + TB(src_c, src_p, l+15) |
---|
| 358 | + TB(src_c, src_p, l+17) |
---|
| 359 | - TB(src_c, src_p, l-5) |
---|
| 360 | - TB(src_c, src_p, l-9) |
---|
| 361 | - TB(src_c, src_p, l-12) |
---|
| 362 | - TB(src_c, src_p, l-16) |
---|
| 363 | - TB(src_c, src_p, l-18); |
---|
| 364 | TC(dst_c, dst_l, p) = sum_l/vnorm; |
---|
[158] | 365 | } |
---|
| 366 | // third domain |
---|
[159] | 367 | for ( l = NL-17 ; l < NL ; l++ ) |
---|
[158] | 368 | { |
---|
| 369 | // dst_c and dst_l are the cluster index and the line index for C |
---|
| 370 | int dst_c = l/lines_per_cluster; |
---|
| 371 | int dst_l = l%lines_per_cluster; |
---|
| 372 | |
---|
[159] | 373 | sum_l = sum_l + TB(src_c, src_p, min(l+4,NL-1)) |
---|
| 374 | + TB(src_c, src_p, min(l+8,NL-1)) |
---|
| 375 | + TB(src_c, src_p, min(l+11,NL-1)) |
---|
| 376 | + TB(src_c, src_p, min(l+15,NL-1)) |
---|
| 377 | + TB(src_c, src_p, min(l+17,NL-1)) |
---|
| 378 | - TB(src_c, src_p, l-5) |
---|
| 379 | - TB(src_c, src_p, l-9) |
---|
| 380 | - TB(src_c, src_p, l-12) |
---|
| 381 | - TB(src_c, src_p, l-16) |
---|
| 382 | - TB(src_c, src_p, l-18); |
---|
| 383 | TC(dst_c, dst_l, p) = sum_l/vnorm; |
---|
[158] | 384 | } |
---|
| 385 | PRINTF(" - column %d computed at cycle %d\n", p, proctime()); |
---|
| 386 | } |
---|
| 387 | |
---|
| 388 | delta = proctime() - date; |
---|
| 389 | date = date + delta; |
---|
| 390 | PRINTF("*** Completing vertical filter at cycle %d (%d)\n", date, delta); |
---|
[170] | 391 | VERT_ENDED[cid][lid] = date; |
---|
[158] | 392 | |
---|
| 393 | barrier_wait(2); |
---|
| 394 | |
---|
[159] | 395 | //////////////////////////////////////////////////////////////// |
---|
| 396 | // final computation and parallel display |
---|
| 397 | // Z <= D + C |
---|
[158] | 398 | // Each processor use its private DMA channel to display |
---|
| 399 | // the resulting image, line per line (one byte per pixel). |
---|
| 400 | // Eah processor computes & displays (NL/ntasks) lines. |
---|
| 401 | |
---|
| 402 | delta = proctime() - date; |
---|
| 403 | date = date + delta; |
---|
| 404 | PRINTF("\n*** Starting display at cycle %d (%d)\n", date, delta); |
---|
[170] | 405 | DISP_START[cid][lid] = date; |
---|
[158] | 406 | |
---|
[162] | 407 | first = lid*lines_per_task; |
---|
| 408 | last = first + lines_per_task; |
---|
| 409 | |
---|
| 410 | for ( l=first ; l<last ; l++) |
---|
[158] | 411 | { |
---|
[162] | 412 | for ( p=0 ; p<NP ; p++) |
---|
[158] | 413 | { |
---|
| 414 | TZ(cid,l,p) = (unsigned char)(((TD(cid,l,p) + TC(cid,l,p))>>8) & 0xFF); |
---|
| 415 | } |
---|
[162] | 416 | fb_write(NP*(cid*lines_per_cluster+l), &TZ(cid,l,0), NP); |
---|
[158] | 417 | } |
---|
| 418 | |
---|
| 419 | delta = proctime() - date; |
---|
| 420 | date = date + delta; |
---|
| 421 | PRINTF("*** Completing display at cycle %d (%d)\n", date, delta); |
---|
[170] | 422 | DISP_ENDED[cid][lid] = date; |
---|
[158] | 423 | |
---|
[170] | 424 | barrier_wait(3); |
---|
| 425 | |
---|
| 426 | PRINTF("\n*** Starting Instrumentation at cycle %d (%d)\n\n", date, delta); |
---|
| 427 | |
---|
| 428 | // Instrumentation (done by processor 0 in all clusters) |
---|
| 429 | int cc, pp; |
---|
| 430 | unsigned int min_load_start = 1000000000; |
---|
| 431 | unsigned int max_load_start = 0; |
---|
| 432 | unsigned int min_load_ended = 1000000000; |
---|
| 433 | unsigned int max_load_ended = 0; |
---|
| 434 | |
---|
| 435 | unsigned int min_hori_start = 1000000000; |
---|
| 436 | unsigned int max_hori_start = 0; |
---|
| 437 | unsigned int min_hori_ended = 1000000000; |
---|
| 438 | unsigned int max_hori_ended = 0; |
---|
| 439 | |
---|
| 440 | unsigned int min_vert_start = 1000000000; |
---|
| 441 | unsigned int max_vert_start = 0; |
---|
| 442 | unsigned int min_vert_ended = 1000000000; |
---|
| 443 | unsigned int max_vert_ended = 0; |
---|
| 444 | |
---|
| 445 | unsigned int min_disp_start = 1000000000; |
---|
| 446 | unsigned int max_disp_start = 0; |
---|
| 447 | unsigned int min_disp_ended = 1000000000; |
---|
| 448 | unsigned int max_disp_ended = 0; |
---|
| 449 | |
---|
| 450 | if ( lid == 0 ) |
---|
| 451 | { |
---|
| 452 | for ( cc=0 ; cc<nclusters ; cc++ ) |
---|
| 453 | { |
---|
| 454 | for ( pp=0 ; pp<nprocs ; pp++ ) |
---|
| 455 | { |
---|
| 456 | if ( LOAD_START[cc][pp] < min_load_start ) min_load_start = LOAD_START[cc][pp]; |
---|
| 457 | if ( LOAD_START[cc][pp] > max_load_start ) max_load_start = LOAD_START[cc][pp]; |
---|
| 458 | if ( LOAD_ENDED[cc][pp] < min_load_ended ) min_load_ended = LOAD_ENDED[cc][pp]; |
---|
| 459 | if ( LOAD_ENDED[cc][pp] > max_load_ended ) max_load_ended = LOAD_ENDED[cc][pp]; |
---|
| 460 | |
---|
| 461 | if ( HORI_START[cc][pp] < min_hori_start ) min_hori_start = HORI_START[cc][pp]; |
---|
| 462 | if ( HORI_START[cc][pp] > max_hori_start ) max_hori_start = HORI_START[cc][pp]; |
---|
| 463 | if ( HORI_ENDED[cc][pp] < min_hori_ended ) min_hori_ended = HORI_ENDED[cc][pp]; |
---|
| 464 | if ( HORI_ENDED[cc][pp] > max_hori_ended ) max_hori_ended = HORI_ENDED[cc][pp]; |
---|
| 465 | |
---|
| 466 | if ( VERT_START[cc][pp] < min_vert_start ) min_vert_start = VERT_START[cc][pp]; |
---|
| 467 | if ( VERT_START[cc][pp] > max_vert_start ) max_vert_start = VERT_START[cc][pp]; |
---|
| 468 | if ( VERT_ENDED[cc][pp] < min_vert_ended ) min_vert_ended = VERT_ENDED[cc][pp]; |
---|
| 469 | if ( VERT_ENDED[cc][pp] > max_vert_ended ) max_vert_ended = VERT_ENDED[cc][pp]; |
---|
| 470 | |
---|
| 471 | if ( DISP_START[cc][pp] < min_disp_start ) min_disp_start = DISP_START[cc][pp]; |
---|
| 472 | if ( DISP_START[cc][pp] > max_disp_start ) max_disp_start = DISP_START[cc][pp]; |
---|
| 473 | if ( DISP_ENDED[cc][pp] < min_disp_ended ) min_disp_ended = DISP_ENDED[cc][pp]; |
---|
| 474 | if ( DISP_ENDED[cc][pp] > max_disp_ended ) max_disp_ended = DISP_ENDED[cc][pp]; |
---|
| 475 | } |
---|
| 476 | } |
---|
| 477 | } |
---|
| 478 | PRINTF(" - LOAD_START : min = %d / max = %d / med = %d / delta = %d\n", |
---|
| 479 | min_load_start, max_load_start, (min_load_start+max_load_start)/2, max_load_start-min_load_start); |
---|
| 480 | PRINTF(" - LOAD_END : min = %d / max = %d / med = %d / delta = %d\n", |
---|
| 481 | min_load_ended, max_load_ended, (min_load_ended+max_load_ended)/2, max_load_ended-min_load_ended); |
---|
| 482 | |
---|
| 483 | PRINTF(" - HORI_START : min = %d / max = %d / med = %d / delta = %d\n", |
---|
| 484 | min_hori_start, max_hori_start, (min_hori_start+max_hori_start)/2, max_hori_start-min_hori_start); |
---|
| 485 | PRINTF(" - HORI_END : min = %d / max = %d / med = %d / delta = %d\n", |
---|
| 486 | min_hori_ended, max_hori_ended, (min_hori_ended+max_hori_ended)/2, max_hori_ended-min_hori_ended); |
---|
| 487 | |
---|
| 488 | PRINTF(" - VERT_START : min = %d / max = %d / med = %d / delta = %d\n", |
---|
| 489 | min_vert_start, max_vert_start, (min_vert_start+max_vert_start)/2, max_vert_start-min_vert_start); |
---|
| 490 | PRINTF(" - VERT_END : min = %d / max = %d / med = %d / delta = %d\n", |
---|
| 491 | min_vert_ended, max_vert_ended, (min_vert_ended+max_vert_ended)/2, max_vert_ended-min_vert_ended); |
---|
| 492 | |
---|
| 493 | PRINTF(" - DISP_START : min = %d / max = %d / med = %d / delta = %d\n", |
---|
| 494 | min_disp_start, max_disp_start, (min_disp_start+max_disp_start)/2, max_disp_start-min_disp_start); |
---|
| 495 | PRINTF(" - DISP_END : min = %d / max = %d / med = %d / delta = %d\n", |
---|
| 496 | min_disp_ended, max_disp_ended, (min_disp_ended+max_disp_ended)/2, max_disp_ended-min_disp_ended); |
---|
| 497 | |
---|
| 498 | PRINTF(" - BARRIER LOAD/HORI = %d\n", min_hori_start - max_load_ended); |
---|
| 499 | PRINTF(" - BARRIER HORI/VERT = %d\n", min_vert_start - max_hori_ended); |
---|
| 500 | PRINTF(" - BARRIER VERT/DISP = %d\n", min_disp_start - max_vert_ended); |
---|
| 501 | |
---|
[158] | 502 | while(1); |
---|
| 503 | |
---|
| 504 | } // end main() |
---|
| 505 | |
---|