Changeset 473 for soft/giet_vm/applications/classif/main.c
- Timestamp:
- Dec 12, 2014, 5:44:59 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/applications/classif/main.c
r457 r473 17 17 // as global variables distributed in (up to) 16 clusters. 18 18 // 19 // WARNING: the platform cannot contain more than 16 clusters: (X_SIZE < 4) && (Y_SIZE < 4) 20 // 21 // 1) The "load" task transfer one container from the kernel chbuf associated to the 22 // NIC_RX channel, to a private buffer. Then it copies this bufferer to the local MWMR fifo. 19 // Initialisation is done in two steps by the "load" tasks: 20 // - Task "load" in cluster[0][0] initialises NIC & CMA channel, and initialises 21 // the barrier between all "load" tasks. Other "load" tasks are waiting on the 22 // global_sync synchronisation variable. 23 // - In each cluster[x][y], the load" task allocates the MWMR fifo descriptor & the data 24 // buffer in the local heap, and store the pointers on a global array of pointers. 25 // The "analyse" tasks are waiting on the sync[x][y] variables. 26 // 27 // When initialisation is completed, all "load and "analyse" tasks loop on containers: 28 // 1) The "load" task transfer containers from the kernel chbuf associated to the 29 // NIC_RX channel (in cluster[0][0]), to the local MWMR fifo (in cluster[x][y]), 30 // after an in termediate copy in a private stack buffer. 23 31 // Each "load" task loads CONTAINERS_MAX containers before exit, and the 24 32 // task in cluster[0,0] displays the results stored in global counters filled 25 // by the "analyse" tasks .33 // by the "analyse" tasks when all "load" tasks reach the barrier. 26 34 // 27 35 // 2) The "analyse" task transfer one container from the local MWMR fifo to a private … … 47 55 #define CONTAINERS_MAX 10 48 56 49 /////////// distributed data ///////////////////////////////////////////////////////////// 50 // - fifo_x_y is the local MWMR fifo descriptor 51 // - data_x_y is the local MWMR fifo data buffer 52 // - sync_x_y is the local variable signaling MWMR fifo initialisation 53 /////////// distributed data ///////////////////////////////////////////////////////////// 54 55 #if ( (X_SIZE > 0) && (Y_SIZE > 0) ) 56 __attribute__((section (".data_0_0"))) mwmr_channel_t fifo_0_0; 57 __attribute__((section (".data_0_0"))) unsigned int data_0_0[NB_PROCS_MAX<<10]; 58 __attribute__((section (".data_0_0"))) unsigned int sync_0_0 = 0; 59 #endif 60 #if ( (X_SIZE > 0) && (Y_SIZE > 1) ) 61 __attribute__((section (".data_0_1"))) mwmr_channel_t fifo_0_1; 62 __attribute__((section (".data_0_1"))) unsigned int data_0_1[NB_PROCS_MAX<<10]; 63 __attribute__((section (".data_0_1"))) unsigned int sync_0_1 = 0; 64 #endif 65 #if ( (X_SIZE > 0) && (Y_SIZE > 2) ) 66 __attribute__((section (".data_0_2"))) mwmr_channel_t fifo_0_2; 67 __attribute__((section (".data_0_2"))) unsigned int data_0_2[NB_PROCS_MAX<<10]; 68 __attribute__((section (".data_0_2"))) unsigned int sync_0_2 = 0; 69 #endif 70 #if ( (X_SIZE > 0) && (Y_SIZE > 3) ) 71 __attribute__((section (".data_0_3"))) mwmr_channel_t fifo_0_3; 72 __attribute__((section (".data_0_3"))) unsigned int data_0_3[NB_PROCS_MAX<<10]; 73 __attribute__((section (".data_0_3"))) unsigned int sync_0_3 = 0; 74 #endif 75 #if ( (X_SIZE > 1) && (Y_SIZE > 0) ) 76 __attribute__((section (".data_1_0"))) mwmr_channel_t fifo_1_0; 77 __attribute__((section (".data_1_0"))) unsigned int data_1_0[NB_PROCS_MAX<<10]; 78 __attribute__((section (".data_1_0"))) unsigned int sync_1_0 = 0; 79 #endif 80 #if ( (X_SIZE > 1) && (Y_SIZE > 1) ) 81 __attribute__((section (".data_1_1"))) mwmr_channel_t fifo_1_1; 82 __attribute__((section (".data_1_1"))) unsigned int data_1_1[NB_PROCS_MAX<<10]; 83 __attribute__((section (".data_1_1"))) unsigned int sync_1_1 = 0; 84 #endif 85 #if ( (X_SIZE > 1) && (Y_SIZE > 2) ) 86 __attribute__((section (".data_1_2"))) mwmr_channel_t fifo_1_2; 87 __attribute__((section (".data_1_2"))) unsigned int data_1_2[NB_PROCS_MAX<<10]; 88 __attribute__((section (".data_1_2"))) unsigned int sync_1_2 = 0; 89 #endif 90 #if ( (X_SIZE > 1) && (Y_SIZE > 3) ) 91 __attribute__((section (".data_1_3"))) mwmr_channel_t fifo_1_3; 92 __attribute__((section (".data_1_3"))) unsigned int data_1_3[NB_PROCS_MAX<<10]; 93 __attribute__((section (".data_1_3"))) unsigned int sync_1_3 = 0; 94 #endif 95 #if ( (X_SIZE > 2) && (Y_SIZE > 0) ) 96 __attribute__((section (".data_2_0"))) mwmr_channel_t fifo_2_0; 97 __attribute__((section (".data_2_0"))) unsigned int data_2_0[NB_PROCS_MAX<<10]; 98 __attribute__((section (".data_2_0"))) unsigned int sync_2_0 = 0; 99 #endif 100 #if ( (X_SIZE > 2) && (Y_SIZE > 1) ) 101 __attribute__((section (".data_2_1"))) mwmr_channel_t fifo_2_1; 102 __attribute__((section (".data_2_1"))) unsigned int data_2_1[NB_PROCS_MAX<<10]; 103 __attribute__((section (".data_2_1"))) unsigned int sync_2_1 = 0; 104 #endif 105 #if ( (X_SIZE > 2) && (Y_SIZE > 2) ) 106 __attribute__((section (".data_2_2"))) mwmr_channel_t fifo_2_2; 107 __attribute__((section (".data_2_2"))) unsigned int data_2_2[NB_PROCS_MAX<<10]; 108 __attribute__((section (".data_2_2"))) unsigned int sync_2_2 = 0; 109 #endif 110 #if ( (X_SIZE > 2) && (Y_SIZE > 3) ) 111 __attribute__((section (".data_2_3"))) mwmr_channel_t fifo_2_3; 112 __attribute__((section (".data_2_3"))) unsigned int data_2_3[NB_PROCS_MAX<<10]; 113 __attribute__((section (".data_2_3"))) unsigned int sync_2_3 = 0; 114 #endif 115 #if ( (X_SIZE > 3) && (Y_SIZE > 0) ) 116 __attribute__((section (".data_3_0"))) mwmr_channel_t fifo_3_0; 117 __attribute__((section (".data_3_0"))) unsigned int data_3_0[NB_PROCS_MAX<<10]; 118 __attribute__((section (".data_3_0"))) unsigned int sync_3_0 = 0; 119 #endif 120 #if ( (X_SIZE > 3) && (Y_SIZE > 1) ) 121 __attribute__((section (".data_3_1"))) mwmr_channel_t fifo_3_1; 122 __attribute__((section (".data_3_1"))) unsigned int data_3_1[NB_PROCS_MAX<<10]; 123 __attribute__((section (".data_3_1"))) unsigned int sync_3_1 = 0; 124 #endif 125 #if ( (X_SIZE > 3) && (Y_SIZE > 2) ) 126 __attribute__((section (".data_3_2"))) mwmr_channel_t fifo_3_2; 127 __attribute__((section (".data_3_2"))) unsigned int data_3_2[NB_PROCS_MAX<<10]; 128 __attribute__((section (".data_3_2"))) unsigned int sync_3_2 = 0; 129 #endif 130 #if ( (X_SIZE > 3) && (Y_SIZE > 3) ) 131 __attribute__((section (".data_3_3"))) mwmr_channel_t fifo_3_3; 132 __attribute__((section (".data_3_3"))) unsigned int data_3_3[NB_PROCS_MAX<<10]; 133 __attribute__((section (".data_3_3"))) unsigned int sync_3_3 = 0; 134 #endif 135 136 /////////// shared variables in cluster[0,0] ////////////////////////// 137 138 __attribute__((section (".data_0_0"))) unsigned int count[16]; 139 140 __attribute__((section (".data_0_0"))) giet_barrier_t barrier; 141 142 __attribute__((section (".data_0_0"))) unsigned int global_init_ok = 0; 143 144 __attribute__((section (".data_0_0"))) unsigned int nic_channel; 145 146 147 ///////////////////////////////////////// 57 /////////////////////////////////////////////////////////////////////////////////////////// 58 // Global variables 59 // The communication channels are distributed in the clusters, 60 // but the pointers arrays are global variables in cluster[0][0] 61 /////////////////////////////////////////////////////////////////////////////////////////// 62 63 mwmr_channel_t* mwmr[X_SIZE][Y_SIZE]; // distributed MWMR fifos pointers 64 65 unsigned int local_sync[X_SIZE][Y_SIZE]; // distributed synchros "load" / "analyse" 66 67 unsigned int global_sync = 0; // global synchro between "load" tasks 68 69 unsigned int count[16]; // instrumentation counters 70 71 giet_barrier_t barrier; // barrier between "load" (instrumentation) 72 73 unsigned int nic_channel; // allocated NIC channel index 74 75 /////////////////////////////////////////////////////////////////////////////////////////// 148 76 __attribute__ ((constructor)) void load() 149 ///////////////////////////////////////// 77 /////////////////////////////////////////////////////////////////////////////////////////// 150 78 { 151 79 // get processor identifiers … … 158 86 if (Y_SIZE > 4 ) giet_exit("The Y_SIZE parameter cannot be larger than 4\n"); 159 87 160 // local buffer to store one container 88 // local buffer to store one container in private stack 161 89 unsigned int temp[1024]; 162 90 163 // get pointer on local MWMR fifo descriptor and data buffer 164 unsigned int offset = ((x * 4) + y) * 0x10000; 165 mwmr_channel_t* fifo = (mwmr_channel_t*)(((unsigned int)&fifo_0_0) + offset); 166 unsigned int* data = (unsigned int*) (((unsigned int)data_0_0) + offset); 167 unsigned int* sync = (unsigned int*) (((unsigned int)&sync_0_0) + offset); 168 91 // giet_shr_printf("\n@@@ P[%d,%d,%d] enters load task at cycle %d\n", 92 // x, y, l, giet_proctime() ); 93 94 // allocates data buffer for MWMR fifo in local heap 95 unsigned int* data = malloc( NB_PROCS_MAX<<12 ); 96 97 //giet_shr_printf("\n@@@ P[%d,%d,%d] completes data malloc at cycle %d " 98 // "/ &data = %x\n", x, y, l, giet_proctime(), (unsigned int)data ); 99 100 // allocates MWMR fifo descriptor in local heap 101 mwmr_channel_t* fifo = malloc( sizeof(mwmr_channel_t) ); 102 103 //giet_shr_printf("\n@@@ P[%d,%d,%d] completes mwmr malloc at cycle %d " 104 // "/ &mwmr = %x\n", x, y, l, giet_proctime(), (unsigned int)mwmr ); 105 106 // makes copy of pointer in global array for "analyse" tasks 107 mwmr[x][y] = fifo; 108 109 // display status for cluster[X_SIZE-1][Y_SIZE-1] 169 110 if ( (x==X_SIZE-1) && (y==Y_SIZE-1) ) 170 111 giet_shr_printf("\n*** Task load starts on P[%d,%d,%d] at cycle %d\n" 171 " &fifo = %x / &data = %x / &sync = %x\n", 172 x, y, l, giet_proctime(), 173 (unsigned int)fifo, (unsigned int)data, (unsigned int)sync ); 112 " &fifo = %x / &data = %x / &sync = %x\n" 113 " x_size = %d / y_size = %d / nprocs = %d\n", 114 x , y , l , giet_proctime() , 115 (unsigned int)fifo , (unsigned int)data, (unsigned int)(&local_sync[x][y]) , 116 X_SIZE, Y_SIZE, NB_PROCS_MAX ); 174 117 175 118 // Task load on cluster[0,0] makes global initialisation: … … 188 131 barrier_init( &barrier, X_SIZE * Y_SIZE ); 189 132 190 global_init_ok = 1; 133 // clear NIC RX channels stats 134 giet_nic_rx_clear(); 135 136 global_sync = 1; 191 137 } 192 138 else 193 139 { 194 while ( global_ init_ok== 0 ) asm volatile ("nop");140 while ( global_sync == 0 ) asm volatile ("nop"); 195 141 } 196 142 … … 198 144 mwmr_init( fifo , data , 1024 , NB_PROCS_MAX ); 199 145 200 // signal MWMR fifo initialisation completion 201 *sync= 1;146 // signal MWMR fifo initialisation completion to analyse tasks 147 local_sync[x][y] = 1; 202 148 203 149 // main loop (on containers) … … 226 172 barrier_wait( &barrier ); 227 173 228 // Task load in cluster[0,0] displays counters and stops NIC / CMA transfer174 // Task load in cluster[0,0] stops NIC and displays results 229 175 if ( (x==0) && (y==0) ) 230 176 { 177 giet_nic_rx_stop(); 178 231 179 giet_shr_printf("\n@@@@ Clasification Results @@@\n" 232 180 " - TYPE 0 : %d packets\n" … … 246 194 " - TYPE E : %d packets\n" 247 195 " - TYPE F : %d packets\n", 248 count[0x0], count[0x1], count[0x2], count[0x3], 249 count[0x4], count[0x5], count[0x6], count[0x7], 250 count[0x8], count[0x9], count[0xA], count[0xB], 251 count[0xC], count[0xD], count[0xE], count[0xF] ); 252 253 giet_nic_rx_stop(); 196 count[0x0], count[0x1], count[0x2], count[0x3], 197 count[0x4], count[0x5], count[0x6], count[0x7], 198 count[0x8], count[0x9], count[0xA], count[0xB], 199 count[0xC], count[0xD], count[0xE], count[0xF] ); 254 200 255 201 giet_nic_rx_stats(); … … 277 223 unsigned int temp[1024]; 278 224 225 // wait MWMR channel initialisation (done by task load) 226 while ( local_sync[x][y] == 0 ) asm volatile ("nop"); 227 279 228 // get pointer on MWMR channel descriptor 280 unsigned int offset = ((x * 4) + y) * 0x10000; 281 mwmr_channel_t* fifo = (mwmr_channel_t*)(((unsigned int)&fifo_0_0) + offset); 282 unsigned int* sync = (unsigned int*) (((unsigned int)&sync_0_0) + offset); 283 229 mwmr_channel_t* fifo = mwmr[x][y]; 230 231 // display status for cluster[X_SIZE-1][Y_SIZE-1] 284 232 if ( (x==X_SIZE-1) && (y==Y_SIZE-1) ) 285 233 giet_shr_printf("\n*** Task analyse starts on P[%d,%d,%d] at cycle %d\n" 286 234 " &fifo = %x / &sync = %x\n", 287 235 x, y, l, giet_proctime(), 288 (unsigned int)fifo, (unsigned int) sync);236 (unsigned int)fifo, (unsigned int)(&local_sync[x][y]) ); 289 237 290 // wait MWMR channel initialisation (done by task load) 291 while ( *sync == 0 ) asm volatile ("nop"); 292 293 // infinite loop (on containers) 238 // main loop (on containers) 294 239 unsigned int nwords; // number of words in container 295 240 unsigned int npackets; // number of packets in container
Note: See TracChangeset
for help on using the changeset viewer.