Changeset 451 for soft/giet_vm/applications/router
- Timestamp:
- Nov 11, 2014, 4:22:27 PM (10 years ago)
- 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 1 31 #include "stdio.h" 2 32 #include "mwmr_channel.h" … … 4 34 #include "hard_config.h" 5 35 6 #if NB_TTY_CHANNELS == 17 # define printf(...) giet_shr_printf(__VA_ARGS__)8 #else9 # define printf(...) giet_tty_printf(__VA_ARGS__)10 #endif11 36 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 13 51 14 52 ///////////////////////////////////////////// … … 18 56 unsigned int n; 19 57 unsigned int buf; 20 mwmr_channel_t* mwmr;21 58 22 59 // get processor identifiers … … 26 63 giet_proc_xyp( &x, &y, &lpid ); 27 64 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() ); 30 67 31 giet_vobj_get_vbase( "router" , 32 "mwmr_in", 33 (void*)&mwmr ); 68 // initializes fifo_in 69 mwmr_init( &fifo_in, 1 , DEPTH ); 34 70 35 71 // main loop : display token value = source index … … 37 73 { 38 74 buf = n; 39 mwmr_write( mwmr, &buf , 1 ); 40 printf( "transmitted value : %d\n", buf); 75 mwmr_write( &fifo_in , &buf , 1 ); 41 76 } 42 77 … … 50 85 unsigned int n; 51 86 unsigned int buf; 52 mwmr_channel_t* mwmr;53 87 54 88 // get processor identifiers … … 58 92 giet_proc_xyp( &x, &y, &lpid ); 59 93 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() ); 62 96 63 giet_vobj_get_vbase( "router" , 64 "mwmr_out", 65 (void*)&mwmr ); 97 // initializes fifo_out 98 mwmr_init( &fifo_out, 1 , DEPTH ); 66 99 67 // main loop : displaytoken arrival index and value68 for( n = 0 ; n < NMAX ; n++ )100 // main loop : register token arrival index and value 101 for( n = 0 ; n < NMAX ; n++ ) 69 102 { 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] ); 72 113 } 73 114 … … 82 123 unsigned int n; 83 124 unsigned int tempo; 84 mwmr_channel_t* mwmr_in ;85 mwmr_channel_t* mwmr_out ;86 125 87 126 // get processor identifiers … … 91 130 giet_proc_xyp( &x, &y, &lpid ); 92 131 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() ); 95 134 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" ); 99 137 100 giet_vobj_get_vbase( "router" ,101 "mwmr_in",102 (void*)&mwmr_in );103 138 // main loop 104 139 while(1) 105 140 { 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 ); 111 149 } 112 } 150 } // end router -
soft/giet_vm/applications/router/router.ld
r258 r451 3 3 *****************************************************************************/ 4 4 5 seg_code_base = 0x00400000; 6 seg_data_base = 0x00500000; 5 seg_code_base = 0x10000000; 6 seg_data_0_base = 0x20000000; 7 seg_data_1_base = 0x30000000; 7 8 8 9 /*************************************************************************** … … 17 18 *(.text) 18 19 } 19 . = seg_data_ base;20 seg_data :20 . = seg_data_0_base; 21 seg_data_0 : 21 22 { 22 23 *(.ctors) 23 24 *(.rodata) 24 /* . = ALIGN(4); */25 25 *(.rodata.*) 26 /* . = ALIGN(4); */27 26 *(.data) 28 /* . = ALIGN(4); */29 27 *(.lit8) 30 28 *(.lit4) 31 29 *(.sdata) 32 /* . = ALIGN(4); */33 30 *(.bss) 34 31 *(COMMON) 35 32 *(.sbss) 36 33 *(.scommon) 34 *(.data_in) 35 } 36 . = seg_data_1_base; 37 seg_data_1 : 38 { 39 *(.data_out) 37 40 } 38 41 }
Note: See TracChangeset
for help on using the changeset viewer.