Changeset 669 for soft/giet_vm/applications/transpose/main.c
- Timestamp:
- Jul 27, 2015, 8:40:45 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/applications/transpose/main.c
r661 r669 33 33 #define CLUSTER_MAX (X_MAX * Y_MAX) // max number of clusters 34 34 #define NN 256 // image size : nlines = npixels 35 #define INITIAL_FILE_PATH " misc/lena.raw"// pathname on virtual disk35 #define INITIAL_FILE_PATH "/misc/lena_256.raw" // pathname on virtual disk 36 36 #define TRANSPOSED_FILE_PATH "/home/lena_transposed.raw" // pathname on virtual disk 37 37 #define RESTORED_FILE_PATH "/home/lena_restored.raw" // pathname on virtual disk 38 38 #define INSTRUMENTATION_OK 1 // display statistics on TTY 39 40 // macro to use a shared TTY 41 #define printf(...) lock_acquire( &tty_lock ); \ 42 giet_tty_printf(__VA_ARGS__); \ 43 lock_release( &tty_lock ) 39 44 40 45 /////////////////////////////////////////////////////// … … 61 66 unsigned check_line_after[NN]; 62 67 63 // global synchronisation barrier 68 // lock protecting shared TTY 69 user_lock_t tty_lock; 70 71 // global & local synchronisation variables 64 72 giet_sqt_barrier_t barrier; 65 73 … … 98 106 unsigned int task_id = (cluster_id * nprocs) + lpid; // "continuous" task index 99 107 108 // checking parameters 109 giet_assert( ((nprocs == 1) || (nprocs == 2) || (nprocs == 4)), 110 "[TRANSPOSE ERROR] number of procs per cluster must be 1, 2 or 4"); 111 112 giet_assert( ((x_size == 1) || (x_size == 2) || (x_size == 4) || 113 (x_size == 8) || (x_size == 16)), 114 "[TRANSPOSE ERROR] x_size must be 1,2,4,8,16"); 115 116 giet_assert( ((y_size == 1) || (y_size == 2) || (y_size == 4) || 117 (y_size == 8) || (y_size == 16)), 118 "[TRANSPOSE ERROR] y_size must be 1,2,4,8,16"); 119 120 giet_assert( (ntasks <= NN ), 121 "[TRANSPOSE ERROR] number of tasks larger than number of lines"); 100 122 101 123 /////////////////////////////////////////////////////////////////////// … … 107 129 if ( (x==0) && (y==0) && (lpid==0) ) 108 130 { 109 if ((nprocs != 1) && (nprocs != 2) && (nprocs != 4)) 110 { 111 giet_exit("[TRANSPOSE ERROR] number of procs per cluster must be 1, 2 or 4"); 112 } 113 if ((nclusters != 1) && (nclusters != 2) && (nclusters != 4) && 114 (nclusters != 8) && (nclusters != 16) && (nclusters != 32) && (nclusters != 64) ) 115 { 116 giet_exit("[TRANSPOSE ERROR] number of clusters must be 1,2,4,8,16,32,64"); 117 } 118 if ( ntasks > NN ) 119 { 120 giet_exit("[TRANSPOSE ERROR] number of tasks larger than number of lines"); 121 } 122 131 // shared TTY allocation 132 giet_tty_alloc( 1 ); 133 134 // TTY lock initialisation 135 lock_init( &tty_lock); 136 123 137 // distributed heap initialisation 124 138 unsigned int cx , cy; … … 134 148 sqt_barrier_init( &barrier, x_size , y_size , nprocs ); 135 149 136 giet_shr_printf("\n[TRANSPOSE] Proc [0,0,0] completes heap & barrier initat cycle %d\n",137 150 printf("\n[TRANSPOSE] Proc [0,0,0] completes initialisation at cycle %d\n", 151 giet_proctime() ); 138 152 139 153 global_init_ok = 1; … … 157 171 158 172 if ( (x==0) && (y==0) ) 159 giet_shr_printf("\n[TRANSPOSE] Proc [%d,%d,%d] completes buffer allocation"160 161 162 163 164 173 printf("\n[TRANSPOSE] Proc [%d,%d,%d] completes buffer allocation" 174 " for cluster[%d,%d] at cycle %d\n" 175 " - buf_in = %x\n" 176 " - buf_out = %x\n", 177 x, y, lpid, x, y, giet_proctime(), 178 (unsigned int)buf_in[cluster_id], (unsigned int)buf_out[cluster_id] ); 165 179 166 180 /////////////////////////////////////////////////////////////////////// … … 173 187 if ( fd_initial < 0 ) 174 188 { 175 giet_shr_printf("\n[TRANSPOSE ERROR] Proc [%d,%d,%d] cannot open file %s\n",176 189 printf("\n[TRANSPOSE ERROR] Proc [%d,%d,%d] cannot open file %s\n", 190 x , y , lpid , INITIAL_FILE_PATH ); 177 191 giet_exit(" open() failure"); 178 192 } 179 193 else if ( (x==0) && (y==0) && (lpid==0) ) 180 194 { 181 giet_shr_printf("\n[TRANSPOSE] Proc [0,0,0] open file %s / fd = %d\n",182 195 printf("\n[TRANSPOSE] Proc [0,0,0] open file %s / fd = %d\n", 196 INITIAL_FILE_PATH , fd_initial ); 183 197 } 184 198 … … 187 201 if ( fd_transposed < 0 ) 188 202 { 189 giet_shr_printf("\n[TRANSPOSE ERROR] Proc [%d,%d,%d] cannot open file %s\n",203 printf("\n[TRANSPOSE ERROR] Proc [%d,%d,%d] cannot open file %s\n", 190 204 x , y , lpid , TRANSPOSED_FILE_PATH ); 191 205 giet_exit(" open() failure"); … … 193 207 else if ( (x==0) && (y==0) && (lpid==0) ) 194 208 { 195 giet_shr_printf("\n[TRANSPOSE] Proc [0,0,0] open file %s / fd = %d\n",196 209 printf("\n[TRANSPOSE] Proc [0,0,0] open file %s / fd = %d\n", 210 TRANSPOSED_FILE_PATH , fd_transposed ); 197 211 } 198 212 … … 201 215 if ( fd_restored < 0 ) 202 216 { 203 giet_shr_printf("\n[TRANSPOSE ERROR] Proc [%d,%d,%d] cannot open file %s\n",204 217 printf("\n[TRANSPOSE ERROR] Proc [%d,%d,%d] cannot open file %s\n", 218 x , y , lpid , RESTORED_FILE_PATH ); 205 219 giet_exit(" open() failure"); 206 220 } 207 221 else if ( (x==0) && (y==0) && (lpid==0) ) 208 222 { 209 giet_shr_printf("\n[TRANSPOSE] Proc [0,0,0] open file %s / fd = %d\n",210 223 printf("\n[TRANSPOSE] Proc [0,0,0] open file %s / fd = %d\n", 224 RESTORED_FILE_PATH , fd_restored ); 211 225 } 212 226 … … 244 258 SEEK_SET ) != offset ) 245 259 { 246 giet_shr_printf("\n[TRANSPOSE ERROR] Proc [%d,%d,%d] cannot seek fd = %d\n",247 260 printf("\n[TRANSPOSE ERROR] Proc [%d,%d,%d] cannot seek fd = %d\n", 261 x , y , lpid , fd_in ); 248 262 giet_exit(" seek() failure"); 249 263 } … … 254 268 pixels ) != pixels ) 255 269 { 256 giet_shr_printf("\n[TRANSPOSE ERROR] Proc [%d,%d,%d] cannot read fd = %d\n",257 270 printf("\n[TRANSPOSE ERROR] Proc [%d,%d,%d] cannot read fd = %d\n", 271 x , y , lpid , fd_in ); 258 272 giet_exit(" read() failure"); 259 273 } 260 274 261 275 if ( (x==0) && (y==0) ) 262 giet_shr_printf("\n[TRANSPOSE] Proc [%d,%d,%d] completes load"263 264 276 printf("\n[TRANSPOSE] Proc [%d,%d,%d] completes load" 277 " for iteration %d at cycle %d\n", 278 x, y, lpid, iteration, giet_proctime() ); 265 279 } 266 280 … … 314 328 } 315 329 316 if ( lpid == 0 )317 { 318 if ( (x==0) && (y==0) )319 giet_shr_printf("\n[TRANSPOSE] proc [%d,%d,0] completes transpose"320 321 330 // if ( lpid == 0 ) 331 { 332 // if ( (x==0) && (y==0) ) 333 printf("\n[TRANSPOSE] proc [%d,%d,0] completes transpose" 334 " for iteration %d at cycle %d\n", 335 x, y, iteration, giet_proctime() ); 322 336 323 337 } … … 340 354 npt ); 341 355 342 if ( (x==0) && (y==0) && (lpid==0) )343 giet_shr_printf("\n[TRANSPOSE] Proc [%d,%d,%d] completes display"344 345 356 // if ( (x==0) && (y==0) && (lpid==0) ) 357 printf("\n[TRANSPOSE] Proc [%d,%d,%d] completes display" 358 " for iteration %d at cycle %d\n", 359 x, y, lpid, iteration, giet_proctime() ); 346 360 347 361 DISP_END[x][y][lpid] = giet_proctime(); … … 364 378 SEEK_SET ) != offset ) 365 379 { 366 giet_shr_printf("\n[TRANSPOSE ERROR] Proc [%d,%d,%d] cannot seek fr = %d\n",367 380 printf("\n[TRANSPOSE ERROR] Proc [%d,%d,%d] cannot seek fr = %d\n", 381 x , y , lpid , fd_out ); 368 382 giet_exit(" seek() failure"); 369 383 } … … 374 388 pixels ) != pixels ) 375 389 { 376 giet_shr_printf("\n[TRANSPOSE ERROR] Proc [%d,%d,%d] cannot write fd = %d\n",377 390 printf("\n[TRANSPOSE ERROR] Proc [%d,%d,%d] cannot write fd = %d\n", 391 x , y , lpid , fd_out ); 378 392 giet_exit(" write() failure"); 379 393 } 380 394 381 395 if ( (x==0) && (y==0) ) 382 giet_shr_printf("\n[TRANSPOSE] Proc [%d,%d,%d] completes store"383 384 396 printf("\n[TRANSPOSE] Proc [%d,%d,%d] completes store" 397 " for iteration %d at cycle %d\n", 398 x, y, lpid, iteration, giet_proctime() ); 385 399 } 386 400 … … 437 451 } 438 452 439 giet_shr_printf("\n ---------------- Instrumentation Results ---------------------\n");440 441 giet_shr_printf(" - LOAD_START : min = %d / max = %d / med = %d / delta = %d\n",442 443 444 445 giet_shr_printf(" - LOAD_END : min = %d / max = %d / med = %d / delta = %d\n",446 447 448 449 giet_shr_printf(" - TRSP_START : min = %d / max = %d / med = %d / delta = %d\n",450 451 452 453 giet_shr_printf(" - TRSP_END : min = %d / max = %d / med = %d / delta = %d\n",454 455 456 457 giet_shr_printf(" - DISP_START : min = %d / max = %d / med = %d / delta = %d\n",458 459 460 461 giet_shr_printf(" - DISP_END : min = %d / max = %d / med = %d / delta = %d\n",462 463 464 465 giet_shr_printf(" - STOR_START : min = %d / max = %d / med = %d / delta = %d\n",466 467 468 469 giet_shr_printf(" - STOR_END : min = %d / max = %d / med = %d / delta = %d\n",470 471 453 printf("\n ---------------- Instrumentation Results ---------------------\n"); 454 455 printf(" - LOAD_START : min = %d / max = %d / med = %d / delta = %d\n", 456 min_load_start, max_load_start, (min_load_start+max_load_start)/2, 457 max_load_start-min_load_start); 458 459 printf(" - LOAD_END : min = %d / max = %d / med = %d / delta = %d\n", 460 min_load_ended, max_load_ended, (min_load_ended+max_load_ended)/2, 461 max_load_ended-min_load_ended); 462 463 printf(" - TRSP_START : min = %d / max = %d / med = %d / delta = %d\n", 464 min_trsp_start, max_trsp_start, (min_trsp_start+max_trsp_start)/2, 465 max_trsp_start-min_trsp_start); 466 467 printf(" - TRSP_END : min = %d / max = %d / med = %d / delta = %d\n", 468 min_trsp_ended, max_trsp_ended, (min_trsp_ended+max_trsp_ended)/2, 469 max_trsp_ended-min_trsp_ended); 470 471 printf(" - DISP_START : min = %d / max = %d / med = %d / delta = %d\n", 472 min_disp_start, max_disp_start, (min_disp_start+max_disp_start)/2, 473 max_disp_start-min_disp_start); 474 475 printf(" - DISP_END : min = %d / max = %d / med = %d / delta = %d\n", 476 min_disp_ended, max_disp_ended, (min_disp_ended+max_disp_ended)/2, 477 max_disp_ended-min_disp_ended); 478 479 printf(" - STOR_START : min = %d / max = %d / med = %d / delta = %d\n", 480 min_stor_start, max_stor_start, (min_stor_start+max_stor_start)/2, 481 max_stor_start-min_stor_start); 482 483 printf(" - STOR_END : min = %d / max = %d / med = %d / delta = %d\n", 484 min_stor_ended, max_stor_ended, (min_stor_ended+max_stor_ended)/2, 485 max_stor_ended-min_stor_ended); 472 486 } 473 487 … … 497 511 } 498 512 499 // clean up500 if ( (x==0) && (y == 0) && (lpid == 0) )501 {502 giet_fat_remove( "/home/lena_transposed" , 0 );503 giet_fat_remove( "/home/lena_restored" , 0 );504 505 giet_fat_remove( "/home" , 1 );506 }507 508 513 giet_exit("Completed"); 509 514
Note: See TracChangeset
for help on using the changeset viewer.