Calling functions within the kernels

How can we call a user defined function within a pragma accregion?? I’ve tried almost everything and the compiler still says :

kernel_PGI:
41, Accelerator region ignored
50, Accelerator restriction: function/procedure calls are not supported
58, Accelerator restriction: unsupported call to ‘dotProduct’
PGC/x86-64 Linux 11.3-0: compilation completed with warnings

I guess it’s allowed to call functions within the kernel, but how can I do it? If my functions is for instance :

float dotProduct{
return 5.0;
}

Hi luiceur,

How can we call a user defined function within a pragma accregion?

Functions need to be inlined before they can used within an accelerator compute region. We do plan on adding support for calling CUDA C/Fortran routines from within acc regions in a later release.

For a simple function, like your dotProduct example, the compiler will be able to automatically inline them if you add the “-Minline” option when the functions are within the same file, or “-Mipa=inline” when the functions are in separate files. For functions where the compiler is unable to auto-inline, you will need to manually inline them.

Hope this helps,
Mat

And how can I manually inline a function because I’ve tried -Minline=name:dotProduct and still the compiler seems to complain.
My kernel is using quite a lot external functions but I’ve implemented them in CUDA so it is not something that a device can not do.

BTW, thank you very much for your help

And how can I manually inline a function because I’ve tried -Minline=name:dotProduct and still the compiler seems to complain.

Do you have an example? What’s the compiler’s complaint?

  • Mat

31, Accelerator region ignored
33, Accelerator restriction: function/procedure calls are not supported
34, Accelerator restriction: unsupported call to ‘dotProduct’

I get a complain like that. I’ve tried with very simple functions and I am getting the same answer. I think I am not properly inlinining or the compiler doesn’t know how to do it and I have to force it to do it.

I’ve managed to create a short program with calls to functions within the same file and in another file. Just with -Minline seems to work, don’t if I specify the name of the function though.
In what cases should I use -Mipa=inline then?

Hi luiceur,

-Minline wont inline functions from another file unless you’ve first created an extract library or compile them together on the same compilation line. To create an extract library, first compile all your files using “-Mextract=lib:name”, then compile again using “-Minline=lib:name”.

Just with -Minline seems to work, don’t if I specify the name of the function though.

I’d need an example since if a function inlines using -Minline, it should also inline if you use the name.

  • Mat