编译以下代码:
#include <iostream>
#include <omp.h>
int main(int argc, char *argv[])
{
std::cout << omp_get_default_device() << '\n';
return 0;
}
对于 GNU G++ 4.8.2,使用命令:
g++ -fopenmp test.cpp
导致以下错误消息:
test.cpp: In function ‘int main(int, char**)’:
test.cpp:6:39: error: ‘omp_get_default_device’ was not declared in this scope
std::cout << omp_get_default_device() << '\n';
我认为 omp_get_default_device
应该可以在并行区域之外调用是正确的吗?这是一个错误吗?
最佳答案
omp_get_default_device
似乎已添加到 OpenMP 4.0 中( here 是 3.1 规范,没有该功能)。 GCC 4.8 仅支持版本 3.1,但 GCC 4.9 将支持 4.0:http://gcc.gnu.org/wiki/openmp
关于c++ - GCC 4.8.2 中缺少 OpenMP 4 功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19506299/