Hi Tobias,
many thanks for all these informations!
- I confirm, this clause solve the problem with GNU Fortran
- This workaround is fully compatible with Nvidia Fortran
- The problem with Cray Fortran remains (with this compiler, the
test-case runs but the result is wrong)
I've tested the suggested options for debugging but I must admit that
these intermediates files are a little bit out of my knowledge level to
easily identify the problem.
In my work, portability is important and I have access to different
compilers and GPU architectures and may be my best contribution to GNU
software is limited to these tests and reports with small test-cases
from a large scientific code that is expected to run on most GPU with
various compilers.
Thanks again for your help and detailed explanation
Patrick
Le 23/08/2023 à 13:41, Tobias Burnus a écrit :
Hi,
On 23.08.23 12:19, Patrick Begou via Fortran wrote:
For several days I have some trouble with OpenACC offloading and
fortran pointers. I'm testing with a very small peace of code to
investigate but I do not progress for several days and I need your help.
Could someone give me advices or a small explanation on what I have
not understood there ?
First, for debugging, using -fdump-tree-original -fdump-tree-gimple
-fdump-tree-omplower and looking at the file <prefix-><filename>.* might
help - grep for '#pragma'; this shows the internal representation
(incomplete) in a C like output. That's how I spotted the issue below.
* * *
For gfortran, the issue is:
!$acc parallel loop collapse(2) default(present) if(runongpu)
It works if you add a "present(current)" → see also newly filed
https://gcc.gnu.org/PR111116
gfortran seems to follow - but not completely - the spec:
Quoting from OpenACC 3.2: "2.6.2 Variables with Implicitly Determined
Data Attributes":
"A scalar variable will be treated as if it appears either:
* In a copy clause if the compute construct is a kernels construct.
* In a firstprivate clause otherwise.
Note: Any default(none) clause visible at the compute construct applies
to both aggregate and scalar variables. However, any default(present)
clause visible at the compute construct applies only to aggregate
variables."
However, the glossary defines:
"Aggregate variables – a variable of any non-scalar datatype, including
array or composite variables.
In Fortran, this includes any variable with allocatable or pointer
attribute and character variables."
And, as you have a (scalar) Fortran pointer, the following should have
applied instead:
"An aggregate variable will be treated as if it appears either:
• In a present clause if there is a default(present) clause visible at
the compute construct.
• In a copy clause otherwise."
* * *
Thus: It looks as if your program is valid, adding 'present(current)'
will fix it for gfortran (and Cray?), 'default(...)' and implicit
mapping is confusing, and there is now a gfortran PR to track this
issue: https://gcc.gnu.org/PR111116
Tobias
-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße
201, 80634 München; Gesellschaft mit beschränkter Haftung;
Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft:
München; Registergericht München, HRB 106955