Ignore:
Timestamp:
Nov 3, 2014, 12:40:50 PM (10 years ago)
Author:
alain
Message:

Introducing application "display"

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  
    33// Date   : june 2014
    44// 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).
    519//
    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.
    722////////////////////////////////////////////////////////////////////////////////////////////
    823
     
    106121    unsigned int task_id     = (cluster_id * nprocs) + lpid;  // continuous task index
    107122    unsigned int ntasks      = nclusters * nprocs;            // number of tasks
    108     unsigned int npixels     = NB_PIXELS;                     // pixels per frame
    109123    unsigned int frame_size  = FRAME_SIZE;                    // total size (bytes)
    110124    unsigned int nblocks     = frame_size / 512;              // number of blocks per frame
     
    126140     // parameters checking
    127141   
     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    }
    128146    if ((nprocs != 1) && (nprocs != 2) && (nprocs != 4))
    129147        giet_exit( "[CONVOL ERROR] NB_PROCS_MAX must be 1, 2 or 4\n");
     
    148166    if ( (x==0) && (y==0) && (lpid==0) )
    149167    {
     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   
    150188        giet_shr_printf("\n[CONVOL] task[0,0,0] starts barrier init at cycle %d\n"
    151189                        "- NB_CLUSTERS     = %d\n"
    152                         "- NB_LOCAL_PROCS  = %d\n"
     190                        "- NB_PROCS_MAX    = %d\n"
    153191                        "- NB_TASKS        = %d\n"
    154                         "- NB_PIXELS       = %x\n"           
    155                         "- FRAME_SIZE      = %x\n"             
    156192                        "- NB_BLOCKS       = %x\n",
    157                         giet_proctime(), nclusters, nprocs, ntasks,
    158                         npixels, frame_size, nblocks );
     193                        giet_proctime(), nclusters, nprocs, ntasks, nblocks );
    159194#if USE_SBT_BARRIER
    160195        sbt_barrier_init( &barrier, ntasks );
     
    294329            }
    295330
    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);
    299334        }
    300335
     
    572607            }
    573608
    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);
    577612        }
    578613
  • soft/giet_vm/applications/display/display.ld

    r258 r444  
    33*****************************************************************************/
    44
    5 seg_code_base      = 0x00400000;
    6 seg_data_base      = 0x00500000;       
     5seg_code_base      = 0x10000000;
     6seg_data_base      = 0x20000000;       
    77
    88/***************************************************************************
  • 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///////////////////////////////////////////////////////////////////////////////////////
    310
    4 #define NBLOCKS 32   // (128 * 128) / 512
     11#include <stdio.h>
     12#include <hard_config.h>
    513
    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
    719
     20
     21unsigned char buf0[NPIXELS*NLINES] __attribute__((aligned(512)));
     22unsigned char buf1[NPIXELS*NLINES] __attribute__((aligned(512)));
     23
     24////////////////////////////////////////////
    825__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
    1034    int             fd;
    11     int             blocks;
    12     unsigned int    ko;
    13     unsigned int    blocks_to_skip = 8*NBLOCKS;
     35    unsigned int    image = 0;
    1436
    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) )
    3339    {
    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");
    4741    }
    4842
    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");
    50100}
  • soft/giet_vm/applications/gameoflife/main.c

    r432 r444  
    106106   }
    107107
    108    giet_fb_sync_write( base_line * WIDTH ,
     108   giet_fbf_sync_write( base_line * WIDTH ,
    109109                       &world[NEW][base_line][0],
    110110                       nb_line * WIDTH);
  • soft/giet_vm/applications/transpose/main.c

    r432 r444  
    1 ///////////////////////////////////////////////////////////////////////////////////////////////
     1/////////////////////////////////////////////////////////////////////////////////////////////
    22// File   : main.c   (for transpose application)
    33// Date   : february 2014
    44// 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//
    716// The image sequence is read from a file (one byte per pixel).
    817// The input and output buffers containing the image are distributed in all clusters.
    918//
    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.
    1120// - 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.
    1322// - The image size NN must be larger or equal to the total number of processor.
    1423//
    1524// For each image the application makes a self test (checksum for each line).
    1625// The actual display on the frame buffer depends on frame buffer availability.
    17 ///////////////////////////////////////////////////////////////////////////////////////////////
     26/////////////////////////////////////////////////////////////////////////////////////////////
    1827
    1928#include "hard_config.h"
     
    2332
    2433#define NN                  128                 // image size : nlines = npixels = 128
    25 #define NB_IMAGES           2                   // number of images to be handled
     34#define NB_IMAGES           5                   // number of images to be handled
    2635#define FILE_PATHNAME       "misc/images.raw"   // file pathname on disk
    2736#define NB_CLUSTERS         (X_SIZE * Y_SIZE)   // number of clusters
     
    5463giet_barrier_t barrier;
    5564
    56 volatile unsigned int init_ok = 1;
     65volatile unsigned int init_ok = 0;
    5766
    5867//////////////////////////////////////////
     
    8695    {
    8796        // 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        }
    88101        if ((NB_PROCS_MAX != 1) && (NB_PROCS_MAX != 2) && (NB_PROCS_MAX != 4))
    89102        {
     
    149162            giet_shr_printf("\n[TRANSPOSE] Proc [0,0,0] open file misc/images.raw\n");
    150163        }
    151         init_ok = 0;
     164        init_ok = 1;
    152165    }
    153166    else   // others processors wait initialisation completion
    154167    {
    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() );
    157171    }
    158172   
     
    247261            unsigned int  npt   = npixels / ntasks;   // number of pixels per task
    248262
    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 );
    252266
    253267            if ( lpid == 0 )
  • soft/giet_vm/applications/transpose/transpose.py

    r432 r444  
    2525    x_size    = mapping.x_size
    2626    y_size    = mapping.y_size
    27     nprocs = mapping.nprocs
     27    nprocs    = mapping.nprocs
    2828    x_width   = mapping.x_width
    2929    y_width   = mapping.y_width
Note: See TracChangeset for help on using the changeset viewer.