Changeset 687 for soft


Ignore:
Timestamp:
Aug 4, 2015, 11:21:24 AM (9 years ago)
Author:
alain
Message:

Introduce the ps command in shell.
Adapt the router application.

Location:
soft/giet_vm/applications
Files:
3 edited

Legend:

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

    r457 r687  
    44// author : Alain Greiner
    55/////////////////////////////////////////////////////////////////////////////////////////////
    6 // This multi-threaded application emulates a packet routing communication application,
    7 // described as a TCG (Task and Communication Graph).
     6// This multi-threaded application illustrates "task-farm" parallelism.
     7// It is described as a TCG (Task and Communication Graph).
    88// It contains 2 + N tasks : one "producer", one "consumer" and N "router")
    99// It contains 2 MWMR channels : "fifo_in" and "fifo_out".
     
    1212// - The "consumer" task read token from "fifo_out" and displays instrumentation results.
    1313// Token are indexed (by the producer) from 0 to NMAX-1.
    14 // The router task contain a random delay emulating a variable processing time.
     14// The router task contains a random delay emulating a variable processing time.
    1515//
    1616// This application is intended to run on a multi-processors, multi-clusters architecture,
     
    2828//   Each entry contain the arrival order to the consumer task.
    2929/////////////////////////////////////////////////////////////////////////////////////////////
     30// Implementation note:
     31// The synchronisation variables fifo_in, fifo_out, and tty_lock are initialised by the
     32// "producer" task. Other tasks are waiting on the init_ok variable until completion.
     33/////////////////////////////////////////////////////////////////////////////////////////////
     34
    3035
    3136#include "stdio.h"
     
    3439#include "hard_config.h"
    3540
     41#define VERBOSE  1
     42#define NMAX     50           // total number of token
     43#define DEPTH    20       // MWMR channels depth
    3644
    37 #define NMAX   50                       // total number of token
    38 #define DEPTH  20           // MWMR channels depth
    39 
    40 //////////////// MWMR channels and associated buffers  /////////////////////
     45// MWMR channels and associated buffers
    4146
    4247__attribute__((section (".data_in")))  mwmr_channel_t fifo_in;
     
    4651__attribute__((section (".data_out"))) unsigned int   buf_out[DEPTH];
    4752 
    48 //////////////// Instrumentation Counters //////////////////////////////////
     53// Instrumentation Counters
    4954
    5055__attribute__((section (".data_out")))  unsigned int consumer_tab[NMAX];
    5156__attribute__((section (".data_out")))  unsigned int router_tab[NMAX];
    5257
     58// synchronisation variables
    5359
     60unsigned int  init_ok = 0;
    5461
    5562/////////////////////////////////////////////
     
    6370    unsigned int    x;
    6471    unsigned int    y;
    65     unsigned int    lpid;
    66     giet_proc_xyp( &x, &y, &lpid );
     72    unsigned int    p;
     73    giet_proc_xyp( &x , &y , &p );
    6774
    68     giet_shr_printf("\n*** Starting task producer on P[%d,%d,%d] at cycle %d\n",
    69                     x, y, lpid, giet_proctime() );
     75    // allocates a private TTY
     76    giet_tty_alloc( 0 );
     77
     78    // initialises TTY lock
     79    // lock_init( &tty_lock );
    7080
    7181    // initializes fifo_in
    72     mwmr_init( &fifo_in, buf_in, 1 , DEPTH );
     82    mwmr_init( &fifo_in  , buf_in  , 1 , DEPTH );
    7383
    74     // main loop : display token value = source index
     84    // initializes fifo_out
     85    mwmr_init( &fifo_out , buf_out , 1 , DEPTH );
     86
     87    init_ok = 1;
     88
     89    giet_tty_printf("\n[Producer] completes initialisation on P[%d,%d,%d] at cycle %d\n",
     90                    x , y , p , giet_proctime() );
     91
     92    // main loop
    7593    for(n = 0 ; n < NMAX ; n++)
    7694    {
    7795        buf = n;
    7896        mwmr_write( &fifo_in , &buf , 1 );
     97
     98        if ( VERBOSE )
     99        giet_tty_printf(" - token %d sent at cycle %d\n", n , giet_proctime() );
    79100    }
    80101
     
    92113    unsigned int    x;
    93114    unsigned int    y;
    94     unsigned int    lpid;
    95     giet_proc_xyp( &x, &y, &lpid );
     115    unsigned int    p;
     116    giet_proc_xyp( &x, &y, &p );
    96117
    97     giet_shr_printf("\n*** Starting task consumer on P[%d,%d,%d] at cycle %d\n",
    98                     x, y, lpid, giet_proctime() );
     118    // allocates a private TTY
     119    giet_tty_alloc( 0 );
    99120
    100     // initializes fifo_out
    101     mwmr_init( &fifo_out, buf_out, 1 , DEPTH );
     121    while ( init_ok == 0 ) asm volatile( "nop" );
    102122
    103     // main loop : register token arrival index and value
     123    giet_tty_printf("\n[Consumer] starts execution on P[%d,%d,%d] at cycle %d\n",
     124                    x, y, p, giet_proctime() );
     125
     126    // main loop
    104127    for( n = 0 ; n < NMAX ; n++ )
    105128    {
    106129        mwmr_read( &fifo_out , &buf , 1 );
    107130        consumer_tab[n] = buf;
     131
     132        if ( VERBOSE )
     133        giet_tty_printf(" - token %d received at cycle %d\n", buf , giet_proctime() );
    108134    }
    109135
    110136    // instrumentation display
    111     giet_shr_printf("\n");
     137    giet_tty_printf("\n[Consumer] displays instrumentation results\n");
    112138    for( n = 0 ; n < NMAX ; n++ )
    113139    {
    114         giet_shr_printf("@@@ arrival = %d / value = %d / router = %x\n",
    115                         n, consumer_tab[n], router_tab[n] );
     140        giet_tty_printf(" - arrival = %d / value = %d / router = %x\n",
     141                        n , consumer_tab[n] , router_tab[n] );
    116142    }
    117143
    118     giet_exit( "Consumer task completed");
     144    giet_exit( "Consumer completed" );
    119145
    120146} // end consumer()
     
    130156    unsigned int    x;
    131157    unsigned int    y;
    132     unsigned int    lpid;
    133     giet_proc_xyp( &x, &y, &lpid );
     158    unsigned int    p;
     159    giet_proc_xyp( &x, &y, &p );
    134160
    135     giet_shr_printf("\n*** Starting task router on P[%d,%d,%d] at cycle %d\n",
    136                     x, y, lpid, giet_proctime() );
     161    // allocates a private TTY
     162    giet_tty_alloc( 0 );
    137163
    138     // waiting fifo_in and fifo_out initialisation
    139     while( (fifo_in.depth == 0) || (fifo_out.depth == 0) ) asm volatile( "nop" );
     164    giet_tty_printf("\n[Router] starts execution on P[%d,%d,%d] at cycle %d\n",
     165                    x, y, p, giet_proctime() );
     166
     167    while ( init_ok == 0 ) asm volatile( "nop" );
    140168
    141169    // main loop
     
    147175        for ( n = 0 ; n < tempo ; n++ ) asm volatile ( "nop" );
    148176
    149         router_tab[buf] = (x<<(Y_WIDTH + P_WIDTH)) + (y<<P_WIDTH) + lpid;
     177        router_tab[buf] = (x<<(Y_WIDTH + P_WIDTH)) + (y<<P_WIDTH) + p;
    150178
    151179        mwmr_write( &fifo_out , &buf , 1 );
     180
     181        if ( VERBOSE )
     182        giet_tty_printf(" - token %d routed at cycle %d\n", buf , giet_proctime() );
    152183    }
    153184} // end router
  • soft/giet_vm/applications/shell/main.c

    r672 r687  
    245245        giet_tty_printf("\n  error : %s cannot be killed\n", argv[0] );
    246246    }
     247}
     248
     249///////////////////////////////////////////////
     250static void cmd_ps(int argc, char** argv)
     251{
     252    giet_tasks_status();
    247253}
    248254
     
    260266    { "exec",       cmd_exec },
    261267    { "kill",       cmd_kill },
     268    { "ps",         cmd_ps },
    262269    { NULL,         NULL }
    263270};
  • soft/giet_vm/applications/sort/main.c

    r669 r687  
    2525#include "user_lock.h"
    2626
    27 #define ARRAY_LENGTH    0x1000
     27#define ARRAY_LENGTH    0x400
    2828#define IPT             (ARRAY_LENGTH / threads) // ITEMS PER THREAD
    2929
Note: See TracChangeset for help on using the changeset viewer.