查看: 700|回复: 1

【瑞萨RA4系列开发板体验】基准性能测试:整数计算能力

[复制链接]

116

主题

134

帖子

3778

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
3778
发表于 2023-1-5 23:46:51 | 显示全部楼层 |阅读模式
[color=rgb(12, 147, 228) !important]【瑞萨RA4系列开发板体验】基准性能测试之一:整数计算能力Dhrystone
作者:jf_1137202360

前言
基准测试有很多种,比如常见的coremark,已经有小伙伴测试过了,这里就不再重复测试了。这里采用Dhrystone进行整数性能测试。

过程
添加代码
获取代码
解压classic_benchmarks.tar.gz将\classic_benchmarks\classic_benchmarks\source_code\dhrystone2文件夹复制到自己的工程。
添加代码将\classic_benchmarks\source_code\dhrystone2文件夹复制到工程目录,并添加工程中



移植接口
在上一篇基础上,实现时间获取接口
ra-fsp-examples\example_projects\ek_ra4m2\sci_uart\sci_uart_ek_ra4m2_ep\keil\src\hal_entry.c中

  1. uint32_t SysTick_Gettime(void)
  2. {

  3. return s_time_u32;

  4. }
复制代码
dhry1.c中
注释掉//#include "cpuidh.h"
添加#include <stdint.h>
添加extern uint32_t SysTick_Gettime(void);
原来是以下代码获取之间代码执行时间(S),到全局变量User_Time
start_time();
......
end_time();
User_Time = secs
我们使用SysTick_Gettime来获取时间
我们之前配置systick的中断周期是1mS。
所以可以改为
uint32_t s_stime_u32 = SysTick_Gettime();
......
uint32_t s_etime_u32 = SysTick_Gettime();
User_Time = (s_etime_u32 - s_stime_u32)/1000.0;
void main (int argc, char *argv[])
改为
void dhry_main(int argc, char *argv[])
注释掉以下内容

  1. ///getDetails();

  2.     ///for (i=1; i<10; i++)

  3.     ///{

  4.     ///    printf("%s\n", configdata);

  5.     ///}

  6.     ///printf("\n");



  7.     ///fprintf (Ap, " #####################################################\n\n");                     

  8.     ///for (i=1; i<10; i++)

  9.     ///{

  10.     ///    fprintf(Ap, "%s \n", configdata);

  11.     ///}

  12. ///fprintf (Ap, "\n");
复制代码
185行
#endif "Register option Selected."
改为
#endif // "Register option Selected."
注释掉452行

  1. ///local_time();

  2.    ///fprintf (Ap, " #####################################################\n\n");                     

  3.    ///fprintf (Ap, " Dhrystone Benchmark 2.1 %s via C/C++ %s\n", options, timeday);

  4.    ///fprintf (Ap, " VAX MIPS rating:      %12.2lf\n\n",Vax_Mips);
复制代码
注释掉130的内容
  1. ///if ((Ap = fopen("Dhry.txt","a+")) == NULL)

  2.    ///  {

  3.    ///     printf(" Can not open Dhry.txt\n\n");

  4.    ///     printf(" Press Enter\n\n");

  5.    ///     int g = getchar();

  6.    ///     exit(1);

  7.    //  }
复制代码
113行
int nopause = 1;
改为
int nopause = 0;

测试
ra-fsp-examples\example_projects\ek_ra4m2\sci_uart\sci_uart_ek_ra4m2_ep\retarget.c中
修改发送\n时替换为发\r\n

  1. int fputc(int ch, FILE *f)

  2. {

  3. (void)f;

  4. uint8_t data = (uint8_t)ch;

  5. /* Your implementation of fputc(). */

  6. if(data == '\n')

  7. {
  8. uart_poll_send('\r');
  9. }

  10. uart_poll_send(data);

  11. return ch;

  12. }
复制代码
hal_entry中
申明 void dhry_main (int argc, char *argv[]);
调用dhry_main(0,0);
-O3优化



-Ofast优化


-O2优化

和100MHz的Pentium差不多


总结
优化等级影响较大,O3和Ofast得分一样。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
回复

使用道具 举报

3

主题

195

帖子

1540

积分

金牌会员

Rank: 6Rank: 6

积分
1540
发表于 2023-3-14 11:26:57 | 显示全部楼层

不错,学习一下
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

用户排行榜

RA助手

主题: 116帖子:134精华:0

RA_Lance

主题: 92帖子:132精华:9

lugl

主题: 44帖子:133精华:0

xujiwei263

主题: 16帖子:73精华:0

books咦

主题: 11帖子:11精华:2

Juggernaut

主题: 9帖子:95精华:0
快速回复 返回顶部 返回列表