编译 HPC Challenge Benchmark 时出现 Undeclared variable 错误

Undeclared variable error when compiling 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 使用了一些未声明的变量。

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

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

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/