Changeset 393
- Timestamp:
- Aug 11, 2014, 9:29:28 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/transpose/main.c
r383 r393 14 14 // 15 15 // For each image the application makes a self test (checksum for each line). 16 // The actual display on the frame buffer is optional (controled by DISPLAY_OK define)16 // The actual display on the frame buffer depends on frame buffer availability. 17 17 /////////////////////////////////////////////////////////////////////////////////////////////// 18 18 … … 26 26 #define FILE_PATHNAME "misc/images.raw" // file pathname on disk 27 27 #define NB_CLUSTERS (X_SIZE * Y_SIZE) // number of clusters 28 #define INSTRUMENTATION_OK 1// display statistics on TTY when non zero28 #define INSTRUMENTATION_OK 0 // display statistics on TTY when non zero 29 29 30 30 /////////////////////////////////////////////////////// … … 64 64 unsigned int l; // line index for loops 65 65 unsigned int p; // pixel index for loops 66 unsigned int c; // cluster index for loops 66 67 67 68 unsigned int proc_id = giet_procid(); // global processor id 68 69 unsigned int lpid = proc_id % NB_PROCS_MAX; // local processor id 69 unsigned int cluster_xy = proc_id / NB_PROCS_MAX; // cluster index (8 bits format)70 unsigned int cluster_xy = proc_id / NB_PROCS_MAX; // 8 bits format 70 71 unsigned int x = cluster_xy >> Y_WIDTH; // x coordinate 71 72 unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1); // y coordinate … … 75 76 unsigned int image = 0; // image counter 76 77 77 unsigned int nclusters = X_SIZE * Y_SIZE; // clusters with procs 78 unsigned int cluster_id = (x * Y_SIZE) + y; // "continuous" cluster index 79 unsigned int ntasks = nclusters * NB_PROCS_MAX; // number of tasks 78 unsigned int cluster_id = (x * Y_SIZE) + y; // "continuous" index 79 unsigned int ntasks = NB_CLUSTERS * NB_PROCS_MAX; // number of tasks 80 80 unsigned int task_id = (cluster_id * NB_PROCS_MAX) + lpid; // "continuous" task index 81 81 82 // processor [0,0,0] makes parameters checking and barriers initialization 82 // processor [0,0,0] makes nitialisation 83 // It includes parameters checking, barriers initialization, 84 // distributed buffers allocation, and file open 83 85 if ( proc_id == 0 ) 84 86 { 87 // Parameters checking 85 88 if ((NB_PROCS_MAX != 1) && (NB_PROCS_MAX != 2) && (NB_PROCS_MAX != 4)) 86 89 { 87 90 giet_exit("[TRANSPOSE ERROR] NB_PROCS_MAX must be 1, 2 or 4"); 88 91 } 89 if (( nclusters != 1) && (nclusters != 2) && (nclusters != 4) && (nclusters != 8) &&90 ( nclusters != 16) && (nclusters!= 32) )91 { 92 giet_exit("[TRANSPOSE ERROR] number of clusters must be 2,4,8,16,32");92 if ((NB_CLUSTERS != 1) && (NB_CLUSTERS != 2) && (NB_CLUSTERS != 4) && 93 (NB_CLUSTERS != 8) && (NB_CLUSTERS != 16) && (NB_CLUSTERS != 32) ) 94 { 95 giet_exit("[TRANSPOSE ERROR] number of clusters must be 1,2,4,8,16,32"); 93 96 } 94 97 if ( ntasks > NN ) … … 97 100 } 98 101 102 giet_shr_printf("\n[TRANSPOSE] Processor[0,0,0] starts at cycle %d\n" 103 " - x_size = %d\n" 104 " - y_size = %d\n" 105 " - nprocs = %d\n" 106 " - nclusters = %d\n" 107 " - ntasks = %d\n", 108 giet_proctime(), X_SIZE, Y_SIZE, NB_PROCS_MAX, NB_CLUSTERS, ntasks ); 109 110 // Barrier initialisation 99 111 barrier_init( &barrier, ntasks ); 100 112 101 giet_shr_printf("\n[TRANSPOSE] Proc [%d,%d,%d] completes barrier init at cycle %d\n", 102 x, y, lpid, giet_proctime() ); 103 104 giet_shr_printf(" - x_size = %d\n", X_SIZE ); 105 giet_shr_printf(" - y_size = %d\n", Y_SIZE ); 106 giet_shr_printf(" - y_size = %d\n", Y_SIZE ); 107 giet_shr_printf(" - nprocs = %d\n", NB_PROCS_MAX ); 108 giet_shr_printf(" - nclusters = %d\n", nclusters ); 109 giet_shr_printf(" - ntasks = %d\n", ntasks ); 110 113 giet_shr_printf("\n[TRANSPOSE] Proc [0,0,0] completes barrier init at cycle %d\n", 114 giet_proctime() ); 115 116 // Distributed buffers allocation 117 // The buffers containing one image are distributed in clusters 118 // (one buf_in and one buf_out per cluster). 119 // Each buffer contains (NN*NN / NB_CLUSTERS) bytes. 120 for ( c = 0 ; c < NB_CLUSTERS ; c++ ) 121 { 122 unsigned int rx = c / Y_SIZE; 123 unsigned int ry = c % Y_SIZE; 124 125 buf_in[c] = remote_malloc( npixels/NB_CLUSTERS, rx, ry ); 126 buf_out[c] = remote_malloc( npixels/NB_CLUSTERS, rx, ry ); 127 128 giet_shr_printf("\n[TRANSPOSE] Proc [0,0,0] completes buffer allocation" 129 " for cluster[%d,%d] at cycle %d\n" 130 " - buf_in = %x\n" 131 " - buf_out = %x\n", 132 rx, ry, giet_proctime(), 133 (unsigned int)buf_in[c], 134 (unsigned int)buf_out[c] ); 135 } 136 137 // open file containing images 138 file = giet_fat_open( "misc/images.raw", 0); 139 140 if (file < 0) 141 { 142 giet_shr_printf("\n[TRANSPOSE ERROR] Processor[%d,%d,%d]" 143 " cannot open file misc/images.raw", 144 x, y, lpid ); 145 giet_exit(" open() failure"); 146 } 147 else 148 { 149 giet_shr_printf("\n[TRANSPOSE] Processor[0,0,0] open file misc/images.raw\n"); 150 } 111 151 init_ok = 0; 112 152 } … … 116 156 } 117 157 118 // The buffers containing the images are distributed in clusters119 // (one buf_in and one buf_out per cluster).120 // Each buffer contains (NN*NN / nclusters) bytes.121 // They are allocated in the cluster[x,y] heap by processor[x,y,0]122 if ( lpid == 0 )123 {124 // get heap vaddr in cluster[0,0]125 unsigned int heap_base;126 giet_vobj_get_vbase( "transpose", "trsp_heap_0_0", &heap_base );127 128 // allocate buffers in cluster[x,y]129 buf_in[cluster_id] = remote_malloc( npixels/NB_CLUSTERS, x, y);130 buf_out[cluster_id] = remote_malloc( npixels/NB_CLUSTERS, x, y);131 132 giet_shr_printf("\n[TRANSPOSE] Proc [%d,%d,%d] completes buffer allocation at cycle %d\n"133 " - buf_in = %x\n"134 " - buf_out = %x\n",135 x, y, 0, giet_proctime(),136 (unsigned int)buf_in[cluster_id],137 (unsigned int)buf_out[cluster_id] );138 139 // open file containing images140 file = giet_fat_open( "misc/images.raw", 0);141 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 }149 else150 {151 giet_shr_printf("\n[TRANSPOSE] Processor[%d,%d,%d]"152 " open file misc/images.raw\n",153 x, y, lpid );154 }155 }156 158 157 159 ///////////////////////// 158 barrier_wait( &barrier );159 160 160 // Main loop (on images) 161 161 while (image < NB_IMAGES) 162 162 { 163 // pseudo parallel load from disk to buf_in buffer : nblocks/ nclustersblocks163 // pseudo parallel load from disk to buf_in buffer : nblocks/NB_CLUSTERS blocks 164 164 // only task running on processor with (lpid == 0) does it 165 165 … … 170 170 giet_fat_read( file, 171 171 buf_in[cluster_id], 172 (nblocks / nclusters),173 ((image*nblocks) + ((nblocks*cluster_id)/ nclusters)) );172 (nblocks / NB_CLUSTERS), 173 ((image*nblocks) + ((nblocks*cluster_id)/NB_CLUSTERS)) ); 174 174 175 175 giet_shr_printf("\n[TRANSPOSE] Proc [%d,%d,0] completes load" … … 192 192 193 193 unsigned int nlt = NN / ntasks; // number of lines per task 194 unsigned int nlc = NN / nclusters; // number of lines per cluster194 unsigned int nlc = NN / NB_CLUSTERS; // number of lines per cluster 195 195 196 196 unsigned int src_cluster; … … 325 325 unsigned int max_disp_ended = 0; 326 326 327 for (cc = 0; cc < nclusters; cc++)327 for (cc = 0; cc < NB_CLUSTERS; cc++) 328 328 { 329 329 for (pp = 0; pp < NB_PROCS_MAX; pp++) … … 371 371 image++; 372 372 373 ////////////////////////////////////////////////// 374 // all tasks must wait instrumentation completion 375 ////////////////////////////////////////////////// 373 ///////////////////////// 376 374 barrier_wait( &barrier ); 377 375
Note: See TracChangeset
for help on using the changeset viewer.