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.

Problems with output buffer memory

Hi,

I am developing a new function to be ran in the DSP  with the DaVinci Platform TMDXEVM8148. The function has two arrays of char and one of them is modified inside.  I have seen that this array is modified but there are some elements (none contiguous elements and only a few of them) of the array that don't change. I have tested the algorithm in the ARM and it works excelent. I suppose that is a problem of memory management.

****In the main function (running in the ARM) I have defined the array and its memory like this:*********************

    memParams.flags = Memory_CACHED;
    memParams.type = Memory_CONTIGHEAP;

     framesize = (o*p* sizeof(char));
    
    pSrcBuf_16bpp = Memory_alloc(framesize, &memParams);
    if (pSrcBuf_16bpp == NULL) {
        goto end;
    }

**** In the c6Accelw.c I defined the output buffer like this:*********************

CACHE_INV_OUTPUT_BUFFERS_AND_SETUP_FOR_C6ACCEL(ptr_Y,0,o*p*sizeof(unsigned char));

**** Finally at the function test_vector (defined by myself) *********************

int test_vector (unsigned char *restrict X,unsigned char *restrict Y)

I don't know which is the problem because I reserve the needed memory space. Can anybody helps me?

Thanks!

  • Could you specify a few things before I can suggest any changes here. Just to make sure we understand we understand each other here, I am repeating a few things I get from your post. You are adding a function on the DSP,in which you pass 2 character type arrays of which 1 is input while the other(ptr_Y) is an output array. It appears you have allocated the right amount of memory but I dont think I fully understand the follwoing

    You mention

    "I have seen that this array is modified but there are some elements (none contiguous elements and only a few of them)"

    Is your ptr_Y an input output array wherein you pass some data using this array to the function which then gets modified? Do you mean to say only some parts of the output array gives the correct output while other parts are wrong?

    If Y is an input output array you should use the function macro CACHE_WB_INV_INPUT_OUTPUT_BUFFERS_AND_SETUP_FOR_C6ACCEL. Can you use an integer value to collect the status of you C6Accel call and let me know what value you get. Also it is important that you unmarshall the arrays correctly on the DSP side. Can you also post your DSPside code that you have added inside the switch statement.

    Regards,

    Rahul

  • In my function I have two arrays:

           ptr_X --> Input char array

          ptr_Y--> Output char array

    In the main code I clean the output buffer before calling the test_vector function. My function multiplies the elements of ptr_X by 2 and then copy the result to ptr_Y. Some of the elements in ptr_Y are wrong. I post the DSPside code inside the switch statement

     

    case (F_TEST_VECTOR_FXN_ID):{
                        
                        DSPF_test_vector_Params *C6ACCEL_TI_DSPF_test_vector_paramPtr;
                        C6ACCEL_TI_DSPF_test_vector_paramPtr = pFnArray;
                        
                     
    		if(((C6ACCEL_TI_DSPF_test_vector_paramPtr->X_InArrID1)>INBUF15)|
                            ((C6ACCEL_TI_DSPF_filtre_htal_paramPtr->Y_OutArrID1)>OUTBUF15)){
                             return(IUNIVERSAL_EPARAMFAIL);
                         }
                        else
    		    {
    	
      e=test_vector ((unsigned char *)inBufs->descs[C6ACCEL_TI_DSPF_filtre_htal_paramPtr->X_InArrID1].buf,
                          (unsigned char *)outBufs->descs[C6ACCEL_TI_DSPF_filtre_htal_paramPtr->Y_OutArrID1].buf);
    
     
              	return(e);
                        }
                     }
                     break;
  • You have made a mistake in your code here

    You have defined C6ACCEL_TI_DSPF_test_vector_paramPtr to unmarshall the arguments on the DSP side but are calling the function using C6ACCEL_TI_DSPF_filtre_htal_paramPtr

    This needs to change to

    case (F_TEST_VECTOR_FXN_ID):{
                        
                        DSPF_test_vector_Params *C6ACCEL_TI_DSPF_test_vector_paramPtr;
                        C6ACCEL_TI_DSPF_test_vector_paramPtr = pFnArray;
                        
                     
    		if(((C6ACCEL_TI_DSPF_test_vector_paramPtr->X_InArrID1)>INBUF15)|
                            ((C6ACCEL_TI_DSPF_test_vector_paramPtr->Y_OutArrID1)>OUTBUF15)){
                             return(IUNIVERSAL_EPARAMFAIL);
                         }
                        else
    		    {
    	
      e=test_vector ((unsigned char *)inBufs->descs[C6ACCEL_TI_DSPF_test_vector_paramPtr->X_InArrID1].buf,
                          (unsigned char *)outBufs->descs[C6ACCEL_TI_DSPF_test_vector_paramPtr->Y_OutArrID1].buf);
    
     
              	return(e);
                        }
                     }
                     break;
     
    I am little suprised your code compiled on the DSP side. Can you do a make clean and then rebuild the package when you make a chnage.
     
    Regards,
    Rahul
  • Also note mutliplication with 2 can also be done using the C6accel_IMG_mulS_8 API as described here

    http://processors.wiki.ti.com/index.php/C6Accel_Image_Processing_API_Reference_guide#int_C6accel_IMG_mulS_8.288_bit_signed_Image_Multiplication_.29

     

    Regards,

    Rahul

  • Sorry I make a mistake when I paste here the code and as you said before it is not filtre_htal. The correct version (without the filtre_htal mistake) compiles without any problem.  When you said to rebuild all, do you mean to make a "make clean" and then a "make all" ? I have done it previously and the mistake carries on.

    I know that there are functions implemented to multiply a number but I need to develop harder functions and a multiplier function seems to be easy to start. 

  •  

    Can you attach your c6accelw.c file and the DSP side .c file here so that I can verify very thiing is okay.

    Regards,

    Rahul

  • I attach the files you required ( in txt format because .c is not addmited by the server).

    int test_vector (unsigned char *restrict X,unsigned char *restrict Y)
    {
        
        int o,p;
        int i=0;
      
        o=923;
        p=1153;
    
    
    for (i=0;i<o*p;i++)
    {  
    
      Y[i]=2*X[i];   	
    		
    }
    
    return(1);
    }

  • Sorry I forgot to attach the c6accelw.c

    1464.c6accelw.txt

  • Joan,

    SOrry for the delay here.

    You seem to be hard coding the size of ptr_X and ptr_y buffers in there, are you sure that is you buffer size, to be safe you should pass ur width and height as input to the C6accel_DSPF_test_vector function and use that here. It is a bit odd that your frame size is not multiple of 2, how are you obtaining the image or array data?

    CACHE_WB_INV_INPUT_BUFFERS_AND_SETUP_FOR_C6ACCEL(ptr_X,0,1153*923*sizeof(unsigned char));
    CACHE_INV_OUTPUT_BUFFERS_AND_SETUP_FOR_C6ACCEL(ptr_Y,0,1153*923*sizeof(unsigned char));

    Did you check the value of status that you obtain after you call the C6Accel function as I had asked you to? Also, I was interested in seeing the C6Accel_DSPfunctioncall.c file rather than the test vector function.

    Regards,

    Rahul

  • The status value I receive, if I didn't forced to return 1 inside the test vector function, is 0 (_EOK).  Although the size of the buffers are the correct ones, I tried to change the frame size of the buffer to make it multiple of 2, but the function did the same. I attach below the code I had added inside the c6accel_ti_imglibFunctionCall.c.

    case (F_TEST_VECTOR_FXN_ID):{
                        


                        DSPF_test_vector_Params *C6ACCEL_TI_DSPF_test_vector_paramPtr;
                        C6ACCEL_TI_DSPF_test_vector_paramPtr = pFnArray;
                        
                     

            if(((C6ACCEL_TI_DSPF_test_vector_paramPtr->X_InArrID1)>INBUF15)|
                            ((C6ACCEL_TI_DSPF_test_vector_paramPtr->Y_OutArrID1)>OUTBUF15)){
                             return(IUNIVERSAL_EPARAMFAIL);
                         }
                        else
                {
        


     pa=test_vector ((unsigned char *)inBufs->descs[C6ACCEL_TI_DSPF_test_vector_paramPtr->X_InArrID1].buf,
                          (unsigned char *)outBufs->descs[C6ACCEL_TI_DSPF_test_vector_paramPtr->Y_OutArrID1].buf);

     


                  return(pa);
                        }
                     }
                     break;