Question about loop including function/procedure call


I am using PGI programming for some days only and I am still learning a lot from each page I am reading about it. Yet, I am stuck on a question which I do not find the answer:

I would like to improve the computing efficiency of a fortran application I am developing through parallelization of the code on GPU. However, the loop I intend to parallelize include a function call which is itself calling a function. From what I have read until now, such a loop appears not to be parallelizable and that’s exactly the compiler warning message I received: “Accelerator region ignored -> function/procedure calls are not supported” (Here is the compiler comand I used: pgfortran -plmex.f90 -zbsubs.f -machine.f90 -ta=nvidia -Minfo=accel -Minline -Mipa=inline, so I consider inlining) … unfortunately but not really surprisingly…

… until I have read this post in which the code presents a loop with function and then a subroutine calls, but for which parallelization seems to work. I also succeded to compile it on my machine.
Why is it working here, is it a particular case?
And more generally, is there a way to circumvent problems of loop parallelization when it contains function or procedure call?

Sorry for this, may be, basic question and many thanks in advance for helping me!

Hi Fred,

Functions called within an accelerator region must first be inlined before the region can be accelerated. Currently, the GPU does not support true subroutine calling, hence the restriction. In the case of the other post, the FUNC routine was inlined. In your case, look at the “-Minfo=inline” messages to determine why the compiler is not able to automatically inline your routines.

For help on Inlining into accelerator regions, you may find this post helpful: function/procedure calls not supported

Hope this helps,

Hi Mat,

Thank you so much for this very quick reply. It helped me a lot and I could already solve several inlining problems, mainly related to FOTMAT and DATA statements.
Yet, I apparently still have some inlining problems but I cannot identify them because there are so many “-Minfo=inline” messages that, at the end of the compilation, I cannot access anymore to the first ones in the compiler command window. I am trying to capute them with print screens during compilation but it is not so easy.
Is there a way to export these messages in a text file? or something else…?

Thanks again,

Hi Fred,

If you’re running from a command line shell, you should be able to redirect stderr to a file. “pgfortran -c … >& logfile.txt”. Which shell are you using?

  • Mat