Support for function pointers in OpenACC regions

Hi,

I am currently adding GPU support to a fluid dynamics code in C language using OpenACC directives and the PGI compilers. While this approach works really well for most parts, the code uses function pointers in some loops to allow for modularity (e.g., to choose boundary conditions). It seems that this is not currently supported by the PGI compilers. Compiling a code like

#pragma acc routine seq
int myfunction() {
    return 1;
}

void setarr( float * a, int n) {
#pragma acc parallel copy(a[0:n])
{
    int (*function_ptr)();
    function_ptr = &myfunction;

#pragma acc loop
    for( int i = 0; i < n; ++i ) a[i] = (*function_ptr)();
}
}

will fail with the error message:

Accelerator restriction: Indirect function/procedure calls are not supported

The OpenACC 2.5 standard does not seem to explicitly disallow function pointers, so I was wondering whether there are any plans to support them in the future?

Thanks!

The OpenACC 2.5 standard does not seem to explicitly disallow function pointers, so I was wondering whether there are any plans to support them in the future?

This wouldn’t necessarily be addressed by the OpenACC standard, rather it’s more an implementation issue on how to support this language feature for a given target accelerator.

We are in the process of defining how we can support function pointers as well as C++ virtual functions for Tesla devices. No firm timeline, but it is something we hope to support in the future.

  • Mat