编译 HPC Challenge Benchmark 时出现未声明的变量错误

问题描述

我想在我的服务器上编译和运行 HPC Challenge 基准测试。 当我想使用 mpicc 编译器制作 hpcc-1.5.0 时,出现此错误

../../../../STREAM/stream.c:178:26: error: expected ‘=’,‘,’,‘;’,‘asm’ or ‘__attribute__’ before ‘a’
 static double * restrict a,* restrict b,* restrict c;
                          ^
../../../../STREAM/stream.c: In function ‘checkSTREAMresults’:
../../../../STREAM/stream.c:263:16: error: ‘a’ undeclared (first use in this function)
       if (fabs(a[j]/aj-1.0) > epsilon) {
                ^
../../../../STREAM/stream.c:263:16: note: each undeclared identifier is reported only once for each function it appears in
../../../../STREAM/stream.c:280:16: error: ‘b’ undeclared (first use in this function)
       if (fabs(b[j]/bj-1.0) > epsilon) {
                ^
../../../../STREAM/stream.c:297:16: error: ‘c’ undeclared (first use in this function)
       if (fabs(c[j]/cj-1.0) > epsilon) {
                ^
../../../../STREAM/stream.c: In function ‘computeSTREAMerrors’:
../../../../STREAM/stream.c: In function ‘HPCC_Stream’:
../../../../STREAM/stream.c: In function ‘tuned_STREAM_copy’:
../../../../STREAM/stream.c: In function ‘tuned_STREAM_Scale’:
../../../../STREAM/stream.c: In function ‘tuned_STREAM_Add’:
../../../../STREAM/stream.c: In function ‘tuned_STREAM_Triad’:

make[1]: *** [../../../../STREAM/stream.o] Error 1
make[1]: Leaving directory `/root/hpcc-1.5.0/hpl/lib/arch/build'
make: *** [all] Error 2

似乎 STREAM 使用了一些未声明的变量。

解决方法

这是因为数组使用了restrict关键字。要编译流,您必须使用 -std=c99 选项。

-std=c99 部分的 Make.$(arch) 文件中添加 CCFLAGS 标志。像这样:

CCFLAGS      = $(HPL_DEFS) -fomit-frame-pointer -O3 -funroll-loops -std=c99

来源:https://anilmaurya.wordpress.com/2016/04/26/hpc-1-5-0-compile-time-error/

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...