Changeset 444 for soft/giet_vm/applications
- Timestamp:
- Nov 3, 2014, 12:40:50 PM (10 years ago)
- Location:
- soft/giet_vm/applications
- Files:
-
- 1 added
- 1 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/applications/convol/main.c
r432 r444 3 3 // Date : june 2014 4 4 // author : Alain Greiner 5 //////////////////////////////////////////////////////////////////////////////////////////// 6 // This multi-threaded application application implements a 2D convolution product. 7 // The convolution kernel is [201]*[35] pixels, but it can be factored in two 8 // independant line and column convolution products. 9 // It can run on a multi-processors, multi-clusters architecture, with one thread 10 // per processor. It uses the he following hardware parameters, that must be defined 11 // in the hard_config.h file: 12 // - X_SIZE : number of clusters in a row 13 // - Y_SIZE : number of clusters in a column 14 // - NB_PROCS_MAX : number of processors per cluster 15 // - FBUF_X_SIZE : number of pixels per line in frame buffer 16 // - FBUF_Y_SIZE : number of lines in frame buffer 17 // 18 // The (1024 * 1024) pixels image is read from a file (2 bytes per pixel). 5 19 // 6 // The "convol" application implements a 2D convolution product. 20 // - The number of clusters containing processors must be a power of 2. 21 // - The number of processors per cluster must be a power of 2. 7 22 //////////////////////////////////////////////////////////////////////////////////////////// 8 23 … … 106 121 unsigned int task_id = (cluster_id * nprocs) + lpid; // continuous task index 107 122 unsigned int ntasks = nclusters * nprocs; // number of tasks 108 unsigned int npixels = NB_PIXELS; // pixels per frame109 123 unsigned int frame_size = FRAME_SIZE; // total size (bytes) 110 124 unsigned int nblocks = frame_size / 512; // number of blocks per frame … … 126 140 // parameters checking 127 141 142 if ( (NP != FBUF_X_SIZE) || (NL != FBUF_Y_SIZE) ) 143 { 144 giet_exit("[TRANSPOSE ERROR] Frame buffer size does not fit image size"); 145 } 128 146 if ((nprocs != 1) && (nprocs != 2) && (nprocs != 4)) 129 147 giet_exit( "[CONVOL ERROR] NB_PROCS_MAX must be 1, 2 or 4\n"); … … 148 166 if ( (x==0) && (y==0) && (lpid==0) ) 149 167 { 168 // parameters checking 169 if ( (NP != FBUF_X_SIZE) || (NL != FBUF_Y_SIZE) ) 170 giet_exit("[TRANSPOSE ERROR] Frame buffer size does not fit image size"); 171 172 if ((nprocs != 1) && (nprocs != 2) && (nprocs != 4)) 173 giet_exit( "[CONVOL ERROR] NB_PROCS_MAX must be 1, 2 or 4\n"); 174 175 if ((X_SIZE!=1) && (X_SIZE!=2) && (X_SIZE!=4) && (X_SIZE!=8) && (X_SIZE!=16)) 176 giet_exit( "[CONVOL ERROR] X_SIZE must be 1, 2, 4, 8, 16\n"); 177 178 if ((Y_SIZE!=1) && (Y_SIZE!=2) && (Y_SIZE!=4) && (Y_SIZE!=8) && (Y_SIZE!=16)) 179 giet_exit( "[CONVOL ERROR] Y_SIZE must be 1, 2, 4, 8, 16\n"); 180 181 if ( NL % nclusters != 0 ) 182 giet_exit( "[CONVOL ERROR] NB_CLUSTERS must be a divider of NL"); 183 184 if ( NP % nclusters != 0 ) 185 giet_exit( "[CONVOL ERROR] NB_CLUSTERS must be a divider of NP"); 186 187 150 188 giet_shr_printf("\n[CONVOL] task[0,0,0] starts barrier init at cycle %d\n" 151 189 "- NB_CLUSTERS = %d\n" 152 "- NB_ LOCAL_PROCS= %d\n"190 "- NB_PROCS_MAX = %d\n" 153 191 "- NB_TASKS = %d\n" 154 "- NB_PIXELS = %x\n"155 "- FRAME_SIZE = %x\n"156 192 "- NB_BLOCKS = %x\n", 157 giet_proctime(), nclusters, nprocs, ntasks, 158 npixels, frame_size, nblocks ); 193 giet_proctime(), nclusters, nprocs, ntasks, nblocks ); 159 194 #if USE_SBT_BARRIER 160 195 sbt_barrier_init( &barrier, ntasks ); … … 294 329 } 295 330 296 giet_fb _sync_write( NP*(l + (task_id * lines_per_task) ),297 &TZ(cluster_id, line, 0),298 NP);331 giet_fbf_sync_write( NP*(l + (task_id * lines_per_task) ), 332 &TZ(cluster_id, line, 0), 333 NP); 299 334 } 300 335 … … 572 607 } 573 608 574 giet_fb _sync_write( NP*(l + (task_id * lines_per_task) ),575 &TZ(cluster_id, line, 0),576 NP);609 giet_fbf_sync_write( NP*(l + (task_id * lines_per_task) ), 610 &TZ(cluster_id, line, 0), 611 NP); 577 612 } 578 613 -
soft/giet_vm/applications/display/display.ld
r258 r444 3 3 *****************************************************************************/ 4 4 5 seg_code_base = 0x 00400000;6 seg_data_base = 0x 00500000;5 seg_code_base = 0x10000000; 6 seg_data_base = 0x20000000; 7 7 8 8 /*************************************************************************** -
soft/giet_vm/applications/display/main.c
r297 r444 1 #include "stdio.h" 2 #include "hard_config.h" 1 /////////////////////////////////////////////////////////////////////////////// 2 // file : main.c (for display application) 3 // date : may 2014 4 // author : Alain Greiner 5 /////////////////////////////////////////////////////////////////////////////////////// 6 // This file describes the single thread "display" application. 7 // It uses the external chained buffer DMA to display a stream 8 // of images on the frame buffer. 9 /////////////////////////////////////////////////////////////////////////////////////// 3 10 4 #define NBLOCKS 32 // (128 * 128) / 512 11 #include <stdio.h> 12 #include <hard_config.h> 5 13 6 unsigned char buf[128*128] __attribute__((aligned(512))); 14 #define FILENAME "misc/images.raw" 15 #define NPIXELS 128 16 #define NLINES 128 17 #define NIMAGES 10 18 #define NBLOCKS (NPIXELS*NLINES/512) // number of blocks per image 7 19 20 21 unsigned char buf0[NPIXELS*NLINES] __attribute__((aligned(512))); 22 unsigned char buf1[NPIXELS*NLINES] __attribute__((aligned(512))); 23 24 //////////////////////////////////////////// 8 25 __attribute__((constructor)) void main() 9 { 26 //////////////////////////////////////////// 27 { 28 // get processor identifiers 29 unsigned int x; 30 unsigned int y; 31 unsigned int lpid; 32 giet_proc_xyp( &x, &y, &lpid ); 33 10 34 int fd; 11 int blocks; 12 unsigned int ko; 13 unsigned int blocks_to_skip = 8*NBLOCKS; 35 unsigned int image = 0; 14 36 15 unsigned int procid = giet_procid(); 16 unsigned int cluster_xy = procid/NB_PROCS_MAX; 17 unsigned int lpid = procid%NB_PROCS_MAX; 18 unsigned int x = cluster_xy >> Y_WIDTH; 19 unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1); 20 21 giet_tty_printf( "*** Starting task display on processor[%d,%d,%d] at cycle %d\n\n", 22 x, y, lpid, giet_proctime() ); 23 24 /////////////////////////////////////////// 25 fd = giet_fat_open( "misc/images.raw", 0 ); 26 if ( fd < 0 ) giet_exit("echec giet_fat_open for misc/images.raw"); 27 28 giet_tty_printf("\ngiet_fat_open completed for misc/images.raw at cycle %d\n", 29 giet_proctime() ); 30 31 ///////////////////////////////////////// 32 while ( blocks_to_skip < (10 * NBLOCKS) ) 37 // parameters checking 38 if ( (NPIXELS != FBUF_X_SIZE) || (NLINES != FBUF_Y_SIZE) ) 33 39 { 34 // lecture image sur le disque 35 giet_fat_read( fd, buf, NBLOCKS, blocks_to_skip ); 36 37 giet_tty_printf("\ngiet_fat_read for image %d completed at cycle %d \n", 38 (blocks_to_skip>>5), giet_proctime()); 39 40 // transfert vers le frame buffer 41 giet_fb_sync_write( 0, buf, 128 * 128 ); 42 43 giet_tty_printf("\ndisplay completed for image %d at cycle %d \n", 44 (blocks_to_skip>>5), giet_proctime()); 45 46 blocks_to_skip = blocks_to_skip + NBLOCKS; 40 giet_exit("[DISPLAY ERROR] Frame buffer size does not fit image size"); 47 41 } 48 42 49 giet_exit("completed"); 43 giet_shr_printf("\n[DISPLAY] Processor[%d,%d,%d] starts at cycle %d\n", 44 x, y, lpid, giet_proctime() ); 45 46 // open file 47 fd = giet_fat_open( FILENAME , 0 ); 48 if ( fd < 0 ) 49 { 50 giet_exit("echec giet_fat_open for misc/images.raw"); 51 } 52 else 53 { 54 giet_shr_printf("\n[DISPLAY] Proc[%d,%d,%d] open file %s at cycle %d\n", 55 x, y, lpid, FILENAME, giet_proctime() ); 56 } 57 58 // get a Chained Buffer DMA channel 59 giet_fbf_cma_alloc(); 60 61 // start Chained Buffer DMA channel 62 giet_fbf_cma_start( buf0, buf1, NPIXELS*NLINES ); 63 64 giet_shr_printf("\n[DISPLAY] Proc[%d,%d,%d] starts CMA at cycle %d\n", 65 x, y, lpid, giet_proctime() ); 66 67 // Main loop (on images) 68 while ( image < NIMAGES ) 69 { 70 giet_fat_read( fd, buf0, NBLOCKS, image*NBLOCKS ); 71 72 giet_shr_printf("\n[DISPLAY] Proc[%d,%d,%d] load image %d to buf0 at cycle %d\n", 73 x, y, lpid, image, giet_proctime() ); 74 75 giet_fbf_cma_display( 0 ); 76 77 giet_shr_printf("\n[DISPLAY] Proc[%d,%d,%d] display image %d from buf0 at cycle %d\n", 78 x, y, lpid, image, giet_proctime() ); 79 80 image++; 81 82 giet_fat_read( fd, buf1, NBLOCKS, image*NBLOCKS ); 83 84 giet_shr_printf("\n[DISPLAY] Proc[%d,%d,%d] load image %d to buf1 at cycle %d\n", 85 x, y, lpid, image, giet_proctime() ); 86 87 giet_fbf_cma_display( 1 ); 88 89 giet_shr_printf("\n[DISPLAY] Proc[%d,%d,%d] display image %d from buf1 at cycle %d\n", 90 x, y, lpid, image, giet_proctime() ); 91 92 93 image++; 94 } 95 96 // stop Chained buffer DMA channel 97 giet_fbf_cma_stop(); 98 99 giet_exit("display completed"); 50 100 } -
soft/giet_vm/applications/gameoflife/main.c
r432 r444 106 106 } 107 107 108 giet_fb _sync_write( base_line * WIDTH ,108 giet_fbf_sync_write( base_line * WIDTH , 109 109 &world[NEW][base_line][0], 110 110 nb_line * WIDTH); -
soft/giet_vm/applications/transpose/main.c
r432 r444 1 ///////////////////////////////////////////////////////////////////////////////////////////// //1 ///////////////////////////////////////////////////////////////////////////////////////////// 2 2 // File : main.c (for transpose application) 3 3 // Date : february 2014 4 4 // author : Alain Greiner 5 // 6 // This application makes a transpose for a NN*NN pixels sequence of images. 5 ///////////////////////////////////////////////////////////////////////////////////////////// 6 // This multi-threaded application makes a transpose for a NN*NN pixels sequence of images. 7 // It can run on a multi-processors, multi-clusters architecture, with one thread 8 // per processor. It uses the he following hardware parameters, that must be defined 9 // in the hard_config.h file: 10 // - X_SIZE : number of clusters in a row 11 // - Y_SIZE : number of clusters in a column 12 // - NB_PROCS_MAX : number of processors per cluster 13 // - FBUF_X_SIZE : number of pixels per line in frame buffer 14 // - FBUF_Y_SIZE : number of lines in frame buffer 15 // 7 16 // The image sequence is read from a file (one byte per pixel). 8 17 // The input and output buffers containing the image are distributed in all clusters. 9 18 // 10 // - The image size NN must be a power of 2 .19 // - The image size NN must be a power of 2 and must fit the frame buffer size. 11 20 // - The number of clusters containing processors must be a power of 2. 12 // - The number of processors per cluster (NB_PROCS_MAX)must be a power of 2.21 // - The number of processors per cluster must be a power of 2. 13 22 // - The image size NN must be larger or equal to the total number of processor. 14 23 // 15 24 // For each image the application makes a self test (checksum for each line). 16 25 // The actual display on the frame buffer depends on frame buffer availability. 17 ///////////////////////////////////////////////////////////////////////////////////////////// //26 ///////////////////////////////////////////////////////////////////////////////////////////// 18 27 19 28 #include "hard_config.h" … … 23 32 24 33 #define NN 128 // image size : nlines = npixels = 128 25 #define NB_IMAGES 2// number of images to be handled34 #define NB_IMAGES 5 // number of images to be handled 26 35 #define FILE_PATHNAME "misc/images.raw" // file pathname on disk 27 36 #define NB_CLUSTERS (X_SIZE * Y_SIZE) // number of clusters … … 54 63 giet_barrier_t barrier; 55 64 56 volatile unsigned int init_ok = 1;65 volatile unsigned int init_ok = 0; 57 66 58 67 ////////////////////////////////////////// … … 86 95 { 87 96 // Parameters checking 97 if ( (NN != FBUF_X_SIZE) || (NN != FBUF_Y_SIZE) ) 98 { 99 giet_exit("[TRANSPOSE ERROR] Frame buffer size does not fit image size"); 100 } 88 101 if ((NB_PROCS_MAX != 1) && (NB_PROCS_MAX != 2) && (NB_PROCS_MAX != 4)) 89 102 { … … 149 162 giet_shr_printf("\n[TRANSPOSE] Proc [0,0,0] open file misc/images.raw\n"); 150 163 } 151 init_ok = 0;164 init_ok = 1; 152 165 } 153 166 else // others processors wait initialisation completion 154 167 { 155 while ( init_ok == 1 ); 156 giet_shr_printf("\n[TRANSPOSE] Processor[%d,%d,%d] starts at cycle %d\n", x, y, lpid); 168 while ( init_ok == 0 ); 169 giet_shr_printf("\n[TRANSPOSE] Processor[%d,%d,%d] starts at cycle %d\n", 170 x, y, lpid, giet_proctime() ); 157 171 } 158 172 … … 247 261 unsigned int npt = npixels / ntasks; // number of pixels per task 248 262 249 giet_fb _sync_write( npt * task_id,250 &buf_out[cluster_id][lpid*npt],251 npt );263 giet_fbf_sync_write( npt * task_id, 264 &buf_out[cluster_id][lpid*npt], 265 npt ); 252 266 253 267 if ( lpid == 0 ) -
soft/giet_vm/applications/transpose/transpose.py
r432 r444 25 25 x_size = mapping.x_size 26 26 y_size = mapping.y_size 27 nprocs = mapping.nprocs27 nprocs = mapping.nprocs 28 28 x_width = mapping.x_width 29 29 y_width = mapping.y_width
Note: See TracChangeset
for help on using the changeset viewer.