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.

[参考译文] TMS320F28388D:双 MAC 所需的构建选项

Guru**** 2606725 points
Other Parts Discussed in Thread: C2000WARE

请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1046122/tms320f28388d-dual-mac-required-build-options

器件型号:TMS320F28388D
主题中讨论的其他器件:C2000WARE

大家好、

在我的上一个问题中、页面似乎崩溃。TMS320F28377D:双 MAC 所需的构建选项

我提交的编译器测试用例如下: https://tidrive.itg.ti.com/a/TFG8Yt5RvEdeUbxD/84bd9166-9fd1-4611-8b65-ff67e71701c1?l

编译器选项: "c:/ti/ccs1040/ccs/tools/compiler/ti-cgt-c2000_20.2.5.LTS/bin/cl2000 -v28 -ml -mt ---cla_support=cla2 -float_support=fpu64 -idiv_support=idiv0 -tmu_support=tmu0 -vcu_support=vcrc -O2 -opt_for_speed=5 -fp_mode=relaxed--tmu_support=tmu_ex-at_guide-express-ipe_display_guide-ine-express-express-ipe_remot_subs=-express-ip_dive-over-ine-board-at_subs=-express-express-express-express-ip_dive-over-ine-over-m=pf-ine_display_remot_remot_remot_infot_infot_subsection-ex-express-express-over-ment-board-express-over-ment-board-express-express-express-express-over-ment-board-express-over-ine_remot_remot_remot_subs=/ti/c2000/C2000Ware_3_04_00_00/driverlib/f2838x/driverlib/ccs/Debug/driverlib.lib /device/f2838x_codestartbranch.obj /device/device.obj /ti/ccs1040/ccs/tools/compiler/ti-cgt-c2000_20.2.5.LTS/include /ti/ccs1040/ccs/tools/compiler/ti-cgt-c2000_20.2.5.LTS/lib  

请帮助检查我无法生成 优化代码的原因。 谢谢!

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    感谢您发送测试案例。  我现在理解问题了。

    带有_DMAC 的循环对全局变量进行操作。  将其更改为对局部变量进行操作。  以下是一种实现该目的的方法...

    更改此代码...

        long res = 0;
        long temp = 0;
        for (i=0; i < 5; i++) // N does not have to be a known constant
             __dmac(((long *)a)[i], ((long *)b)[i], res, temp, 0);
        res += temp;

    (笑声) 调用函数...

        res = intrinsic_mac(a, b, 10);

    该函数的实现复制自文章 TI 编译器演示文稿中 C28x 优化演示文稿的第27页

    int32_t intrinsic_mac(int16_t *p1, int16_t *p2, int_fast16_t length)
    {
       int_fast16_t i;
       int32_t *p1_32 = (int32_t *) p1;
       int32_t *p2_32 = (int32_t *) p2;
       int32_t acc1, acc2;
    
       acc1 = acc2 = 0;
       length >>= 1;
    
       for (i = 0; i < length; i++)
          __dmac(p1_32[i], p2_32[i], acc1, acc2, 0);
    
       return acc1 + acc2;
    }

    在适当的头文件中添加此函数的原型...

    int32_t intrinsic_mac(int16_t *p1, int16_t *p2, int_fast16_t length);

    内在函数_Mac 的这种实现假定传递的数组 a b 在32位边界上对齐。  默认情况下不会发生这种情况。  添加这些 pragma 以告诉编译器需要进行此对齐...

    #pragma DATA_ALIGN(a, 2)
    #pragma DATA_ALIGN(b, 2)
    

    在所有这些更改之后,生成的 DMAC 循环是...

            RPT       AR5
    ||      DMAC     ACC:P,*XAR4++,*XAR7++
            MOVL      XAR6,ACC

    谢谢、此致、

    乔治

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 乔治:

    感谢您的支持! DMAC 环路现在可以很好地生成。

    我还想请您提供帮助。 目前、我有任务为当地团队编写与编译器优化相关的指导文档、以便更好地支持客户。 我知道您是这一领域的专家。 关于 C2000编译器优化、值得验证哪些工作?

    -Bruce

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    请考虑使用 C28x 优化指南、以及 TI 编译器演示文稿一文中的 C28x 编译器演示文稿。

    谢谢、此致、

    乔治