Changeset 480


Ignore:
Timestamp:
Jan 1, 2015, 8:06:14 PM (9 years ago)
Author:
alain
Message:

Cosmetic

Location:
soft/giet_vm/applications
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/applications/classif/main.c

    r473 r480  
    44// author : Alain Greiner
    55/////////////////////////////////////////////////////////////////////////////////////////////
    6 // This multi-threaded application takes a Gigabit Ethernet packets stream, and
    7 // makes a packet analysis and classification, based on the source MAC address.
    8 // It uses the NIC peripheral, and the chained buffer build by the CMA component
    9 // to consume packets on the Gigabit Ethernet port.
    10 //
    11 // It is described as a TCG (Task and Communication Graph) containing
     6// This multi-threaded application takes a stream of Gigabit Ethernet packets,
     7// and makes packet analysis and classification, based on the source MAC address.
     8// It uses the NIC peripheral, and the distributed kernel chbuf filled by the CMA
     9// component to consume packets on the Gigabit Ethernet port.
     10//
     11// This application is described as a TCG (Task and Communication Graph) containing
    1212// - one "load" task per cluster.
    1313// - from one to three "analyse" tasks per cluster.
    1414// In each cluster, the "load" task communicates with the local "analyse" tasks through
    1515// a local MWMR fifo containing NB_PROCS_MAX containers (one item = one container).
    16 // The MWMR fifo descriptor and the data buffer containing the containers are defined
    17 // as global variables distributed in (up to) 16 clusters.
     16// The MWMR fifo descriptors array is defined as a global variable in cluster[0][0].
    1817//
    1918// Initialisation is done in two steps by the "load" tasks:
     
    2120//   the barrier between all "load" tasks. Other "load" tasks are waiting on the
    2221//   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.
     22// - In each cluster[x][y], the "load" task allocates the MWMR fifo descriptor and
     23//   the data buffer in the local heap, and initializes the MWMR descriptor.
    2524//   The "analyse" tasks are waiting on the sync[x][y] variables.
    2625//     
     
    3534// 2) The "analyse" task transfer one container from the local MWMR fifo to a private
    3635//    local buffer. It analyse each packet contained in the container, compute the
    37 //    packet type, depending on the 4 MSB bits of the source MAC address,
    38 //    and increment the corresponding counters.
     36//    packet type, depending on the source MAC address, and increment the counters.
    3937//
    4038// It uses the he following hardware parameters, defined in the hard_config.h file:
     
    5149#include "hard_config.h"
    5250
    53 #define LOAD_VERBOSE     0
    54 #define ANALYSE_VERBOSE  0
    5551#define CONTAINERS_MAX   10
    5652
    5753///////////////////////////////////////////////////////////////////////////////////////////
    5854//    Global variables
    59 // The communication channels are distributed in the clusters,
    60 // but the pointers arrays are global variables in cluster[0][0]
     55// The MWMR channels (descriptors and buffers) are distributed in the clusters,
     56// but the pointers array is stored in cluster[0][0]
    6157///////////////////////////////////////////////////////////////////////////////////////////
    6258
     
    7369unsigned int     nic_channel;                 // allocated NIC channel index
    7470
    75 ///////////////////////////////////////////////////////////////////////////////////////////
     71/////////////////////////////////////////
    7672__attribute__ ((constructor)) void load()
    77 ///////////////////////////////////////////////////////////////////////////////////////////
     73/////////////////////////////////////////
    7874{
    7975    // get processor identifiers
     
    8379    giet_proc_xyp( &x, &y, &l );
    8480
    85     if (X_SIZE > 4 )  giet_exit("The X_SIZE parameter cannot be larger than 4\n");
    86     if (Y_SIZE > 4 )  giet_exit("The Y_SIZE parameter cannot be larger than 4\n");
    87 
    8881    // local buffer to store one container in private stack
    8982    unsigned int  temp[1024];
    9083
    91 // giet_shr_printf("\n@@@ P[%d,%d,%d] enters load task at cycle %d\n",
    92 //                 x, y, l, giet_proctime() );
    93 
    9484    // allocates data buffer for MWMR fifo in local heap
    9585    unsigned int*  data = malloc( NB_PROCS_MAX<<12 );
    9686
    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 
    10087    // 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]
     88    mwmr[x][y] = malloc( sizeof(mwmr_channel_t) );
     89    mwmr_channel_t* fifo = mwmr[x][y];
     90
     91    // initialises local MWMR fifo : width = 4kbytes / depth = NB_PROCS_MAX
     92    mwmr_init( fifo , data , 1024 , NB_PROCS_MAX );
     93
     94    // display for cluster[X_SIZE-1][Y_SIZE-1]
    11095    if ( (x==X_SIZE-1) && (y==Y_SIZE-1) )
    11196    giet_shr_printf("\n*** Task load starts on P[%d,%d,%d] at cycle %d\n"
    112                     "      &fifo  = %x / &data  = %x / &sync  = %x\n"
     97                    "      &mwmr  = %x / &data  = %x / &sync  = %x\n"
    11398                    "      x_size = %d / y_size = %d / nprocs = %d\n",
    11499                    x , y , l , giet_proctime() ,
    115                     (unsigned int)fifo , (unsigned int)data, (unsigned int)(&local_sync[x][y]) ,
     100                    (unsigned int)fifo, (unsigned int)data, (unsigned int)(&local_sync[x][y]),
    116101                    X_SIZE, Y_SIZE, NB_PROCS_MAX );
    117102
    118103    // Task load on cluster[0,0] makes global initialisation:
    119104    // - NIC & CMA channels allocation & initialisation.
    120     // - barrier for all load tasks initialisation.
     105    // - barrier for load tasks initialisation.
    121106    // Other load task wait completion.
    122107    if ( (x==0) && (y==0) )
     
    131116        barrier_init( &barrier, X_SIZE * Y_SIZE );
    132117
    133         // clear NIC RX channels stats
    134         giet_nic_rx_clear();
    135 
    136118        global_sync = 1;
    137119    }
     
    141123    }   
    142124
    143     // Each load task initialises local MWMR fifo (width = 4kbytes / depth = NB_PROCS_MAX)
    144     mwmr_init( fifo , data , 1024 , NB_PROCS_MAX );
    145 
    146     // signal MWMR fifo initialisation completion to analyse tasks
     125    // "load" task signals MWMR initialisation to "analyse" tasks
    147126    local_sync[x][y] = 1;
    148127
     
    177156        giet_nic_rx_stop();
    178157
    179         giet_shr_printf("\n@@@@ Clasification Results @@@\n"
     158        giet_shr_printf("\n@@@@ Classification Results @@@\n"
    180159                        " - TYPE 0 : %d packets\n"
    181160                        " - TYPE 1 : %d packets\n"
     
    232211    if ( (x==X_SIZE-1) && (y==Y_SIZE-1) )
    233212    giet_shr_printf("\n*** Task analyse starts on P[%d,%d,%d] at cycle %d\n"
    234                     "       &fifo = %x / &sync = %x\n",
     213                    "       &mwmr = %x / &sync = %x\n",
    235214                    x, y, l, giet_proctime(),
    236215                    (unsigned int)fifo, (unsigned int)(&local_sync[x][y]) );
     
    267246            else                   length = temp[1+(p>>1)] & 0x0000FFFF;
    268247
    269             // get packet type (source mac address 4 MSB bits)
    270             type = (temp[word+1] & 0x0000F000) >> 12;
     248            // get packet type (source mac address)
     249            type = (temp[word+1] & 0x0000000F);
    271250
    272251            // increment counter
  • soft/giet_vm/applications/display/main.c

    r444 r480  
    6868    while ( image < NIMAGES )
    6969    {
     70        // load buf0
    7071        giet_fat_read( fd, buf0, NBLOCKS, image*NBLOCKS );
    7172
     
    7374                        x, y, lpid, image, giet_proctime() );
    7475
     76        // display buf0
    7577        giet_fbf_cma_display( 0 );
    7678
     
    8082        image++;
    8183
     84        // load buf1
    8285        giet_fat_read( fd, buf1, NBLOCKS, image*NBLOCKS );
    8386
     
    8588                        x, y, lpid, image, giet_proctime() );
    8689
     90        // display buf1
    8791        giet_fbf_cma_display( 1 );
    8892
    8993        giet_shr_printf("\n[DISPLAY] Proc[%d,%d,%d] display image %d from buf1 at cycle %d\n",
    9094                        x, y, lpid, image, giet_proctime() );
    91 
    9295
    9396        image++;
Note: See TracChangeset for help on using the changeset viewer.