Changeset 307 for soft/giet_vm
- Timestamp:
- Apr 21, 2014, 5:17:36 AM (11 years ago)
- Location:
- soft/giet_vm/transpose
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/transpose/main.c
r295 r307 9 9 // 10 10 // - The image size NN must be a power of 2. 11 // - The number of clusters containing processors (X_SIZE*Y_SIZE-1)must be a power of 2.11 // - The number of clusters containing processors must be a power of 2. 12 12 // - The number of processors per cluster (NB_PROCS_MAX) must be a power of 2. 13 13 // - The image size NN must be larger or equal to the total number of processor. … … 26 26 #define FILE_PATHNAME "misc/images.raw" // file pathname on disk 27 27 28 #define VERBOSE_OK 0 // display a detailed log on TTY when non zero29 28 #define INSTRUMENTATION_OK 0 // display statistcs on TTY when non zero 30 29 … … 48 47 unsigned char* buf_out[32]; 49 48 50 // array of heap names51 // one heap per cluster52 char* heap_name[32] = { "trsp_heap_0" , "trsp_heap_1" , "trsp_heap_2" , "trsp_heap_3" ,53 "trsp_heap_4" , "trsp_heap_5" , "trsp_heap_6" , "trsp_heap_7" ,54 "trsp_heap_8" , "trsp_heap_9" , "trsp_heap_10", "trsp_heap_11",55 "trsp_heap_12", "trsp_heap_13", "trsp_heap_14", "trsp_heap_15",56 "trsp_heap_16", "trsp_heap_17", "trsp_heap_18", "trsp_heap_19",57 "trsp_heap_20", "trsp_heap_21", "trsp_heap_22", "trsp_heap_23",58 "trsp_heap_24", "trsp_heap_25", "trsp_heap_26", "trsp_heap_27",59 "trsp_heap_28", "trsp_heap_29", "trsp_heap_30", "trsp_heap_31" };60 61 49 // checksum variables 62 50 unsigned check_line_before[NN]; … … 76 64 { 77 65 78 int file; // file descriptor for images 79 unsigned int l; // line index for loops 80 unsigned int p; // pixel index for loops 81 unsigned int proc_id = giet_procid(); // processor id 82 unsigned int nclusters = X_SIZE*(Y_SIZE-1); // number of clusters with procs 83 unsigned int lpid = proc_id % NB_PROCS_MAX; // local processor id 84 unsigned int cluster_xy = proc_id / NB_PROCS_MAX; // cluster index (8 bits format) 85 unsigned int x = cluster_xy >> Y_WIDTH; // x coordinate 86 unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1); // y coordinate 87 unsigned int ntasks = nclusters * NB_PROCS_MAX; // number of tasks 88 unsigned int npixels = NN * NN; // number of pixel per image 89 unsigned int nblocks = npixels / 512; // number of blocks per image 90 unsigned int image = 0; 91 92 // cluster_id is a "continuous" index from (0 to nclusters-1) 93 // for a cluster with coordinates (x,y) 94 unsigned int cluster_id = (x * (Y_SIZE-1)) + y; 95 96 // task_id is a "continuous" index (from 0 to ntasks-1 97 // for the the task running on processor[x,y,lpid] 98 unsigned int task_id = (cluster_id * NB_PROCS_MAX) + lpid; 99 100 giet_shr_printf("\n*** Proc [%d,%d,%d] enters main() at cycle %d ***\n", 101 x, y, lpid, giet_proctime() ); 66 int file; // file descriptor for images 67 unsigned int l; // line index for loops 68 unsigned int p; // pixel index for loops 69 70 unsigned int proc_id = giet_procid(); // processor id 71 unsigned int lpid = proc_id % NB_PROCS_MAX; // local processor id 72 unsigned int cluster_xy = proc_id / NB_PROCS_MAX; // cluster index (8 bits format) 73 unsigned int x = cluster_xy >> Y_WIDTH; // x coordinate 74 unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1); // y coordinate 75 76 unsigned int npixels = NN * NN; // number of pixel per image 77 unsigned int nblocks = npixels / 512; // number of blocks per image 78 unsigned int image = 0; // image counter 79 80 unsigned int nclusters = X_SIZE * Y_SIZE; // number of clusters with procs 81 unsigned int cluster_id = (x * Y_SIZE) + y; // "continuous" cluster index 82 unsigned int ntasks = nclusters * NB_PROCS_MAX; // number of tasks 83 unsigned int task_id = (cluster_id * NB_PROCS_MAX) +lpid; // "continuous" task index 102 84 103 85 // processor [0,0,0] makes parameters checking and barriers initialization … … 126 108 giet_shr_printf("\n*** Proc [%d,%d,%d] completes barrier init at cycle %d\n", 127 109 0, 0, 0, giet_proctime() ); 110 128 111 init_ok = 0; 129 112 } … … 136 119 // (one buf_in and one buf_out per cluster). 137 120 // Each buffer contains (NN*NN / nclusters) bytes. 138 // They are allocated in the cluster heap by processor with (lpid == 0).121 // They are allocated in the cluster[x,y] heap by processor[x,y,0] 139 122 if ( lpid == 0 ) 140 123 { 141 unsigned int heap_base;142 giet_vobj_get_vbase( "transpose",143 heap_name[cluster_id],144 &heap_base );145 146 buf_in[cluster_id] = ( unsigned char*)heap_base;147 buf_out[cluster_id] = (unsigned char*)(heap_base + NN*NN/nclusters);124 // get heap vaddr in cluster[0,0] 125 unsigned int heap_base; 126 giet_vobj_get_vbase( "transpose", "heap_0_0", &heap_base ); 127 128 // allocate buffers in cluster[x,y] 129 buf_in[cluster_id] = ((unsigned char*)heap_base) + (cluster_xy << 20); 130 buf_out[cluster_id] = buf_in[cluster_id] + NN*NN/nclusters; 148 131 149 132 giet_shr_printf("\n*** Proc [%d,%d,%d] completes buffer allocation at cycle %d\n" … … 157 140 file = giet_fat_open( "misc/images.raw", 0); 158 141 159 giet_assert( (file >= 0), 160 "[TRANSPOSE ERROR] cannot open file misc/images.raw"); 161 162 giet_shr_printf("\n*** Proc [%d,%d,%d] completes _fat_open at cycle %d\n", 163 x, y, 0, giet_proctime() ); 142 if (file < 0) 143 { 144 giet_shr_printf("[TRANSPOSE ERROR] Processor[%d,%d,%d]" 145 " cannot open file misc/images.raw", 146 x, y, lpid ); 147 giet_exit(" open() failure"); 148 } 164 149 } 165 150 166 ////////////////////////////////////////////////// 167 // all tasks wait buffer allocation completion 168 ////////////////////////////////////////////////// 151 /////////////////////////// 169 152 barrier_wait( &barrier_0 ); 170 153 … … 179 162 if (lpid == 0) 180 163 { 181 giet_shr_printf("\n*** Proc [%d,%d,%d] starts load for image %d at cycle %d\n",182 x, y, 0, image, giet_proctime() );183 184 164 giet_fat_read( file, 185 165 buf_in[cluster_id], … … 193 173 LOAD_END[cluster_id][lpid] = giet_proctime(); 194 174 195 ////////////////////////////////////////////////// 196 // all tasks wait buf_in load completion 197 ////////////////////////////////////////////////// 175 /////////////////////////// 198 176 barrier_wait( &barrier_1 ); 199 177 … … 203 181 // (p,l) are the absolute pixel coordinates in the source image 204 182 205 giet_shr_printf("\n*** proc [%d,%d,%d] starts transpose for image %d at cycle %d\n",206 x, y, lpid, image, giet_proctime());207 183 208 184 TRSP_START[cluster_id][lpid] = giet_proctime(); … … 223 199 for ( l = first ; l < last ; l++ ) 224 200 { 225 226 #if VERBOSE_OK227 giet_shr_printf(" - Proc[%d,%d,%d] process line %d\n", x, y, lpid, l );228 #endif229 230 201 check_line_before[l] = 0; 231 202 … … 248 219 } 249 220 250 giet_shr_printf("\n*** proc [%d,%d,%d] completes transpose for image %d at cycle %d\n", 251 x, y, lpid, image, giet_proctime() ); 252 221 if ( lpid == 0 ) 222 { 223 giet_shr_printf("\n*** proc [%d,%d,0] completes transpose for image %d at cycle %d\n", 224 x, y, image, giet_proctime() ); 225 226 } 253 227 TRSP_END[cluster_id][lpid] = giet_proctime(); 254 228 255 ////////////////////////////////////////////////// 256 // all tasks wait transpose completion 257 ////////////////////////////////////////////////// 229 /////////////////////////// 258 230 barrier_wait( &barrier_2 ); 259 231 … … 261 233 // all processors contribute to display using memcpy... 262 234 263 if ( ( X_IO != 0) || (Y_IO != 0) ) // external frame buffer available 264 { 265 giet_shr_printf("\n*** proc [%d,%d,%d] starts display for image %d at cycle %d\n", 266 x, y, lpid, image, giet_proctime() ); 267 235 if ( USE_FBF ) // external frame buffer available 236 { 268 237 DISP_START[cluster_id][lpid] = giet_proctime(); 269 238 … … 274 243 npt ); 275 244 276 giet_shr_printf("\n*** Proc [%d,%d,%d] completes display for image %d at cycle %d\n", 277 x, y, lpid, image, giet_proctime() ); 245 if ( lpid == 0 ) 246 { 247 giet_shr_printf("\n*** Proc [%d,%d,0] completes display for image %d at cycle %d\n", 248 x, y, image, giet_proctime() ); 249 } 278 250 279 251 DISP_END[cluster_id][lpid] = giet_proctime(); 280 252 281 ////////////////////////////////////////////////// 282 // all tasks wait display completion 283 ////////////////////////////////////////////////// 253 /////////////////////////// 284 254 barrier_wait( &barrier_3 ); 285 255 } … … 289 259 if ( lpid == 0 ) 290 260 { 291 giet_shr_printf("\n*** Proc [%d,%d,%d] starts checks for image %d at cycle %d\n",292 x, y, lpid, image, giet_proctime() );293 294 261 unsigned int success = 1; 295 262 unsigned int start = cluster_id * nlc; … … 311 278 } 312 279 313 #if VERBOSE_OK314 giet_shr_printf(" - l = %d / before = %d / after = %d \n",315 l, check_line_before[l], check_line_after[l] );316 #endif317 280 if ( check_line_before[l] != check_line_after[l] ) success = 0; 318 281 } -
soft/giet_vm/transpose/transpose.ld
r295 r307 3 3 *****************************************************************************/ 4 4 5 seg_code_base = 0x 00400000;6 seg_data_base = 0x 00500000;5 seg_code_base = 0x10000000; 6 seg_data_base = 0x20000000; 7 7 8 8 /***************************************************************************
Note: See TracChangeset
for help on using the changeset viewer.