2

当我尝试编译以下代码时

#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 = %d\n",sum);

  printf("devices %d\n", omp_get_num_devices());
  printf("default device %d\n", omp_get_default_device());
  printf("device id %d\n", 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 上试过这个。

4

1 回答 1

2

PGI 在 17.7 中增加了对 Linux/OpenPOWER CPU 的任务、绑定、SIMD、同步、归约、原子和其他 CPU 特性的支持。适用于 Linux x86-64 的 PGI LLVM 编译器 18.1 版本支持这些功能。PGI 计划在 2018 年开始开发 OpenMP 4.xtarget功能。

更多详情:https ://www.pgroup.com/resources/accel.htm#openmp

于 2018-03-16T14:05:55.553 回答