Changeset 372 for soft/giet_vm
- Timestamp:
- Jul 31, 2014, 9:54:37 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/convol/main.c
r362 r372 11 11 #include "stdlib.h" 12 12 #include "barrier.h" 13 13 #include "remote_malloc.h" 14 15 #define USE_SBT_BARRIER 1 14 16 #define VERBOSE 0 15 17 #define SUPER_VERBOSE 0 … … 34 36 #define min(x,y) ((x) < (y) ? (x) : (y)) 35 37 36 // instrumentation counters indexed by (cluster_id, lpid] 38 // global instrumentation counters (cluster_id, lpid] 39 37 40 unsigned int START[NB_CLUSTERS][NB_PROCS_MAX]; 38 41 unsigned int H_BEG[NB_CLUSTERS][NB_PROCS_MAX]; … … 43 46 unsigned int D_END[NB_CLUSTERS][NB_PROCS_MAX]; 44 47 45 // synchronization barriers 46 giet_barrier_t barrier_1; 47 giet_barrier_t barrier_2; 48 giet_barrier_t barrier_3; 49 giet_barrier_t barrier_4; 50 51 volatile unsigned int init_ok = 0; 52 volatile unsigned int exit_ok = 0; 53 48 // global synchronization barrier 49 50 #if USE_SBT_BARRIER 51 giet_sbt_barrier_t barrier; 52 #else 53 giet_barrier_t barrier; 54 #endif 55 56 volatile unsigned int barrier_init_ok = 0; 57 volatile unsigned int load_image_ok = 0; 58 volatile unsigned int instrumentation_ok = 0; 59 60 // global pointers on distributed buffers in all clusters 61 unsigned short * GA[NB_CLUSTERS]; 62 int * GB[NB_CLUSTERS]; 63 int * GC[NB_CLUSTERS]; 64 int * GD[NB_CLUSTERS]; 65 unsigned char * GZ[NB_CLUSTERS]; 54 66 55 67 /////////////////////////////////////////// … … 128 140 giet_exit( "[CONVOL ERROR] NB_CLUSTERS must be a divider of NP"); 129 141 142 130 143 /////////////////////////////////////////////////////////////////// 131 // All tasks initialise in their private stack five 132 // arrays of pointers on the shared, distributed buffers, 133 // containing the image. These buffers are indexed by cluster_id, 134 // as there one set of 5 buffers per cluster. 144 // task[0][0][0] makes barrier initialisation 135 145 /////////////////////////////////////////////////////////////////// 136 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]; 142 143 // get heap vaddr in cluster[0,0] 144 unsigned int base; 145 giet_vobj_get_vbase( "convol", "conv_heap_0_0", &base ); 146 147 // size allocated to each cluster depends on the number of clusters 148 unsigned int size = 0x01000000 / nclusters; 149 150 // initialise pointers on distributed buffers 151 for (c = 0; c < nclusters; c++) 152 { 153 unsigned int cluster_offset = base + (size * c); 154 A[c] = (unsigned short *) (cluster_offset); 155 B[c] = (int *) (cluster_offset + (frame_size * 1 / nclusters)); 156 C[c] = (int *) (cluster_offset + (frame_size * 3 / nclusters)); 157 D[c] = (int *) (cluster_offset + (frame_size * 5 / nclusters)); 158 Z[c] = (unsigned char *) (cluster_offset + (frame_size * 7 / nclusters)); 159 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 170 } 171 172 /////////////////////////////////////////////////////////////////////////// 173 // task[0,0,0] makes barrier initialisation, 174 // open the file containing image, and load it from disk to A[c] buffers 175 // (nblocks / nclusters loaded in each cluster). 176 // Other tasks are waiting on the init_ok condition. 177 ////////////////////////////////////////////////////////////////////////// 146 178 147 if ( pid == 0 ) 179 148 { … … 187 156 giet_proctime(), nclusters, nprocs, ntasks, 188 157 npixels, frame_size, nblocks ); 189 190 // barriers initialization 191 barrier_init( &barrier_1, ntasks ); 192 barrier_init( &barrier_2, ntasks ); 193 barrier_init( &barrier_3, ntasks ); 194 barrier_init( &barrier_4, ntasks ); 195 196 giet_shr_printf( "\n[CONVOL] task[0,0,0] completes barrier init at cycle %d\n", 197 giet_proctime() ); 198 158 #if USE_SBT_BARRIER 159 sbt_barrier_init( &barrier, ntasks ); 160 #else 161 barrier_init( &barrier, ntasks ); 162 #endif 163 164 giet_shr_printf( "\n[CONVOL] task[0,0,0] completes barrier init at cycle %d\n", 165 giet_proctime() ); 166 167 barrier_init_ok = 1; 168 } 169 else 170 { 171 while ( barrier_init_ok == 0 ); 172 } 173 174 /////////////////////////////////////////////////////////////////// 175 // All task[x][y][0] allocate the global buffers in cluster(x,y) 176 // These buffers mut be sector-aligned. 177 /////////////////////////////////////////////////////////////////// 178 if ( lpid == 0 ) 179 { 180 181 #if VERBOSE 182 giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] enters malloc at cycle %d\n", x,y,lpid, date ); 183 #endif 184 185 GA[cluster_id] = remote_malloc( (FRAME_SIZE/nclusters) , 9 , x , y ); 186 GB[cluster_id] = remote_malloc( (FRAME_SIZE/nclusters)*2 , 9 , x , y ); 187 GC[cluster_id] = remote_malloc( (FRAME_SIZE/nclusters)*2 , 9 , x , y ); 188 GD[cluster_id] = remote_malloc( (FRAME_SIZE/nclusters)*2 , 9 , x , y ); 189 GZ[cluster_id] = remote_malloc( (FRAME_SIZE/nclusters)/2 , 9 , x , y ); 190 191 #if VERBOSE 192 giet_shr_printf( "\n[CONVOL] Shared Buffer Virtual Addresses in cluster(%d,%d)\n" 193 "### GA = %x\n" 194 "### GB = %x\n" 195 "### GC = %x\n" 196 "### GD = %x\n" 197 "### GZ = %x\n", 198 x, y, 199 GA[cluster_id], 200 GB[cluster_id], 201 GC[cluster_id], 202 GD[cluster_id], 203 GZ[cluster_id] ); 204 #endif 205 } 206 207 #if USE_SBT_BARRIER 208 sbt_barrier_wait( &barrier ); 209 #else 210 barrier_wait( &barrier ); 211 #endif 212 213 214 /////////////////////////////////////////////////////////////////// 215 // All tasks initialise in their private stack a copy of the 216 // arrays of pointers on the shared, distributed buffers. 217 /////////////////////////////////////////////////////////////////// 218 219 unsigned short * A[NB_CLUSTERS]; 220 int * B[NB_CLUSTERS]; 221 int * C[NB_CLUSTERS]; 222 int * D[NB_CLUSTERS]; 223 unsigned char * Z[NB_CLUSTERS]; 224 225 for (c = 0; c < nclusters; c++) 226 { 227 A[c] = GA[c]; 228 B[c] = GB[c]; 229 C[c] = GC[c]; 230 D[c] = GD[c]; 231 Z[c] = GZ[c]; 232 } 233 234 /////////////////////////////////////////////////////////////////////////// 235 // task[0,0,0] open the file containing image, and load it from disk 236 // to all A[c] buffers (nblocks / nclusters loaded in each cluster). 237 // Other tasks are waiting on the init_ok condition. 238 ////////////////////////////////////////////////////////////////////////// 239 if ( pid == 0 ) 240 { 199 241 // open file 200 242 file = giet_fat_open("misc/philips_image.raw", 0 ); … … 218 260 "for cluster %d at cycle %d\n", c, giet_proctime() ); 219 261 } 220 init_ok = 1;262 load_image_ok = 1; 221 263 } 222 264 else 223 265 { 224 while ( init_ok == 0 );266 while ( load_image_ok == 0 ); 225 267 } 226 268 … … 262 304 #endif 263 305 264 /////////////////////////// 265 barrier_wait( &barrier_1 ); 306 #if USE_SBT_BARRIER 307 sbt_barrier_wait( &barrier ); 308 #else 309 barrier_wait( &barrier ); 310 #endif 266 311 267 312 } … … 362 407 #endif 363 408 364 /////////////////////////// 365 barrier_wait( &barrier_2 ); 409 #if USE_SBT_BARRIER 410 sbt_barrier_wait( &barrier ); 411 #else 412 barrier_wait( &barrier ); 413 #endif 414 366 415 367 416 /////////////////////////////////////////////////////////////// … … 475 524 #endif 476 525 477 /////////////////////////// 478 barrier_wait( &barrier_3 ); 526 #if USE_SBT_BARRIER 527 sbt_barrier_wait( &barrier ); 528 #else 529 barrier_wait( &barrier ); 530 #endif 479 531 480 532 //////////////////////////////////////////////////////////////// … … 528 580 #endif 529 581 530 /////////////////////////// 531 barrier_wait( &barrier_4 ); 582 #if USE_SBT_BARRIER 583 sbt_barrier_wait( &barrier ); 584 #else 585 barrier_wait( &barrier ); 586 #endif 587 532 588 } 533 589 … … 622 678 giet_shr_printf( " - DISPLAY = %d\n", (max_d_end - min_d_beg)/1000 ); 623 679 624 exit_ok = 1;680 instrumentation_ok = 1; 625 681 } 626 682 else 627 683 { 628 while ( exit_ok == 0 );684 while ( instrumentation_ok == 0 ); 629 685 } 630 686
Note: See TracChangeset
for help on using the changeset viewer.