前言
上一篇我们使用Dhrystone进行了整数运算性能的测试。这次我们使用whetstone进行浮点相关的计算性能测试。
过程
添加代码
获取代码
http://www.roylongbottom.org.uk/classic_benchmarks.tar.gz
解压classic_benchmarks.tar.gz将\classic_benchmarks\classic_benchmarks\source_code\whetstone文件夹复制到自己的工程。
添加代码
将\classic_benchmarks\source_code\whetstone文件夹复制到工程目录,并添加工程中
移植接口
whets.c中
161行 **************************************************************************
改为
**************************************************************************/
167行注释掉
//#include "cpuidh.h"
201行int main(int argc, char *argv[])
改为
int whets_main(int argc, char *argv[])
212行
int nopause = 1;
改为
int nopause = 0;
注释掉228行以下内容
#if 0
getDetails();
for (i=1; i<10; i++)
{
printf("%s\n", configdata);
}
local_time();
printf("\n");
printf("##########################################\n");
printf("%s Precision C Whetstone Benchmark %s, %s\n", Precision, opt, timeday);
outfile = fopen("whets.txt","a+");
if (outfile == NULL)
{
printf ("Cannot open results file \n\n");
printf("Press Enter to exit\n");
i = getchar();
exit (0);
}
#endif
注释掉314行以下内容
#if 0
fprintf (outfile, "\n");
fprintf (outfile, "##############################################\n\n");
for (i=1; i<10; i++)
{
fprintf(outfile, "%s \n", configdata);
}
fprintf (outfile, "\n");
fprintf (outfile, "##############################################\n\n");
fprintf (outfile, "Whetstone %s Precision C Benchmark %s, %s\n",Precision, opt, timeday);
fprintf (outfile, "\n");
fprintf (outfile,"Loop content Result"
" MFLOPS MOPS Seconds\n\n");
for (section=1; section<9; section++)
{
fprintf (outfile, "%s %24.17f ", headings[section],
results[section]);
if (loop_mops[section] == 99999)
{
fprintf (outfile," %9.3f %9.3f\n",
loop_mflops[section], loop_time[section]);
}
else
{
fprintf (outfile, " %9.3f %9.3f\n",
loop_mops[section], loop_time[section], results[section]);
}
}
fflush(outfile);
fprintf (outfile, "\nMWIPS ");
fprintf (outfile, "%39.3f%20.3f\n\n",mwips,TimeUsed);
fprintf (outfile, "Results to load to spreadsheet ");
fprintf (outfile, " MWIPS Mflops1 Mflops2 Mflops3 Cosmops"
" Expmops Fixpmops Ifmops Eqmops\n");
fprintf (outfile, "Results to load to spreadsheet ");
fprintf (outfile, " %9.3f %9.3f %9.3f", mwips, loop_mflops[1],
loop_mflops[2]);
fprintf (outfile, " %9.3f %9.3f %9.3f", loop_mflops[6],
loop_mops[5], loop_mops[8]);
fprintf (outfile, " %9.3f %9.3f %9.3f\n\n", loop_mops[4],
loop_mops[3], loop_mops[7]);
fflush(outfile);
fclose (outfile);
printf ("\n");
printf ("A new results file, whets.txt, will have been created in the same\n");
printf ("directory as the .EXE files, if one did not already exist.\n\n");
if (nopause)
{
printf(" Press Enter\n\n");
i = getchar();
}
#endif
407行
start_time();改为
uint32_t s_stime_u32 = SYSTICK_GetTickCounter();
423行
end_time();改为
uint32_t s_etime_u32 = SYSTICK_GetTickCounter();
其他地方类似不再枚举
包含头文件
#include "definitions.h"
测试
main.c中
申明 void whets_main (int argc, char *argv[]);
int main ( void )
{
/* Initialize all modules */
SYS_Initialize ( NULL );
SYSTICK_TimerStart();
PORT_REGS->GROUP[1].PORT_PINCFG[24] = 0x1U;
PORT_REGS->GROUP[1].PORT_PINCFG[25] = 0x1U;
PORT_REGS->GROUP[1].PORT_PMUX[12] = 0x33U;
whets_main(0,0);
while ( true )
{
/* Maintain state machines of all polled MPLAB Harmony modules. */
SYS_Tasks ( );
}
/* Execution should not come here during normal operation */
return ( EXIT_FAILURE );
}
可以从以下地址对比,可以看到和80486DX2差不多
http://www.roylongbottom.org.uk/whetstone%20results.htm
总结
本文进行了浮点数运算性能测试,也和其他芯片对比,可以横向参考下芯片的性能。