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.

[参考译文] TDA4VM:使用 DSPLIB 链接器脚本在 CCS 上的 DSP C7X 上执行 DSPLIB_FIR 代码

Guru**** 2419530 points
Other Parts Discussed in Thread: TDA4VM

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

https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1529007/tda4vm-using-dsplib-linker-script-to-execute-dsplib_fir-codes-on-dsp-c7x-on-ccs

器件型号:TDA4VM

工具/软件:

尊敬的 TI:  

我的目标是 检查我们是否能够达到最高 MAC 性能  80GFLOPS、  数据表(TDA4VM 处理器)中提供了相关信息。 为此、我使用 DSPLIB 函数实施了代码、这允许我在 C7x 上运行 FIR 算法。  我 主要使用中的代码 DSPLIB_fir_example.cpp 要开发我的代码:  

/**
 * main.cpp
 */

#include "dsplib.h"
#include <stdint.h>
#include <iostream>
#include "signalFiltreInfloat.h"
#include "IndicesFiltreNyquistV2.h"     //contient les coefficients du filtre de nyquist
#include <c7x.h>

#define CLOCK_PER_SEC   1000000000 //1GHz

using namespace std;

int main(void){

   /* --- Vecteurs d entree - sortie du filtre FIR --- */
   long nbSymboles = 131704;

   /* Utilisation petits vecteurs */
   /* x(t) : vecteur de complexe en entree, appele in(t) ici */
   float* x = signalFiltreInfloat;

   /* h(t) : vecteur coefficients filtre FIR */
   float* h = IndicesFiltreNyquist;

   /* y(t)*/
   /* Conformement au benchmark de TI, on met y(t) de meme taille que x(t) */
   // La fonction fir de DSPLIB impose d'initialise le tableau stockant les echantillons de sortie
   float* y = (float*)malloc(nbSymboles * sizeof(float));


   /* Tailles des @ du filtre FIR */
   uint32_t dataSize = nbSymboles;  //x(t) contient 8 elements
   // in bytes
   uint32_t dataPitchInSize = nbSymboles * 8; //taille x(t) en bytes, pour rappel pour notre architecture, 1 float = 4 octet et 1 Complexe = 8 octets
    // in bytes
   uint32_t dataPitchOutSize = nbSymboles * 8;   //taille y(t) en bytes : 131704 * 8
   uint32_t batchSize        = 1;
   uint32_t filterSize       = 128;             //correspond à l'ordre du filtre
   // float data type
   uint32_t shift = 1;
   /* --- Donnees sur le filtre h(t) --- */
   //ajout pour compenser erreur DSPLIB_bufParams1D_t
   uint32_t dataPitchFilterSize = 129 * 8;  //129 coefficients, de type Complexe, 1 Complexe = 8 floats
   //ajout pour compenser erreur DSPLIB_bufParams1D_t. Initialisation d'un @ prop par TI
   uint32_t filterPitch = 0;   //cf fichier DSPLIB_fir_idat.c



   /* --- Caracteristiques du kernel --- */
   DSPLIB_STATUS       status;
   DSPLIB_fir_InitArgs kerInitArgs;
   int32_t             handleSize = DSPLIB_fir_getHandleSize(&kerInitArgs);
   DSPLIB_kernelHandle handle     = malloc(handleSize);

   /* Types des buffers d entree et sortie */
   DSPLIB_bufParams2D_t bufParamsIn, bufParamsOut;
//   DSPLIB_bufParams1D_t bufParamsFilter;  //modification car cree erreur
   DSPLIB_bufParams2D_t bufParamsFilter;

   /* Remplissages des buffers avec les valeurs des vecteurs */
   /* Buffer contenant x(t) */
   bufParamsIn.data_type = DSPLIB_FLOAT32;
   bufParamsIn.dim_x     = dataSize;
   bufParamsIn.stride_y  = dataPitchInSize;
   bufParamsIn.dim_y     = batchSize;

   /* Buffer contenant y(t) */
   bufParamsOut.data_type = DSPLIB_FLOAT32;
   bufParamsOut.dim_x     = dataSize;
   bufParamsOut.stride_y  = dataPitchOutSize;
   bufParamsOut.dim_y     = batchSize;

   /* Buffer contenant h(t) */
   bufParamsFilter.data_type = DSPLIB_FLOAT32;
   bufParamsFilter.dim_x     = filterSize;
   bufParamsFilter.stride_y  = dataPitchFilterSize;
   bufParamsFilter.dim_y     = batchSize;

   /* Remplissage des champs de la structure des @ du kernel */
   kerInitArgs.dataSize   = dataSize;
   kerInitArgs.batchSize  = batchSize;
   kerInitArgs.filterSize = filterSize;
   kerInitArgs.shift      = shift;
   /*
    * Optimized C implementation of the function for the MMA + C7x architecture
    */
   kerInitArgs.funcStyle  = DSPLIB_FUNCTION_OPTIMIZED;   //indicateur d'optimisation

   /* Statut initial de l algo */
   status = DSPLIB_SUCCESS;

   /* --- Initialisation de l'algo FIR */
   if (status == DSPLIB_SUCCESS){

        status = DSPLIB_fir_init_checkParams(handle, &bufParamsIn, &bufParamsOut, &bufParamsFilter, &kerInitArgs);
    }

   if (status == DSPLIB_SUCCESS){

       status = DSPLIB_fir_init(handle, &bufParamsIn, &bufParamsFilter, &bufParamsOut, &kerInitArgs);
   }


   /* --- Check avant Execution de l'algo FIR --- */

   if (status == DSPLIB_SUCCESS){

       status = DSPLIB_fir_exec_checkParams(handle, x, h, y);
   }


   /* --- Execution de l'algo FIR --- */

   int nb_ap_fir = 1;

   /* Timer de start */
   unsigned long start_timer = __TSC;

   for(int s=0;s<nb_ap_fir;s++){

       if (status == DSPLIB_SUCCESS){

           status = DSPLIB_fir_exec(handle, x, h, y);
       }

       else{

           cout << "Impossible d'appliquer l'algo FIR " << endl;
       }
   }

   /* Timer de stop */
   unsigned long stop_timer = __TSC;

   /* Nombre de cycles CPU ecoules */
   unsigned long nb_cycles = stop_timer - start_timer;
   /* Temps ecoule en µs */
   double tec = (double)(nb_cycles) / CLOCK_PER_SEC ;

   cout << "Le temps écoulé lors de l'exécution algo FIR vaut : " << tec << " s" << endl;


   long MAC = nb_ap_fir * (33979632/2);     //hypothese faite
   /* Recuperation temps d execution en MAC\µs */
   double MAC_par_sec = (double) MAC / tec;
   /* Affichage des perfomances */
   cout << "Le temps d'exécution est de " << MAC_par_sec << " MAC/s " << endl;




   return 0;
}

然后、我使用了链接器脚本 lnk.cmd 、由 TI 提供、位于 C7100 文件夹中、路径为:  TI-PROCESSOR-SDK-RTOS-j721e-evm-10_01_00_04\DSPLIB\cmake\linkers。  但是、每当我尝试运行项目时(在“发布“模式下)、我都会得到不同于的状态 DSPLIB_SUCCESS 因此我从不进入 DSPLIB_fir_exec() 功能...

有人能解决这个问题吗?

此致、  

M é lanie

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

    您好 Melanie、

    您能否提供signalFiltreInfloat.hIndicesFiltreNyquistV2.h头文件、其中包含输入和系数数据、以便我能够从我这边重现问题?

    此致、
    Shabary.

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

    您好 Melanie、

    我能够在我这边重现这个问题。 我将进一步调查、并尽快回复您、提供最新信息。

    此致、
    Shabary.

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

    您好 Melanie、

    问题出在链接器脚本中。 输入和输出数据很大(超过 512KB)、并且将输入和输出数组存储在栈和堆中。 在这种情况下、您应该在链接器脚本中增加栈和堆大小、并将输出存储在 MSMC 存储器中、因为 L2 SRAM 的最大大小为 512KB。您能否在链接器脚本中更新这些更改、然后尝试再次编译和运行?

    此致、
    Shabary.

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

    如果这是链接器脚本中的空间内存问题、那么运行代码时是否应该出现该问题?  

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

    您好 Melanie、

    .是否可以在链接器脚本中更新这些更改并尝试重新构建和运行?

    您是否有机会试用此解决方案? 它是否按预期工作?

    此致、
    Shabary S Sundar.

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

    我更改了它、现在我们进入函数内部

    然而我得到了这些表演:  5.28967e+09 MAC/s 您能否解释一下为什么我们与数据集显示的性能数据相差这么远?

    此致。  

    M é lanie ESTEVES  

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

    您好 Melanie、

    [引述 userid=“647126" url="“ url="~“~/support/processors-group/processors/f/processors-forum/1529007/tda4vm-using-dsplib-linker-script-to-execute-dsplib_fir-codes-on-dsp-c7x-on-ccs/5894111 #5894111“] 您能否解释一下为什么我们与数据集显示的性能数据相差这么远? [/报价]

    只有使用启用了缓存和 MMU 等的 FIR 内核中的测试函数才能获得最高性能。使用示例代码无法获得如此高的性能。  
    示例代码用于了解内核中提到的 API 的实现。
    为了获得卓越性能、 您可以在 CSV 文件中将您的用例添加为测试用例、并将其作为测试代码的一部分运行。


    此致、
    Shabary S Sundar.

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

    尊敬的 Shabary:  

    您能告诉我在哪里可以找到 FIR 内核中的测试函数吗?  
    而且,我不理解你的最后一句话,你能以不同的方式解释吗? 您引用的代码是“ 测试代码 “?  

    此致、  

    M é lanie

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

    您好 Melanie、

    要复制性能表中提到的周期数或性能、请在 DSP 库中运行 FIR 内核。 如果您希望在独立代码中获得相同的结果、请参阅以下主题中概述的步骤。

    TDA4VH-Q1:在 C7x DSP 上复制 DSPLIB 周期计数所需的帮助

    此致、

    Betsy Varughese.