Search code examples
c++openmppgioffloading

OpenMP 4.5 runtime functions not supported in PGI


When I try and compile the following code

#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;
}

with

pgc++ -mp foo.cpp

I get the error

error: identifier "omp_get_num_devices" is undefined

The remaining OpenMP runtime functions are also undefined. The code compiles fine with gcc7. Are these functions supported by the PGI 17.10 community edition compiler? According to their website the PGI 17.10 community edition compiler supports OpenMP 4.5. What am I doing wrong?

I tried this with Ubuntu 16.04 and 17.04.


Solution

  • PGI added support for the tasking, binding, SIMD, synchronization, reduction, atomic and other CPU features for Linux/OpenPOWER CPUs in 17.7. These features are supported in the 18.1 release of the PGI LLVM compilers for Linux x86-64. PGI is planning to start working on the OpenMP 4.x target features in 2018.

    More details: https://www.pgroup.com/resources/accel.htm#openmp