【发布时间】:2021-06-07 19:24:09
【问题描述】:
我正在尝试使用OMPTrace,这是一个跟踪和可视化OpenMP 程序执行的工具,如https://github.com/passlab/omptrace 所示。 示例中给出的代码写在C中。 (jacobi.c 和 axpy.c)
该库已安装在/home/hakim/llvm-openmp/BUILD/omptrace/build/libomptrace.so 中。我创建了一个makefile 如下:
OMP_INSTALL=/home/hakim/llvm-openmp-install
OMP_LIB_PATH=${OMP_INSTALL}/lib
OMPTRACE_LIB=/home/hakim/llvm-openmp/BUILD/omptrace/build/libomptrace.so
default:runaxpy
axpyclang: axpy.c
clang -g -fopenmp axpy.c -o axpyclang
objdump -d axpyclang >axpyclang.objdump
jacobi: jacobi.c
clang -g -fopenmp jacobi.c -o jacobi -lm
objdump -d jacobi >jacobi.objdump
runaxpy: axpyclang
LD_PRELOAD=${OMP_LIB_PATH}/libomp.so:${OMPTRACE_LIB} ./axpyclang 1024
runjacobi: jacobi
LD_PRELOAD=${OMP_LIB_PATH}/libomp.so:${OMPTRACE_LIB} ./jacobi
clean:
rm axpyclang axpyclang.objdump core jacobi jacobi.objdump
当执行它时,我得到:
clang -g -fopenmp axpy.c -o axpyclang
axpy.c:18:5: warning: 'ftime' is deprecated [-Wdeprecated-declarations]
ftime(&tm);
^
/usr/include/x86_64-linux-gnu/sys/timeb.h:40:19: note: 'ftime' has been explicitly marked deprecated here
__nonnull ((1)) __attribute_deprecated__;
^
/usr/include/x86_64-linux-gnu/sys/cdefs.h:251:51: note: expanded from macro '__attribute_deprecated__'
# define __attribute_deprecated__ __attribute__ ((__deprecated__))
^
axpy.c:25:5: warning: 'ftime' is deprecated [-Wdeprecated-declarations]
ftime(&tm);
^
/usr/include/x86_64-linux-gnu/sys/timeb.h:40:19: note: 'ftime' has been explicitly marked deprecated here
__nonnull ((1)) __attribute_deprecated__;
^
/usr/include/x86_64-linux-gnu/sys/cdefs.h:251:51: note: expanded from macro '__attribute_deprecated__'
# define __attribute_deprecated__ __attribute__ ((__deprecated__))
^
axpy.c:95:5: warning: implicit declaration of function 'sleep' is invalid in C99 [-Wimplicit-function-declaration]
sleep(1);
^
3 warnings generated.
/usr/bin/ld: cannot find -lomp
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [makefile:8: axpyclang] Error 1
真正困扰我的是,我在 3 小时前成功执行了 makefile 并生成了一个 graphml 文件,但现在,我收到了新的倍数警告 + 一个错误。
我想知道它是否来自 clang 编译器(版本 10.0.0-4ubuntu1),因为收到新的警告让我觉得我可能更新了编译器(然后忘记了)。
有什么帮助吗?
【问题讨论】:
-
/usr/bin/ld: cannot find -lompomp 找不到,请确保libomp.a(或omp.lib)确实存在于您的库搜索路径中。 -
包含
unistd.h用于sleep函数警告 -
ftime的替换是clock_gettime或GetLocalTime,具体取决于您的系统。 -
链接器命令由于链接器推荐失败通知上面所述的原因而失败。不要自下而上地阅读错误信息。尽管在这里您似乎只阅读了底线,甚至没有向上。所有这些警告都可能是压倒性的,导致您无法看到实际的错误。解决方案很简单 - 也修复警告!
-
@ 谢谢!我摆脱了
sleep函数警告。