前言
Linpack是国际上使用最广泛的测试高性能计算机系统浮点性能的基准测试。通过对高性能计算机采用高斯消元法求解一元 N次稠密线性代数方程组的测试,评价高性能计算机的浮点计算性能。Linpack的结果按每秒浮点运算次数(flops)表示。
过程
添加代码
获取代码
http://www.roylongbottom.org.uk/classic_benchmarks.tar.gz
解压classic_benchmarks.tar.gz将\classic_benchmarks\classic_benchmarks\source_code\linpack文件夹复制到自己的工程。
添加代码
将\classic_benchmarks\source_code\linpack文件夹复制到工程目录,并添加工程中
移植接口
linpack.c中
62行注释掉//#include "cpuidh.h"
81行main (int argc, char *argv[])
改为
int linpack_main (int argc, char *argv[])
95行 int nopause = 1;改为
int nopause = 0;
注释掉113行的内容
#if 0
getDetails();
for (i=1; i<10; i++)
{
printf("%s\n", configdata);
}
printf("\n");
printf("##########################################\n");
outfile = fopen("Linpack.txt","a+");
if (outfile == NULL)
{
printf (" Cannot open results file \n\n");
printf(" Press Enter\n\n");
int g = getchar();
exit (0);
}
fprintf (outfile, " ########################################################\n\n");
for (i=1; i<10; i++)
{
fprintf(outfile, "%s \n", configdata);
}
fprintf (outfile, "\n");
#endif
start_time();改为
uint32_t s_stime_u32 = SYSTICK_GetTickCounter();
end_time();改为
uint32_t s_etime_u32 = SYSTICK_GetTickCounter();
uint32_t secs = (s_etime_u32-s_stime_u32)/1000.0;
添加
#include <stdint.h>
#include "definitions.h"
注释掉432行
//local_time();
注释掉438行
//fprintf (outfile, " ########################################################\n\n");
//fprintf (outfile, " Linpack %s Precision %s Benchmark n @ 100\n", PREC, ROLLING);
//fprintf (outfile, " Optimisation %s, %s\n", options, timeday);
注释掉507行
#if 0
for (i=0; i<5; i++)
{
if (strcmp (expect, was) != 0)
{
fprintf(outfile, " Variable %s Non-standard result was %s instead of %s\n",
title, was, expect);
errors = errors + 1;
}
}
#endif
532行添加 return 0;
编译ram可能不够可以修改
#define LDA 21
#define LDAA 20
#define N 10
lda = 201;
ldaa = 200;
cray = .056;
n = 100;改为
static REAL aa[200*200],a[200*201],b[200],x[200];
改为
static REAL aa[LDAA*LDAA],a[LDAA*LDA],b[LDAA],x[LDAA];
static int ipvt[200]
改为
static int ipvt[LDAA]
测试
main.c中
申明 void linpack_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;
linpack_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 );
}
结果如下
http://www.roylongbottom.org.uk/linpack%20results.htm
对比得分比AMD 80386高一些
总结
本文进行了线性浮点数运算性能测试,也和其他芯片对比,可以横向参考下芯片的性能。