Changeset 708 for soft/giet_vm/applications
- Timestamp:
- Oct 1, 2015, 4:09:25 PM (9 years ago)
- Location:
- soft/giet_vm/applications
- Files:
-
- 5 added
- 6 deleted
- 20 edited
- 3 moved
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/applications/classif/Makefile
r589 r708 2 2 APP_NAME = classif 3 3 4 OBJS= main.o4 OBJS= classif.o 5 5 6 6 LIBS= -L../../build/libs -luser -
soft/giet_vm/applications/classif/classif.py
r610 r708 10 10 # This file describes the mapping of the multi-threaded "classif" 11 11 # application on a multi-clusters, multi-processors architecture. 12 # The mapping of tasks on processors is the following: 13 # - one "load" task per cluster containing processors, 14 # - one "store" task per cluster containing processors, 15 # - (nprocs-2) "analyse" task per cluster containing processors. 12 # The mapping of threads on processors is the following: 13 # - the "main" on cluster[0][0] 14 # - one "load" thread per cluster containing processors, 15 # - one "store" thread per cluster containing processors, 16 # - (nprocs-2) "analyse" thread per cluster containing processors. 16 17 # The mapping of virtual segments is the following: 17 18 # - There is one shared data vseg in cluster[0][0] … … 39 40 y_width = mapping.y_width 40 41 41 assert (nprocs >= 3) 42 assert (nprocs >= 3) and (nprocs <= 8) 42 43 43 44 # define vsegs base & size 44 code_base = 0x10000000 45 code_size = 0x00010000 # 64 Kbytes ( replicated in eachcluster)45 code_base = 0x10000000 46 code_size = 0x00010000 # 64 Kbytes (per cluster) 46 47 47 48 data_base = 0x20000000 48 data_size = 0x00010000 # 64 Kbytes 49 data_size = 0x00010000 # 64 Kbytes (non replicated) 49 50 50 51 heap_base = 0x30000000 51 heap_size = 0x00 040000 # 256 Kbytes (per cluster)52 heap_size = 0x00200000 # 2M bytes (per cluster) 52 53 53 54 stack_base = 0x40000000 54 stack_size = 0x00 200000 # 2 Mbytes (per cluster)55 stack_size = 0x00010000 # 64 Kbytes (per thread) 55 56 56 57 # create vspace 57 vspace = mapping.addVspace( name = 'classif', startname = 'classif_data' )58 vspace = mapping.addVspace( name = 'classif', startname = 'classif_data', active = False ) 58 59 59 60 # data vseg : shared / cluster[0][0] … … 73 74 mapping.addVseg( vspace, 'classif_heap_%d_%d' %(x,y), base , size, 74 75 'C_WU', vtype = 'HEAP', x = x, y = y, pseg = 'RAM', 75 local = False )76 local = False, big = True ) 76 77 77 # code vsegs : local (one copy in eachcluster)78 # code vsegs : local (one copy per cluster) 78 79 for x in xrange (x_size): 79 80 for y in xrange (y_size): … … 88 89 89 90 # stacks vsegs: local (one stack per processor => nprocs stacks per cluster) 91 # ... plus main_stack in cluster[0][0] 92 mapping.addVseg( vspace, 'main_stack', 93 stack_base, stack_size, 'C_WU', vtype = 'BUFFER', 94 x = 0 , y = 0 , pseg = 'RAM', 95 local = True ) 96 90 97 for x in xrange (x_size): 91 98 for y in xrange (y_size): … … 94 101 for p in xrange( nprocs ): 95 102 proc_id = (((x * y_size) + y) * nprocs) + p 96 size = (stack_size / nprocs) & 0xFFFFF000 97 base = stack_base + (proc_id * size) 103 base = stack_base + (proc_id * stack_size) + stack_size 98 104 99 105 mapping.addVseg( vspace, 'classif_stack_%d_%d_%d' % (x,y,p), 100 base, s ize, 'C_WU', vtype = 'BUFFER',106 base, stack_size, 'C_WU', vtype = 'BUFFER', 101 107 x = x , y = y , pseg = 'RAM', 102 local = True , big = True)108 local = True ) 103 109 104 # distributed tasks / one task per processor 110 # distributed threads / one thread per processor 111 # ... plus main on P[0][0][0] 112 mapping.addThread( vspace, 'main', True, 0, 0, 1, 113 'main_stack', 114 'classif_heap_0_0', 115 0 ) # index in start_vector 116 105 117 for x in xrange (x_size): 106 118 for y in xrange (y_size): … … 108 120 if ( mapping.clusters[cluster_id].procs ): 109 121 for p in xrange( nprocs ): 110 trdid = (((x * y_size) + y) * nprocs) + p 111 if ( p== 0 ): # task load 112 task_index = 2 113 task_name = 'load_%d_%d_%d' %(x,y,p) 114 elif ( p== 1 ): # task store 115 task_index = 1 116 task_name = 'store_%d_%d_%d' %(x,y,p) 117 else : # task analyse 118 task_index = 0 119 task_name = 'analyse_%d_%d_%d' % (x,y,p) 122 if ( p== 0 ): # thread load 123 start_index = 3 124 thread_name = 'load_%d_%d_%d' %(x,y,p) 125 elif ( p== 1 ): # thread store 126 start_index = 2 127 thread_name = 'store_%d_%d_%d' %(x,y,p) 128 else : # thread analyse 129 start_index = 1 130 thread_name = 'analyse_%d_%d_%d' % (x,y,p) 120 131 121 mapping.addT ask( vspace, task_name, trdid, x, y, p,122 'classif_stack_%d_%d_%d' % (x,y,p),123 'classif_heap_%d_%d' % (x,y),124 task_index )132 mapping.addThread( vspace, thread_name, False , x, y, p, 133 'classif_stack_%d_%d_%d' % (x,y,p), 134 'classif_heap_%d_%d' % (x,y), 135 start_index ) # index in start_vector 125 136 126 137 # extend mapping name -
soft/giet_vm/applications/convol/Makefile
r589 r708 1 2 CC = mipsel-unknown-elf-gcc 3 AS = mipsel-unknown-elf-as 4 LD = mipsel-unknown-elf-ld 5 DU = mipsel-unknown-elf-objdump 6 AR = mipsel-unknown-elf-ar 1 7 2 8 APP_NAME = convol 3 9 4 OBJS= main.o10 OBJS= convol.o 5 11 6 12 LIBS= -L../../build/libs -luser 7 13 8 INCLUDES = -I../../giet_libs -I. -I../.. 14 INCLUDES = -I../../giet_libs -I. -I../.. -I../../giet_xml 9 15 10 16 LIB_DEPS = ../../build/libs/libuser.a -
soft/giet_vm/applications/convol/convol.py
r669 r708 11 11 # application on a multi-clusters, multi-processors architecture. 12 12 # This include both the mapping of virtual segments on the clusters, 13 # and the mapping of t asks on processors.14 # There is one t askper processor.13 # and the mapping of threads on processors. 14 # There is one thread per processor. 15 15 # The mapping of virtual segments is the following: 16 16 # - There is one shared data vseg in cluster[0][0] … … 85 85 local = True, big = True ) 86 86 87 # heap vsegs : distributed but non local (any heap can be accessed by any t ask)87 # heap vsegs : distributed but non local (any heap can be accessed by any thread) 88 88 for x in xrange (x_size): 89 89 for y in xrange (y_size): … … 97 97 local = False, big = True ) 98 98 99 # distributed t asks : one taskper processor99 # distributed threads : one thread per processor 100 100 for x in xrange (x_size): 101 101 for y in xrange (y_size): … … 103 103 if ( mapping.clusters[cluster_id].procs ): 104 104 for p in xrange( nprocs ): 105 trdid = (((x * y_size) + y) * nprocs) + p 105 if (x == 0) and (y == 0) and (p == 0) : # main thread 106 startid = 1 107 is_main = True 108 else : # trsp thread 109 startid = 0 110 is_main = False 106 111 107 mapping.addTask( vspace, 'conv_%d_%d_%d' % (x,y,p), 108 trdid, x, y, p, 109 'conv_stack_%d_%d_%d' % (x,y,p), 110 'conv_heap_%d_%d' % (x,y), 0 ) 112 mapping.addThread( vspace, 113 'conv_%d_%d_%d' % (x,y,p), 114 is_main, 115 x, y, p, 116 'conv_stack_%d_%d_%d' % (x,y,p), 117 'conv_heap_%d_%d' % (x,y), 118 startid ) 111 119 112 120 # extend mapping name -
soft/giet_vm/applications/coproc/Makefile
r589 r708 1 2 CC = mipsel-unknown-elf-gcc 3 AS = mipsel-unknown-elf-as 4 LD = mipsel-unknown-elf-ld 5 DU = mipsel-unknown-elf-objdump 6 AR = mipsel-unknown-elf-ar 1 7 2 8 APP_NAME = coproc 3 9 4 OBJS= main.o10 OBJS= coproc.o 5 11 6 12 LIBS= -L../../build/libs -luser -
soft/giet_vm/applications/coproc/coproc.c
r707 r708 1 1 /////////////////////////////////////////////////////////////////////////////////////// 2 // file : main.c (for coproc application)2 // file : coproc.c 3 3 // date : avril 2015 4 4 // author : Alain Greiner 5 5 /////////////////////////////////////////////////////////////////////////////////////// 6 6 // This file describes the single thread "coproc" application. 7 // It uses the embedded GCD (Greater Common Divider) coprocessor to make8 // t he GCD computation between two vectors of 32 bits integers.7 // It uses the GCD (Greater Common Divider) hardware coprocessor 8 // to make the GCD computation between two vectors of 32 bits integers. 9 9 // The vectors size is defined by the VECTOR_SIZE parameter. 10 10 /////////////////////////////////////////////////////////////////////////////////////// … … 18 18 #define DMA_MODE MODE_DMA_IRQ 19 19 20 #define VERBOSE120 #define VERBOSE 1 21 21 22 22 // Memory buffers for coprocessor … … 59 59 unsigned int nb_config = (coproc_info>>16) & 0xFF; 60 60 unsigned int nb_status = (coproc_info>>24) & 0xFF; 61 giet_ assert( ((nb_to_coproc == 2) &&62 (nb_from_coproc == 1) &&63 (nb_config == 1) &&64 (nb_status == 0) ) ,65 "wrong GCD coprocessor interface" );61 giet_pthread_assert( ((nb_to_coproc == 2) && 62 (nb_from_coproc == 1) && 63 (nb_config == 1) && 64 (nb_status == 0) ) , 65 "wrong GCD coprocessor interface" ); 66 66 67 if ( VERBOSE ) 67 #if VERBOSE 68 68 giet_tty_printf("\n*** get GCD coprocessor at cycle %d\n", giet_proctime() ); 69 #endif 69 70 70 71 //////////////////////// initializes channel for OPA … … 89 90 giet_coproc_channel_init( 2 , &res_desc ); 90 91 91 if ( VERBOSE ) 92 #if VERBOSE 92 93 giet_tty_printf("\n*** channels initialized at cycle %d\n", giet_proctime() ); 94 #endif 93 95 94 96 /////////////////////// starts communication channels 95 97 giet_coproc_run( 0 ); 96 98 97 if ( VERBOSE ) 99 #if VERBOSE 98 100 giet_tty_printf("\n*** start GCD coprocessor at cycle %d\n", giet_proctime() ); 101 #endif 99 102 100 103 /////////////////////// wait coprocessor completion … … 104 107 } 105 108 106 if ( VERBOSE ) 109 #if VERBOSE 107 110 giet_tty_printf("\n*** GCD computation completed at cycle %d\n", giet_proctime() ); 111 #endif 108 112 109 113 // display result … … 117 121 giet_coproc_release( 0 ); 118 122 119 giet_ exit("completed");123 giet_pthread_exit("completed"); 120 124 121 125 } // end main -
soft/giet_vm/applications/coproc/coproc.py
r610 r708 33 33 x = 0 34 34 y = 0 35 p = 035 p = 1 36 36 37 37 assert( (x < x_size) and (y < y_size) ) … … 50 50 51 51 # create vspace 52 vspace = mapping.addVspace( name = 'coproc', startname = 'coproc_data' )52 vspace = mapping.addVspace( name = 'coproc', startname = 'coproc_data', active = False ) 53 53 54 54 # data vseg in cluster[x,y] … … 69 69 local = False, big = True ) 70 70 71 # one task on processor[x,y,0] 72 mapping.addTask( vspace, 'coproc', 0 , x , y , 0 , 73 'coproc_stack' , '' , 0 ) 71 # one thread on processor[x,y,p] 72 mapping.addThread( vspace, 73 'coproc', 74 True, # is_main 75 x, y, p, 76 'coproc_stack', 77 '', # no heap 78 0 ) # start_id 74 79 75 80 # extend mapping name -
soft/giet_vm/applications/display/Makefile
r589 r708 1 2 CC = mipsel-unknown-elf-gcc 3 AS = mipsel-unknown-elf-as 4 LD = mipsel-unknown-elf-ld 5 DU = mipsel-unknown-elf-objdump 6 AR = mipsel-unknown-elf-ar 1 7 2 8 APP_NAME = display 3 9 4 OBJS= main.o10 OBJS= display.o 5 11 6 12 LIBS= -L../../build/libs -luser -
soft/giet_vm/applications/display/display.py
r644 r708 18 18 x_width = mapping.x_width 19 19 y_width = mapping.y_width 20 21 # define thread placement 22 x = 0 23 y = 0 24 p = 2 20 25 21 26 # define vsegs base & size … … 58 63 59 64 # task 60 mapping.addTask( vspace, 'disp', 0, 0, 0, 1, 'disp_stack', 'disp_heap', 0 ) 65 mapping.addThread( vspace, 'display', 66 True, # is_main 67 x, y, p, 68 'disp_stack', 69 'disp_heap', 70 0 ) # startid 61 71 62 72 # extend mapping name -
soft/giet_vm/applications/gameoflife/Makefile
r589 r708 1 2 CC = mipsel-unknown-elf-gcc 3 AS = mipsel-unknown-elf-as 4 LD = mipsel-unknown-elf-ld 5 DU = mipsel-unknown-elf-objdump 6 AR = mipsel-unknown-elf-ar 1 7 2 8 APP_NAME = gameoflife 3 9 4 OBJS= main.o10 OBJS= gameoflife.o 5 11 6 12 LIBS= -L../../build/libs -luser -
soft/giet_vm/applications/gameoflife/gameoflife.c
r707 r708 4 4 // Authors : Alexandre Joannou <alexandre.joannou@lip6.fr> november 2013 5 5 // Alain Greiner <alain.greiner@lip6.fr> february 2015 6 // 6 ////////////////////////////////////////////////////////////////////////////////// 7 7 // This multi-threaded application is an emulation of the Game of Life automaton. 8 8 // The world size is defined by the HEIGHT and WIDTH parameters. 9 // There is one task per processor.10 // Each task compute HEIGHT/nbprocs lines.11 // Task running on processor P(0,0,0) initialises the barrier, the TTY terminal,12 // and the chained buffer DMA controler.13 9 // 14 // The number of processors must be a power of 2 not larger than HEIGHT. 10 // There is at most one thread per processor in the platform. 11 // - If the number of processors is larger than the number of lines, 12 // the number of threads is equal to the number of lines, and 13 // each thread process one single line. 14 // - if the number of processors is not larger than the number of lines, 15 // the number of threads is equal to the number of processors, and 16 // each thread process HEIGHT/nthreads (or HEIGHT/nthreads + 1) lines. 17 // 18 // Thread running on processor P(0,0,0) execute the main() function, 19 // that initialises the barrier, the TTY terminal, the CMA controler, 20 // and launch the other threads, before calling the execute function. 21 // Other threads are just running the execute() function. 22 // 23 // The total number of processors cannot be larger than 1024 = 16 * 16 * 4 15 24 ////////////////////////////////////////////////////////////////////////////////// 16 25 … … 20 29 #include "mapping_info.h" 21 30 #include "hard_config.h" 22 23 #define WIDTH 128 24 #define HEIGHT 12825 #define NB_ITERATION 100000000026 27 #define PRINTF(...) ({ if ( proc_id==0) { giet_tty_printf(__VA_ARGS__); } })31 #include "malloc.h" 32 33 #define WIDTH FBUF_X_SIZE 34 #define HEIGHT FBUF_Y_SIZE 35 36 #define VERBOSE 1 28 37 29 38 typedef unsigned char uint8_t; 30 39 31 uint8_t WORLD[2][HEIGHT][WIDTH] __attribute__((aligned(64))); 32 33 uint8_t DISPLAY[2][HEIGHT][WIDTH] __attribute__((aligned(64))); 40 typedef struct 41 { 42 unsigned int index; // index of first line to be processed 43 unsigned int lines; // number of lines to be processed 44 } arguments_t; 45 46 arguments_t args[1024]; // at most 1024 threads 47 48 uint8_t world[2][HEIGHT][WIDTH] __attribute__((aligned(64))); 49 50 uint8_t display[2][HEIGHT][WIDTH] __attribute__((aligned(64))); 34 51 35 52 unsigned int status0[16]; … … 37 54 38 55 giet_sqt_barrier_t barrier; 39 40 volatile unsigned int init_ok;41 56 42 57 //////////////////////////////////// … … 50 65 for(x = 0 ; x < WIDTH ; x++) 51 66 { 52 WORLD[phase][y][x] = (giet_rand() >> (x % 8)) & 0x1;67 world[phase][y][x] = (giet_rand() >> (x % 8)) & 0x1; 53 68 } 54 69 } … … 62 77 uint8_t nb = 0; 63 78 64 nb += WORLD[phase][(y - 1) % HEIGHT][(x - 1) % WIDTH];65 nb += WORLD[phase][ y ][(x - 1) % WIDTH];66 nb += WORLD[phase][(y + 1) % HEIGHT][(x - 1) % WIDTH];67 nb += WORLD[phase][(y - 1) % HEIGHT][ x ];68 nb += WORLD[phase][(y + 1) % HEIGHT][ x ];69 nb += WORLD[phase][(y - 1) % HEIGHT][(x + 1) % WIDTH];70 nb += WORLD[phase][ y ][(x + 1) % WIDTH];71 nb += WORLD[phase][(y + 1) % HEIGHT][(x + 1) % WIDTH];79 nb += world[phase][(y - 1) % HEIGHT][(x - 1) % WIDTH]; 80 nb += world[phase][ y ][(x - 1) % WIDTH]; 81 nb += world[phase][(y + 1) % HEIGHT][(x - 1) % WIDTH]; 82 nb += world[phase][(y - 1) % HEIGHT][ x ]; 83 nb += world[phase][(y + 1) % HEIGHT][ x ]; 84 nb += world[phase][(y - 1) % HEIGHT][(x + 1) % WIDTH]; 85 nb += world[phase][ y ][(x + 1) % WIDTH]; 86 nb += world[phase][(y + 1) % HEIGHT][(x + 1) % WIDTH]; 72 87 73 88 return nb; … … 81 96 uint8_t nb_neighbours_alive = number_of_alive_neighbour( phase, x , y ); 82 97 83 if ( WORLD[phase][y][x] == 1)98 if (world[phase][y][x] == 1) 84 99 { 85 100 if (nb_neighbours_alive == 2 || nb_neighbours_alive == 3) return 1; … … 88 103 { 89 104 if (nb_neighbours_alive == 3) return 1; 90 else return WORLD[phase][y][x];105 else return world[phase][y][x]; 91 106 } 92 107 return 0; … … 103 118 for(x = 0; x < WIDTH ; x++) 104 119 { 105 WORLD[phase][y][x] = compute_cell( 1 - phase , x , y );120 world[phase][y][x] = compute_cell( 1 - phase , x , y ); 106 121 } 107 122 } … … 118 133 for(x = 0; x < WIDTH ; x++) 119 134 { 120 DISPLAY[phase][y][x] = WORLD[phase][y][x]*255; 121 } 122 } 123 } 135 display[phase][y][x] = world[phase][y][x]*255; 136 } 137 } 138 } 139 140 141 142 /////////////////////////////////////////////////////////////// 143 __attribute__((constructor)) void execute( arguments_t* pargs ) 144 /////////////////////////////////////////////////////////////// 145 { 146 unsigned int nb_lines = pargs->lines; 147 unsigned int base_line = pargs->index; 148 149 ///////////// parallel world initialization 150 151 // All processors initialize world[0] 152 init_world( 0 , base_line , nb_lines ); 153 154 // copy world[0] to display[0] 155 copy_world( 0 , base_line , nb_lines ); 156 157 // synchronise with other procs 158 sqt_barrier_wait( &barrier ); 159 160 // main() makes display[0] 161 if ( base_line == 0 ) giet_fbf_cma_display ( 0 ); 162 163 //////////// evolution : 2 steps per iteration 164 165 unsigned int i = 0; 166 while( 1 ) 167 { 168 // compute world[1] from world[0] 169 compute_new_gen( 1 , base_line , nb_lines ); 170 171 // copy world[1] to display[1] 172 copy_world( 1 , base_line , nb_lines ); 173 174 // synchronise with other procs 175 sqt_barrier_wait( &barrier ); 176 177 // main makes display[1] 178 if ( base_line == 0 ) giet_fbf_cma_display ( 1 ); 179 180 #if VERBOSE 181 if ( base_line == 0 ) giet_tty_printf(" - step %d\n", 2*i ); 182 #endif 183 184 // compute world[0] from world[1] 185 compute_new_gen( 0 , base_line , nb_lines ); 186 187 // copy world[0] to display[0] 188 copy_world( 0 , base_line , nb_lines ); 189 190 // synchronise with other procs 191 sqt_barrier_wait( &barrier ); 192 193 // main makes display[0] 194 if ( base_line == 0 ) giet_fbf_cma_display ( 0 ); 195 196 #if VERBOSE 197 if ( base_line == 0 ) giet_tty_printf(" - step %d\n", 2*i + 1 ); 198 #endif 199 200 i++; 201 202 } // end evolution loop 203 204 giet_pthread_exit("Completed"); 205 206 } // end main() 207 208 124 209 125 210 //////////////////////////////////////// … … 133 218 giet_proc_xyp( &x, &y, &p ); 134 219 135 // get p rocessors number220 // get platform parameters 136 221 unsigned int x_size; 137 222 unsigned int y_size; … … 139 224 giet_procs_number( &x_size, &y_size, &nprocs ); 140 225 141 // compute continuous processor index & number of procs 142 unsigned int proc_id = (((x * y_size) + y) * nprocs) + p; 143 unsigned int n_global_procs = x_size * y_size * nprocs; 144 145 unsigned int i; 146 147 unsigned int nb_line = HEIGHT / n_global_procs; 148 unsigned int base_line = nb_line * proc_id; 149 150 // parameters checking 151 giet_assert( (n_global_procs <= HEIGHT), 152 " Number or processors larger than world height" ); 153 154 giet_assert( ((WIDTH == FBUF_X_SIZE) && (HEIGHT == FBUF_Y_SIZE)), 155 "Frame Buffer size does not fit the world size" ); 156 157 giet_assert( ((x_size == 1) || (x_size == 2) || (x_size == 4) || 158 (x_size == 8) || (x_size == 16)), 159 "x_size must be a power of 2 no larger than 16" ); 160 161 giet_assert( ((y_size == 1) || (y_size == 2) || (y_size == 4) || 162 (y_size == 8) || (y_size == 16)), 163 "y_size must be a power of 2 no larger than 16" ); 164 165 giet_assert( ((nprocs == 1) || (nprocs == 2) || (nprocs == 4)), 166 "nprocs must be a power of 2 no larger than 4" ); 167 168 // P[0,0,0] makes initialisation 169 if ( proc_id == 0 ) 170 { 171 // get a private TTY for P[0,0,0] 172 giet_tty_alloc( 0 ); 173 174 // get a Chained Buffer DMA channel 175 giet_fbf_cma_alloc(); 176 177 // initializes the source and destination buffers 178 giet_fbf_cma_init_buf( &DISPLAY[0][0][0] , 179 &DISPLAY[1][0][0] , 180 status0 , 181 status1 ); 182 183 // activates CMA channel 184 giet_fbf_cma_start( HEIGHT * WIDTH ); 185 186 // initializes distributed heap 187 unsigned int cx; 188 unsigned int cy; 189 for ( cx = 0 ; cx < x_size ; cx++ ) 190 { 191 for ( cx = 0 ; cx < x_size ; cx++ ) 192 { 193 heap_init( cx , cy ); 194 } 195 } 196 197 // initialises barrier 198 sqt_barrier_init( &barrier , x_size , y_size , nprocs ); 199 200 PRINTF("\n[GAMEOFLIFE] P[0,0,0] completes initialisation at cycle %d\n" 201 " nprocs = %d / nlines = %d\n", 202 giet_proctime() , n_global_procs, HEIGHT ); 203 204 // activates all other processors 205 init_ok = 1; 226 giet_pthread_assert( (x_size <= 16) , "x_size no larger than 16" ); 227 giet_pthread_assert( (y_size <= 16) , "y_size no larger than 16" ); 228 giet_pthread_assert( (nprocs <= 4) , "nprocs no larger than 16" ); 229 230 // compute number of threads and min number of lines per thread 231 // extra is the number of threads that must process one extra line 232 unsigned int total_procs = x_size * y_size * nprocs; 233 unsigned int nthreads; 234 unsigned int nlines; 235 unsigned int extra; 236 if ( total_procs > HEIGHT ) 237 { 238 nthreads = HEIGHT; 239 nlines = 1; 240 extra = 0; 206 241 } 207 242 else 208 243 { 209 while ( init_ok == 0 ) asm volatile("nop\n nop\n nop"); 210 } 211 212 ///////////// world initialization ( All processors ) 213 214 // All processors initialize WORLD[0] 215 init_world( 0 , base_line , nb_line ); 216 217 // copy WORLD[0] to DISPLAY[0] 218 copy_world( 0 , base_line , nb_line ); 219 220 // synchronise with other procs 221 sqt_barrier_wait( &barrier ); 222 223 // P(0,0,0) displays DISPLAY[0] 224 if ( proc_id == 0 ) giet_fbf_cma_display ( 0 ); 225 226 PRINTF("\n[GAMEOFLIFE] starts evolution at cycle %d\n", giet_proctime() ); 227 228 //////////// evolution : 2 steps per iteration 229 230 for (i = 0 ; i < NB_ITERATION ; i++) 231 { 232 // compute WORLD[1] from WORLD[0] 233 compute_new_gen( 1 , base_line , nb_line ); 234 235 // copy WORLD[1] to DISPLAY[1] 236 copy_world( 1 , base_line , nb_line ); 237 238 // synchronise with other procs 239 sqt_barrier_wait( &barrier ); 240 241 // P(0,0,0) displays DISPLAY[1] 242 if ( proc_id == 0 ) giet_fbf_cma_display ( 1 ); 243 244 PRINTF(" - step %d\n", 2*i ); 245 246 // compute WORLD[0] from WORLD[1] 247 compute_new_gen( 0 , base_line , nb_line ); 248 249 // copy WORLD[0] to DISPLAY[0] 250 copy_world( 0 , base_line , nb_line ); 251 252 // synchronise with other procs 253 sqt_barrier_wait( &barrier ); 254 255 // P(0,0,0) displays DISPLAY[0] 256 if ( proc_id == 0 ) giet_fbf_cma_display ( 0 ); 257 258 PRINTF(" - step %d\n", 2*i + 1 ); 259 } // end main loop 260 261 PRINTF("\n*** End of main at cycle %d ***\n", giet_proctime()); 262 263 giet_exit("Completed"); 244 nthreads = total_procs; 245 nlines = HEIGHT / total_procs; 246 extra = HEIGHT % total_procs; 247 } 248 249 // get a shared TTY 250 giet_tty_alloc( 1 ); 251 252 // get a Chained Buffer DMA channel 253 giet_fbf_cma_alloc(); 254 255 // initializes the source and destination buffers 256 giet_fbf_cma_init_buf( &display[0][0][0] , 257 &display[1][0][0] , 258 status0 , 259 status1 ); 260 261 // activates CMA channel 262 giet_fbf_cma_start( HEIGHT * WIDTH ); 263 264 // initializes distributed heap 265 unsigned int cx; 266 unsigned int cy; 267 for ( cx = 0 ; cx < x_size ; cx++ ) 268 { 269 for ( cy = 0 ; cy < y_size ; cy++ ) 270 { 271 heap_init( cx , cy ); 272 } 273 } 274 275 // initialises barrier 276 sqt_barrier_init( &barrier , x_size , y_size , nprocs ); 277 278 giet_tty_printf("\n[GAMEOFLIFE] P[%d,%d,%d] completes initialisation at cycle %d\n" 279 " nprocs = %d / nlines = %d / nthreads = %d\n", 280 x, y, p, giet_proctime() , total_procs , HEIGHT , nthreads ); 281 282 // compute arguments (index, nlines) for all threads 283 unsigned int n; // thread index 284 unsigned int index; // first line index 285 for ( n = 0 , index = 0 ; n < nthreads ; n++ ) 286 { 287 if ( extra ) 288 { 289 args[n].index = index; 290 args[n].lines = nlines + 1; 291 index = index + nlines + 1; 292 } 293 else 294 { 295 args[n].index = index; 296 args[n].lines = nlines; 297 index = index + nlines; 298 } 299 #if VERBOSE 300 giet_tty_printf("[GAMEOFLIFE] Thread %d : first = %d / nlines = %d\n", 301 n , args[n].index , args[n].lines ); 302 #endif 303 } 304 305 // launch all other threads 306 pthread_t trdid; // unused because no pthread_join() 307 for ( n = 1 ; n < nthreads ; n++ ) 308 { 309 if ( giet_pthread_create( &trdid, 310 NULL, // no attribute 311 &execute, 312 &args[n] ) ) 313 { 314 giet_tty_printf("\n[TRANSPOSE ERROR] creating thread %x\n", n ); 315 giet_pthread_exit( NULL ); 316 } 317 } 318 319 // run execute function 320 execute( &args[0] ); 321 322 giet_pthread_exit( "completed" ); 323 264 324 } // end main() 325 326 265 327 266 328 // Local Variables: -
soft/giet_vm/applications/gameoflife/gameoflife.py
r669 r708 10 10 # This file describes the mapping of the multi-threaded "gameoflife" 11 11 # application on a multi-clusters, multi-processors architecture. 12 # This include both the mapping of virtual segments on the clusters, 13 # and the mapping of tasks on processors. 14 # There is one task per processor. 12 # There is one thread per processor. 15 13 # The mapping of virtual segments is the following: 16 14 # - There is one shared data vseg in cluster[0][0] … … 102 100 if ( mapping.clusters[cluster_id].procs ): 103 101 for p in xrange( nprocs ): 104 trdid = (((x * y_size) + y) * nprocs) + p 102 if (x == 0) and (y == 0) and (p == 0) : # main thread 103 startid = 1 104 is_main = True 105 else : # other threads 106 startid = 0 107 is_main = False 105 108 106 mapping.addTask( vspace, 'gol_%d_%d_%d' % (x,y,p), 107 trdid, x, y, p, 108 'gol_stack_%d_%d_%d' % (x,y,p), 109 'gol_heap_%d_%d' %(x,y) , 0 ) 109 mapping.addThread( vspace, 110 'gol_%d_%d_%d' % (x,y,p), 111 is_main, 112 x, y, p, 113 'gol_stack_%d_%d_%d' % (x,y,p), 114 'gol_heap_%d_%d' % (x,y), 115 startid ) 110 116 111 117 # extend mapping name -
soft/giet_vm/applications/raycast/Makefile
r673 r708 1 2 CC = mipsel-unknown-elf-gcc 3 AS = mipsel-unknown-elf-as 4 LD = mipsel-unknown-elf-ld 5 DU = mipsel-unknown-elf-objdump 6 AR = mipsel-unknown-elf-ar 1 7 2 8 APP_NAME = raycast 3 9 4 OBJS = ctrl.o disp.o game.o main.o10 OBJS = disp.o game.o raycast.o 5 11 6 12 LIBS = -L../../build/libs -luser -lmath -
soft/giet_vm/applications/raycast/disp.c
r692 r708 6 6 #include <math.h> 7 7 #include <hard_config.h> 8 #include <user_ sqt_lock.h>8 #include <user_lock.h> 9 9 10 10 #define FIELD_OF_VIEW (70.f * M_PI / 180.f) // Camera field of view … … 13 13 #define FLOOR_COLOR (0x33) // dark gray 14 14 15 // Globals 16 17 static unsigned char* buf[2]; // framebuffer 18 static void * sts[2]; // for fbf_cma 19 static unsigned int cur_buf; // current framebuffer 20 static volatile unsigned int slice_x; // slice index (shared) 21 static sqt_lock_t slice_x_lock; // slice index lock 22 static volatile unsigned int slice_cnt; // slice count (shared) 23 24 // Textures indexed by block number 25 static unsigned char *g_tex[] = 26 { 27 NULL, // 0 28 NULL, // rock 29 NULL, // door 30 NULL, // handle 31 NULL, // wood 32 }; 33 15 16 //////////////////////////// 17 // Extern variables 18 //////////////////////////// 19 20 extern unsigned char* g_tex[5]; 21 extern unsigned char* buf[2]; 22 extern void* sts[2]; 23 extern unsigned int cur_buf; 24 extern unsigned int slice_x; 25 extern unsigned int slice_count; 26 extern sqt_lock_t slice_get_lock; 27 extern sqt_lock_t slice_done_lock; 28 extern Game game; 29 30 ////////////////////// 34 31 // Local functions 35 32 //////////////////////// 33 34 ///////////////////////////////////////////////////////////////////////// 36 35 static void dispDrawColumnTex(int x, int y0, int y1, unsigned char *line) 37 36 { … … 47 46 } 48 47 48 /////////////////////////////////////////////////////////////////////////// 49 49 static void dispDrawColumnSolid(int x, int y0, int y1, unsigned char color) 50 50 { … … 57 57 } 58 58 59 static void dispDrawSlice(Game *game, int x, int height, int type, int tx) 59 //////////////////////////////////////////////////////////////// 60 static void dispDrawSlice( int x, int height, int type, int tx ) 60 61 { 61 62 // Ceiling … … 90 91 } 91 92 92 static float dispRaycast(Game *game, int *type, float *tx, float angle) 93 { 94 float x = game->player.x; 95 float y = game->player.y; 93 /////////////////////////////////////////////////////////////////////// 94 static float dispRaycast( int *type, float *tx, float angle ) 95 { 96 float x = game.player.x; 97 float y = game.player.y; 96 98 97 99 // Camera is inside a block. … … 162 164 } 163 165 166 //////////////////////////////////////////////////////////////// 164 167 static void dispTranspose(unsigned char *buf, unsigned int size) 165 168 { … … 179 182 } 180 183 181 static unsigned char *dispLoadTexture(char *path) 184 //////////////////////// 185 // Exported functions 186 //////////////////////// 187 188 ////////////////////////////////////////// 189 unsigned char* dispLoadTexture(char *path) 182 190 { 183 191 int fd; … … 186 194 tex = malloc(TEX_SIZE * TEX_SIZE); 187 195 fd = giet_fat_open(path, O_RDONLY); 188 if (fd < 0) { 196 if (fd < 0) 197 { 189 198 free(tex); 190 199 return NULL; … … 196 205 dispTranspose(tex, TEX_SIZE); 197 206 198 giet_tty_printf("[RAYCAST] loaded tex %s\n", path);199 200 207 return tex; 201 208 } 202 209 203 // Exported functions 204 205 void dispInit() 206 { 207 unsigned int w, h, p; 208 209 // Initialize lock 210 giet_procs_number(&w, &h, &p); 211 sqt_lock_init(&slice_x_lock, w, h, p); 212 213 // Allocate framebuffer 214 buf[0] = malloc(FBUF_X_SIZE * FBUF_Y_SIZE); 215 buf[1] = malloc(FBUF_X_SIZE * FBUF_Y_SIZE); 216 sts[0] = malloc(64); 217 sts[1] = malloc(64); 218 219 // Initialize framebuffer 220 giet_fbf_cma_alloc(); 221 giet_fbf_cma_init_buf(buf[0], buf[1], sts[0], sts[1]); 222 giet_fbf_cma_start(FBUF_X_SIZE * FBUF_Y_SIZE); 223 224 // Load textures 225 g_tex[1] = dispLoadTexture("misc/rock_32.raw"); 226 g_tex[2] = dispLoadTexture("misc/door_32.raw"); 227 g_tex[3] = dispLoadTexture("misc/handle_32.raw"); 228 g_tex[4] = dispLoadTexture("misc/wood_32.raw"); 229 230 cur_buf = 0; 231 slice_cnt = 0; 232 slice_x = FBUF_X_SIZE; 233 } 234 235 int dispRenderSlice(Game *game) 236 { 237 unsigned int x; 210 /////////////////////////////////////////////////// 211 unsigned int dispRenderSlice( unsigned int* slice ) 212 { 213 // return 0 when there is no more slice to do 214 238 215 int type; 239 216 float angle, dist, tx; 240 241 sqt_lock_acquire(&slice_x_lock); 242 243 if (slice_x == FBUF_X_SIZE) { 244 // No more work to do for this frame 245 sqt_lock_release(&slice_x_lock); 217 unsigned int x; 218 219 // get a slice index 220 sqt_lock_acquire( &slice_get_lock ); 221 222 if (slice_x >= FBUF_X_SIZE) // No more work to do for this frame 223 { 224 sqt_lock_release( &slice_get_lock ); 246 225 return 0; 247 226 } 248 else { 249 // Keep slice coordinate 250 x = slice_x++; 251 } 252 253 sqt_lock_release(&slice_x_lock); 254 255 angle = game->player.dir - FIELD_OF_VIEW / 2.f + 227 else // Keep slice coordinate 228 { 229 x = slice_x; 230 slice_x = x + 1; 231 sqt_lock_release( &slice_get_lock ); 232 *slice = x; 233 } 234 235 // Cast a ray to get wall distance 236 angle = game.player.dir - FIELD_OF_VIEW / 2.f + 256 237 x * FIELD_OF_VIEW / FBUF_X_SIZE; 257 238 258 // Cast a ray to get wall distance 259 dist = dispRaycast(game, &type, &tx, angle); 260 261 // Perspective correction 262 dist *= cos(game->player.dir - angle); 239 dist = dispRaycast(&type, &tx, angle); 240 241 dist *= cos(game.player.dir - angle); 263 242 264 243 // Draw ceiling, wall and floor 265 dispDrawSlice( game,x, FBUF_Y_SIZE / dist, type, tx * TEX_SIZE);244 dispDrawSlice(x, FBUF_Y_SIZE / dist, type, tx * TEX_SIZE); 266 245 267 246 // Signal this slice is done 268 atomic_increment((unsigned int*)&slice_cnt, 1); 247 248 sqt_lock_acquire( &slice_done_lock ); 249 slice_count++; 250 sqt_lock_release( &slice_done_lock ); 269 251 270 252 return 1; 271 } 272 273 void dispRender(Game *game) 274 { 275 int start = giet_proctime(); 276 277 // Start rendering 278 slice_cnt = 0; 279 slice_x = 0; 280 281 // Render slices 282 while (dispRenderSlice(game)); 283 284 // Wait for completion 285 while (slice_cnt != FBUF_X_SIZE); 286 287 // Flip framebuffer 288 giet_fbf_cma_display(cur_buf); 289 cur_buf = !cur_buf; 290 giet_tty_printf("[RAYCAST] flip (took %d cycles)\n", giet_proctime() - start); 291 } 292 253 } // end dispRenderSlice() 254 255 -
soft/giet_vm/applications/raycast/disp.h
r683 r708 4 4 #include "game.h" 5 5 6 void dispInit(); 7 int dispRenderSlice(Game *game); 8 void dispRender(Game *game); 6 unsigned char* dispLoadTexture( char* path ); 7 unsigned int dispRenderSlice( unsigned int* slice ); 9 8 10 9 #endif // __DISP_H -
soft/giet_vm/applications/raycast/game.c
r683 r708 3 3 #include "ctrl.h" 4 4 #include <math.h> 5 6 // Globals 5 #include <stdio.h> 6 7 ////////////////////////////// 8 // Game Maps 9 ////////////////////////////// 7 10 8 11 static Map map[] = … … 70 73 }; 71 74 72 static Game game = 73 { 74 .mapId = 0 75 }; 76 77 static bool g_exit; 78 75 //////////////////////////// 76 // extern variables 77 //////////////////////////// 78 79 extern Game game; 80 81 ////////////////////// 79 82 // Local functions 80 83 ////////////////////// 84 85 //////////////////////////////////// 81 86 static void gameOnBlockHit(int type) 82 87 { 83 g_exit = true; 84 } 85 88 giet_tty_printf("\n[RAYCAST] Fatal collision, killed...\n"); 89 game.exit = 1; 90 } 91 92 /////////////////////////////////////////////// 86 93 static void gameCollision(float opx, float opy) 87 94 { 88 static bool collided_x = false;89 static bool collided_y = false;90 91 float px = game.player.x;92 float py = game.player.y;93 int fpx = floor(px);94 int fpy = floor(py);95 bool colliding_x = false;96 bool colliding_y = false;97 int collide_type_x = 0;98 int collide_type_y = 0;99 int type;95 static unsigned int collided_x = 0; 96 static unsigned int collided_y = 0; 97 98 float px = game.player.x; 99 float py = game.player.y; 100 int fpx = floor(px); 101 int fpy = floor(py); 102 unsigned int colliding_x = 0; 103 unsigned int colliding_y = 0; 104 int collide_type_x = 0; 105 int collide_type_y = 0; 106 int type; 100 107 101 108 // Check for x axis collisions 102 if ((type = gameLocate(floor(px + COLLIDE_GAP), fpy))) { 103 colliding_x = true, collide_type_x = type; 109 if ((type = gameLocate(floor(px + COLLIDE_GAP), fpy))) 110 { 111 colliding_x = 1, collide_type_x = type; 104 112 game.player.x = fpx - COLLIDE_GAP + 1; 105 113 } 106 else if ((type = gameLocate(floor(px - COLLIDE_GAP), fpy))) { 107 colliding_x = true, collide_type_x = type; 114 else if ((type = gameLocate(floor(px - COLLIDE_GAP), fpy))) 115 { 116 colliding_x = 1, collide_type_x = type; 108 117 game.player.x = fpx + COLLIDE_GAP; 109 118 } 110 119 111 120 // Check for y axis collisions 112 if ((type = gameLocate(fpx, floor(py + COLLIDE_GAP)))) { 113 colliding_y = true, collide_type_y = type; 121 if ((type = gameLocate(fpx, floor(py + COLLIDE_GAP)))) 122 { 123 colliding_y = 1, collide_type_y = type; 114 124 game.player.y = fpy - COLLIDE_GAP + 1; 115 125 } 116 else if ((type = gameLocate(fpx, floor(py - COLLIDE_GAP)))) { 117 colliding_y = true, collide_type_y = type; 126 else if ((type = gameLocate(fpx, floor(py - COLLIDE_GAP)))) 127 { 128 colliding_y = 1, collide_type_y = type; 118 129 game.player.y = fpy + COLLIDE_GAP; 119 130 } 120 131 121 132 // Check if we're inside a wall 122 if ((type = gameLocate(fpx, fpy))) { 123 colliding_x = true, collide_type_x = type; 124 colliding_y = true, collide_type_y = type; 125 game.player.x = opx, game.player.y = opy; 133 if ((type = gameLocate(fpx, fpy))) 134 { 135 colliding_x = 1 , collide_type_x = type; 136 colliding_y = 1 , collide_type_y = type; 137 game.player.x = opx , game.player.y = opy; 126 138 } 127 139 … … 136 148 } 137 149 138 static void gameLogic() 139 { 140 float opx = game.player.x; 141 float opy = game.player.y; 142 143 ctrlLogic(&game); 144 gameCollision(opx, opy); 145 } 146 147 static void gameInitMap() 148 { 149 game.map = &map[game.mapId]; 150 game.player.x = game.map->startX; 151 game.player.y = game.map->startY; 150 ///////////////////////// 151 // Exported functions 152 ///////////////////////// 153 154 /////////////// 155 void gameInit() 156 { 157 game.mapId = 0; 158 game.map = &map[0]; 159 game.player.x = game.map->startX; 160 game.player.y = game.map->startY; 152 161 game.player.dir = game.map->startDir; 153 game.timeLeft = TIME_TOTAL; 154 } 155 156 // Exported functions 157 162 game.timeLeft = TIME_TOTAL; 163 game.exit = 0; 164 } 165 166 ////////////////// 167 void gameControl() 168 { 169 // Only six commands are accepted: 170 // - key Q : quit game 171 // - key UP : forward move 172 // - key DOWN : backward move 173 // - key RIGHT : right move 174 // - key LEFT : left move 175 // - any other key : continue 176 // several moves can be made before continue 177 178 char c; 179 unsigned int state = 0; 180 unsigned int done = 0; 181 182 // display prompt 183 giet_tty_printf("\n[RAYCAST] > " ); 184 185 // get one command 186 while ( done == 0 ) 187 { 188 // get one character 189 giet_tty_getc( &c ); 190 191 if (state == 0) // first character 192 { 193 if (c == 0x1B) // ESCAPE : possible player move 194 { 195 state = 1; 196 } 197 else if (c == 0x71) // quit game 198 { 199 game.exit = 1; 200 done = 1; 201 giet_tty_printf("QUIT\n"); 202 } 203 else // continue 204 { 205 done = 1; 206 giet_tty_printf("\n"); 207 } 208 } 209 else if (state == 1) // previous character was ESCAPE 210 { 211 if (c == 0x5B) // BRAKET : possible player move 212 { 213 state = 2; 214 } 215 else // continue 216 { 217 done = 1; 218 giet_tty_printf("\n"); 219 } 220 } 221 else // previous characters were ESCAPE,BRACKET 222 { 223 if (c == 0x41) // UP arrow <=> forward move 224 { 225 game.player.x += PLAYER_MOVE * cos(game.player.dir); 226 game.player.y += PLAYER_MOVE * sin(game.player.dir); 227 giet_tty_printf("GO "); 228 state = 0; 229 } 230 else if (c == 0x42) // DOWN arrow <=> backward move 231 { 232 game.player.x -= PLAYER_MOVE * cos(game.player.dir); 233 game.player.y -= PLAYER_MOVE * sin(game.player.dir); 234 giet_tty_printf("BACK "); 235 state = 0; 236 } 237 else if (c == 0x43) // RIGHT arrow <=> turn right 238 { 239 game.player.dir += PLAYER_ROT; 240 giet_tty_printf("RIGHT "); 241 state = 0; 242 } 243 else if (c == 0x44) // LEFT arrow <=> turn left 244 { 245 game.player.dir -= PLAYER_ROT; 246 giet_tty_printf("LEFT "); 247 state = 0; 248 } 249 else // continue 250 { 251 done = 1; 252 giet_tty_printf("\n"); 253 } 254 } 255 } // end while 256 257 // check new position 258 int hit = gameLocate( game.player.x , game.player.y ); 259 if ( hit ) gameOnBlockHit( hit ); 260 } 261 262 //////////////////////////// 158 263 int gameLocate(int x, int y) 159 264 { 160 265 if ((x < 0 || x >= game.map->w) || 161 (y < 0 || y >= game.map->h)) { 266 (y < 0 || y >= game.map->h)) 267 { 162 268 // Outside the map bounds 163 269 return 1; … … 167 273 } 168 274 169 void gameRun() 170 { 171 gameInitMap(); 172 173 g_exit = false; 174 175 // Game loop 176 while (!g_exit) { 177 gameLogic(); 178 dispRender(&game); 179 } 180 181 if (game.timeLeft == 0) { 182 // Time's up! 183 game.mapId = 0; 184 } 185 else { 186 // Go to next map 187 game.mapId++; 188 } 189 } 190 275 /////////////// 191 276 void gameTick() 192 277 { 193 278 game.timeLeft--; 194 279 195 if (game.timeLeft == 0) { 196 g_exit = true; 197 } 198 } 199 200 Game *gameInstance() 201 { 202 return &game; 203 } 280 if (game.timeLeft == 0) 281 { 282 game.exit = 1; 283 } 284 } 285 -
soft/giet_vm/applications/raycast/game.h
r683 r708 2 2 #define __GAME_H 3 3 4 #include <stdint.h>5 #include <stdbool.h>6 4 7 5 #define M_PI (3.14159f) … … 11 9 #define TIME_TOTAL (30) 12 10 13 typedef struct 11 typedef struct 14 12 { 15 13 float x; … … 20 18 typedef struct 21 19 { 22 uint8_ttile[10][10];23 uint8_tw;24 uint8_th;25 float startX;26 float startY;27 float startDir;20 char tile[10][10]; 21 char w; 22 char h; 23 float startX; 24 float startY; 25 float startDir; 28 26 } Map; 29 27 30 28 typedef struct 31 { 32 Player player; 33 Map *map; 34 int mapId; 35 int timeLeft; 29 { 30 Player player; 31 Map *map; 32 int mapId; 33 int timeLeft; 34 int exit; // exit requested 36 35 } Game; 37 36 38 int gameLocate(int x, int y); 39 void gameRun(); 37 38 void gameInit(); 39 int gameLocate(int x, int y); 40 void gameControl(); 40 41 void gameTick(); 41 Game *gameInstance();42 42 43 43 #endif // __GAME_H -
soft/giet_vm/applications/raycast/raycast.py
r683 r708 10 10 # This file describes the mapping of the multi-threaded "raycast" application 11 11 # on a multi-clusters, multi-processors architecture. 12 # The mapping of t asks on processors is the following:13 # - one "main" t askon (0,0,0)14 # - one "render" t askper processor but (0,0,0)12 # The mapping of threads on processors is the following: 13 # - one "main" thread on (0,0,0) 14 # - one "render" thread per processor but (0,0,0) 15 15 # The mapping of virtual segments is the following: 16 16 # - There is one shared data vseg in cluster[0][0] … … 89 89 mapping.addVseg( vspace, 'raycast_heap_%d_%d' %(x,y), base , size, 90 90 'C_WU', vtype = 'HEAP', x = x, y = y, pseg = 'RAM', 91 local = False )91 local = False, big = True ) 92 92 93 # distributed t asks / one taskper processor93 # distributed threads / one thread per processor 94 94 for x in xrange (x_size): 95 95 for y in xrange (y_size): … … 98 98 for p in xrange( nprocs ): 99 99 trdid = (((x * y_size) + y) * nprocs) + p 100 if ( x == 0 and y == 0 and p == 0 ): # main t ask101 task_index= 1102 task_name = 'main_%d_%d_%d' %(x,y,p)103 else: # render t ask104 task_index= 0105 task_name = 'render_%d_%d_%d' % (x,y,p)100 if ( x == 0 and y == 0 and p == 0 ): # main thread 101 start_id = 1 102 is_main = True 103 else: # render thread 104 start_id = 0 105 is_main = False 106 106 107 mapping.addTask( vspace, task_name, trdid, x, y, p, 108 'raycast_stack_%d_%d_%d' % (x,y,p), 109 'raycast_heap_%d_%d' % (x,y), 110 task_index ) 107 mapping.addThread( vspace, 108 'raycast_%d_%d_%d' % (x,y,p), 109 is_main, 110 x, y, p, 111 'raycast_stack_%d_%d_%d' % (x,y,p), 112 'raycast_heap_%d_%d' % (x,y), 113 start_id ) 111 114 112 115 # extend mapping name -
soft/giet_vm/applications/shell/Makefile
r589 r708 2 2 APP_NAME = shell 3 3 4 OBJS = main.o4 OBJS = shell.o 5 5 6 6 LIBS = -L../../build/libs -luser -
soft/giet_vm/applications/shell/shell.c
r707 r708 1 1 /////////////////////////////////////////////////////////////////////////////////////// 2 // File : main.c (for shell application)2 // File : shell.c 3 3 // Date : july 2015 4 4 // author : Clément Guérin … … 17 17 { 18 18 char *name; 19 char *desc; 19 20 void (*fn)(int, char**); 20 21 }; … … 35 36 for (i = 0; cmd[i].name; i++) 36 37 { 37 giet_tty_printf("\t%s\ n", cmd[i].name);38 } 39 } 40 41 /////////////////////////////////////////// ////42 static void cmd_ proctime(int argc, char** argv)43 { 44 giet_tty_printf("% u\n", giet_proctime());38 giet_tty_printf("\t%s\t : %s\n", cmd[i].name , cmd[i].desc ); 39 } 40 } 41 42 /////////////////////////////////////////// 43 static void cmd_time(int argc, char** argv) 44 { 45 giet_tty_printf("%d\n", giet_proctime()); 45 46 } 46 47 … … 52 53 53 54 if (argc < 2) 54 fd = giet_fat_opendir("/"); 55 else 56 fd = giet_fat_opendir(argv[1]); 55 { 56 giet_tty_printf(" usage : %s <pathname>\n", argv[0]); 57 return; 58 } 59 60 fd = giet_fat_opendir(argv[1]); 57 61 58 62 if (fd < 0) 59 63 { 60 giet_tty_printf(" can't list directory (err=%d)\n", fd);64 giet_tty_printf(" error : cannot open %s / err = %d)\n", argv[1], fd); 61 65 return; 62 66 } … … 81 85 if (argc < 2) 82 86 { 83 giet_tty_printf(" %s <path>\n", argv[0]);87 giet_tty_printf(" usage : %s <path>\n", argv[0]); 84 88 return; 85 89 } 86 90 87 91 int ret = giet_fat_mkdir(argv[1]); 92 88 93 if (ret < 0) 89 94 { 90 giet_tty_printf(" can't create directory (err=%d)\n", ret);95 giet_tty_printf(" error : cannot create directory %s / err = %d\n", argv[1], ret); 91 96 } 92 97 } … … 97 102 if (argc < 3) 98 103 { 99 giet_tty_printf(" %s <src> <dst>\n", argv[0]);104 giet_tty_printf(" usage : %s <src> <dst>\n", argv[0]); 100 105 return; 101 106 } … … 111 116 if (src_fd < 0) 112 117 { 113 giet_tty_printf(" can't open %s (err=%d)\n", argv[1], src_fd);118 giet_tty_printf(" error : cannot open %s / err = %d\n", argv[1], src_fd); 114 119 goto exit; 115 120 } 116 121 117 122 giet_fat_file_info(src_fd, &info); 123 118 124 if (info.is_dir) 119 125 { 120 giet_tty_printf(" can't copy a directory\n");126 giet_tty_printf(" error : %s is a directory\n", argv[1] ); 121 127 goto exit; 122 128 } 129 123 130 size = info.size; 124 131 125 132 dst_fd = giet_fat_open( argv[2] , O_CREATE | O_TRUNC ); 133 126 134 if (dst_fd < 0) 127 135 { 128 giet_tty_printf(" can't open %s (err=%d)\n", argv[2], dst_fd);136 giet_tty_printf(" error : cannot open %s / err = %d\n", argv[2], dst_fd); 129 137 goto exit; 130 138 } 131 139 132 140 giet_fat_file_info(dst_fd, &info); 141 133 142 if (info.is_dir) 134 143 { 135 giet_tty_printf(" can't copy to a directory\n");// TODO144 giet_tty_printf("error : %s is a directory\n", argv[2] ); // TODO 136 145 goto exit; 137 146 } … … 149 158 if (wlen != len) 150 159 { 151 giet_tty_printf(" \nwrite error\n");160 giet_tty_printf(" error : cannot write on device\n"); 152 161 goto exit; 153 162 } … … 168 177 if (argc < 2) 169 178 { 170 giet_tty_printf(" %s <file>\n", argv[0]);179 giet_tty_printf(" usage : %s <file>\n", argv[0]); 171 180 return; 172 181 } 173 182 174 183 int ret = giet_fat_remove(argv[1], 0); 184 175 185 if (ret < 0) 176 186 { 177 giet_tty_printf(" can't remove %s (err=%d)\n", argv[1], ret);187 giet_tty_printf(" error : cannot remove %s / err = %d\n", argv[1], ret ); 178 188 } 179 189 } … … 184 194 if (argc < 2) 185 195 { 186 giet_tty_printf(" %s <path>\n", argv[0]);196 giet_tty_printf(" usage : %s <pathname>\n", argv[0]); 187 197 return; 188 198 } … … 191 201 if (ret < 0) 192 202 { 193 giet_tty_printf(" can't remove %s (err=%d)\n", argv[1], ret);203 giet_tty_printf(" error : cannot remove %s / err = %d\n", argv[1], ret ); 194 204 } 195 205 } … … 200 210 if (argc < 3) 201 211 { 202 giet_tty_printf(" %s <src> <dst>\n", argv[0]);212 giet_tty_printf(" usage : %s <src> <dst>\n", argv[0]); 203 213 return; 204 214 } … … 207 217 if (ret < 0) 208 218 { 209 giet_tty_printf(" can't move %s to %s (err=%d)\n", argv[1], argv[2], ret);219 giet_tty_printf("error : cannot move %s to %s / err = %d\n", argv[1], argv[2], ret ); 210 220 } 211 221 } … … 216 226 if (argc < 2) 217 227 { 218 giet_tty_printf(" %s <pathname>\n", argv[0]);228 giet_tty_printf(" usage : %s <vspace_name>\n", argv[0]); 219 229 return; 220 230 } … … 223 233 if ( ret == -1 ) 224 234 { 225 giet_tty_printf(" \nerror : %s not found\n", argv[1] );235 giet_tty_printf(" error : %s not found\n", argv[1] ); 226 236 } 227 237 } … … 232 242 if (argc < 2) 233 243 { 234 giet_tty_printf(" %s <pathname>\n", argv[0]);244 giet_tty_printf(" usage : %s <vspace_name>\n", argv[0]); 235 245 return; 236 246 } … … 239 249 if ( ret == -1 ) 240 250 { 241 giet_tty_printf(" \nerror : %s not found\n", argv[1] );251 giet_tty_printf(" error : %s not found\n", argv[1] ); 242 252 } 243 253 if ( ret == -2 ) 244 254 { 245 giet_tty_printf(" \nerror : %s cannot be killed\n", argv[1] );246 } 247 } 248 249 ///////////////////////////////////////// //////255 giet_tty_printf(" error : %s cannot be killed\n", argv[1] ); 256 } 257 } 258 259 ///////////////////////////////////////// 250 260 static void cmd_ps(int argc, char** argv) 251 261 { 252 giet_tasks_status(); 253 } 254 255 /////////////////////////////////////////////// 256 static void cmd_sleep(int argc, char** argv) 257 { 258 int start = giet_proctime(); 259 260 if (argc < 2) 261 { 262 giet_tty_printf("%s <cycles>\n", argv[0]); 263 return; 264 } 265 266 while (giet_proctime() < start + atoi(argv[1])); 267 } 262 giet_applications_status(); 263 } 264 265 //////////////////////////////////////////// 266 static void cmd_pause(int argc, char** argv) 267 { 268 if (argc < 3) 269 { 270 giet_tty_printf(" usage : %s <vspace_name> <thread_name>\n", argv[0] ); 271 return; 272 } 273 274 int ret = giet_pthread_pause( argv[1] , argv[2] ); 275 276 if ( ret == -1 ) 277 { 278 giet_tty_printf(" error : vspace %s not found\n", argv[1] ); 279 } 280 if ( ret == -2 ) 281 { 282 giet_tty_printf(" error : thread %s not found\n", argv[2] ); 283 } 284 } 285 286 ///////////////////////////////////////////// 287 static void cmd_resume(int argc, char** argv) 288 { 289 if (argc < 3) 290 { 291 giet_tty_printf(" usage : %s <vspace_name> <thread_name>\n", argv[0] ); 292 return; 293 } 294 295 int ret = giet_pthread_resume( argv[1] , argv[2] ); 296 297 if ( ret == -1 ) 298 { 299 giet_tty_printf(" error : vspace %s not found\n", argv[1] ); 300 } 301 if ( ret == -2 ) 302 { 303 giet_tty_printf(" error : thread %s not found\n", argv[2] ); 304 } 305 } 306 307 ///////////////////////////////////////////// 308 static void cmd_context(int argc, char** argv) 309 { 310 if (argc < 3) 311 { 312 giet_tty_printf(" usage : %s <vspace_name> <thread_name>\n", argv[0] ); 313 return; 314 } 315 316 int ret = giet_pthread_context( argv[1] , argv[2] ); 317 318 if ( ret == -1 ) 319 { 320 giet_tty_printf(" error : vspace %s not found\n", argv[1] ); 321 } 322 if ( ret == -2 ) 323 { 324 giet_tty_printf(" error : thread %s not found\n", argv[2] ); 325 } 326 } 327 268 328 269 329 //////////////////////////////////////////////////////////////////// 270 330 struct command_t cmd[] = 271 331 { 272 { "help", cmd_help }, 273 { "proctime", cmd_proctime }, 274 { "ls", cmd_ls }, 275 { "mkdir", cmd_mkdir }, 276 { "cp", cmd_cp }, 277 { "rm", cmd_rm }, 278 { "rmdir", cmd_rmdir }, 279 { "mv", cmd_mv }, 280 { "exec", cmd_exec }, 281 { "kill", cmd_kill }, 282 { "ps", cmd_ps }, 283 { "sleep", cmd_sleep }, 284 { NULL, NULL } 332 { "help", "list available commands", cmd_help }, 333 { "time", "return current date", cmd_time }, 334 { "ls", "list content of a directory", cmd_ls }, 335 { "mkdir", "create a new directory", cmd_mkdir }, 336 { "cp", "replicate a file in file system", cmd_cp }, 337 { "rm", "remove a file from file system", cmd_rm }, 338 { "rmdir", "remove a directory from file system", cmd_rmdir }, 339 { "mv", "move a file in file system", cmd_mv }, 340 { "exec", "start an application", cmd_exec }, 341 { "kill", "kill an application (all threads)", cmd_kill }, 342 { "ps", "list all mapped applications status", cmd_ps }, 343 { "pause", "pause a thread", cmd_pause }, 344 { "resume", "resume a thread", cmd_resume }, 345 { "context", "display a thread context", cmd_context }, 346 { NULL, NULL, NULL } 285 347 }; 286 348 287 349 // shell 288 350 289 //////////////////////////// ///////////351 //////////////////////////// 290 352 static void parse(char *buf) 291 353 { … … 351 413 // get a private TTY 352 414 giet_tty_alloc( 0 ); 353 giet_tty_printf( "~~~ shell ~~~\n " );415 giet_tty_printf( "~~~ shell ~~~\n\n" ); 354 416 355 417 // display first prompt -
soft/giet_vm/applications/shell/shell.py
r643 r708 58 58 59 59 # task 60 mapping.addT ask( vspace, 'shell', 0, 0, 0, 0, 'shell_stack', 'shell_heap', 0 )60 mapping.addThread( vspace, 'shell', True, 0, 0, 0, 'shell_stack', 'shell_heap', 0 ) 61 61 62 62 # extend mapping name -
soft/giet_vm/applications/transpose/Makefile
r589 r708 1 2 CC = mipsel-unknown-elf-gcc 3 AS = mipsel-unknown-elf-as 4 LD = mipsel-unknown-elf-ld 5 DU = mipsel-unknown-elf-objdump 6 AR = mipsel-unknown-elf-ar 1 7 2 8 APP_NAME = transpose 3 9 4 OBJS= main.o10 OBJS= transpose.o 5 11 6 12 LIBS= -L../../build/libs -luser -
soft/giet_vm/applications/transpose/transpose.py
r669 r708 10 10 # This file describes the mapping of the multi-threaded "transpose" 11 11 # application on a multi-clusters, multi-processors architecture. 12 # This include both the mapping of virtual segments on the clusters, 13 # and the mapping of tasks on processors. 14 # There is one task per processor. 12 # There is one thread per processor. 15 13 # The mapping of virtual segments is the following: 16 14 # - There is one shared data vseg in cluster[0][0] … … 37 35 # define vsegs base & size 38 36 code_base = 0x10000000 39 code_size = 0x00010000 # 64 Kbytes ( replicated in eachcluster)37 code_size = 0x00010000 # 64 Kbytes (per cluster) 40 38 41 39 data_base = 0x20000000 … … 43 41 44 42 stack_base = 0x40000000 45 stack_size = 0x00 200000 # 2 Mbytes (per cluster)43 stack_size = 0x00010000 # 64 Kbytes (per thread) 46 44 47 45 heap_base = 0x60000000 … … 76 74 for p in xrange( nprocs ): 77 75 proc_id = (((x * y_size) + y) * nprocs) + p 78 size = (stack_size / nprocs) & 0xFFFFF000 79 base = stack_base + (proc_id * size) 76 base = stack_base + (proc_id * stack_size) 80 77 81 78 mapping.addVseg( vspace, 'trsp_stack_%d_%d_%d' % (x,y,p), 82 base, s ize, 'C_WU', vtype = 'BUFFER',79 base, stack_size, 'C_WU', vtype = 'BUFFER', 83 80 x = x , y = y , pseg = 'RAM', 84 81 local = True, big = True ) … … 96 93 local = False, big = True ) 97 94 98 # distribute d tasks / one task per processor95 # distribute one thread per processor / main on P[0,0,0] 99 96 for x in xrange (x_size): 100 97 for y in xrange (y_size): … … 102 99 if ( mapping.clusters[cluster_id].procs ): 103 100 for p in xrange( nprocs ): 104 trdid = (((x * y_size) + y) * nprocs) + p 101 if (x == 0) and (y == 0) and (p == 0) : # main thread 102 startid = 1 103 is_main = True 104 else : # other threads 105 startid = 0 106 is_main = False 105 107 106 mapping.addTask( vspace, 'trsp_%d_%d_%d' % (x,y,p), 107 trdid, x, y, p, 108 'trsp_stack_%d_%d_%d' % (x,y,p), 109 'trsp_heap_%d_%d' % (x,y), 0 ) 108 mapping.addThread( vspace, 109 'trsp_%d_%d_%d' % (x,y,p), 110 is_main, 111 x, y, p, 112 'trsp_stack_%d_%d_%d' % (x,y,p), 113 'trsp_heap_%d_%d' % (x,y), 114 startid ) 110 115 111 116 # extend mapping name
Note: See TracChangeset
for help on using the changeset viewer.