Changeset 712 for soft


Ignore:
Timestamp:
Oct 7, 2015, 11:56:33 AM (9 years ago)
Author:
alain
Message:

Introduce the giet_fbf_size() and giet_fbf_alloc() system calls.

Location:
soft/giet_vm/applications
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/applications/classif/classif.py

    r708 r712  
    125125                    elif  ( p== 1 ):                            # thread store
    126126                        start_index = 2
    127                         thread_name = 'store_%d_%d_%d' %(x,y,p)           
     127                        thread_name = 'stor_%d_%d_%d' %(x,y,p)           
    128128                    else :                                      # thread analyse
    129129                        start_index = 1
    130                         thread_name = 'analyse_%d_%d_%d' % (x,y,p)
     130                        thread_name = 'anal_%d_%d_%d' % (x,y,p)
    131131
    132132                    mapping.addThread( vspace, thread_name, False , x, y, p,
  • soft/giet_vm/applications/display/display.c

    r708 r712  
    1010
    1111#include <stdio.h>
     12#include <stdlib.h>
    1213#include <hard_config.h>     // To check Frame Buffer size
    1314
     
    3738    int             fd;
    3839    unsigned int    image = 0;
     40    char            byte;
     41    unsigned int    fbuf_x_size;
     42    unsigned int    fbuf_y_size;
    3943
    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");
    4748
    4849    // get a private TTY
     
    6263    giet_tty_printf("\n[DISPLAY] P[%d,%d,%d] open file %s at cycle %d\n",
    6364                    x, y, p, FILENAME, giet_proctime() );
     65
     66    // get Frame Buffer ownership
     67    giet_fbf_alloc();
    6468
    6569    // get a Chained Buffer DMA channel
  • soft/giet_vm/applications/gameoflife/gameoflife.c

    r708 r712  
    66//////////////////////////////////////////////////////////////////////////////////
    77// 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.
    99//
    1010// There is at most one thread per processor in the platform.
     
    1414// - if the number of processors is not larger than the number of lines,
    1515//   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.
    1717//
    1818// Thread running on processor P(0,0,0) execute the main() function,
     
    3131#include "malloc.h"
    3232
    33 #define WIDTH           FBUF_X_SIZE
    34 #define HEIGHT          FBUF_Y_SIZE
    35 
    3633#define VERBOSE         1
    3734
     
    4643arguments_t   args[1024];     // at most 1024 threads
    4744
    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];
     45uint8_t world[2][256][256] __attribute__((aligned(64)));
     46
     47uint8_t display[2][256][256] __attribute__((aligned(64)));
     48
     49unsigned int status0[16] __attribute__((aligned(64)));
     50unsigned int status1[16] __attribute__((aligned(64)));
    5451
    5552giet_sqt_barrier_t barrier;
     53
     54unsigned int width;
     55unsigned int height;
    5656
    5757////////////////////////////////////
     
    6363   for (y = base_line ; y < base_line + nb_line ; y++)
    6464   {
    65       for(x = 0 ; x < WIDTH ; x++)
     65      for(x = 0 ; x < width ; x++)
    6666      {
    6767         world[phase][y][x] = (giet_rand() >> (x % 8)) & 0x1;
     
    7777   uint8_t nb = 0;
    7878
    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];
    8787
    8888   return nb;
     
    116116   for (y = base_line; y < base_line + nb_line; y++)
    117117   {
    118       for(x = 0; x < WIDTH ; x++)
     118      for(x = 0; x < width ; x++)
    119119      {
    120120         world[phase][y][x] = compute_cell( 1 - phase , x , y ); 
     
    131131   for (y = base_line; y < base_line + nb_line; y++)
    132132   {
    133       for(x = 0; x < WIDTH ; x++)
     133      for(x = 0; x < width ; x++)
    134134      {
    135135         display[phase][y][x] = world[phase][y][x]*255; 
     
    224224   giet_procs_number( &x_size, &y_size, &nprocs );
    225225
     226   // get a shared TTY
     227   giet_tty_alloc( 1 );
     228
    226229   giet_pthread_assert( (x_size <= 16) , "x_size no larger than 16" );
    227230   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" );
    229239
    230240   // compute number of threads and min number of lines per thread
     
    234244   unsigned int nlines;
    235245   unsigned int extra;
    236    if ( total_procs > HEIGHT )
    237    {
    238       nthreads = HEIGHT;
     246   if ( total_procs > height )
     247   {
     248      nthreads = height;
    239249      nlines   = 1;
    240250      extra    = 0;
     
    243253   {
    244254      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 );
     255      nlines   = height / total_procs;
     256      extra    = height % total_procs; 
     257   }
     258
     259   // get FBF ownership
     260   giet_fbf_alloc();
    251261
    252262   // get a Chained Buffer DMA channel
     
    260270
    261271   // activates CMA channel
    262    giet_fbf_cma_start( HEIGHT * WIDTH );
     272   giet_fbf_cma_start( height * width );
    263273
    264274   // initializes distributed heap
     
    278288   giet_tty_printf("\n[GAMEOFLIFE] P[%d,%d,%d] completes initialisation at cycle %d\n"
    279289                   " 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 );
    281291
    282292   // compute arguments (index, nlines) for all threads
  • soft/giet_vm/applications/raycast/raycast.c

    r708 r712  
    1818pthread_t                trdid[1024];        // thread identifiers array
    1919Game                     game;               // Game state
     20unsigned int             fbuf_x_size;        // FBF width
     21unsigned int             fbuf_y_size;        // FBF height
    2022
    2123// Textures
     
    5254    unsigned int i, j, n;   // indexes for loops
    5355
     56    // get private TTY
    5457    giet_tty_alloc(0);
    5558
     
    6366    giet_pthread_assert( (h<=16) , "[RAYCAST ERROR] check hardware config" );
    6467    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" );
    6573
    6674    // compute total number of threads
     
    8391
    8492    // Initialize frame buffer and start Chained buffer DMA
     93    giet_fbf_alloc();
    8594    giet_fbf_cma_alloc();
    8695    giet_fbf_cma_init_buf(buf[0], buf[1], sts[0], sts[1]);
     
    127136        unsigned int slice;
    128137        while ( dispRenderSlice( &slice ) );
    129 /*
    130         unsigned int again;
    131         do
    132         {
    133             again = dispRenderSlice( &slice );
    134         }
    135         while ( again );
    136 */
     138
    137139        // Wait last slice completion
    138140        while (slice_count < FBUF_X_SIZE)  giet_tty_printf(" ");
  • soft/giet_vm/applications/shell/shell.c

    r708 r712  
    1414#define MAX_ARGS    (32)
    1515
     16
    1617struct command_t
    1718{
     
    260261static void cmd_ps(int argc, char** argv)
    261262{
    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    }
    263271}
    264272
     
    272280    }
    273281
    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] );
    284283}
    285284
     
    293292    }
    294293
    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] );
    305295}
    306296
     
    314304    }
    315305
    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] );
    326307}
    327308
  • soft/giet_vm/applications/shell/shell.py

    r708 r712  
    88#   author : Alain Greiner
    99#######################################################################################
    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.
    1213####################################################################################
    1314
     
    1516def extend( mapping ):
    1617
    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
    2022
    2123    # define vsegs base & size
     
    3739    # data vseg
    3840    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',
    4042                     binpath = 'bin/shell/appli.elf',
    4143                     local = False )
     
    4345    # code vseg
    4446    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',
    4648                     binpath = 'bin/shell/appli.elf',
    4749                     local = False )
     
    4951    # stack vseg             
    5052    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',
    5254                     local = False, big = True )
    5355
    5456    # heap vseg (unused)           
    5557    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',
    5759                     local = False )
    5860
    5961    # 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
    6169
    6270    # extend mapping name
  • soft/giet_vm/applications/transpose/transpose.c

    r708 r712  
    77// It can run on a multi-processors, multi-clusters architecture, with one thread
    88// per processor, and uses the POSIX threads API.
     9// It does not use the CMA to display the result image.
    910//
    1011// The main() function can be launched on any processor P[x,y,l].
     
    2829
    2930#include "stdio.h"
     31#include "stdlib.h"
    3032#include "user_barrier.h"
    3133#include "malloc.h"
     
    3638#define PROCS_MAX             4                           // max number of procs per cluster
    3739#define CLUSTER_MAX           (X_MAX * Y_MAX)             // max number of clusters
    38 #define IMAGE_SIZE            256                         // image size : nlines = npixels
    39 #define INPUT_FILE_PATH       "/misc/lena_256.raw"        // pathname on virtual disk
    40 #define OUTPUT_FILE_PATH      "/home/lena_transposed.raw" // pathname on virtual disk
     40#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
    4143
    4244// macro to use a shared TTY
     
    6567
    6668// checksum variables
    67 unsigned check_line_before[IMAGE_SIZE];
    68 unsigned check_line_after[IMAGE_SIZE];
     69unsigned check_line_before[1024];
     70unsigned check_line_after[1024];
    6971
    7072// lock protecting shared TTY
     
    7375// synchronisation barrier (all threads)
    7476giet_sqt_barrier_t barrier;
     77
     78// input & output files pathname and size
     79char          input_file_name[256];
     80char          output_file_name[256];
     81unsigned int  image_size;
    7582
    7683////////////////////////////////////////////
     
    97104    unsigned int nclusters     = x_size * y_size;               // number of clusters
    98105    unsigned int nthreads      = x_size * y_size * nprocs;      // number of threads
    99     unsigned int npixels       = IMAGE_SIZE * IMAGE_SIZE;       // pixels per image
     106    unsigned int npixels       = image_size * image_size;       // pixels per image
    100107    int          fd_in         = 0;                             // initial file descriptor
    101108    int          fd_out        = 0;                             // output file descriptor
     
    122129
    123130        // open input file
    124         fd_in = giet_fat_open( INPUT_FILE_PATH , O_RDONLY );  // read_only
     131        fd_in = giet_fat_open( input_file_name , O_RDONLY );  // read_only
    125132        if ( fd_in < 0 )
    126133        {
    127134            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 );
    129136            giet_pthread_exit(" open() failure");
    130137        }
     
    132139        {
    133140            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 );
    135142        }
    136143
    137144        // open output file
    138         fd_out = giet_fat_open( OUTPUT_FILE_PATH , O_CREATE );   // create if required
     145        fd_out = giet_fat_open( output_file_name , O_CREATE );   // create if required
    139146        if ( fd_out < 0 )
    140147        {
    141148            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 );
    143150            giet_pthread_exit(" open() failure");
    144151        }
     
    146153        {
    147154            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 );
    149156        }
    150157
     
    184191
    185192    // 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)
    187194    // from line [thread_id*nlt] to line [(thread_id + 1)*nlt - 1]
    188195    // (p,l) are the absolute pixel coordinates in the source image
     
    190197    TRSP_START[x_id][y_id][p_id] = giet_proctime();
    191198
    192     unsigned int nlt   = IMAGE_SIZE / nthreads;    // number of lines per thread
    193     unsigned int nlc   = IMAGE_SIZE / nclusters;   // number of lines per cluster
     199    unsigned int nlt   = image_size / nthreads;    // number of lines per thread
     200    unsigned int nlc   = image_size / nclusters;   // number of lines per cluster
    194201
    195202    unsigned int src_cluster;
     
    208215     
    209216        // in each iteration we transfer one byte
    210         for ( p = 0 ; p < IMAGE_SIZE ; p++ )
     217        for ( p = 0 ; p < image_size ; p++ )
    211218        {
    212219            // read one byte from local buf_in
    213220            src_cluster = l / nlc;
    214             src_index   = (l % nlc)*IMAGE_SIZE + p;
     221            src_index   = (l % nlc)*image_size + p;
    215222            byte        = buf_in[src_cluster][src_index];
    216223
     
    220227            // write one byte to remote buf_out
    221228            dst_cluster = p / nlc;
    222             dst_index   = (p % nlc)*IMAGE_SIZE + l;
     229            dst_index   = (p % nlc)*image_size + l;
    223230            buf_out[dst_cluster][dst_index] = byte;
    224231        }
     
    436443                         "[TRANSPOSE ERROR] y_size must be 1,2,4,8,16");
    437444
    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
    441446    unsigned int nthreads = x_size * y_size * nprocs;
    442447
     
    445450    lock_init( &tty_lock);
    446451
    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");
    448486
    449487    // distributed heap initialisation
Note: See TracChangeset for help on using the changeset viewer.