Changeset 736 for soft


Ignore:
Timestamp:
Dec 3, 2015, 4:40:49 PM (8 years ago)
Author:
alain
Message:

Modify the mjpeg application to support an optional
DCT hardware coprocessor.

Location:
soft/giet_vm/applications
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/applications/coproc/coproc.c

    r708 r736  
    1 ///////////////////////////////////////////////////////////////////////////////////////
     1/////////////////////////////////////////////////////////////////////////////////////
    22//  file   : coproc.c
    33//  date   : avril 2015
    44//  author : Alain Greiner
    5 ///////////////////////////////////////////////////////////////////////////////////////
     5/////////////////////////////////////////////////////////////////////////////////////
    66//  This file describes the single thread "coproc" application.
    77//  It uses the GCD (Greater Common Divider) hardware coprocessor
    88//  to make the GCD computation between two vectors of 32 bits integers.
     9//  It supports two coprocessor operating modes: MODE_DMA_IRQ or MODE_DMA_NO_IRQ.
    910//  The vectors size is defined by the VECTOR_SIZE parameter.
    10 ///////////////////////////////////////////////////////////////////////////////////////
     11/////////////////////////////////////////////////////////////////////////////////////
    1112
    1213
     
    4142                    x, y, lpid, giet_proctime() );
    4243
     44    // check coprocessor operating mode
     45    giet_pthread_assert( (DMA_MODE == MODE_DMA_IRQ) || (DMA_MODE == MODE_DMA_NO_IRQ),
     46    "\n[COPROC ERROR] only MODE_DMA_IRQ and MODE_DMA_NO_IRQ modes are supported");
     47
    4348    // initializes opa & opb buffers
    4449    unsigned int word;
     
    5055
    5156    unsigned int coproc_info;
     57    unsigned int cluster_xy  = (x << 4) + y;
     58    unsigned int coproc_type = MWR_SUBTYPE_GCD;
    5259
    53     /////////////////////// request a GCD coprocessor
    54     giet_coproc_alloc( MWR_SUBTYPE_GCD, &coproc_info );
     60    // get a GCD coprocessor in local cluster
     61    giet_coproc_alloc( cluster_xy,
     62                       coproc_type,
     63                       &coproc_info );
    5564
    5665    // check coprocessor ports
     
    6978#endif
    7079
    71     //////////////////////// initializes channel for OPA
     80    // initializes OPA channel
    7281    giet_coproc_channel_t opa_desc;
    7382    opa_desc.channel_mode = DMA_MODE;
    7483    opa_desc.buffer_size  = VECTOR_SIZE<<2;
    7584    opa_desc.buffer_vaddr = (unsigned int)opa;
    76     giet_coproc_channel_init( 0 , &opa_desc );
     85    giet_coproc_channel_init( cluster_xy,
     86                              coproc_type,
     87                              0,
     88                              &opa_desc );
    7789   
    78     //////////////////////// initializes channel for OPB
     90    // initializes OPB channel
    7991    giet_coproc_channel_t opb_desc;
    8092    opb_desc.channel_mode = DMA_MODE;
    8193    opb_desc.buffer_size  = VECTOR_SIZE<<2;
    8294    opb_desc.buffer_vaddr = (unsigned int)opb;
    83     giet_coproc_channel_init( 1 , &opb_desc );
     95    giet_coproc_channel_init( cluster_xy,
     96                              coproc_type,
     97                              1,
     98                              &opb_desc );
    8499   
    85     //////////////////////// initializes channel for RES
     100    // initializes RES channel
    86101    giet_coproc_channel_t res_desc;
    87102    res_desc.channel_mode = DMA_MODE;
    88103    res_desc.buffer_size  = VECTOR_SIZE<<2;
    89104    res_desc.buffer_vaddr = (unsigned int)res;
    90     giet_coproc_channel_init( 2 , &res_desc );
     105    giet_coproc_channel_init( cluster_xy,
     106                              coproc_type,
     107                              2,
     108                              &res_desc );
    91109   
    92110#if  VERBOSE
     
    94112#endif
    95113
    96     /////////////////////// starts communication channels
    97     giet_coproc_run( 0 );
     114    // starts coprocessor
     115    giet_coproc_run( cluster_xy,
     116                     coproc_type );
    98117
    99118#if  VERBOSE
     
    101120#endif
    102121
    103     /////////////////////// wait coprocessor completion
     122    // wait coprocessor completion
    104123    if ( DMA_MODE == MODE_DMA_NO_IRQ )
    105124    {
    106         giet_coproc_completed( );
     125        giet_coproc_completed( cluster_xy,
     126                               coproc_type );
    107127    }
    108128
     
    118138    }
    119139
    120     ////////////////////// release GCD coprocessor
    121     giet_coproc_release( 0 );
     140    // release GCD coprocessor
     141    giet_coproc_release( cluster_xy,
     142                         coproc_type );
    122143
    123144    giet_pthread_exit("completed");
  • soft/giet_vm/applications/coproc/coproc.py

    r708 r736  
    3333    x = 0
    3434    y = 0
    35     p = 1
     35    p = 0
    3636
    3737    assert( (x < x_size) and (y < y_size) )
     
    5050
    5151    # create vspace
    52     vspace = mapping.addVspace( name = 'coproc', startname = 'coproc_data', active = False )
     52    vspace = mapping.addVspace( name = 'coproc', startname = 'coproc_data', active = True )
    5353   
    5454    # data vseg in cluster[x,y]
  • soft/giet_vm/applications/mjpeg/demux.c

    r723 r736  
    8686    // giet_tty_alloc( 0 );
    8787
    88     PRINTF("\n[MJPEG] thread DEMUX[%d] starts on P[%d,%d,%d]\n", index, x, y, p )
     88    PRINTF("\n[MJPEG] thread DEMUX[%d] starts on P[%d,%d,%d] / trdid = %x\n",
     89           index , x , y , p, (uint32_t)trdid_demux[index] )
    8990
    9091    // initialise BUFIO for MWMR channel <in>
     
    9596
    9697#if (DEBUG_DEMUX > 1)
    97 PRINTF("\nDEMUX[%d] <in> : &mwmr = %x / &bufio = %x\n",
    98        index , mwmr_in , &bufio_in )
     98if ( (index == DEBUG_CLUSTER_INDEX) || (DEBUG_CLUSTER_INDEX == 0XFFFFFFFF) )
     99{ PRINTF("\nDEMUX[%d] <in> : &mwmr = %x / &bufio = %x\n",
     100         index , mwmr_in , &bufio_in ) }
    99101#endif
    100102
     
    106108
    107109#if (DEBUG_DEMUX > 1)
    108 PRINTF("\nDEMUX[%d] : <out_quanti> : mwmr = %x / &bufio = %x\n",
    109        index , mwmr_out_quanti , &bufio_out_quanti )
     110if ( (index == DEBUG_CLUSTER_INDEX) || (DEBUG_CLUSTER_INDEX == 0XFFFFFFFF) )
     111{ PRINTF("\nDEMUX[%d] : <out_quanti> : mwmr = %x / &bufio = %x\n",
     112         index , mwmr_out_quanti , &bufio_out_quanti ) }
    110113#endif
    111114
     
    117120
    118121#if (DEBUG_DEMUX > 1)
    119 PRINTF("\nDEMUX[%d] : <out_huff> : mwmr = %x / &bufio = %x\n",
    120        index , mwmr_out_huff , &bufio_out_huff )
     122if ( (index == DEBUG_CLUSTER_INDEX) || (DEBUG_CLUSTER_INDEX == 0XFFFFFFFF) )
     123{ PRINTF("\nDEMUX[%d] : <out_huff> : mwmr = %x / &bufio = %x\n",
     124         index , mwmr_out_huff , &bufio_out_huff ) }
    121125#endif
    122126
     
    128132
    129133#if (DEBUG_DEMUX > 1)
    130 PRINTF("\nDEMUX[%d] : <out_data> : mwmr = %x / &bufio = %x\n",
    131        index , mwmr_out_data , &bufio_out_data )
     134if ( (index == DEBUG_CLUSTER_INDEX) || (DEBUG_CLUSTER_INDEX == 0XFFFFFFFF) )
     135{ PRINTF("\nDEMUX[%d] : <out_data> : mwmr = %x / &bufio = %x\n",
     136         index , mwmr_out_data , &bufio_out_data ) }
    132137#endif
    133138
     
    150155            marker = get_next_marker( &bufio_in );
    151156
    152 #if (DEBUG_DEMUX > 1)
    153 if ( marker == SOI_MK ) PRINTF("\nDEMUX[%x] found Start of Image marker\n", index )
    154 #endif
    155157        }
    156158        while ( marker != SOI_MK );
     159
     160#if (DEBUG_DEMUX > 1)
     161if ( (index == DEBUG_CLUSTER_INDEX) || (DEBUG_CLUSTER_INDEX == 0XFFFFFFFF) )
     162{ PRINTF("\nDEMUX[%x] found Start of Image marker\n", index ) }
     163#endif
    157164
    158165        found_marker = 0;
     
    173180
    174181#if (DEBUG_DEMUX > 1)
    175 PRINTF("\nDEMUX[%x] found Start of Frame marker\n", index )
     182if ( (index == DEBUG_CLUSTER_INDEX) || (DEBUG_CLUSTER_INDEX == 0XFFFFFFFF) )
     183{ PRINTF("\nDEMUX[%x] found Start of Frame marker\n", index ) }
    176184#endif
    177185                // Only one component per image is supported
     
    208216
    209217#if (DEBUG_DEMUX > 1)
    210 PRINTF("\nDEMUX[%x] found Quantization Table marker\n", index )
     218if ( (index == DEBUG_CLUSTER_INDEX) || (DEBUG_CLUSTER_INDEX == 0XFFFFFFFF) )
     219{ PRINTF("\nDEMUX[%x] found Quantization Table marker\n", index ) }
    211220#endif
    212221                // The  quantisation table segment being fixed length,
     
    235244
    236245#if (DEBUG_DEMUX > 1)
    237 PRINTF("\nDEMUX[%x] found Huffman Table marker\n", index )
     246if ( (index == DEBUG_CLUSTER_INDEX) || (DEBUG_CLUSTER_INDEX == 0XFFFFFFFF) )
     247{ PRINTF("\nDEMUX[%x] found Huffman Table marker\n", index ) }
    238248#endif
    239249                // The Huffman Table segment being variable length,
     
    279289
    280290#if (DEBUG_DEMUX > 1)
    281 PRINTF("\nDEMUX[%x] found Start of Scan marker\n", index )
     291if ( (index == DEBUG_CLUSTER_INDEX) || (DEBUG_CLUSTER_INDEX == 0XFFFFFFFF) )
     292{ PRINTF("\nDEMUX[%x] found Start of Scan marker\n", index ) }
    282293#endif
    283294                // The scan segment has a variable length:
     
    330341
    331342#if (DEBUG_DEMUX > 1)
    332 PRINTF("\nDEMUX[%x] found End of Image marker\n", index )
     343if ( (index == DEBUG_CLUSTER_INDEX) || (DEBUG_CLUSTER_INDEX == 0XFFFFFFFF) )
     344{ PRINTF("\nDEMUX[%x] found End of Image marker\n", index ) }
    333345#endif
    334346                mwmr_bufio_flush( &bufio_out_data );
     
    341353
    342354#if (DEBUG_DEMUX > 1)
    343 PRINTF("\nDEMUX[%x] found Comment or Application marker\n", index )
     355if ( (index == DEBUG_CLUSTER_INDEX) || (DEBUG_CLUSTER_INDEX == 0XFFFFFFFF) )
     356{ PRINTF("\nDEMUX[%x] found Comment or Application marker\n", index ) }
    344357#endif
    345358                // read segment length from bufio_in
     
    367380
    368381#if DEBUG_DEMUX
    369 PRINTF("\nDEMUX[%d] completes image %d at cycle %d\n", index , image , giet_proctime() )
     382if ( (index == DEBUG_CLUSTER_INDEX) || (DEBUG_CLUSTER_INDEX == 0XFFFFFFFF) )
     383{ PRINTF("\nDEMUX[%d] completes image %d at cycle %d\n", index , image , giet_proctime() ) }
    370384#endif
    371385        image = image + x_size * y_size;
     
    373387    }  // end while on images
    374388
    375     giet_pthread_exit( "demux completed" );
     389    giet_pthread_exit( "DEMUX completed" );
    376390
    377391}  // end demux()
  • soft/giet_vm/applications/mjpeg/idct.c

    r723 r736  
    155155    // giet_tty_alloc( 0 );
    156156
    157     PRINTF("\n[MJPEG] thread IDCT[%d] starts on P[%d,%d,%d]\n", index , x , y , p )
     157    PRINTF("\n[MJPEG] thread IDCT[%d] starts on P[%d,%d,%d] / trdid = %x\n",
     158           index , x , y , p, (uint32_t)trdid_idct[index] )
     159
    158160
    159161    uint32_t  image = index;
     
    210212            mwmr_write( output, (uint32_t*)bout , 16 );
    211213
    212 #if (DEBUG_IDCT > 1)
    213 PRINTF("\nIDCT[%d] completes block %d/%d in image %d\n",
    214        index , block , nblocks , image )
    215 PRINTF("  %x  %x  %x  %x  %x  %x  %x  %x\n"
    216        "  %x  %x  %x  %x  %x  %x  %x  %x\n"
    217        "  %x  %x  %x  %x  %x  %x  %x  %x\n"
    218        "  %x  %x  %x  %x  %x  %x  %x  %x\n"
    219        "  %x  %x  %x  %x  %x  %x  %x  %x\n"
    220        "  %x  %x  %x  %x  %x  %x  %x  %x\n"
    221        "  %x  %x  %x  %x  %x  %x  %x  %x\n"
    222        "  %x  %x  %x  %x  %x  %x  %x  %x\n",
    223        bout[0] , bout[1] , bout[2] , bout[3] , bout[4] , bout[5] , bout[6] , bout[7] ,
    224        bout[8] , bout[9] , bout[10], bout[11], bout[12], bout[13], bout[14], bout[15],
    225        bout[16], bout[17], bout[18], bout[19], bout[20], bout[21], bout[22], bout[23],
    226        bout[24], bout[25], bout[26], bout[27], bout[28], bout[29], bout[30], bout[31],
    227        bout[32], bout[33], bout[34], bout[35], bout[36], bout[37], bout[38], bout[39],
    228        bout[40], bout[41], bout[42], bout[43], bout[44], bout[45], bout[46], bout[47],
    229        bout[48], bout[49], bout[50], bout[51], bout[52], bout[53], bout[54], bout[55],
    230        bout[56], bout[57], bout[58], bout[59], bout[60], bout[61], bout[62], bout[63])
     214#if (DEBUG_IDCT > 1)
     215if ( (index == DEBUG_CLUSTER_INDEX) || (DEBUG_CLUSTER_INDEX == 0XFFFFFFFF) )
     216 PRINTF("\nIDCT[%d] completes block %d/%d in image %d\n"
     217         "  %x  %x  %x  %x  %x  %x  %x  %x\n"
     218         "  %x  %x  %x  %x  %x  %x  %x  %x\n"
     219         "  %x  %x  %x  %x  %x  %x  %x  %x\n"
     220         "  %x  %x  %x  %x  %x  %x  %x  %x\n"
     221         "  %x  %x  %x  %x  %x  %x  %x  %x\n"
     222         "  %x  %x  %x  %x  %x  %x  %x  %x\n"
     223         "  %x  %x  %x  %x  %x  %x  %x  %x\n"
     224         "  %x  %x  %x  %x  %x  %x  %x  %x\n",
     225         index , block , nblocks , image ,
     226         bout[0] , bout[1] , bout[2] , bout[3] , bout[4] , bout[5] , bout[6] , bout[7] ,
     227         bout[8] , bout[9] , bout[10], bout[11], bout[12], bout[13], bout[14], bout[15],
     228         bout[16], bout[17], bout[18], bout[19], bout[20], bout[21], bout[22], bout[23],
     229         bout[24], bout[25], bout[26], bout[27], bout[28], bout[29], bout[30], bout[31],
     230         bout[32], bout[33], bout[34], bout[35], bout[36], bout[37], bout[38], bout[39],
     231         bout[40], bout[41], bout[42], bout[43], bout[44], bout[45], bout[46], bout[47],
     232         bout[48], bout[49], bout[50], bout[51], bout[52], bout[53], bout[54], bout[55],
     233         bout[56], bout[57], bout[58], bout[59], bout[60], bout[61], bout[62], bout[63]) }
    231234}
    232235#endif
     
    234237
    235238#if DEBUG_IDCT
    236 PRINTF("IDCT[%d] completes image %d at cycle %d\n", index , image , giet_proctime() )
     239if ( (index == DEBUG_CLUSTER_INDEX) || (DEBUG_CLUSTER_INDEX == 0XFFFFFFFF) )
     240{ PRINTF("\nIDCT[%d] completes image %d at cycle %d\n", index , image , giet_proctime() ) }
    237241#endif
    238242
     
    241245    }  // end while (1) on images
    242246
    243     giet_pthread_exit( "idct completed" );
     247    giet_pthread_exit( "IDCT completed" );
    244248
    245249}  // end idct()
  • soft/giet_vm/applications/mjpeg/iqzz.c

    r723 r736  
    3939    uint32_t    block;
    4040    uint32_t    i;
    41     uint8_t     QTable[64];    // Quantisation Table / 1 byte per pixel
    42     int16_t     bufin[64];     // Input data buffer  / 2 bytes per pixel
    43     int32_t     bufout[64];    // Output data buffer / 4 bytes per pixel
     41    uint8_t     QT[64];      // Quantisation Table / 1 byte per pixel
     42    int16_t     bin[64];     // Input data buffer  / 2 bytes per pixel
     43    int32_t     bout[64];    // Output data buffer / 4 bytes per pixel
    4444
    4545    uint32_t    nblocks = nblocks_w * nblocks_h;
     
    5555    giet_proc_xyp( &x , &y , &p );
    5656
    57     PRINTF("\n[MJPEG] thread IQZZ[%d] starts on P[%d,%d,%d]\n", index, x, y, p )
     57    PRINTF("\n[MJPEG] thread IQZZ[%d] starts on P[%d,%d,%d] / trdid = %x\n",
     58           index , x , y , p, (uint32_t)trdid_iqzz[index] )
     59
    5860
    5961    uint32_t image = index;
     
    6264    {
    6365        // read the quantization coefs from mwmr_in_quanti (one byte per coef)
    64         mwmr_read( mwmr_in_quanti , (uint32_t*)QTable , 16 );
     66        mwmr_read( mwmr_in_quanti , (uint32_t*)QT , 16 );
    6567
    6668#if (DEBUG_IQZZ > 1)
    67 PRINTF("\nIQZZ[%d] get quantisation coefs for image %d\n", index , image )
     69if ( (index == DEBUG_CLUSTER_INDEX) || (DEBUG_CLUSTER_INDEX == 0XFFFFFFFF) )
     70{ PRINTF("\nIQZZ[%d] get quantisation coefs for image %d\n"
     71         "%d  %d  %d  %d  %d  %d  %d  %d\n"
     72         "%d  %d  %d  %d  %d  %d  %d  %d\n"
     73         "%d  %d  %d  %d  %d  %d  %d  %d\n"
     74         "%d  %d  %d  %d  %d  %d  %d  %d\n"
     75         "%d  %d  %d  %d  %d  %d  %d  %d\n"
     76         "%d  %d  %d  %d  %d  %d  %d  %d\n"
     77         "%d  %d  %d  %d  %d  %d  %d  %d\n"
     78         "%d  %d  %d  %d  %d  %d  %d  %d\n",
     79         index , image ,
     80         QT[ 0],QT[ 1],QT[ 2],QT[ 3],QT[ 4],QT[ 5],QT[ 6],QT[ 7],
     81         QT[ 8],QT[ 9],QT[10],QT[11],QT[12],QT[13],QT[14],QT[15],
     82         QT[16],QT[17],QT[18],QT[19],QT[20],QT[21],QT[22],QT[23],
     83         QT[24],QT[25],QT[26],QT[27],QT[28],QT[29],QT[30],QT[31],
     84         QT[32],QT[33],QT[34],QT[35],QT[36],QT[37],QT[38],QT[39],
     85         QT[40],QT[41],QT[42],QT[43],QT[44],QT[45],QT[46],QT[47],
     86         QT[48],QT[49],QT[50],QT[51],QT[52],QT[53],QT[54],QT[55],
     87         QT[56],QT[57],QT[58],QT[59],QT[60],QT[61],QT[62],QT[63] ) }
    6888#endif
    6989
     
    7191        {
    7292            // read one block from mwmr_in_data (2 bytes per pixel)
    73             mwmr_read( mwmr_in_data , (uint32_t*)bufin , 32 );
     93            mwmr_read( mwmr_in_data , (uint32_t*)bin , 32 );
    7494
    7595            // unquantify & UnZZ each pixel
    7696            for ( i = 0 ; i < 64 ; ++i )
    7797            {
    78                 bufout[G_ZZ[i]] = bufin[i] * QTable[i];
     98                bout[G_ZZ[i]] = bin[i] * QT[i];
    7999            }
    80    
     100
    81101            // write one block to IDCT / 4 bytes per pixel
    82             mwmr_write( mwmr_out_data , (uint32_t*)bufout , 64 );
     102            mwmr_write( mwmr_out_data , (uint32_t*)bout , 64 );
    83103
    84104#if (DEBUG_IQZZ > 1)
    85 PRINTF("\nIQZZ[%d] completes block %d/%d in image %d\n",
    86        index , block , nblocks , image )
    87 PRINTF("  %d  %d  %d  %d  %d  %d  %d  %d\n"
    88        "  %d  %d  %d  %d  %d  %d  %d  %d\n"
    89        "  %d  %d  %d  %d  %d  %d  %d  %d\n"
    90        "  %d  %d  %d  %d  %d  %d  %d  %d\n"
    91        "  %d  %d  %d  %d  %d  %d  %d  %d\n"
    92        "  %d  %d  %d  %d  %d  %d  %d  %d\n"
    93        "  %d  %d  %d  %d  %d  %d  %d  %d\n"
    94        "  %d  %d  %d  %d  %d  %d  %d  %d\n",
    95        bufout[0] , bufout[1] , bufout[2] , bufout[3] , bufout[4] , bufout[5] , bufout[6] , bufout[7] ,
    96        bufout[8] , bufout[9] , bufout[10], bufout[11], bufout[12], bufout[13], bufout[14], bufout[15],
    97        bufout[16], bufout[17], bufout[18], bufout[19], bufout[20], bufout[21], bufout[22], bufout[23],
    98        bufout[24], bufout[25], bufout[26], bufout[27], bufout[28], bufout[29], bufout[30], bufout[31],
    99        bufout[32], bufout[33], bufout[34], bufout[35], bufout[36], bufout[37], bufout[38], bufout[39],
    100        bufout[40], bufout[41], bufout[42], bufout[43], bufout[44], bufout[45], bufout[46], bufout[47],
    101        bufout[48], bufout[49], bufout[50], bufout[51], bufout[52], bufout[53], bufout[54], bufout[55],
    102        bufout[56], bufout[57], bufout[58], bufout[59], bufout[60], bufout[61], bufout[62], bufout[63])
     105if ( (index == DEBUG_CLUSTER_INDEX) || (DEBUG_CLUSTER_INDEX == 0XFFFFFFFF) )
     106{ PRINTF("\nIQZZ[%d] completes block %d/%d in image %d\n"
     107         "  %d  %d  %d  %d  %d  %d  %d  %d\n"
     108         "  %d  %d  %d  %d  %d  %d  %d  %d\n"
     109         "  %d  %d  %d  %d  %d  %d  %d  %d\n"
     110         "  %d  %d  %d  %d  %d  %d  %d  %d\n"
     111         "  %d  %d  %d  %d  %d  %d  %d  %d\n"
     112         "  %d  %d  %d  %d  %d  %d  %d  %d\n"
     113         "  %d  %d  %d  %d  %d  %d  %d  %d\n"
     114         "  %d  %d  %d  %d  %d  %d  %d  %d\n",
     115         index , block , nblocks , image ,
     116         bout[0] , bout[1] , bout[2] , bout[3] , bout[4] , bout[5] , bout[6] , bout[7] ,
     117         bout[8] , bout[9] , bout[10], bout[11], bout[12], bout[13], bout[14], bout[15],
     118         bout[16], bout[17], bout[18], bout[19], bout[20], bout[21], bout[22], bout[23],
     119         bout[24], bout[25], bout[26], bout[27], bout[28], bout[29], bout[30], bout[31],
     120         bout[32], bout[33], bout[34], bout[35], bout[36], bout[37], bout[38], bout[39],
     121         bout[40], bout[41], bout[42], bout[43], bout[44], bout[45], bout[46], bout[47],
     122         bout[48], bout[49], bout[50], bout[51], bout[52], bout[53], bout[54], bout[55],
     123         bout[56], bout[57], bout[58], bout[59], bout[60], bout[61], bout[62], bout[63]) }
    103124#endif
    104125        }  // end for blocks
    105126
    106127#if DEBUG_IQZZ
    107 PRINTF("\nIQZZ[%d] completes image %d at cycle %d\n", index , image , giet_proctime() )
     128if ( (index == DEBUG_CLUSTER_INDEX) || (DEBUG_CLUSTER_INDEX == 0XFFFFFFFF) )
     129{ PRINTF("\nIQZZ[%d] completes image %d at cycle %d\n", index , image , giet_proctime() ) }
    108130#endif
    109131
     
    112134    } // end while(1) on images
    113135
    114     giet_pthread_exit( "iqzz completed" );
     136    giet_pthread_exit( "IQZZ completed" );
    115137
    116138} // end iqzz()
  • soft/giet_vm/applications/mjpeg/libu.c

    r723 r736  
    5252    // giet_tty_alloc( 0 );
    5353
    54     PRINTF("\n[MJPEG] thread LIBU[%d] starts on P[%d,%d,%d]\n", index , x , y , p )
     54    PRINTF("\n[MJPEG] thread LIBU[%d] starts on P[%d,%d,%d] / trdid = %x\n",
     55           index , x , y , p, (uint32_t)trdid_libu[index] )
    5556
    5657    uint32_t image = index;
     
    8384
    8485#if (DEBUG_LIBU > 1)
    85 PRINTF("\nLIBU[%d] copy block[%d] for image %d\n",
    86 index, line * nblocks_w + column , image )
     86if ( (index == DEBUG_CLUSTER_INDEX) || (DEBUG_CLUSTER_INDEX == 0XFFFFFFFF) )
     87{ PRINTF("\nLIBU[%d] copy block[%d] for image %d\n",
     88         index, line * nblocks_w + column , image ) }
    8789#endif
    8890            }
     
    9799
    98100#if DEBUG_LIBU
    99 PRINTF("\nLIBU[%d] completes image %d at cycle %d\n", index , image , time )
     101if ( (index == DEBUG_CLUSTER_INDEX) || (DEBUG_CLUSTER_INDEX == 0XFFFFFFFF) )
     102{ PRINTF("\nLIBU[%d] completes image %d at cycle %d\n", index , image , time ) }
    100103#endif
    101104        // register date of display for instrumentation
     
    106109    }  // end while on images
    107110
    108     giet_pthread_exit( "libu completed" );
     111    giet_pthread_exit( "LIBU completed" );
    109112
    110113}  // end libu()
  • soft/giet_vm/applications/mjpeg/mjpeg.c

    r723 r736  
    2626#include <stdlib.h>
    2727#include "mjpeg.h"
     28#include <mapping_info.h>     // for coprocessor types and modes
    2829
    2930
     
    3940uint32_t         fd;    // file descriptor for the file containing the MJPEG stream
    4041
     42// arrays of pointers on MWMR channels
    4143mwmr_channel_t*  tg_2_demux[256];         // one per cluster
    4244mwmr_channel_t*  demux_2_vld_data[256];   // one per cluster
     
    4648mwmr_channel_t*  iqzz_2_idct[256];        // one per cluster
    4749mwmr_channel_t*  idct_2_libu[256];        // one per cluster
     50
     51// thread trdid ( for pthread_create() and pthread_join() )
     52pthread_t   trdid_tg;
     53pthread_t   trdid_demux[256];             // one per cluster
     54pthread_t   trdid_vld[256];               // one per cluster
     55pthread_t   trdid_iqzz[256];              // one per cluster
     56pthread_t   trdid_idct[256];              // one per cluster
     57pthread_t   trdid_libu[256];              // one per cluster
    4858
    4959user_lock_t      tty_lock;                // lock protecting shared TTY
     
    113123    uint32_t      image_height;
    114124
    115     PRINTF("\n[MJPEG] enter path for JPEG stream file\n> "); 
    116     giet_tty_gets( file_pathname , 256 );
    117 
    118     if ( file_pathname[0] == 0 )
     125    if ( INTERACTIVE_MODE )
     126    {
     127        PRINTF("\n[MJPEG] enter path for JPEG stream file (default is plan_48.mjpg)\n> ")
     128        giet_tty_gets( file_pathname , 256 );
     129
     130        if ( file_pathname[0] == 0 )
     131        {
     132            strcpy( file_pathname , "/misc/plan_48.mjpg" );
     133            image_width  = 48;
     134            image_height = 48;
     135        }
     136        else
     137        {
     138            PRINTF("\n[MJPEG] enter image width\n> ") 
     139            giet_tty_getw( &image_width );
     140            PRINTF("\n[MJPEG] enter image height\n> ") 
     141            giet_tty_getw( &image_height );
     142            PRINTF("\n")
     143        }
     144    }
     145    else
    119146    {
    120147        strcpy( file_pathname , "/misc/plan_48.mjpg" );
    121148        image_width  = 48;
    122149        image_height = 48;
    123         PRINTF("\n\n[MJPEG] use /misc/plan_48.mjpg\n" );
    124     }
    125     else
    126     {
    127         PRINTF("\n[MJPEG] enter image width\n> "); 
    128         giet_tty_getw( &image_width );
    129         PRINTF("\n[MJPEG] enter image height\n> "); 
    130         giet_tty_getw( &image_height );
    131         PRINTF("\n");
    132     }
    133 
     150    }
     151   
    134152    giet_pthread_assert( (image_width == fbf_width) && (image_height == fbf_height) ,
    135153                         "[MJPEG ERROR] image size doesn't fit frame buffer size");
    136154 
     155    PRINTF("\n\n[MJPEG] starts for stream %s\n", file_pathname )
     156
    137157    // compute nblocks_h & nblocks_w
    138158    nblocks_w = fbf_width / 8;
     
    201221
    202222    // start CMA channel
    203     giet_fbf_cma_start( );
    204 
    205     PRINTF("\n[MJPEG] main thread completes initialisation for %d cores\n", 
     223    giet_fbf_cma_start();
     224
     225    PRINTF("\n[MJPEG] main thread completes initialisation for %d cores\n",
    206226           x_size * y_size * nprocs )
    207227
    208     // thread trdid for pthread_create() and pthread_join()
    209     pthread_t   trdid_tg;
    210     pthread_t   trdid_demux[256];
    211     pthread_t   trdid_vld[256];
    212     pthread_t   trdid_iqzz[256];
    213     pthread_t   trdid_idct[256];
    214     pthread_t   trdid_libu[256];
    215 
     228    mwmr_channel_t* ptr;
     229
     230    for ( n = 0 ; n < x_size*y_size ; n++ )
     231    {
     232        ptr = tg_2_demux[n];
     233        PRINTF(" - tg_2_demux[%d]  = %x / &lock = %x / &buf = %x / size = %d\n",
     234               n, ptr, (uint32_t)&ptr->lock, (uint32_t)ptr->data, ptr->depth<<2 )
     235
     236        ptr = demux_2_vld_data[n];
     237        PRINTF(" - demux_2_vld[%d] = %x / &lock = %x / &buf = %x / size = %d\n",
     238               n, ptr, (uint32_t)&ptr->lock, (uint32_t)ptr->data, ptr->depth<<2 )
     239
     240        ptr = vld_2_iqzz[n];
     241        PRINTF(" - vld_2_iqzz[%d]  = %x / &lock = %x / &buf = %x / size = %d\n",
     242               n, ptr, (uint32_t)&ptr->lock, (uint32_t)ptr->data, ptr->depth<<2 )
     243
     244        ptr = iqzz_2_idct[n];
     245        PRINTF(" - iqzz_2_idct[%d] = %x / &lock = %x / &buf = %x / size = %d\n",
     246               n, ptr, (uint32_t)&ptr->lock, (uint32_t)ptr->data, ptr->depth<<2 )
     247
     248        ptr = idct_2_libu[n];
     249        PRINTF(" - idct_2_libu[%d] = %x / &lock = %x / &buf = %x / size = %d\n",
     250               n, ptr, (uint32_t)&ptr->lock, (uint32_t)ptr->data, ptr->depth<<2 )
     251    }
     252
     253    // launch all threads : precise mapping is defined in the mjpeg.py file
    216254    uint32_t index;
    217 
    218     // launch all threads : precise mapping is defined in the mjpeg.py file
    219255
    220256    if ( giet_pthread_create( &trdid_tg, NULL, &tg , NULL ) )
    221257    giet_pthread_exit( "error launching thread tg\n");
    222258
    223     for ( index = 0 ; index < (x_size * y_size) ; index++ )
    224     {
    225         if ( giet_pthread_create( &trdid_demux[index], NULL, &demux , (void*)index ) )
    226         giet_pthread_exit( "error launching thread demux\n");
    227 
    228         if ( giet_pthread_create( &trdid_vld[index], NULL, &vld , (void*)index ) )
    229         giet_pthread_exit( "error launching thread vld\n");
    230 
    231         if ( giet_pthread_create( &trdid_iqzz[index], NULL, &iqzz , (void*)index ) )
    232         giet_pthread_exit( "error launching thread iqzz");
    233 
    234         if ( giet_pthread_create( &trdid_idct[index], NULL, &idct , (void*)index ) )
    235         giet_pthread_exit( "error launching thread idct\n");
    236 
    237         if ( giet_pthread_create( &trdid_libu[index], NULL, &libu , (void*)index ) )
    238         giet_pthread_exit( "error launching thread libu\n");
     259    for ( x = 0 ; x < x_size ; x++ )
     260    {
     261        for ( y = 0 ; y < y_size ; y++ )
     262        {
     263            index = x * y_size + y;
     264
     265            // DEMUX 
     266            if ( giet_pthread_create( &trdid_demux[index], NULL, &demux , (void*)index ) )
     267            giet_pthread_exit( "error launching thread demux\n");
     268
     269            // VLD
     270            if ( giet_pthread_create( &trdid_vld[index], NULL, &vld , (void*)index ) )
     271            giet_pthread_exit( "error launching thread vld\n");
     272
     273            // IQZZ
     274            if ( giet_pthread_create( &trdid_iqzz[index], NULL, &iqzz , (void*)index ) )
     275            giet_pthread_exit( "error launching thread iqzz");
     276
     277            // IDCT
     278            if ( USE_DCT_COPROC )  // allocate, initialise, and start hardware coprocessor
     279            {
     280                giet_coproc_channel_t in_channel;
     281                giet_coproc_channel_t out_channel;
     282                uint32_t  cluster_xy  = (x<<4) + y;
     283                uint32_t  coproc_type = 2;
     284                uint32_t  info;
     285
     286                // allocate DCT coprocessor
     287                giet_coproc_alloc( cluster_xy , coproc_type , &info );
     288
     289                // initialize channels
     290                in_channel.channel_mode = MODE_MWMR;
     291                in_channel.buffer_size  = (iqzz_2_idct[index]->depth)<<2;
     292                in_channel.buffer_vaddr = (uint32_t)(iqzz_2_idct[index]->data);
     293                in_channel.status_vaddr = (uint32_t)(&iqzz_2_idct[index]->sts);
     294                in_channel.lock_vaddr   = (uint32_t)(&iqzz_2_idct[index]->lock);
     295   
     296                giet_coproc_channel_init( cluster_xy , coproc_type , 0 , &in_channel );
     297
     298                out_channel.channel_mode = MODE_MWMR;
     299                out_channel.buffer_size  = (idct_2_libu[index]->depth)<<2;
     300                out_channel.buffer_vaddr = (uint32_t)(idct_2_libu[index]->data);
     301                out_channel.status_vaddr = (uint32_t)(&idct_2_libu[index]->sts);
     302                out_channel.lock_vaddr   = (uint32_t)(&idct_2_libu[index]->lock);
     303
     304                giet_coproc_channel_init( cluster_xy , coproc_type , 1 , &out_channel );
     305
     306                // start coprocessor
     307                giet_coproc_run( cluster_xy , coproc_type );
     308            }
     309            else                   // launches a software thread
     310            {
     311                if ( giet_pthread_create( &trdid_idct[index], NULL, &idct , (void*)index ) )
     312                giet_pthread_exit( "error launching thread idct\n");
     313            }
     314
     315            // LIBU
     316            if ( giet_pthread_create( &trdid_libu[index], NULL, &libu , (void*)index ) )
     317            giet_pthread_exit( "error launching thread libu\n");
     318        }
    239319    }
    240320
     
    244324    { PRINTF("\n[MJPEG ERROR] calling giet_pthread_join() for tg\n" ) }
    245325
    246     for ( index = 0 ; index < (x_size * y_size) ; index++ )
    247     {
    248         if ( giet_pthread_join( trdid_demux[index] , NULL ) )
    249         { PRINTF("\n[MJPEG ERROR] calling giet_pthread_join() for demux[%d]\n", index ) }
    250 
    251         if ( giet_pthread_join( trdid_vld[index] , NULL ) )
    252         { PRINTF("\n[MJPEG ERROR] calling giet_pthread_join() for vld[%d]\n", index ) }
    253 
    254         if ( giet_pthread_join( trdid_iqzz[index] , NULL ) )
    255         { PRINTF("\n[MJPEG ERROR] calling giet_pthread_join() for iqzz[%d]\n", index ) }
    256 
    257         if ( giet_pthread_join( trdid_idct[index] , NULL ) )
    258         { PRINTF("\n[MJPEG ERROR] calling giet_pthread_join() for idct[%d]\n", index ) }
    259 
    260         if ( giet_pthread_join( trdid_libu[index] , NULL ) )
    261         { PRINTF("\n[MJPEG ERROR] calling giet_pthread_join() for libu[%d]\n", index ) }
     326    for ( x = 0 ; x < x_size ; x++ )
     327    {
     328        for ( y = 0 ; y < y_size ; y++ )
     329        {
     330            index = x * y_size + y;
     331
     332            if ( giet_pthread_join( trdid_demux[index] , NULL ) )
     333            { PRINTF("\n[MJPEG ERROR] calling giet_pthread_join() for demux[%d]\n", index ) }
     334
     335            if ( giet_pthread_join( trdid_vld[index] , NULL ) )
     336            { PRINTF("\n[MJPEG ERROR] calling giet_pthread_join() for vld[%d]\n", index ) }
     337
     338            if ( giet_pthread_join( trdid_iqzz[index] , NULL ) )
     339            { PRINTF("\n[MJPEG ERROR] calling giet_pthread_join() for iqzz[%d]\n", index ) }
     340
     341            if ( USE_DCT_COPROC == 0 )
     342            {
     343                if ( giet_pthread_join( trdid_idct[index] , NULL ) )
     344                { PRINTF("\n[MJPEG ERROR] calling giet_pthread_join() for idct[%d]\n", index ) }
     345            }
     346
     347            if ( giet_pthread_join( trdid_libu[index] , NULL ) )
     348            { PRINTF("\n[MJPEG ERROR] calling giet_pthread_join() for libu[%d]\n", index ) }
     349
     350            if ( USE_DCT_COPROC )
     351            {
     352                uint32_t  cluster_xy  = (x<<4) + y;
     353                uint32_t  coproc_type = 2;
     354                giet_coproc_release( cluster_xy , coproc_type );
     355            }
     356        }
    262357    }
    263358
  • soft/giet_vm/applications/mjpeg/mjpeg.h

    r723 r736  
    1616#include <user_lock.h>
    1717
    18 #define   MAX_IMAGES  64
     18////////////////////////////////////////////////////////////////////////////////////////
     19//  Configuration Variables
     20////////////////////////////////////////////////////////////////////////////////////////
     21
     22#define   MAX_IMAGES         16
     23
     24#define   USE_DCT_COPROC     1
     25
     26#define   INTERACTIVE_MODE   0
    1927
    2028////////////////////////////////////////////////////////////////////////////////////////
     
    2230////////////////////////////////////////////////////////////////////////////////////////
    2331
    24 #define   TG_2_DEMUX_DEPTH          256
    25 #define   DEMUX_2_VLD_DATA_DEPTH    256
    26 #define   DEMUX_2_VLD_HUFF_DEPTH    256
    27 #define   DEMUX_2_IQZZ_DEPTH        256
    28 #define   VLD_2_IQZZ_DEPTH          256
    29 #define   IQZZ_2_IDCT_DEPTH         256
    30 #define   IDCT_2_LIBU_DEPTH         256
     32#define   TG_2_DEMUX_DEPTH          1024
     33#define   DEMUX_2_VLD_DATA_DEPTH    1024
     34#define   DEMUX_2_VLD_HUFF_DEPTH    1024
     35#define   DEMUX_2_IQZZ_DEPTH        1024
     36#define   VLD_2_IQZZ_DEPTH          1024
     37#define   IQZZ_2_IDCT_DEPTH         1024
     38#define   IDCT_2_LIBU_DEPTH         1024
    3139
    3240////////////////////////////////////////////////////////////////////////////////////////
     
    3745////////////////////////////////////////////////////////////////////////////////////////
    3846
    39 #define DEBUG_TG      1
    40 #define DEBUG_DEMUX   0
    41 #define DEBUG_VLD     0
    42 #define DEBUG_IQZZ    0
    43 #define DEBUG_IDCT    0
    44 #define DEBUG_LIBU    0
     47#define DEBUG_CLUSTER_INDEX   0xFFFFFFFF   // use 0xFFFFFFFF for all clusters
     48
     49#define DEBUG_TG              1
     50#define DEBUG_DEMUX           1
     51#define DEBUG_VLD             1
     52#define DEBUG_IQZZ            1
     53#define DEBUG_IDCT            1
     54#define DEBUG_LIBU            1
    4555
    4656////////////////////////////////////////////////////////////////////////////////////////
    47 //       Global variables
     57//       Global variables (allocated in mjpeg.c)
    4858////////////////////////////////////////////////////////////////////////////////////////
    4959
     
    5767extern mwmr_channel_t*  iqzz_2_idct[256];        // one per cluster
    5868extern mwmr_channel_t*  idct_2_libu[256];        // one per cluster
     69
     70extern pthread_t        trdid_tg;
     71extern pthread_t        trdid_demux[256];        // one per cluster
     72extern pthread_t        trdid_vld[256];          // one per cluster
     73extern pthread_t        trdid_iqzz[256];         // one per cluster
     74extern pthread_t        trdid_idct[256];         // one per cluster
     75extern pthread_t        trdid_libu[256];         // one per cluster
    5976
    6077extern user_lock_t      tty_lock;                // lock protecting shared TTY
  • soft/giet_vm/applications/mjpeg/mjpeg.py

    r723 r736  
    3232    nprocs    = mapping.nprocs
    3333
    34     assert (nprocs >= 1)
     34    assert (nprocs >= 1) and (nprocs <= 4)
    3535
    3636    # define vsegs base & size
     
    4242
    4343    heap_base  = 0x30000000
    44     heap_size  = 0x00100000     # 1M bytes (per cluster)     
     44    heap_size  = 0x00200000     # 2 Mbytes (per cluster)     
    4545
    4646    stack_base = 0x40000000
     
    4949    # create vspace
    5050    vspace = mapping.addVspace( name = 'mjpeg',
    51                                 startname = 'data',
     51                                startname = 'mjpeg_data',
    5252                                active = True )
    5353   
    5454    # data vseg : shared / cluster[0][0]
    55     mapping.addVseg( vspace, 'data', data_base , data_size,
     55    mapping.addVseg( vspace, 'mjpeg_data', data_base , data_size,
    5656                     'C_WU', vtype = 'ELF', x = 0, y = 0, pseg = 'RAM',
    5757                     binpath = 'bin/mjpeg/appli.elf',
     
    6666                base  = heap_base + (cluster_id * size)
    6767
    68                 mapping.addVseg( vspace, 'heap_%d_%d' %(x,y), base , size,
     68                mapping.addVseg( vspace, 'mjpeg_heap_%d_%d' %(x,y), base , size,
    6969                                 'C_WU', vtype = 'HEAP', x = x, y = y, pseg = 'RAM',
    7070                                 local = False, big = True )
     
    7676            if ( mapping.clusters[cluster_id].procs ):
    7777
    78                 mapping.addVseg( vspace, 'code_%d_%d' %(x,y),
     78                mapping.addVseg( vspace, 'mjpeg_code_%d_%d' %(x,y),
    7979                                 code_base , code_size,
    8080                                 'CXWU', vtype = 'ELF', x = x, y = y, pseg = 'RAM',
     
    8585    # ... plus main_stack and tg_stack in cluster[0][0]
    8686    base = stack_base
    87     mapping.addVseg( vspace, 'main_stack',
     87    mapping.addVseg( vspace, 'mjpeg_main_stack',
    8888                     base, stack_size, 'C_WU', vtype = 'BUFFER',
    8989                     x = 0 , y = 0 , pseg = 'RAM',
     
    9292    base += stack_size
    9393
    94     mapping.addVseg( vspace, 'tg_stack',
     94    mapping.addVseg( vspace, 'mjpeg_tg_stack',
    9595                     base , stack_size, 'C_WU', vtype = 'BUFFER',
    9696                     x = 0 , y = 0 , pseg = 'RAM',
     
    103103            if ( mapping.clusters[cluster_id].procs ):
    104104
    105                 mapping.addVseg( vspace, 'demux_stack_%d_%d' % (x,y),
    106                                  base, stack_size, 'C_WU', vtype = 'BUFFER',
    107                                  x = x , y = y , pseg = 'RAM',
    108                                  local = True )
    109 
    110                 base += stack_size
    111 
    112                 mapping.addVseg( vspace, 'vld_stack_%d_%d' % (x,y),
    113                                  base, stack_size, 'C_WU', vtype = 'BUFFER',
    114                                  x = x , y = y , pseg = 'RAM',
    115                                  local = True )
    116 
    117                 base += stack_size
    118 
    119                 mapping.addVseg( vspace, 'iqzz_stack_%d_%d' % (x,y),
    120                                  base, stack_size, 'C_WU', vtype = 'BUFFER',
    121                                  x = x , y = y , pseg = 'RAM',
    122                                  local = True )
    123 
    124                 base += stack_size
    125 
    126                 mapping.addVseg( vspace, 'idct_stack_%d_%d' % (x,y),
    127                                  base, stack_size, 'C_WU', vtype = 'BUFFER',
    128                                  x = x , y = y , pseg = 'RAM',
    129                                  local = True )
    130 
    131                 base += stack_size
    132 
    133                 mapping.addVseg( vspace, 'libu_stack_%d_%d' % (x,y),
     105                mapping.addVseg( vspace, 'mjpeg_demux_stack_%d_%d' % (x,y),
     106                                 base, stack_size, 'C_WU', vtype = 'BUFFER',
     107                                 x = x , y = y , pseg = 'RAM',
     108                                 local = True )
     109
     110                base += stack_size
     111
     112                mapping.addVseg( vspace, 'mjpeg_vld_stack_%d_%d' % (x,y),
     113                                 base, stack_size, 'C_WU', vtype = 'BUFFER',
     114                                 x = x , y = y , pseg = 'RAM',
     115                                 local = True )
     116
     117                base += stack_size
     118
     119                mapping.addVseg( vspace, 'mjpeg_iqzz_stack_%d_%d' % (x,y),
     120                                 base, stack_size, 'C_WU', vtype = 'BUFFER',
     121                                 x = x , y = y , pseg = 'RAM',
     122                                 local = True )
     123
     124                base += stack_size
     125
     126                mapping.addVseg( vspace, 'mjpeg_idct_stack_%d_%d' % (x,y),
     127                                 base, stack_size, 'C_WU', vtype = 'BUFFER',
     128                                 x = x , y = y , pseg = 'RAM',
     129                                 local = True )
     130
     131                base += stack_size
     132
     133                mapping.addVseg( vspace, 'mjpeg_libu_stack_%d_%d' % (x,y),
    134134                                 base, stack_size, 'C_WU', vtype = 'BUFFER',
    135135                                 x = x , y = y , pseg = 'RAM',
     
    139139
    140140    # threads mapping: demux, vld, iqzz, idct, libu replicated in all clusters
    141     # ... plus main & tg on P[0,0,0]
     141    # main & tg are mapped in cluster[0,0]
    142142    mapping.addThread( vspace, 'main', True, 0, 0, 0,
    143                        'main_stack',
    144                        'heap_0_0',
     143                       'mjpeg_main_stack',
     144                       'mjpeg_heap_0_0',
    145145                       0 )                      # index in start_vector
    146146
     
    162162        p_tg    = 0
    163163        p_demux = 1
    164         p_vld   = 1
     164        p_vld   = 2
    165165        p_iqzz  = 1
    166         p_idct  = 2
     166        p_idct  = 1
    167167        p_libu  = 1
    168168    elif ( nprocs == 4 ):
    169169        p_tg    = 0
    170170        p_demux = 1
    171         p_vld   = 2
     171        p_vld   = 3
    172172        p_iqzz  = 2
    173173        p_idct  = 3
    174174        p_libu  = 2
    175     elif ( nprocs == 5 ):
    176         p_tg    = 0
    177         p_demux = 1
    178         p_vld   = 2
    179         p_iqzz  = 3
    180         p_idct  = 4
    181         p_libu  = 3
    182     else:
    183         p_tg    = 0
    184         p_demux = 1
    185         p_vld   = 2
    186         p_iqzz  = 3
    187         p_idct  = 4
    188         p_libu  = 5
    189175   
    190176    mapping.addThread( vspace, 'tg', False, 0, 0, p_tg,
    191                        'tg_stack',
    192                        'heap_0_0',
     177                       'mjpeg_tg_stack',
     178                       'mjpeg_heap_0_0',
    193179                       1 )                      # index in start_vector
    194180
     
    198184
    199185                mapping.addThread( vspace, 'demux_%d_%d' % (x,y), False , x, y, p_demux,
    200                                    'demux_stack_%d_%d' % (x,y),
    201                                    'heap_%d_%d' % (x,y),
     186                                   'mjpeg_demux_stack_%d_%d' % (x,y),
     187                                   'mjpeg_heap_%d_%d' % (x,y),
    202188                                   2 )   # start_index 
    203189
    204190                mapping.addThread( vspace, 'vld_%d_%d' % (x,y), False , x, y, p_vld,
    205                                    'vld_stack_%d_%d' % (x,y),
    206                                    'heap_%d_%d' % (x,y),
     191                                   'mjpeg_vld_stack_%d_%d' % (x,y),
     192                                   'mjpeg_heap_%d_%d' % (x,y),
    207193                                   3 )   # start_index 
    208194
    209195                mapping.addThread( vspace, 'iqzz_%d_%d' % (x,y), False , x, y, p_iqzz,
    210                                    'iqzz_stack_%d_%d' % (x,y),
    211                                    'heap_%d_%d' % (x,y),
     196                                   'mjpeg_iqzz_stack_%d_%d' % (x,y),
     197                                   'mjpeg_heap_%d_%d' % (x,y),
    212198                                   4 )   # start_index 
    213199
    214200                mapping.addThread( vspace, 'idct_%d_%d' % (x,y), False , x, y, p_idct,
    215                                    'idct_stack_%d_%d' % (x,y),
    216                                    'heap_%d_%d' % (x,y),
     201                                   'mjpeg_idct_stack_%d_%d' % (x,y),
     202                                   'mjpeg_heap_%d_%d' % (x,y),
    217203                                   5 )   # start_index 
    218204
    219205                mapping.addThread( vspace, 'libu_%d_%d' % (x,y), False , x, y, p_libu,
    220                                    'libu_stack_%d_%d' % (x,y),
    221                                    'heap_%d_%d' % (x,y),
     206                                   'mjpeg_libu_stack_%d_%d' % (x,y),
     207                                   'mjpeg_heap_%d_%d' % (x,y),
    222208                                   6 )   # start_index 
    223209
  • soft/giet_vm/applications/mjpeg/tg.c

    r723 r736  
    3939    //  giet_tty_alloc( 0 );
    4040
    41     PRINTF("\n[MJPEG] thread TG starts on P[%d,%d,%d]\n", x , y , p )
     41    PRINTF("\n[MJPEG] thread TG starts on P[%d,%d,%d] / trdid = %x\n",
     42           x , y , p , (uint32_t)trdid_tg )
    4243
    4344   // allocate input buffer : 1024 bytes
  • soft/giet_vm/applications/mjpeg/vld.c

    r723 r736  
    193193}
    194194
    195 ////////////////////////////////////////////
    196 void huff_tables_load( huff_tables_t*  huff,
     195/////////////////////////////////////////////
     196void huff_tables_load( uint32_t        index,
     197                       huff_tables_t*  huff,
    197198                       mwmr_bufio_t*   bufio )
    198199{
     
    253254    mwmr_bufio_align( bufio );
    254255   
    255 #if (DEBUG_VLD > 2)
     256#if (DEBUG_VLD > 3)
     257if ( (index == DEBUG_CLUSTER_INDEX) || (DEBUG_CLUSTER_INDEX == 0XFFFFFFFF) )
    256258huff_tables_dump( huff , is_ac );
    257259#endif
     
    312314// unpack a 8*8 pixels block with 2 bytes per pixel
    313315//////////////////////////////////////////////////////////
    314 static int16_t vld_unpack_block( bitreader_t*      stream,
    315                                  mwmr_channel_t*   mwmr_out,
    316                                  huff_tables_t*    huff,
    317                                  int16_t           prev_dc )
     316static int16_t vld_unpack_block( uint32_t          index,     // cluster index
     317                                 uint32_t          image,     // image index
     318                                 uint32_t          block,     // block index
     319                                 bitreader_t*      stream,    // input bit stream
     320                                 mwmr_channel_t*   mwmr_out,  // output channel
     321                                 huff_tables_t*    huff,      // Huffman Tables
     322                                 int16_t           prev_dc )  // previous DC coef
    318323{
    319324    uint32_t temp;
     
    335340    buf[0]   = value + prev_dc;
    336341
    337 #if (DEBUG_VLD > 1)
    338 PRINTF("\nDC[0] = %d / reformat( %x , %d ) = %d\n", buf[0], temp , symbol , value )
     342#if (DEBUG_VLD > 2)
     343if ( (index == DEBUG_CLUSTER_INDEX) || (DEBUG_CLUSTER_INDEX == 0XFFFFFFFF) )
     344{ PRINTF("\nVLD[%d] : DC[0] = %d / reformat( %x , %d ) = %d\n",
     345         index , buf[0], temp , symbol , value ) }
    339346#endif
    340347
     
    348355        {
    349356
    350 #if (DEBUG_VLD > 1)
    351 PRINTF("EOB found at i = %d\n", i );
     357#if (DEBUG_VLD > 2)
     358if ( (index == DEBUG_CLUSTER_INDEX) || (DEBUG_CLUSTER_INDEX == 0XFFFFFFFF) )
     359{ PRINTF("\nVLD[%d] : EOB found at i = %d\n", index , i ) }
    352360#endif
    353361            break;
     
    370378
    371379#if (DEBUG_VLD > 2)
    372 PRINTF("AC[%d] = %d / reformat( %x , %d ) = %d\n", i , buf[i] , temp , cat , value )
     380if ( (index == DEBUG_CLUSTER_INDEX) || (DEBUG_CLUSTER_INDEX == 0XFFFFFFFF) )
     381{ PRINTF("\nVLD[%d] : AC[%d] = %d / reformat( %x , %d ) = %d\n",
     382         index , i , buf[i] , temp , cat , value ) }
    373383#endif
    374384
     
    379389
    380390#if (DEBUG_VLD > 1 )
    381 PRINTF("  %d  %d  %d  %d  %d  %d  %d  %d\n"
    382        "  %d  %d  %d  %d  %d  %d  %d  %d\n"
    383        "  %d  %d  %d  %d  %d  %d  %d  %d\n"
    384        "  %d  %d  %d  %d  %d  %d  %d  %d\n"
    385        "  %d  %d  %d  %d  %d  %d  %d  %d\n"
    386        "  %d  %d  %d  %d  %d  %d  %d  %d\n"
    387        "  %d  %d  %d  %d  %d  %d  %d  %d\n"
    388        "  %d  %d  %d  %d  %d  %d  %d  %d\n",
    389        buf[0] , buf[1] , buf[2] , buf[3] , buf[4] , buf[5] , buf[6] , buf[7] ,
    390        buf[8] , buf[9] , buf[10], buf[11], buf[12], buf[13], buf[14], buf[15],
    391        buf[16], buf[17], buf[18], buf[19], buf[20], buf[21], buf[22], buf[23],
    392        buf[24], buf[25], buf[26], buf[27], buf[28], buf[29], buf[30], buf[31],
    393        buf[32], buf[33], buf[34], buf[35], buf[36], buf[37], buf[38], buf[39],
    394        buf[40], buf[41], buf[42], buf[43], buf[44], buf[45], buf[46], buf[47],
    395        buf[48], buf[49], buf[50], buf[51], buf[52], buf[53], buf[54], buf[55],
    396        buf[56], buf[57], buf[58], buf[59], buf[60], buf[61], buf[62], buf[63])
     391if ( (index == DEBUG_CLUSTER_INDEX) || (DEBUG_CLUSTER_INDEX == 0XFFFFFFFF) )
     392{ PRINTF("\nVLD[%d] completes block %d/%d in image %d\n"
     393         "  %d  %d  %d  %d  %d  %d  %d  %d\n"
     394         "  %d  %d  %d  %d  %d  %d  %d  %d\n"
     395         "  %d  %d  %d  %d  %d  %d  %d  %d\n"
     396         "  %d  %d  %d  %d  %d  %d  %d  %d\n"
     397         "  %d  %d  %d  %d  %d  %d  %d  %d\n"
     398         "  %d  %d  %d  %d  %d  %d  %d  %d\n"
     399         "  %d  %d  %d  %d  %d  %d  %d  %d\n"
     400         "  %d  %d  %d  %d  %d  %d  %d  %d\n",
     401         index , block , nblocks_w*nblocks_h , image ,
     402         buf[0] , buf[1] , buf[2] , buf[3] , buf[4] , buf[5] , buf[6] , buf[7] ,
     403         buf[8] , buf[9] , buf[10], buf[11], buf[12], buf[13], buf[14], buf[15],
     404         buf[16], buf[17], buf[18], buf[19], buf[20], buf[21], buf[22], buf[23],
     405         buf[24], buf[25], buf[26], buf[27], buf[28], buf[29], buf[30], buf[31],
     406         buf[32], buf[33], buf[34], buf[35], buf[36], buf[37], buf[38], buf[39],
     407         buf[40], buf[41], buf[42], buf[43], buf[44], buf[45], buf[46], buf[47],
     408         buf[48], buf[49], buf[50], buf[51], buf[52], buf[53], buf[54], buf[55],
     409         buf[56], buf[57], buf[58], buf[59], buf[60], buf[61], buf[62], buf[63]) }
    397410#endif
    398411
     
    428441    // giet_tty_alloc( 0 );
    429442
    430     PRINTF("\n[MJPEG] thread VLD[%d] starts on P[%d,%d,%d]\n" , index, x, y ,p )
     443    PRINTF("\n[MJPEG] thread VLD[%d] starts on P[%d,%d,%d] / trdid = %x\n",
     444           index , x , y , p, (uint32_t)trdid_vld[index] )
     445
    431446
    432447    // initialise BUFIO for MWMR channel <in_data>
     
    436451
    437452#if (DEBUG_VLD > 1)
    438 PRINTF("\nVLD[%d] <in_data> : &mwmr = %x / &bufio = %x\n",
    439        index , mwmr_in_data , &bufio_in_data )
     453if ( (index == DEBUG_CLUSTER_INDEX) || (DEBUG_CLUSTER_INDEX == 0XFFFFFFFF) )
     454{ PRINTF("\nVLD[%d] <in_data> : &mwmr = %x / &bufio = %x\n",
     455         index , mwmr_in_data , &bufio_in_data ) }
    440456#endif
    441457
     
    446462
    447463#if (DEBUG_VLD > 1)
    448 PRINTF("\nVLD[%d] <in_huff> : &mwmr = %x / &bufio = %x\n",
    449        index , mwmr_in_huff , &bufio_in_huff )
     464if ( (index == DEBUG_CLUSTER_INDEX) || (DEBUG_CLUSTER_INDEX == 0XFFFFFFFF) )
     465{ PRINTF("\nVLD[%d] <in_huff> : &mwmr = %x / &bufio = %x\n",
     466         index , mwmr_in_huff , &bufio_in_huff ) }
    450467#endif
    451468
     
    459476    {
    460477        // load first Huffman Table from bufio_in_huff
    461         huff_tables_load( &huff , &bufio_in_huff );
     478        huff_tables_load( index, &huff , &bufio_in_huff );
    462479
    463480        // load second Huffman Table from bufio_in_huff
    464         huff_tables_load( &huff , &bufio_in_huff );
     481        huff_tables_load( index, &huff , &bufio_in_huff );
    465482
    466483#if (DEBUG_VLD > 1)
    467 PRINTF("\nVLD[%d] load Huffman tables for image %d\n", index , image )
     484if ( (index == DEBUG_CLUSTER_INDEX) || (DEBUG_CLUSTER_INDEX == 0XFFFFFFFF) )
     485{ PRINTF("\nVLD[%d] load Huffman tables for image %d\n", index , image ) }
    468486#endif
    469487
     
    482500
    483501#if (DEBUG_VLD > 1)
    484 PRINTF("\nVLD[%d] uncompress block %d/%d in image %d\n", index, block, nblocks, image )
    485 #endif
    486             prev_dc = vld_unpack_block( &stream , mwmr_out, &huff , prev_dc );
     502if ( (index == DEBUG_CLUSTER_INDEX) || (DEBUG_CLUSTER_INDEX == 0XFFFFFFFF) )
     503{ PRINTF("\nVLD[%d] uncompress block %d/%d in image %d\n", index, block, nblocks, image ) }
     504#endif
     505            prev_dc = vld_unpack_block( index,
     506                                        image,
     507                                        block,
     508                                        &stream,
     509                                        mwmr_out,
     510                                        &huff,
     511                                        prev_dc );
    487512        }  // end for blocks
    488513
    489514#if DEBUG_VLD
    490 PRINTF("\nVLD[%d] completes image %d at cycle %d\n", index , image , giet_proctime() )
     515if ( (index == DEBUG_CLUSTER_INDEX) || (DEBUG_CLUSTER_INDEX == 0XFFFFFFFF) )
     516{ PRINTF("\nVLD[%d] completes image %d at cycle %d\n", index , image , giet_proctime() ) }
    491517#endif
    492518        image = image + x_size*y_size;
     
    494520    }  // end while on images
    495521
    496     giet_pthread_exit( "vld completed" );
     522    giet_pthread_exit( "VLD completed" );
    497523
    498524}  // end vld()
Note: See TracChangeset for help on using the changeset viewer.