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.

TMS320C6678: TI 编译器对数组复制会做哪些优化,编译器优化不会EDMA更高效么

Part Number: TMS320C6678

/* Poll on IPR bit 0 */
do {
CSL_edma3GetHwStatus(hModule,CSL_EDMA3_QUERY_INTRPEND,&regionIntr);
} while (!(regionIntr.intr & 0x1));

EDMA传输采用这种轮询的方式查传输是否完成,会影响运算性能么(轮询的同时,单核可以进行其他的运算工作么)

  • 对EDMA传输不是很了解,一个数组传到另一个数组,是不是就相当于数组复制

  • 我测试了一下,1024个float型数组复制给另一个数组,编译器优化比EDMA传输快一倍,但我们使用EDMA,源数组和目的数组分别在不同的存储区,传输结果有的正确有的不正确,使用的是EDMA3CC0通道控制器,共享内存传输到DDR3结果没问题,反过来结果就是错的了,不知道是不是代码有问题

  •     /* Module Initialization */
        CSL_edma3Init(&context);
    
    
        /* Open the EDMA Module using the provided instance number */
     	 hModule = CSL_edma3Open(&edmaObj, instNum, NULL, &status);
    
    
        /* Channel open */
        chAttr.regionNum = CSL_EDMA3_REGION_GLOBAL;
        chAttr.chaNum    = channelNum;
        hChannel = CSL_edma3ChannelOpen(&chObj, instNum, &chAttr, &status);
    
    
        /* For first EDMA instance there are only 2 TCs and 2 event queues
    	 * Modify the channel default queue setup from 0 to 1
    	 */
        CSL_edma3HwChannelSetupQue(hChannel,CSL_EDMA3_QUE_1);
    
    
        /* Map the DMA Channel to PARAM Block 1. */
        CSL_edma3MapDMAChannelToParamBlock (hModule, channelNum, 1);
        /* Obtain a handle to parameter set 1 */
        htrans = CSL_edma3GetParamHandle(hChannel, 1, &status);
    
    
    	myParamSetup.option = CSL_EDMA3_OPT_MAKE(CSL_EDMA3_ITCCH_DIS, \
    											CSL_EDMA3_TCCH_DIS, \
    											CSL_EDMA3_ITCINT_DIS, \
    											CSL_EDMA3_TCINT_EN, \
    											0, CSL_EDMA3_TCC_NORMAL,\
    											CSL_EDMA3_FIFOWIDTH_NONE, \
    											CSL_EDMA3_STATIC_EN, \
    											CSL_EDMA3_SYNC_A, \
    											CSL_EDMA3_ADDRMODE_INCR, \
    											CSL_EDMA3_ADDRMODE_INCR );
    	myParamSetup.srcAddr    = (Uint32)srcBuff1;
    	myParamSetup.aCntbCnt   = CSL_EDMA3_CNT_MAKE(1024*4,1);
    	myParamSetup.dstAddr    = (Uint32)dstBuff1;
    	myParamSetup.srcDstBidx = CSL_EDMA3_BIDX_MAKE(1024*4,1024*4);
    	myParamSetup.linkBcntrld= CSL_EDMA3_LINKBCNTRLD_MAKE(0xffff,0);
    	myParamSetup.srcDstCidx = CSL_EDMA3_CIDX_MAKE(1024*4,1024*4);
    	myParamSetup.cCnt = 1;
    
        /* htrans setup */
    	CSL_edma3ParamSetup(htrans,&myParamSetup);
    
    
        /* Interrupt enable (Bits 0-1)  for the global region interrupts */
        regionIntr.region = CSL_EDMA3_REGION_GLOBAL;
        regionIntr.intr   = 0x1;
        regionIntr.intrh  = 0x0000;
        CSL_edma3HwControl(hModule,CSL_EDMA3_CMD_INTR_ENABLE,&regionIntr);
    
        /* Trigger channel */
        CSL_edma3HwChannelControl(hChannel,CSL_EDMA3_CMD_CHANNEL_SET,NULL);
    
        regionIntr.region = CSL_EDMA3_REGION_GLOBAL;
        regionIntr.intr   = 0;
        regionIntr.intrh  = 0;
    
        /* Poll on IPR bit 0 */
        do {
            CSL_edma3GetHwStatus(hModule,CSL_EDMA3_QUERY_INTRPEND,&regionIntr);
        } while (!(regionIntr.intr & 0x1));
    
        /* Clear the pending bit */
        CSL_edma3HwControl(hModule,CSL_EDMA3_CMD_INTRPEND_CLEAR,&regionIntr);
    
    
        /* Check transfer by comparing the source and destination buffers */
        Verify_Transfer( 1024, 1, 1, 0, 0, 0, 0, srcBuff1, dstBuff1, TRUE);
    
    
    
    
    	/* Close channel */
        CSL_edma3ChannelClose(hChannel);
    
    
    	/* Close EDMA module */
    	CSL_edma3Close(hModule);

    这个是我们的参数配置

  • 编译器优化和EDMA搬数据不可以相比较。编译器优化是对整体代码的调整优化,EDMA搬移数据是不需要CPU的参与从而提高性能。

    看一下Optimizing Your Code章节的内容。

    https://www.ti.com/lit/ug/sprui04b/sprui04b.pdf