微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决编译 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/

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。