网站公告列表

  没有公告

加入收藏
设为首页
联系站长
您现在的位置: 61IC中国电子在线 >> DSP >> 代码示例 >> ADI DSP代码示例 >> Blackfin >> 文章正文
  开发环境为visual DSP++3.0的复数矩阵乘法模块(C)源代码         ★★★ 【字体:
开发环境为visual DSP++3.0的复数矩阵乘法模块(C)源代码
作者:61IC    文章来源:本站原创    点击数:    更新时间:2007-1-22    

/* MatScalMult.c - Performs a multiplication of a matrix and a   */
/* scalar.               */
/*                 */
/* The operation is performed twice for the same data.           */
/* The first execution is for SISD mode and the second for SIMD  */
/* mode.                                                         */
/* Benchmark routines are included to record the cycle count for */
/* execution of each mode and are printed to the output window   */
/* upon completion.                                              */
/*                                                               */
/* Analog Devices, 1999 */

#include <stdio.h>

#define rows 30
#define columns 30

float dm input[rows][columns];   /* The matrices can be treated as single dimensional */
float pm output_SISD[rows][columns]; /* arrays due to the way they are stored in memory.  */
float pm output_SIMD[rows][columns]; /* This will optimize the C code for the architecture. */

int count_start();
int count_end(int);
volatile int time_temp, SISD_cycle_count, SIMD_cycle_count; /* for benchmark routines */

void main(void)
{
   int i;
   float scalar = 5;
         
   for (i = 0; i < rows * columns; i++)
    input[0][i] = (float) i;
         
   time_temp = count_start();    /* Benchmark routine start */
   for (i = 0; i < rows * columns; i++)
    output_SISD[0][i] = input[0][i] * scalar;
   SISD_cycle_count = count_end(time_temp); /* Benchmark routine end   */

   printf("The cycle count for SISD execution is %d cycles.\n",SISD_cycle_count);

   time_temp = count_start();    /* Benchmark routine start */
    #pragma SIMD_for
 for (i = 0; i < rows * columns; i++)
    output_SIMD[0][i] = input[0][i] * scalar;
   SIMD_cycle_count = count_end(time_temp); /* Benchmark routine end   */

   printf("The cycle count for SIMD execution is %d cycles.\n",SIMD_cycle_count);

   exit(0);
}

               欢迎点击进入:TI德州中文网   (国内唯一针对TI应用的中文技术网站)    文章录入:admin    责任编辑:admin 
  • 上一篇文章:

  • 下一篇文章:
  • 发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    最新热点 最新推荐 相关文章
    开发环境为Visual DSP++3.0的…
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    站长:61IC 湘ICP备05002478号