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.

CCS: why udma memcpy so slow?

Tool/software: Code Composer Studio

Hi, TI

 I am now debuging UDMA with C66 On TDA4

 doing image pre-processing ,change RGB to RRR...GGG...BBB...

SO i developed my code based on  "psdk_rtos_auto_j7_06_01_00_15/pdk/packages/ti/drv/udma/examples/udma_memcpy_test"

my data size is 874*774*3

i have 2 questions

1, I count clock cycles , start from DMA trigger by "Udma_ringQueueRaw" , end with receive transfer completion  by "SemaphoreP_pend"

    it costs 24,340,065 clock cycles,  Is this too slow ?

2,when i config "pTr->icnt0 = 1" in "App_udmaTrpdInit" function

   i will get the error ,"TR Response not completed" from App_udmaMemcpy function,but the dma transfer result is correct,

  Is this error a real problem ?

thanks very much

ps:

part of my code

pTr->icnt0 = 1;
pTr->icnt1 = UDMA_TEST_APP_IMAGE_H;
pTr->icnt2 = UDMA_TEST_APP_IMAGE_W;
pTr->icnt3 = 1;
pTr->dim1 = UDMA_TEST_APP_IMAGE_C;
pTr->dim2 = UDMA_TEST_APP_IMAGE_C*UDMA_TEST_APP_IMAGE_H;
pTr->dim3 = UDMA_TEST_APP_IMAGE_C*UDMA_TEST_APP_IMAGE_H*UDMA_TEST_APP_IMAGE_W;
pTr->addr = (uint64_t) srcBuf;
pTr->addr += channel;
pTr->fmtflags = 0x00000000U; /* Linear addressing, 1 byte per elem.
Replace with CSL-FL API */
pTr->dicnt0 = UDMA_TEST_APP_IMAGE_C;
pTr->dicnt1 = UDMA_TEST_APP_IMAGE_H;
pTr->dicnt2 = UDMA_TEST_APP_IMAGE_W;
pTr->dicnt3 = 1;

pTr->ddim1 = UDMA_TEST_APP_IMAGE_C;
pTr->ddim2 = UDMA_TEST_APP_IMAGE_C*UDMA_TEST_APP_IMAGE_H;
pTr->ddim3 = UDMA_TEST_APP_IMAGE_C*UDMA_TEST_APP_IMAGE_H*UDMA_TEST_APP_IMAGE_W;
pTr->daddr = (uint64_t) destBuf;
pTr->daddr += UDMA_TEST_APP_IMAGE_W * UDMA_TEST_APP_IMAGE_H * channel;
  • Hi,

    1.

    Converting RGB interleaved format to RGB planar format using DMA is highly inefficient.

    Every pixel will be read 3 times and written 3 times.

    And for every read or write operation, DMA performs a 128 byte fetch to DDR. This results in wastage of DDR bandwidth and eventually results in performance degradation.

    So it is recommended to do this conversion using C66x core.

    2. icnt0xicnt1xicnt2xicnt3 should match dicnt0xdicnt1xdicnt2xdicnt3. Most likely this should be the issue. To understand the error more, check the TR response field. It has a error code which will through more insight when the response was not right. See CSL macros CSL_UdmapTrResponseStatus* and based on the status the subtype will explain what exactly is the error.

    Regards

    Sivaraj R

  • Hi,

    thanks very much for your reply

    can you tell me more about "to do this conversion using C66x core"

    which C66x instruction should I use?

    thanks very much

  • If you want to do RGB interleaved to RGB planar then we recommend looking at TIADALG library which already has an optimized implementation.

    psdk_rtos_auto_j7_06_02_00_21/tiadalg/tiadalg_image_preprocessing/alg/tiadalg_image_preprocessing_c66.c

    Regards,
    Shyam

  • Hi,

    thanks very much for you reply

    i use the code "psdk_rtos_auto_j7_06_02_00_21/tiadalg/tiadalg_image_preprocessing/alg/tiadalg_image_preprocessing_c66.c"

    i debug this at C66 core

    in fact, this code uses _mem8 , _loll and _hill instructions

    and each instruction will cost more than 700 cycles in average

    why these instruction so slow ?

    Does this caused by prefetch disabled?

    if so , can you tell me how to enable the prefetch

    thanks very much

  • Hi,

    "*dst_ptr_r_u8++ = (uint8_t)(_loll(u64temp1) >> 24);"

    for example, this statement will cost 700 cycles in CCS, running on C66x core

    i think it is very slow and cost too much cycles,

    can you give me any suggestions?

    thanks very much

  • It is possible that you are not running with C66x L1/L2 caches turned on and appropriate MAR bits set for DDR caching.

    I don't expect 700 cycles for just 1 statement. Are you compiling the code in -o3, mode? Do you see the loop software pipelined in the assembler feedback?


    Regards,
    Shyam