Changeset 451 for soft/giet_vm


Ignore:
Timestamp:
Nov 11, 2014, 4:22:27 PM (10 years ago)
Author:
alain
Message:

Modify the "router" application to support the
explicit declaration and initialisation of the MWMR channels
by the user application itself.
Introduce the file "router.py"

Location:
soft/giet_vm/applications/router
Files:
1 added
2 edited

Legend:

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

    r432 r451  
     1/////////////////////////////////////////////////////////////////////////////////////////////
     2// File   : main.c   (for router application)
     3// Date   : november 2014
     4// author : Alain Greiner
     5/////////////////////////////////////////////////////////////////////////////////////////////
     6// This multi-threaded application emulates a packet routing communication application,
     7// described as a TCG (Task and Communication Graph).
     8// It contains 2 + N tasks : one "producer", one "consumer" and N "router")
     9// It contains 2 MWMR channels : "fifo_in" and "fifo_out".
     10// - The "producer" task writes NMAX token into "fifo_in".
     11// - The N "router" tasks read token from "fifo_in" and write them into "fifo_out".
     12// - The "consumer" task read token from "fifo_out" and displays instrumentation results.
     13// Token are indexed (by the producer) from 0 to NMAX-1.
     14// The router task contain a random delay emulating a variable processing time.
     15//
     16// This application is intended to run on a multi-processors, multi-clusters architecture,
     17//  with one thread per processor.
     18//
     19// It uses the he following hardware parameters, defined in the hard_config.h file:
     20// - X_SIZE       : number of clusters in a row
     21// - Y_SIZE       : number of clusters in a column
     22// - NB_PROCS_MAX : number of processors per cluster
     23//
     24// There is two global arrays (indexed by the token index) for insrumentation:
     25// - The "router_tab" array is filled concurrently by all "router" tasks.
     26//   Each entry contains the processor index that routed the token.
     27// - The "consumer_tab" array is filled by the "consumer" task.
     28//   Each entry contain the arrival order to the consumer task.
     29/////////////////////////////////////////////////////////////////////////////////////////////
     30
    131#include "stdio.h"
    232#include "mwmr_channel.h"
     
    434#include "hard_config.h"
    535
    6 #if NB_TTY_CHANNELS == 1
    7 #  define printf(...) giet_shr_printf(__VA_ARGS__)
    8 #else
    9 #  define printf(...) giet_tty_printf(__VA_ARGS__)
    10 #endif
    1136
    12 #define NMAX 50
     37#define NMAX   50                       // total number of token
     38#define DEPTH  20           // MWMR channels depth
     39
     40//////////////// MWMR channels /////////////////////////////////////////////
     41
     42__attribute__((section (".data_in")))  mwmr_channel_t fifo_in;
     43__attribute__((section (".data_out"))) mwmr_channel_t fifo_out;
     44 
     45//////////////// Instrumentation Counters //////////////////////////////////
     46
     47__attribute__((section (".data_out")))  unsigned int consumer_tab[NMAX];
     48__attribute__((section (".data_out")))  unsigned int router_tab[NMAX];
     49
     50
    1351
    1452/////////////////////////////////////////////
     
    1856    unsigned int        n;
    1957    unsigned int        buf;
    20     mwmr_channel_t*     mwmr;
    2158
    2259    // get processor identifiers
     
    2663    giet_proc_xyp( &x, &y, &lpid );
    2764
    28     printf( "*** Starting task producer on processor[%d,%d,%d] at cycle %d\n\n",
    29              x, y, lpid, giet_proctime() );
     65    giet_shr_printf("\n*** Starting task producer on P[%d,%d,%d] at cycle %d\n",
     66                    x, y, lpid, giet_proctime() );
    3067
    31     giet_vobj_get_vbase( "router" ,
    32                          "mwmr_in",
    33                          (void*)&mwmr );
     68    // initializes fifo_in
     69    mwmr_init( &fifo_in, 1 , DEPTH );
    3470
    3571    // main loop : display token value = source index
     
    3773    {
    3874        buf = n;
    39         mwmr_write( mwmr, &buf , 1 );
    40         printf( "transmitted value : %d\n", buf);
     75        mwmr_write( &fifo_in , &buf , 1 );
    4176    }
    4277
     
    5085    unsigned int        n;
    5186    unsigned int        buf;
    52     mwmr_channel_t*     mwmr;
    5387
    5488    // get processor identifiers
     
    5892    giet_proc_xyp( &x, &y, &lpid );
    5993
    60     printf( "*** Starting task consumer on processor[%d,%d,%d] at cycle %d\n\n",
    61              x, y, lpid, giet_proctime() );
     94    giet_shr_printf("\n*** Starting task consumer on P[%d,%d,%d] at cycle %d\n",
     95                    x, y, lpid, giet_proctime() );
    6296
    63     giet_vobj_get_vbase( "router" ,
    64                          "mwmr_out",
    65                          (void*)&mwmr );
     97    // initializes fifo_out
     98    mwmr_init( &fifo_out, 1 , DEPTH );
    6699
    67     // main loop : display token arrival index and value
    68     for(n = 0 ; n < NMAX ; n++ )
     100    // main loop : register token arrival index and value
     101    for( n = 0 ; n < NMAX ; n++ )
    69102    {
    70         mwmr_read( mwmr, &buf , 1 );
    71         printf( "received token %d / value = %d\n", n  , buf);
     103        mwmr_read( &fifo_out , &buf , 1 );
     104        consumer_tab[n] = buf;
     105    }
     106
     107    // instrumentation display
     108    giet_shr_printf("\n");
     109    for( n = 0 ; n < NMAX ; n++ )
     110    {
     111        giet_shr_printf("@@@ arrival = %d / value = %d / router = %x\n",
     112                        n, consumer_tab[n], router_tab[n] );
    72113    }
    73114
     
    82123    unsigned int        n;
    83124    unsigned int        tempo;
    84     mwmr_channel_t*     mwmr_in ;
    85     mwmr_channel_t* mwmr_out ;
    86125
    87126    // get processor identifiers
     
    91130    giet_proc_xyp( &x, &y, &lpid );
    92131
    93     printf( "*** Starting task router on processor[%d,%d,%d] at cycle %d\n\n",
    94              x, y, lpid, giet_proctime() );
     132    giet_shr_printf("\n*** Starting task router on P[%d,%d,%d] at cycle %d\n",
     133                    x, y, lpid, giet_proctime() );
    95134
    96     giet_vobj_get_vbase( "router" ,
    97                          "mwmr_out",
    98                          (void*)&mwmr_out );
     135    // waiting fifo_in and fifo_out initialisation
     136    while( (fifo_in.depth == 0) || (fifo_out.depth == 0) ) asm volatile( "nop" );
    99137
    100     giet_vobj_get_vbase( "router" ,
    101                          "mwmr_in",
    102                          (void*)&mwmr_in );
    103138    // main loop
    104139    while(1)
    105140    {
    106         mwmr_read( mwmr_in , &buf , 1 );
    107         tempo = giet_rand() >> 6;
    108         for ( n = 0 ; n < tempo ; n++ ) asm volatile ("");
    109         printf( "token value : %d / temporisation = %d\n", buf, tempo);
    110         mwmr_write( mwmr_out, &buf , 1 );
     141        mwmr_read( &fifo_in , &buf , 1 );
     142
     143        tempo = giet_rand();
     144        for ( n = 0 ; n < tempo ; n++ ) asm volatile ( "nop" );
     145
     146        router_tab[buf] = (x<<(Y_WIDTH + P_WIDTH)) + (y<<P_WIDTH) + lpid;
     147
     148        mwmr_write( &fifo_out , &buf , 1 );
    111149    }
    112 }
     150} // end router
  • soft/giet_vm/applications/router/router.ld

    r258 r451  
    33*****************************************************************************/
    44
    5 seg_code_base      = 0x00400000;
    6 seg_data_base      = 0x00500000;
     5seg_code_base      = 0x10000000;
     6seg_data_0_base    = 0x20000000;
     7seg_data_1_base    = 0x30000000;
    78
    89/***************************************************************************
     
    1718        *(.text)
    1819    }
    19     . = seg_data_base;
    20     seg_data :
     20    . = seg_data_0_base;
     21    seg_data_0 :
    2122    {
    2223        *(.ctors)
    2324        *(.rodata)
    24         /* . = ALIGN(4); */
    2525        *(.rodata.*)
    26         /* . = ALIGN(4); */
    2726        *(.data)
    28         /* . = ALIGN(4); */
    2927        *(.lit8)
    3028        *(.lit4)
    3129        *(.sdata)
    32         /* . = ALIGN(4); */
    3330        *(.bss)
    3431        *(COMMON)
    3532        *(.sbss)
    3633        *(.scommon)
     34        *(.data_in)
     35    }
     36    . = seg_data_1_base;
     37    seg_data_1 :
     38    {
     39        *(.data_out)
    3740    }
    3841}
Note: See TracChangeset for help on using the changeset viewer.