-fopenmp提供什么预处理程序定义? [英] What preprocessor define does -fopenmp provide?
问题描述
我有一些可以与OpenMP一起运行(或不与OpenMP一起运行)的代码-这取决于用户如何设置Makefile.如果他们想与OpenMP一起运行,则只需将-fopenmp
添加到CFLAGS
和CXXFLAGS
.
我正在尝试确定可以使用什么预处理器宏来告知-fopenmp
何时生效. omp.h
标头看起来不太有趣:
$ cat /usr/lib/gcc/x86_64-linux-gnu/4.8/include/omp.h | grep define
#define OMP_H 1
#define _LIBGOMP_OMP_LOCK_DEFINED 1
# define __GOMP_NOTHROW throw ()
# define __GOMP_NOTHROW __attribute__((__nothrow__))
而且我无法让预处理器提供任何有用的东西:
$ cpp -dM -fopenmp </dev/null | grep -i omp
#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
#define __STDC_IEC_559_COMPLEX__ 1
$ cpp -dM -fopenmp </dev/null | grep -i version
#define __GXX_ABI_VERSION 1002
#define __VERSION__ "4.8.2"
-fopenmp
提供什么预处理程序定义?
这类似于如何确定OpenMP是否正在工作?但是我对编译时感兴趣,而不是在编译时感兴趣构建后或运行时.
注意 :该项目不使用Boost,不使用Autotools,也不使用Cmake.它只使用一个makefile.
您的grep过于具体,您应该寻找"openmp".
或者,将cpp -dM -fopenmp </dev/null
和cpp -dM </dev/null
进行比较会产生一个差异:
#define _OPENMP 201107
应该正是您要寻找的. p>
I've got some code that can run with (or without) OpenMP - it depends on how the user sets up the makefile. If they want to run with OpenMP, then they just add -fopenmp
to CFLAGS
and CXXFLAGS
.
I'm trying to determine what preprocessor macro I can use to tell when -fopenmp
is in effect. The omp.h
header does not look very interesting:
$ cat /usr/lib/gcc/x86_64-linux-gnu/4.8/include/omp.h | grep define
#define OMP_H 1
#define _LIBGOMP_OMP_LOCK_DEFINED 1
# define __GOMP_NOTHROW throw ()
# define __GOMP_NOTHROW __attribute__((__nothrow__))
And I can't get the preprocessor to offer up anything useful:
$ cpp -dM -fopenmp </dev/null | grep -i omp
#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
#define __STDC_IEC_559_COMPLEX__ 1
$ cpp -dM -fopenmp </dev/null | grep -i version
#define __GXX_ABI_VERSION 1002
#define __VERSION__ "4.8.2"
What preprocessor define does -fopenmp
provide?
This is similar to How to tell if OpenMP is working? But I'm interested in compile time, and not post-build or runtime.
Note: this project does not use Boost, does not use Autotools, and does not use Cmake. It just uses a makefile.
Your grep was overly specific, you should have looked for "openmp".
Or rather, diffing cpp -dM -fopenmp </dev/null
and cpp -dM </dev/null
produces a single diff:
#define _OPENMP 201107
Which should be exactly what you are looking for.
这篇关于-fopenmp提供什么预处理程序定义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!