前言上一篇我们使用Dhrystone进行了整数运算性能的测试。这次我们使用whetstone进行浮点相关的计算性能测试。
过程添加代码获取代码
http://www.roylongbottom.org.uk/classic_benchmarks.tar.gz
解压classic_benchmarks.tar.gz将classic_benchmarksclassic_benchmarkssource_codewhetstone文件夹复制到自己的工程。
添加代码
将classic_benchmarkssource_codewhetstone文件夹复制到工程目录,并添加工程中
移植接口whets.c中
161行 **************************************************************************
改为
**************************************************************************/
167行注释掉
//#include "cpuidh.h"
添加 extern uint32_t Systick_Gettime(void); #include
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("%sn", configdata);
}
local_time();
printf("n");
printf("##########################################n");
printf("%s Precision C Whetstone Benchmark %s, %sn", Precision, opt, timeday);
outfile = fopen("whets.txt","a+");
if (outfile == NULL)
{
printf ("Cannot open results file nn");
printf("Press Enter to exitn");
i = getchar();
exit (0);
}
#endif
注释掉314行以下内容
#if 0
fprintf (outfile, "n");
fprintf (outfile, "##############################################nn");
for (i=1; i<10; i++)
{
fprintf(outfile, "%s n", configdata);
}
fprintf (outfile, "n");
fprintf (outfile, "##############################################nn");
fprintf (outfile, "Whetstone %s Precision C Benchmark %s, %sn",Precision, opt, timeday);
fprintf (outfile, "n");
fprintf (outfile,"Loop content Result"
" MFLOPS MOPS Secondsnn");
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.3fn",
loop_mflops[section], loop_time[section]);
}
else
{
fprintf (outfile, " %9.3f %9.3fn",
loop_mops[section], loop_time[section], results[section]);
}
}
fflush(outfile);
fprintf (outfile, "nMWIPS ");
fprintf (outfile, "%39.3f%20.3fnn",mwips,TimeUsed);
fprintf (outfile, "Results to load to spreadsheet ");
fprintf (outfile, " MWIPS Mflops1 Mflops2 Mflops3 Cosmops"
" Expmops Fixpmops Ifmops Eqmopsn");
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.3fnn", 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 samen");
printf ("directory as the .EXE files, if one did not already exist.nn");
if (nopause)
{
printf(" Press Enternn");
i = getchar();
}
#endif
407行
start_time();改为
uint32_t s_stime_u32 = SysTick_Gettime();
423行
end_time();改为
uint32_t s_etime_u32 = SysTick_Gettime()();
其他地方类似不再枚举
测试hal_entry中
申明 void whets_main (int argc, char *argv[]);
调用whets_main(0,0);
http://www.roylongbottom.org.uk/whetstone%20results.htm
下可以对比
总结本篇测试了浮点运算能力,还有其他的线性浮点运算能力测试linpack,并发计算基准测试livermore_loops等都可以参考,不再一一测试。