当我尝试编译以下代码时
#include <omp.h>
#include <stdio.h>
#include <accel.h>
int main (void) {
int sum = 0;
#pragma omp target teams distribute parallel for reduction(+:sum) defaultmap(tofrom:scalar)
for(int i = 0 ; i < 2000000000; i++) {
sum += i%11;
}
printf("sum = %dn",sum);
printf("devices %dn", omp_get_num_devices());
printf("default device %dn", omp_get_default_device());
printf("device id %dn", omp_get_initial_device());
return 0;
}
跟
pgc++ -mp foo.cpp
我收到错误
error: identifier "omp_get_num_devices" is undefined
其余的 OpenMP 运行时函数也未定义。 代码使用 gcc7 编译良好。PGI 17.10 社区版编译器是否支持这些函数? 根据他们的网站,PGI 17.10社区版编译器支持OpenMP 4.5。 我做错了什么?
我在 Ubuntu 16.04 和 17.04 上尝试过这个。
PGI 在 17.7 中为 Linux/OpenPOWER CPU 添加了对任务、绑定、SIMD、同步、缩减、原子和其他 CPU 功能的支持。这些功能在 Linux x86-64 的 PGI LLVM 编译器的 18.1 版本中受支持。PGI计划在2018年开始开发OpenMP 4.x
target
功能。
更多详细信息: https://www.pgroup.com/resources/accel.htm#openmp