Changeset 687 for soft/giet_vm/applications
- Timestamp:
- Aug 4, 2015, 11:21:24 AM (9 years ago)
- Location:
- soft/giet_vm/applications
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/applications/router/main.c
r457 r687 4 4 // author : Alain Greiner 5 5 ///////////////////////////////////////////////////////////////////////////////////////////// 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). 8 8 // It contains 2 + N tasks : one "producer", one "consumer" and N "router") 9 9 // It contains 2 MWMR channels : "fifo_in" and "fifo_out". … … 12 12 // - The "consumer" task read token from "fifo_out" and displays instrumentation results. 13 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.14 // The router task contains a random delay emulating a variable processing time. 15 15 // 16 16 // This application is intended to run on a multi-processors, multi-clusters architecture, … … 28 28 // Each entry contain the arrival order to the consumer task. 29 29 ///////////////////////////////////////////////////////////////////////////////////////////// 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 30 35 31 36 #include "stdio.h" … … 34 39 #include "hard_config.h" 35 40 41 #define VERBOSE 1 42 #define NMAX 50 // total number of token 43 #define DEPTH 20 // MWMR channels depth 36 44 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 41 46 42 47 __attribute__((section (".data_in"))) mwmr_channel_t fifo_in; … … 46 51 __attribute__((section (".data_out"))) unsigned int buf_out[DEPTH]; 47 52 48 // ////////////// Instrumentation Counters //////////////////////////////////53 // Instrumentation Counters 49 54 50 55 __attribute__((section (".data_out"))) unsigned int consumer_tab[NMAX]; 51 56 __attribute__((section (".data_out"))) unsigned int router_tab[NMAX]; 52 57 58 // synchronisation variables 53 59 60 unsigned int init_ok = 0; 54 61 55 62 ///////////////////////////////////////////// … … 63 70 unsigned int x; 64 71 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 ); 67 74 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 ); 70 80 71 81 // initializes fifo_in 72 mwmr_init( &fifo_in , buf_in, 1 , DEPTH );82 mwmr_init( &fifo_in , buf_in , 1 , DEPTH ); 73 83 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 75 93 for(n = 0 ; n < NMAX ; n++) 76 94 { 77 95 buf = n; 78 96 mwmr_write( &fifo_in , &buf , 1 ); 97 98 if ( VERBOSE ) 99 giet_tty_printf(" - token %d sent at cycle %d\n", n , giet_proctime() ); 79 100 } 80 101 … … 92 113 unsigned int x; 93 114 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 ); 96 117 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 ); 99 120 100 // initializes fifo_out 101 mwmr_init( &fifo_out, buf_out, 1 , DEPTH ); 121 while ( init_ok == 0 ) asm volatile( "nop" ); 102 122 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 104 127 for( n = 0 ; n < NMAX ; n++ ) 105 128 { 106 129 mwmr_read( &fifo_out , &buf , 1 ); 107 130 consumer_tab[n] = buf; 131 132 if ( VERBOSE ) 133 giet_tty_printf(" - token %d received at cycle %d\n", buf , giet_proctime() ); 108 134 } 109 135 110 136 // instrumentation display 111 giet_ shr_printf("\n");137 giet_tty_printf("\n[Consumer] displays instrumentation results\n"); 112 138 for( n = 0 ; n < NMAX ; n++ ) 113 139 { 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] ); 116 142 } 117 143 118 giet_exit( "Consumer task completed");144 giet_exit( "Consumer completed" ); 119 145 120 146 } // end consumer() … … 130 156 unsigned int x; 131 157 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 ); 134 160 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 ); 137 163 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" ); 140 168 141 169 // main loop … … 147 175 for ( n = 0 ; n < tempo ; n++ ) asm volatile ( "nop" ); 148 176 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; 150 178 151 179 mwmr_write( &fifo_out , &buf , 1 ); 180 181 if ( VERBOSE ) 182 giet_tty_printf(" - token %d routed at cycle %d\n", buf , giet_proctime() ); 152 183 } 153 184 } // end router -
soft/giet_vm/applications/shell/main.c
r672 r687 245 245 giet_tty_printf("\n error : %s cannot be killed\n", argv[0] ); 246 246 } 247 } 248 249 /////////////////////////////////////////////// 250 static void cmd_ps(int argc, char** argv) 251 { 252 giet_tasks_status(); 247 253 } 248 254 … … 260 266 { "exec", cmd_exec }, 261 267 { "kill", cmd_kill }, 268 { "ps", cmd_ps }, 262 269 { NULL, NULL } 263 270 }; -
soft/giet_vm/applications/sort/main.c
r669 r687 25 25 #include "user_lock.h" 26 26 27 #define ARRAY_LENGTH 0x 100027 #define ARRAY_LENGTH 0x400 28 28 #define IPT (ARRAY_LENGTH / threads) // ITEMS PER THREAD 29 29
Note: See TracChangeset
for help on using the changeset viewer.