Changeset 712
- Timestamp:
- Oct 7, 2015, 11:56:33 AM (9 years ago)
- Location:
- soft/giet_vm/applications
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/applications/classif/classif.py
r708 r712 125 125 elif ( p== 1 ): # thread store 126 126 start_index = 2 127 thread_name = 'stor e_%d_%d_%d' %(x,y,p)127 thread_name = 'stor_%d_%d_%d' %(x,y,p) 128 128 else : # thread analyse 129 129 start_index = 1 130 thread_name = 'anal yse_%d_%d_%d' % (x,y,p)130 thread_name = 'anal_%d_%d_%d' % (x,y,p) 131 131 132 132 mapping.addThread( vspace, thread_name, False , x, y, p, -
soft/giet_vm/applications/display/display.c
r708 r712 10 10 11 11 #include <stdio.h> 12 #include <stdlib.h> 12 13 #include <hard_config.h> // To check Frame Buffer size 13 14 … … 37 38 int fd; 38 39 unsigned int image = 0; 40 char byte; 41 unsigned int fbuf_x_size; 42 unsigned int fbuf_y_size; 39 43 40 char byte; 41 42 // parameters checking 43 if ( (NPIXELS != FBUF_X_SIZE) || (NLINES != FBUF_Y_SIZE) ) 44 { 45 giet_pthread_exit("[DISPLAY ERROR] Frame buffer size does not fit image size"); 46 } 44 // checking frame buffer size 45 giet_fbf_size( &fbuf_x_size , &fbuf_y_size ); 46 giet_pthread_assert( ((NPIXELS == fbuf_x_size) && (NLINES == fbuf_y_size)), 47 "[DISPLAY ERROR] Frame buffer size does not fit image size"); 47 48 48 49 // get a private TTY … … 62 63 giet_tty_printf("\n[DISPLAY] P[%d,%d,%d] open file %s at cycle %d\n", 63 64 x, y, p, FILENAME, giet_proctime() ); 65 66 // get Frame Buffer ownership 67 giet_fbf_alloc(); 64 68 65 69 // get a Chained Buffer DMA channel -
soft/giet_vm/applications/gameoflife/gameoflife.c
r708 r712 6 6 ////////////////////////////////////////////////////////////////////////////////// 7 7 // This multi-threaded application is an emulation of the Game of Life automaton. 8 // The world size is defined by the HEIGHT and WIDTH parameters.8 // The world size is defined by the Frame Buffer width and height. 9 9 // 10 10 // There is at most one thread per processor in the platform. … … 14 14 // - if the number of processors is not larger than the number of lines, 15 15 // the number of threads is equal to the number of processors, and 16 // each thread process HEIGHT/nthreads (or HEIGHT/nthreads + 1) lines.16 // each thread process height/nthreads (or height/nthreads + 1) lines. 17 17 // 18 18 // Thread running on processor P(0,0,0) execute the main() function, … … 31 31 #include "malloc.h" 32 32 33 #define WIDTH FBUF_X_SIZE34 #define HEIGHT FBUF_Y_SIZE35 36 33 #define VERBOSE 1 37 34 … … 46 43 arguments_t args[1024]; // at most 1024 threads 47 44 48 uint8_t world[2][ HEIGHT][WIDTH] __attribute__((aligned(64)));49 50 uint8_t display[2][ HEIGHT][WIDTH] __attribute__((aligned(64)));51 52 unsigned int status0[16] ;53 unsigned int status1[16] ;45 uint8_t world[2][256][256] __attribute__((aligned(64))); 46 47 uint8_t display[2][256][256] __attribute__((aligned(64))); 48 49 unsigned int status0[16] __attribute__((aligned(64))); 50 unsigned int status1[16] __attribute__((aligned(64))); 54 51 55 52 giet_sqt_barrier_t barrier; 53 54 unsigned int width; 55 unsigned int height; 56 56 57 57 //////////////////////////////////// … … 63 63 for (y = base_line ; y < base_line + nb_line ; y++) 64 64 { 65 for(x = 0 ; x < WIDTH; x++)65 for(x = 0 ; x < width ; x++) 66 66 { 67 67 world[phase][y][x] = (giet_rand() >> (x % 8)) & 0x1; … … 77 77 uint8_t nb = 0; 78 78 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];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]; 87 87 88 88 return nb; … … 116 116 for (y = base_line; y < base_line + nb_line; y++) 117 117 { 118 for(x = 0; x < WIDTH; x++)118 for(x = 0; x < width ; x++) 119 119 { 120 120 world[phase][y][x] = compute_cell( 1 - phase , x , y ); … … 131 131 for (y = base_line; y < base_line + nb_line; y++) 132 132 { 133 for(x = 0; x < WIDTH; x++)133 for(x = 0; x < width ; x++) 134 134 { 135 135 display[phase][y][x] = world[phase][y][x]*255; … … 224 224 giet_procs_number( &x_size, &y_size, &nprocs ); 225 225 226 // get a shared TTY 227 giet_tty_alloc( 1 ); 228 226 229 giet_pthread_assert( (x_size <= 16) , "x_size no larger than 16" ); 227 230 giet_pthread_assert( (y_size <= 16) , "y_size no larger than 16" ); 228 giet_pthread_assert( (nprocs <= 4) , "nprocs no larger than 16" ); 231 giet_pthread_assert( (nprocs <= 4) , "nprocs no larger than 4" ); 232 233 // get FBF width and height 234 giet_fbf_size( &width , &height ); 235 236 giet_pthread_assert( (width <= 256) , "FBF width larger than 256" ); 237 giet_pthread_assert( (height <= 256) , "FBF height larger than 256" ); 238 giet_pthread_assert( (width && height) , "FBF not available" ); 229 239 230 240 // compute number of threads and min number of lines per thread … … 234 244 unsigned int nlines; 235 245 unsigned int extra; 236 if ( total_procs > HEIGHT)237 { 238 nthreads = HEIGHT;246 if ( total_procs > height ) 247 { 248 nthreads = height; 239 249 nlines = 1; 240 250 extra = 0; … … 243 253 { 244 254 nthreads = total_procs; 245 nlines = HEIGHT/ total_procs;246 extra = HEIGHT% total_procs;247 } 248 249 // get a shared TTY250 giet_ tty_alloc( 1);255 nlines = height / total_procs; 256 extra = height % total_procs; 257 } 258 259 // get FBF ownership 260 giet_fbf_alloc(); 251 261 252 262 // get a Chained Buffer DMA channel … … 260 270 261 271 // activates CMA channel 262 giet_fbf_cma_start( HEIGHT * WIDTH);272 giet_fbf_cma_start( height * width ); 263 273 264 274 // initializes distributed heap … … 278 288 giet_tty_printf("\n[GAMEOFLIFE] P[%d,%d,%d] completes initialisation at cycle %d\n" 279 289 " nprocs = %d / nlines = %d / nthreads = %d\n", 280 x, y, p, giet_proctime() , total_procs , HEIGHT, nthreads );290 x, y, p, giet_proctime() , total_procs , height , nthreads ); 281 291 282 292 // compute arguments (index, nlines) for all threads -
soft/giet_vm/applications/raycast/raycast.c
r708 r712 18 18 pthread_t trdid[1024]; // thread identifiers array 19 19 Game game; // Game state 20 unsigned int fbuf_x_size; // FBF width 21 unsigned int fbuf_y_size; // FBF height 20 22 21 23 // Textures … … 52 54 unsigned int i, j, n; // indexes for loops 53 55 56 // get private TTY 54 57 giet_tty_alloc(0); 55 58 … … 63 66 giet_pthread_assert( (h<=16) , "[RAYCAST ERROR] check hardware config" ); 64 67 giet_pthread_assert( (p<= 4) , "[RAYCAST ERROR] check hardware config" ); 68 69 // check frame buffer availability 70 giet_fbf_size( &fbuf_x_size , &fbuf_y_size ); 71 giet_pthread_assert( ((fbuf_x_size) && (fbuf_y_size)) , 72 "[RAYCAST ERROR] no frame buffer available" ); 65 73 66 74 // compute total number of threads … … 83 91 84 92 // Initialize frame buffer and start Chained buffer DMA 93 giet_fbf_alloc(); 85 94 giet_fbf_cma_alloc(); 86 95 giet_fbf_cma_init_buf(buf[0], buf[1], sts[0], sts[1]); … … 127 136 unsigned int slice; 128 137 while ( dispRenderSlice( &slice ) ); 129 /* 130 unsigned int again; 131 do 132 { 133 again = dispRenderSlice( &slice ); 134 } 135 while ( again ); 136 */ 138 137 139 // Wait last slice completion 138 140 while (slice_count < FBUF_X_SIZE) giet_tty_printf(" "); -
soft/giet_vm/applications/shell/shell.c
r708 r712 14 14 #define MAX_ARGS (32) 15 15 16 16 17 struct command_t 17 18 { … … 260 261 static void cmd_ps(int argc, char** argv) 261 262 { 262 giet_applications_status(); 263 if (argc == 1) 264 { 265 giet_applications_status( NULL ); 266 } 267 else 268 { 269 giet_applications_status( argv[1] ); 270 } 263 271 } 264 272 … … 272 280 } 273 281 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 } 282 giet_pthread_control( THREAD_CMD_PAUSE , argv[1] , argv[2] ); 284 283 } 285 284 … … 293 292 } 294 293 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 } 294 giet_pthread_control( THREAD_CMD_RESUME , argv[1] , argv[2] ); 305 295 } 306 296 … … 314 304 } 315 305 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 } 306 giet_pthread_control( THREAD_CMD_CONTEXT , argv[1] , argv[2] ); 326 307 } 327 308 -
soft/giet_vm/applications/shell/shell.py
r708 r712 8 8 # author : Alain Greiner 9 9 ####################################################################################### 10 # This file describes the mapping of the single thread "shell" application 11 # on processor[0][0][0] of a multi-clusters, multi-processors architecture. 10 # This file describes the mapping of the single thread "shell" application. 11 # It is mapped on processor[xmap][ymap][pmap] of the target 12 # multi-clusters, multi-processors architecture. 12 13 #################################################################################### 13 14 … … 15 16 def extend( mapping ): 16 17 17 nprocs = mapping.nprocs 18 x_width = mapping.x_width 19 y_width = mapping.y_width 18 # define mapping 19 xmap = mapping.x_size - 1 20 ymap = mapping.y_size - 1 21 pmap = mapping.nprocs - 1 20 22 21 23 # define vsegs base & size … … 37 39 # data vseg 38 40 mapping.addVseg( vspace, 'shell_data', data_base , data_size, 39 'C_WU', vtype = 'ELF', x = 0, y = 0, pseg = 'RAM',41 'C_WU', vtype = 'ELF', x = xmap, y = ymap, pseg = 'RAM', 40 42 binpath = 'bin/shell/appli.elf', 41 43 local = False ) … … 43 45 # code vseg 44 46 mapping.addVseg( vspace, 'shell_code', code_base , code_size, 45 'CXWU', vtype = 'ELF', x = 0, y = 0, pseg = 'RAM',47 'CXWU', vtype = 'ELF', x = xmap, y = ymap, pseg = 'RAM', 46 48 binpath = 'bin/shell/appli.elf', 47 49 local = False ) … … 49 51 # stack vseg 50 52 mapping.addVseg( vspace, 'shell_stack', stack_base, stack_size, 51 'C_WU', vtype = 'BUFFER', x = 0 , y = 0, pseg = 'RAM',53 'C_WU', vtype = 'BUFFER', x = xmap , y = ymap , pseg = 'RAM', 52 54 local = False, big = True ) 53 55 54 56 # heap vseg (unused) 55 57 mapping.addVseg( vspace, 'shell_heap', heap_base, heap_size, 56 'C_WU', vtype = 'BUFFER', x = 0 , y = 0, pseg = 'RAM',58 'C_WU', vtype = 'BUFFER', x = xmap , y = ymap , pseg = 'RAM', 57 59 local = False ) 58 60 59 61 # task 60 mapping.addThread( vspace, 'shell', True, 0, 0, 0, 'shell_stack', 'shell_heap', 0 ) 62 mapping.addThread( vspace, 63 'shell', 64 True, # is_main 65 xmap, ymap, pmap, 66 'shell_stack', 67 'shell_heap', 68 0 ) # startid 61 69 62 70 # extend mapping name -
soft/giet_vm/applications/transpose/transpose.c
r708 r712 7 7 // It can run on a multi-processors, multi-clusters architecture, with one thread 8 8 // per processor, and uses the POSIX threads API. 9 // It does not use the CMA to display the result image. 9 10 // 10 11 // The main() function can be launched on any processor P[x,y,l]. … … 28 29 29 30 #include "stdio.h" 31 #include "stdlib.h" 30 32 #include "user_barrier.h" 31 33 #include "malloc.h" … … 36 38 #define PROCS_MAX 4 // max number of procs per cluster 37 39 #define CLUSTER_MAX (X_MAX * Y_MAX) // max number of clusters 38 #define IMAGE_SIZE 256 // image size : nlines = npixels39 #define INPUT_FILE_PATH "/misc/lena_256.raw" // pathname on virtual disk40 #define OUTPUT_FILE_PATH "/home/lena_transposed.raw" // pathname on virtual disk40 #define IMAGE_SIZE 256 // default image size 41 #define INPUT_FILE_PATH "/misc/lena_256.raw" // default input file pathname 42 #define OUTPUT_FILE_PATH "/home/lena_transposed.raw" // default output file pathname 41 43 42 44 // macro to use a shared TTY … … 65 67 66 68 // checksum variables 67 unsigned check_line_before[ IMAGE_SIZE];68 unsigned check_line_after[ IMAGE_SIZE];69 unsigned check_line_before[1024]; 70 unsigned check_line_after[1024]; 69 71 70 72 // lock protecting shared TTY … … 73 75 // synchronisation barrier (all threads) 74 76 giet_sqt_barrier_t barrier; 77 78 // input & output files pathname and size 79 char input_file_name[256]; 80 char output_file_name[256]; 81 unsigned int image_size; 75 82 76 83 //////////////////////////////////////////// … … 97 104 unsigned int nclusters = x_size * y_size; // number of clusters 98 105 unsigned int nthreads = x_size * y_size * nprocs; // number of threads 99 unsigned int npixels = IMAGE_SIZE * IMAGE_SIZE; // pixels per image106 unsigned int npixels = image_size * image_size; // pixels per image 100 107 int fd_in = 0; // initial file descriptor 101 108 int fd_out = 0; // output file descriptor … … 122 129 123 130 // open input file 124 fd_in = giet_fat_open( INPUT_FILE_PATH, O_RDONLY ); // read_only131 fd_in = giet_fat_open( input_file_name , O_RDONLY ); // read_only 125 132 if ( fd_in < 0 ) 126 133 { 127 134 printf("\n[TRANSPOSE ERROR] Proc [%d,%d,%d] cannot open file %s\n", 128 x_id , y_id , p_id , INPUT_FILE_PATH);135 x_id , y_id , p_id , input_file_name ); 129 136 giet_pthread_exit(" open() failure"); 130 137 } … … 132 139 { 133 140 printf("\n[TRANSPOSE] Proc [0,0,0] open file %s / fd = %d\n", 134 INPUT_FILE_PATH, fd_in );141 input_file_name , fd_in ); 135 142 } 136 143 137 144 // open output file 138 fd_out = giet_fat_open( OUTPUT_FILE_PATH, O_CREATE ); // create if required145 fd_out = giet_fat_open( output_file_name , O_CREATE ); // create if required 139 146 if ( fd_out < 0 ) 140 147 { 141 148 printf("\n[TRANSPOSE ERROR] Proc [%d,%d,%d] cannot open file %s\n", 142 x_id , y_id , p_id , OUTPUT_FILE_PATH);149 x_id , y_id , p_id , output_file_name ); 143 150 giet_pthread_exit(" open() failure"); 144 151 } … … 146 153 { 147 154 printf("\n[TRANSPOSE] Proc [0,0,0] open file %s / fd = %d\n", 148 OUTPUT_FILE_PATH, fd_out );155 output_file_name , fd_out ); 149 156 } 150 157 … … 184 191 185 192 // parallel transpose from buf_in to buf_out 186 // each thread makes the transposition for nlt lines (nlt = IMAGE_SIZE/nthreads)193 // each thread makes the transposition for nlt lines (nlt = image_size/nthreads) 187 194 // from line [thread_id*nlt] to line [(thread_id + 1)*nlt - 1] 188 195 // (p,l) are the absolute pixel coordinates in the source image … … 190 197 TRSP_START[x_id][y_id][p_id] = giet_proctime(); 191 198 192 unsigned int nlt = IMAGE_SIZE/ nthreads; // number of lines per thread193 unsigned int nlc = IMAGE_SIZE/ nclusters; // number of lines per cluster199 unsigned int nlt = image_size / nthreads; // number of lines per thread 200 unsigned int nlc = image_size / nclusters; // number of lines per cluster 194 201 195 202 unsigned int src_cluster; … … 208 215 209 216 // in each iteration we transfer one byte 210 for ( p = 0 ; p < IMAGE_SIZE; p++ )217 for ( p = 0 ; p < image_size ; p++ ) 211 218 { 212 219 // read one byte from local buf_in 213 220 src_cluster = l / nlc; 214 src_index = (l % nlc)* IMAGE_SIZE+ p;221 src_index = (l % nlc)*image_size + p; 215 222 byte = buf_in[src_cluster][src_index]; 216 223 … … 220 227 // write one byte to remote buf_out 221 228 dst_cluster = p / nlc; 222 dst_index = (p % nlc)* IMAGE_SIZE+ l;229 dst_index = (p % nlc)*image_size + l; 223 230 buf_out[dst_cluster][dst_index] = byte; 224 231 } … … 436 443 "[TRANSPOSE ERROR] y_size must be 1,2,4,8,16"); 437 444 438 giet_pthread_assert( (nprocs * x_size * y_size <= IMAGE_SIZE ), 439 "[TRANSPOSE ERROR] number of threads larger than number of lines"); 440 445 // compute number of threads 441 446 unsigned int nthreads = x_size * y_size * nprocs; 442 447 … … 445 450 lock_init( &tty_lock); 446 451 447 printf("\n[TRANSPOSE] start at cycle %d on %d cores\n", giet_proctime(), nthreads ); 452 // get FBF ownership and FBF size 453 unsigned int width; 454 unsigned int height; 455 giet_fbf_alloc(); 456 giet_fbf_size( &width , &height ); 457 458 // enter interactive part if required 459 printf("\n[TRANSPOSE] start at cycle %d on %d cores / FBF = %d * %d pixels\n", 460 giet_proctime(), nthreads , width , height ); 461 462 // input_file_name, output_file_name, and size acquisition 463 printf("\n[TRANSPOSE] enter path for input file / default is : %s\n> ", INPUT_FILE_PATH ); 464 giet_tty_gets( input_file_name , 256 ); 465 printf("\n"); 466 467 if ( strcmp( input_file_name , "" ) == 0 ) strcpy( input_file_name , INPUT_FILE_PATH ); 468 469 printf("\n[TRANSPOSE] enter path for output file / default is : %s\n> ", OUTPUT_FILE_PATH ); 470 giet_tty_gets( output_file_name , 256 ); 471 printf("\n"); 472 473 if ( strcmp( output_file_name , "" ) == 0 ) strcpy( output_file_name , OUTPUT_FILE_PATH ); 474 475 printf("\n[TRANSPOSE] enter image size / default is : %d\n> ", IMAGE_SIZE ); 476 giet_tty_getw( &image_size ); 477 printf("\n"); 478 479 if ( image_size == 0 ) image_size = IMAGE_SIZE; 480 481 printf("\n[TRANSPOSE] input = %s / output = %s / size = %d\n", 482 input_file_name, output_file_name, image_size ); 483 484 giet_pthread_assert( (nprocs * x_size * y_size <= image_size ), 485 "[TRANSPOSE ERROR] number of threads larger than number of lines"); 448 486 449 487 // distributed heap initialisation
Note: See TracChangeset
for help on using the changeset viewer.