This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

extending c6accel question - "consumed by application" - what does this mean ??

Other Parts Discussed in Thread: OMAP-L138

We have a OMAP-L138 on a custom board with a custom file system - the application we write is in a seperate file system (to remove the change of corruptions etc) ;

Currently we can run c6accell programs with the existing core as supplied.

If we want to add our own functions to the c6acell we need to follow the steps in the advanced feature guide - before i do that, can I ask 

a) is the library static or dynamically linked

b) when the document says - the codec server is consumed by the application" - what does that mean ?

"The rebuild compiles the source files and archives the C6accel library files in the
$(C6ACCEL_INSTALL_DIR)/soc/paclages/ti/c6acel/lib to be consumed by the application. When the codec server
builds , it picks up this library, therby integrating the new kernel in the DSP executable that gets consumed in the
application."

So is all new functionality included in the final app or does it need additional "dynamic" resources ?

b

  • Hi,

    We will work on this and will get back to you at the earliest.

    Thanks & regards,
    Sivaraj K
  • Hi,

    I don't think, it requires additional dynamic resources for any new functionality included in the final application.

    Once you modify the function you can recompile the library and link it by adding the rebuilt version of this library to $(c6accel_install_dir)/dsp/libs. Adding a new function to C6Accel has been described processors.wiki.ti.com/.../C6Accel_Advanced_Users_Guide

    Also check this:

    processors.wiki.ti.com/.../Codec_Engine_GenServer_Wizard_FAQ

    Thanks & regards,
    Sivaraj K
  • Dear Sivaraj K.

    I got round to checking this and I did an example program - as you suspected the linkage is static - sofar so good.

    I now have a different question -

    Background:
    I have a simple function (dsp_sum) which adds the elements of an array and returns the sum - the code is below in the snippet.

    I allocate the buffers (in : 10 x float, out 1 x float) using the CMEM functions and the addresses are passed into the c6accel kernel and look reasonable.

    When I call my function CMEM throws an error - it cannot access the arrays.


    I followed (as far as I know the steps in the c6accel wiki) and it all builds cleanly .


    My question is - how does the transfer from my 2 arrays (allocated in CMEM) to the C6accel happen ? Is it by ID (INBUF0. OUTBUF0)
    and how do these addresses become set or allocated ?

    I would have expected that I need to assign the physical address of a buffer into the structure - I do not according to the examples.

    Any input appreciated.

    (The pointer addresses from the error message look uninitalised to me , that is why I am asking).

    B.
    ---------------------------------------------------------------------------------------------------
    Outputs from program looks like:

    Calling cwlib_dsp_sum function (extension of c6accell)
    Entry 0x40018000 0x40022000 10
    Before cache
    after cache
    calling universal
    CMEM Error: getPhys: Failed to get physical address of 0x400f5638
    CMEM Error: getPhys: Failed to get physical address of 0x4011ce13
    Status=-1 - result=0.000000

    >>> dsp side code:

    void cwlib_dsp_sum
    (
    float * src,
    float * dst,

    int n_elements
    )
    {
    unsigned int j;
    double sum = 0.0f;

    /* for each sample... */
    for (j = 0; j <n_elements; j++) {
    sum += (src[j]);
    }
    dst[0] = sum;
    }


    >>>> iC6Accel_ti.h:

    * CW added: */
    typedef struct DSPF_cwlib_dsp_sum_Params{
    unsigned int flt_InArrID1;
    unsigned int flt_OutArrID1;
    int n;
    }DSPF_cwlib_dsp_sum_Params;

    >>>> c6accelw.c:
    -------------------------------------------------------------
    Int C6accel_DSPF_cwlib_dsp_sum(C6accel_Handle hC6accel,
    float *ptr_src,
    float *ptr_dst,
    int npoints
    )
    {

    printf("Entry %p \t %p %d\n", ptr_src, ptr_dst, npoints );

    XDM1_BufDesc inBufDesc;
    XDM1_BufDesc outBufDesc;
    XDAS_Int32 InArg_Buf_size;
    IC6Accel_InArgs *CInArgs;
    UNIVERSAL_OutArgs uniOutArgs;
    Int status;
    /* Define pointer to function parameter structure */
    DSPF_cwlib_dsp_sum_Params *fp0;
    XDAS_Int8 *pAlloc;

    ACQUIRE_CODEC_ENGINE;

    /* Allocate the InArgs structure as it varies in size
    (Needs to be changed everytime we make a API call)*/
    InArg_Buf_size= sizeof(Fxn_struct)+
    sizeof(DSPF_cwlib_dsp_sum_Params)+
    sizeof(CInArgs->size)+
    sizeof(CInArgs->Num_fxns);


    pAlloc=(XDAS_Int8 *)Memory_alloc(InArg_Buf_size, &wrapperMemParams);
    CInArgs= (IC6Accel_InArgs *)pAlloc;

    /* Initialize .size fields for dummy input and output arguments */
    uniOutArgs.size = sizeof(uniOutArgs);

    /* Set up buffers to pass buffers in and out to alg */
    inBufDesc.numBufs = 1;
    outBufDesc.numBufs = 1;

    /* Fill in input/output buffer descriptor parameters -- we return a single sum value
    (array of 1 cell)
    */
    printf("Before cache\n");
    CACHE_WB_INV_INPUT_BUFFERS_AND_SETUP_FOR_C6ACCEL(ptr_src,0,npoints*sizeof(float));
    CACHE_INV_OUTPUT_BUFFERS_AND_SETUP_FOR_C6ACCEL(ptr_dst,1, sizeof(float));
    printf("after cache\n");


    /* Initialize the extended InArgs structure */
    CInArgs->Num_fxns = 1;
    CInArgs->size = InArg_Buf_size;

    /* Set function Id and parameter pointers for first function call */
    CInArgs->fxn[0].FxnID = DSPF_CW_SUM_FXN_ID;
    CInArgs->fxn[0].Param_ptr_offset = sizeof(CInArgs->size)+sizeof(CInArgs->Num_fxns)+sizeof(Fxn_struct);

    /* Initialize pointers to function parameters */
    fp0 = (DSPF_cwlib_dsp_sum_Params *)((XDAS_Int8*)CInArgs + CInArgs->fxn[0].Param_ptr_offset);

    /* Fill in the fields in the parameter structure */
    fp0->flt_InArrID1 = INBUF0;
    fp0->flt_OutArrID1 = OUTBUF0;
    fp0->n = npoints;

    /* Call the actual algorithm */
    if (hC6accel->callType == ASYNC)
    {
    /* Update async structure */
    if (c6accelAsyncParams.asyncCallCount!=0){
    status = UNIVERSAL_EFAIL;
    printf("Async call failed as %d are still pending\n");
    }
    else{
    /* Context Saving */
    c6accelAsyncParams.asyncCallCount++;
    memcpy(&(c6accelAsyncParams.inBufs),&inBufDesc, sizeof (XDM1_BufDesc));
    memcpy(&(c6accelAsyncParams.outBufs), &outBufDesc,sizeof(XDM1_BufDesc));
    memcpy(&(c6accelAsyncParams.inArgs), CInArgs,sizeof(UNIVERSAL_InArgs));
    memcpy(&(c6accelAsyncParams.outArgs),&uniOutArgs,sizeof(UNIVERSAL_OutArgs));
    c6accelAsyncParams.pBuf = pAlloc;
    c6accelAsyncParams.pBufSize = InArg_Buf_size;
    /* Asynchronous Call to the actual algorithm */
    status = UNIVERSAL_processAsync(hC6accel->hUni, &inBufDesc, &outBufDesc, NULL,(UNIVERSAL_InArgs *)CInArgs, &uniOutArgs);
    }
    }
    else{
    /* Synchronous Call to the actual algorithm */
    printf("calling universal\n");
    status = UNIVERSAL_process(hC6accel->hUni, &inBufDesc, &outBufDesc, NULL,(UNIVERSAL_InArgs *)CInArgs, &uniOutArgs);

    /* Free the InArgs structure */
    Memory_free(pAlloc, InArg_Buf_size, &wrapperMemParams);
    }

    RELEASE_CODEC_ENGINE;

    return status;

    }
    `
  • >>> dsp side code:

    void  cwlib_dsp_sum

    (

       float * src,

       float * dst,

       int n_elements

    )

    {

       unsigned int j;

       double   sum = 0.0f;

       /* for each sample... */

       for (j = 0; j <n_elements; j++) {

           sum += (src[j]);

       }

       dst[0] = sum;

    }

    >>>> iC6Accel_ti.h:

    * CW added: */

    typedef struct DSPF_cwlib_dsp_sum_Params{

                                               unsigned int  flt_InArrID1;

                                               unsigned int  flt_OutArrID1;

                                               int n;

                                              }DSPF_cwlib_dsp_sum_Params;

    >>>> c6accelw.c:

    -------------------------------------------------------------

    Int  C6accel_DSPF_cwlib_dsp_sum(C6accel_Handle hC6accel,

                               float       *ptr_src,

                               float       *ptr_dst,

                               int           npoints

    )

    {

    printf("Entry %p \t %p %d\n", ptr_src, ptr_dst, npoints );

       XDM1_BufDesc                inBufDesc;

       XDM1_BufDesc                outBufDesc;

       XDAS_Int32                  InArg_Buf_size;

       IC6Accel_InArgs             *CInArgs;

       UNIVERSAL_OutArgs           uniOutArgs;

       Int status;

       /* Define pointer to function parameter structure */

       DSPF_cwlib_dsp_sum_Params              *fp0;

       XDAS_Int8                   *pAlloc;

       ACQUIRE_CODEC_ENGINE;

       /* Allocate the InArgs structure as it varies in size

       (Needs to be changed everytime we make a API call)*/

       InArg_Buf_size=  sizeof(Fxn_struct)+

                        sizeof(DSPF_cwlib_dsp_sum_Params)+

                        sizeof(CInArgs->size)+

                        sizeof(CInArgs->Num_fxns);

       pAlloc=(XDAS_Int8 *)Memory_alloc(InArg_Buf_size, &wrapperMemParams);

       CInArgs= (IC6Accel_InArgs *)pAlloc;

       /* Initialize .size fields for dummy input and output arguments */

       uniOutArgs.size = sizeof(uniOutArgs);

       /* Set up buffers to pass buffers in and out to alg  */

       inBufDesc.numBufs  = 1;

       outBufDesc.numBufs = 1;

       /* Fill in input/output buffer descriptor parameters -- we return a single sum value

          (array of 1 cell)

        */

        printf("Before cache\n");

        CACHE_WB_INV_INPUT_BUFFERS_AND_SETUP_FOR_C6ACCEL(ptr_src,0,npoints*sizeof(float));

        CACHE_INV_OUTPUT_BUFFERS_AND_SETUP_FOR_C6ACCEL(ptr_dst,1,  sizeof(float));

        printf("after cache\n");

       /* Initialize the extended InArgs structure */

       CInArgs->Num_fxns = 1;

       CInArgs->size     = InArg_Buf_size;

       /* Set function Id and parameter pointers for first function call */

       CInArgs->fxn[0].FxnID     = DSPF_CW_SUM_FXN_ID;

       CInArgs->fxn[0].Param_ptr_offset = sizeof(CInArgs->size)+sizeof(CInArgs->Num_fxns)+sizeof(Fxn_struct);

       /* Initialize pointers to function parameters */

       fp0 = (DSPF_cwlib_dsp_sum_Params *)((XDAS_Int8*)CInArgs + CInArgs->fxn[0].Param_ptr_offset);

       /* Fill in the fields in the parameter structure */

       fp0->flt_InArrID1   =  INBUF0;

       fp0->flt_OutArrID1  =  OUTBUF0;

       fp0->n              =  npoints;

       /* Call the actual algorithm */

       if (hC6accel->callType == ASYNC)

         {

          /* Update async structure */

          if (c6accelAsyncParams.asyncCallCount!=0){

               status = UNIVERSAL_EFAIL;

               printf("Async call failed as %d are still pending\n");

             }

          else{

              /* Context Saving */

              c6accelAsyncParams.asyncCallCount++;

              memcpy(&(c6accelAsyncParams.inBufs),&inBufDesc, sizeof (XDM1_BufDesc));

              memcpy(&(c6accelAsyncParams.outBufs), &outBufDesc,sizeof(XDM1_BufDesc));

              memcpy(&(c6accelAsyncParams.inArgs), CInArgs,sizeof(UNIVERSAL_InArgs));

              memcpy(&(c6accelAsyncParams.outArgs),&uniOutArgs,sizeof(UNIVERSAL_OutArgs));

              c6accelAsyncParams.pBuf = pAlloc;

              c6accelAsyncParams.pBufSize = InArg_Buf_size;

              /* Asynchronous Call to the actual algorithm */

              status = UNIVERSAL_processAsync(hC6accel->hUni, &inBufDesc, &outBufDesc, NULL,(UNIVERSAL_InArgs *)CInArgs, &uniOutArgs);

            }

         }

       else{

         /* Synchronous Call to the actual algorithm */

         printf("calling universal\n");

         status = UNIVERSAL_process(hC6accel->hUni, &inBufDesc, &outBufDesc, NULL,(UNIVERSAL_InArgs *)CInArgs, &uniOutArgs);

         /* Free the InArgs structure */

         Memory_free(pAlloc, InArg_Buf_size, &wrapperMemParams);

        }

       RELEASE_CODEC_ENGINE;

       return status;

    }

    `

  • Posted again since previous post removed all tabs etc making the code hard to read.

    b.