Changeset 353 for soft/giet_vm
- Timestamp:
- Jun 29, 2014, 1:23:18 PM (10 years ago)
- Location:
- soft/giet_vm/convol
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/convol/convol.py
r334 r353 48 48 vspace = mapping.addVspace( name = 'convol', startname = 'conv_data' ) 49 49 50 # non replicated vsegs in cluster[0,0] 51 mapping.addVseg( vspace, 'conv_code', code_base , code_size, 'CXWU', vtype = 'ELF', 52 x = 0, y = 0, pseg = 'RAM', binpath = 'build/convol/convol.elf' ) 50 # data vseg in cluster[0,0] : non local 51 mapping.addVseg( vspace, 'conv_data', data_base , data_size, 'C_WU', vtype = 'ELF', 52 x = 0, y = 0, pseg = 'RAM', binpath = 'build/convol/convol.elf', 53 local = False ) 53 54 54 mapping.addVseg( vspace, 'conv_data', data_base , data_size, 'C_WU', vtype = 'ELF', 55 x = 0, y = 0, pseg = 'RAM', binpath = 'build/convol/convol.elf' ) 55 # code vsegs : local (one replicated vseg per cluster) 56 for x in xrange (x_size): 57 for y in xrange (y_size): 58 59 size = code_size 60 base = code_base 61 mapping.addVseg( vspace, 'conv_code_%d_%d' % (x,y), base, size, 62 'CXWU', vtype = 'ELF', x = x , y = y , pseg = 'RAM', 63 binpath = 'build/convol/convol.elf', 64 local = True ) 56 65 57 mapping.addVseg( vspace, 'conv_ptab', ptab_base , ptab_size, 'C_WU', vtype = 'PTAB', 58 x = 0, y = 0, pseg = 'RAM', align = 13 ) 59 60 # distributed heaps: one heap per cluster : size = 16 Mbytes/NCLUSTERS 66 # heap vsegs : non local (one communication buffer per cluster) 61 67 for x in xrange (x_size): 62 68 for y in xrange (y_size): … … 66 72 base = heap_base + (cluster_id * size) 67 73 mapping.addVseg( vspace, 'conv_heap_%d_%d' % (x,y), base, size, 68 'C_WU', vtype = 'BUFFER', x = x , y = y , pseg = 'RAM' ) 74 'C_WU', vtype = 'BUFFER', x = x , y = y , pseg = 'RAM', 75 local = False ) 69 76 70 # distributed stacks: one stack per processor : size = 32 Mbytes/(NCLUSTERS*NPROCS)77 # stack vsegs : local (one stack per processor) 71 78 for x in xrange (x_size): 72 79 for y in xrange (y_size): … … 77 84 base = stack_base + (proc_id * size) 78 85 mapping.addVseg( vspace, 'conv_stack_%d_%d_%d' % (x,y,p), base, size, 79 'C_WU', vtype = 'BUFFER', x = x , y = y , pseg = 'RAM' ) 86 'C_WU', vtype = 'BUFFER', x = x , y = y , pseg = 'RAM', 87 local = True ) 80 88 81 # distributed tasks / one task per processor 89 # ptab vsegs : local (one ptab per cluster) 90 for x in xrange (x_size): 91 for y in xrange (y_size): 92 93 size = ptab_size 94 base = ptab_base 95 mapping.addVseg( vspace, 'conv_ptab_%d_%d' %(x,y), base , size, 96 'C_WU', vtype = 'PTAB', x = x , y = y , pseg = 'RAM', 97 align = 13, 98 local = True ) 99 100 # distributed tasks : one task per processor 82 101 for x in xrange (x_size): 83 102 for y in xrange (y_size): -
soft/giet_vm/convol/main.c
r345 r353 9 9 #include "hard_config.h" 10 10 #include "stdio.h" 11 #include "stdlib.h" 11 12 #include "barrier.h" 12 13 13 #define VERBOSE 1 14 15 #define INITIAL_DISPLAY_ENABLE 1 14 #define VERBOSE 0 15 #define SUPER_VERBOSE 0 16 17 #define INITIAL_DISPLAY_ENABLE 0 16 18 #define FINAL_DISPLAY_ENABLE 1 17 19 18 #define NB_CLUSTERS _MAX(X_SIZE * Y_SIZE)20 #define NB_CLUSTERS (X_SIZE * Y_SIZE) 19 21 #define PIXEL_SIZE 2 20 22 #define NL 1024 … … 33 35 34 36 // instrumentation counters indexed by (cluster_id, lpid] 35 unsigned int START[NB_CLUSTERS _MAX][NB_PROCS_MAX];36 unsigned int H_BEG[NB_CLUSTERS _MAX][NB_PROCS_MAX];37 unsigned int H_END[NB_CLUSTERS _MAX][NB_PROCS_MAX];38 unsigned int V_BEG[NB_CLUSTERS _MAX][NB_PROCS_MAX];39 unsigned int V_END[NB_CLUSTERS _MAX][NB_PROCS_MAX];40 unsigned int D_BEG[NB_CLUSTERS _MAX][NB_PROCS_MAX];41 unsigned int D_END[NB_CLUSTERS _MAX][NB_PROCS_MAX];37 unsigned int START[NB_CLUSTERS][NB_PROCS_MAX]; 38 unsigned int H_BEG[NB_CLUSTERS][NB_PROCS_MAX]; 39 unsigned int H_END[NB_CLUSTERS][NB_PROCS_MAX]; 40 unsigned int V_BEG[NB_CLUSTERS][NB_PROCS_MAX]; 41 unsigned int V_END[NB_CLUSTERS][NB_PROCS_MAX]; 42 unsigned int D_BEG[NB_CLUSTERS][NB_PROCS_MAX]; 43 unsigned int D_END[NB_CLUSTERS][NB_PROCS_MAX]; 42 44 43 45 // synchronization barriers … … 50 52 volatile unsigned int exit_ok = 0; 51 53 52 //////////////////////////////////////////////////////53 // Required by GCC when initializing an array54 //////////////////////////////////////////////////////55 static void *memcpy( void * _dst,56 const void * _src,57 unsigned int size )58 {59 unsigned int *dst = _dst;60 const unsigned int *src = _src;61 62 if (! ((unsigned int)dst & 3) && ! ((unsigned int)src & 3))63 {64 while (size > 3)65 {66 *dst++ = *src++;67 size -= 4;68 }69 }70 71 unsigned char *cdst = (unsigned char*)dst;72 unsigned char *csrc = (unsigned char*)src;73 74 while ( size-- )75 {76 *cdst++ = *csrc++;77 }78 return _dst;79 }80 54 81 55 /////////////////////////////////////////// … … 108 82 int z; // vertical filter index for loops 109 83 110 int file ;// file descriptor84 int file = 0; // file descriptor 111 85 unsigned int pid = giet_procid(); // processor id 112 86 unsigned int nprocs = NB_PROCS_MAX; // procs per cluster 113 unsigned int nclusters = NB_CLUSTERS _MAX; // number of clusters87 unsigned int nclusters = NB_CLUSTERS; // number of clusters 114 88 unsigned int lpid = pid % nprocs; // local task id 115 89 unsigned int cluster_xy = pid / nprocs; // cluster index … … 131 105 132 106 date = giet_proctime(); 133 giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] starts at cycle %d\n",134 x,y,lpid, date );135 107 START[cluster_id][lpid] = date; 108 109 #if VERBOSE 110 giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] starts at cycle %d\n", x,y,lpid, date ); 111 #endif 136 112 137 113 // parameters checking … … 159 135 /////////////////////////////////////////////////////////////////// 160 136 161 unsigned short * A[NB_CLUSTERS _MAX];162 int * B[NB_CLUSTERS _MAX];163 int * C[NB_CLUSTERS _MAX];164 int * D[NB_CLUSTERS _MAX];165 unsigned char * Z[NB_CLUSTERS _MAX];137 unsigned short * A[NB_CLUSTERS]; 138 int * B[NB_CLUSTERS]; 139 int * C[NB_CLUSTERS]; 140 int * D[NB_CLUSTERS]; 141 unsigned char * Z[NB_CLUSTERS]; 166 142 167 143 // get heap vaddr in cluster[0,0] … … 182 158 Z[c] = (unsigned char *) (cluster_offset + (frame_size * 7 / nclusters)); 183 159 184 if ( pid == 0 && VERBOSE ) 185 { 186 giet_shr_printf( "\n########################################\n" 187 "### A[%d] = %x\n" 188 "### B[%d] = %x\n" 189 "### C[%d] = %x\n" 190 "### D[%d] = %x\n" 191 "### Z[%d] = %x\n" 192 "########################################\n", 193 c,A[c],c,B[c],c,C[c],c,D[c],c,Z[c] ); 194 } 160 #if VERBOSE 161 if ( pid == 0 ) giet_shr_printf( "\n########################################\n" 162 "### A[%d] = %x\n" 163 "### B[%d] = %x\n" 164 "### C[%d] = %x\n" 165 "### D[%d] = %x\n" 166 "### Z[%d] = %x\n" 167 "########################################\n", 168 c,A[c],c,B[c],c,C[c],c,D[c],c,Z[c] ); 169 #endif 195 170 } 196 171 … … 230 205 " at cycle %d\n", giet_proctime() ); 231 206 232 for ( c = 0 ; c < nclusters ; c++ ) 233 { 234 giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] starts load" 235 " for cluster %d at cycle %d\n", 236 x, y, lpid, c, giet_proctime() ); 237 207 for ( c = 0 ; c < NB_CLUSTERS ; c++ ) 208 { 209 giet_shr_printf( "\n[CONVOL] task[0,0,0] starts load " 210 "for cluster %d at cycle %d\n", c, giet_proctime() ); 211 238 212 giet_fat_read( file, 239 213 A[c], … … 241 215 (nblocks/nclusters)*c ); 242 216 243 giet_shr_printf( "[CONVOL] task[%d,%d,%d] completes load" 244 " for cluster %d at cycle %d\n", 245 x, y, lpid, c, giet_proctime() ); 217 giet_shr_printf( "\n[CONVOL] task[0,0,0] completes load " 218 "for cluster %d at cycle %d\n", c, giet_proctime() ); 246 219 } 247 220 init_ok = 1; … … 259 232 if ( INITIAL_DISPLAY_ENABLE ) 260 233 { 261 date = giet_proctime(); 262 giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] starts initial display at cycle %d\n", 263 x, y, lpid, date); 234 235 #if VERBOSE 236 giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] starts initial display" 237 " at cycle %d\n", 238 x, y, lpid, giet_proctime() ); 239 #endif 264 240 265 241 unsigned int line; … … 280 256 } 281 257 282 date = giet_proctime(); 283 giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] completes initial display at cycle %d\n", 284 x, y, lpid, date); 258 #if VERBOSE 259 giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] completes initial display" 260 " at cycle %d\n", 261 x, y, lpid, giet_proctime() ); 262 #endif 285 263 286 264 /////////////////////////// … … 300 278 301 279 date = giet_proctime(); 302 giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] starts horizontal filter at cycle %d\n",303 x, y, lpid, date );304 280 H_BEG[cluster_id][lpid] = date; 281 282 #if VERBOSE 283 giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] starts horizontal filter" 284 " at cycle %d\n", 285 x, y, lpid, date ); 286 #else 287 if ( pid == 0 ) giet_shr_printf( "\n[CONVOL] task[0,0,0] starts horizontal filter" 288 " at cycle %d\n", date ); 289 #endif 305 290 306 291 // l = absolute line index / p = absolute pixel index … … 359 344 } 360 345 361 if ( VERBOSE ) 362 { 363 giet_shr_printf(" - line %d computed at cycle %d\n", l, giet_proctime() ); 364 } 346 #if SUPER_VERBOSE 347 giet_shr_printf(" - line %d computed at cycle %d\n", l, giet_proctime() ); 348 #endif 349 365 350 } 366 351 367 352 date = giet_proctime(); 368 giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] completes horizontal filter at cycle %d\n",369 x, y, lpid, date );370 353 H_END[cluster_id][lpid] = date; 354 355 #if VERBOSE 356 giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] completes horizontal filter" 357 " at cycle %d\n", 358 x, y, lpid, date ); 359 #else 360 if ( pid == 0 ) giet_shr_printf( "\n[CONVOL] task[0,0,0] completes horizontal filter" 361 " at cycle %d\n", date ); 362 #endif 371 363 372 364 /////////////////////////// 373 365 barrier_wait( &barrier_2 ); 374 366 375 ////////////////////////////////////////////////////////// 367 /////////////////////////////////////////////////////////////// 376 368 // parallel vertical filter : 377 369 // C <= transpose(FV(B)) … … 380 372 // if (l<0) TB(cluster_id,p,l) == TB(cluster_id,p,0) 381 373 // if (l>NL-1) TB(cluster_id,p,l) == TB(cluster_id,p,NL-1) 382 ////////////////////////////////////////////////////////// 374 /////////////////////////////////////////////////////////////// 383 375 384 376 date = giet_proctime(); 385 giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] starts vertical filter at cycle %d\n",386 x, y, lpid, date );387 377 V_BEG[cluster_id][lpid] = date; 378 379 #if VERBOSE 380 giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] starts vertical filter" 381 " at cycle %d\n", 382 x, y, lpid, date ); 383 #else 384 if ( pid == 0 ) giet_shr_printf( "\n[CONVOL] task[0,0,0] starts vertical filter" 385 " at cycle %d\n", date ); 386 #endif 388 387 389 388 // l = absolute line index / p = absolute pixel index … … 458 457 } 459 458 460 if ( VERBOSE ) 461 { 462 giet_shr_printf(" - column %d computed at cycle %d\n", p, giet_proctime()); 463 } 459 #if SUPER_VERBOSE 460 giet_shr_printf(" - column %d computed at cycle %d\n", p, giet_proctime()); 461 #endif 462 464 463 } 465 464 466 465 date = giet_proctime(); 467 giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] completes vertical filter at cycle %d\n",468 x, y, lpid, date );469 466 V_END[cluster_id][lpid] = date; 467 468 #if VERBOSE 469 giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] completes vertical filter" 470 " at cycle %d\n", 471 x, y, lpid, date ); 472 #else 473 if ( pid == 0 ) giet_shr_printf( "\n[CONVOL] task[0,0,0] completes vertical filter" 474 " at cycle %d\n", date ); 475 #endif 470 476 471 477 /////////////////////////// … … 480 486 { 481 487 date = giet_proctime(); 482 giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] starts final display at cycle %d\n",483 x, y, lpid, date);484 488 D_BEG[cluster_id][lpid] = date; 489 490 #if VERBOSE 491 giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] starts final display" 492 " at cycle %d\n", 493 x, y, lpid, date); 494 #else 495 if ( pid == 0 ) giet_shr_printf( "\n[CONVOL] task[0,0,0] starts final display" 496 " at cycle %d\n", date ); 497 #endif 485 498 486 499 unsigned int line; … … 504 517 505 518 date = giet_proctime(); 506 giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] completes final display at cycle %d\n",507 x, y, lpid, date);508 519 D_END[cluster_id][lpid] = date; 520 521 #if VERBOSE 522 giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] completes final display" 523 " at cycle %d\n", 524 x, y, lpid, date); 525 #else 526 if ( pid == 0 ) giet_shr_printf( "\n[CONVOL] task[0,0,0] completes final display" 527 " at cycle %d\n", date ); 528 #endif 509 529 510 530 /////////////////////////// … … 519 539 { 520 540 date = giet_proctime(); 521 giet_shr_printf("\n*** Starting Instrumentation at cycle %d\n\n", date); 541 giet_shr_printf("\n[CONVOL] task[0,0,0] starts instrumentation" 542 " at cycle %d\n\n", date ); 522 543 523 544 int cc, pp; … … 577 598 min_h_beg, max_h_beg, (min_h_beg+max_h_beg)/2, max_h_beg-min_h_beg); 578 599 579 giet_shr_printf(" - H_END 600 giet_shr_printf(" - H_END : min = %d / max = %d / med = %d / delta = %d\n", 580 601 min_h_end, max_h_end, (min_h_end+max_h_end)/2, max_h_end-min_h_end); 581 602 … … 583 604 min_v_beg, max_v_beg, (min_v_beg+max_v_beg)/2, max_v_beg-min_v_beg); 584 605 585 giet_shr_printf(" - V_END 606 giet_shr_printf(" - V_END : min = %d / max = %d / med = %d / delta = %d\n", 586 607 min_v_end, max_v_end, (min_v_end+max_v_end)/2, max_v_end-min_v_end); 587 608 … … 589 610 min_d_beg, max_d_beg, (min_d_beg+max_d_beg)/2, max_d_beg-min_d_beg); 590 611 591 giet_shr_printf(" - D_END 612 giet_shr_printf(" - D_END : min = %d / max = %d / med = %d / delta = %d\n", 592 613 min_d_end, max_d_end, (min_d_end+max_d_end)/2, max_d_end-min_d_end); 593 614 594 615 giet_shr_printf( "\n General Scenario (Kcycles for each step)\n" ); 595 giet_shr_printf( " - BOOT OS = %d\n", min_start);596 giet_shr_printf( " - LOAD IMAGE = %d\n", min_h_beg - min_start);597 giet_shr_printf( " - H_FILTER = %d\n", max_h_end - min_h_beg);598 giet_shr_printf( " - BARRIER HORI/VERT = %d\n", min_v_beg - max_h_end);599 giet_shr_printf( " - V_FILTER = %d\n", max_v_end - min_v_beg);600 giet_shr_printf( " - BARRIER VERT/DISP = %d\n", min_d_beg - max_v_end);601 giet_shr_printf( " - DISPLAY = %d\n", max_d_end - min_d_beg);616 giet_shr_printf( " - BOOT OS = %d\n", (min_start )/1000 ); 617 giet_shr_printf( " - LOAD IMAGE = %d\n", (min_h_beg - min_start)/1000 ); 618 giet_shr_printf( " - H_FILTER = %d\n", (max_h_end - min_h_beg)/1000 ); 619 giet_shr_printf( " - BARRIER HORI/VERT = %d\n", (min_v_beg - max_h_end)/1000 ); 620 giet_shr_printf( " - V_FILTER = %d\n", (max_v_end - min_v_beg)/1000 ); 621 giet_shr_printf( " - BARRIER VERT/DISP = %d\n", (min_d_beg - max_v_end)/1000 ); 622 giet_shr_printf( " - DISPLAY = %d\n", (max_d_end - min_d_beg)/1000 ); 602 623 603 624 exit_ok = 1;
Note: See TracChangeset
for help on using the changeset viewer.