[Bug fortran/72741] Fortran OpenACC routine directive doesn't properly handle clauses specifying the level of parallelism

tschwinge at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Aug 10 11:39:00 GMT 2016


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72741

--- Comment #5 from Thomas Schwinge <tschwinge at gcc dot gnu.org> ---
(In reply to cesar from comment #4)
> I could be mistaken, but I don't think there's anything we can do about that
> test case because fortran doesn't have file scope. Specifically, in your
> example,
> 
> SUBROUTINE r_w
>   IMPLICIT NONE
>   INTEGER :: i
>   !$ACC ROUTINE WORKER
> 
>   !$ACC LOOP
>   DO i = 1, 12345
>   END DO
> END SUBROUTINE r_w
> 
> PROGRAM main
>   IMPLICIT NONE
>   EXTERNAL :: r_w
>   !$ACC ROUTINE (r_w) GANG
> 
>   !$ACC PARALLEL
>   CALL r_w
>   !$ACC END PARALLEL
> END PROGRAM main
> 
> from program main's perspective, r_w should be an acc routine with a gang
> attribute, but that's only because the end user included an explicit
> 'external' function declaration. I'm not sure how to catch mismatched
> function declarations in fortran

Maybe I'm assuming too much about the Fortran front end, but I assumed that the
"SUBROUTINE r_w" would create some kind of decl, and the later "!$ACC ROUTINE
(r_w)" would look up some kind of decl (that is, the
gfc_find_function/gfc_find_subroutine/gfc_find_symtree stuff in
gfc_match_oacc_routine), and these decls both have some kind of "attributes"
attached to them, and once these two decls are "paired"/"merged", we can then
see whether these "attributes" match or conflict.  I assume some very similar
verification is done in the Fortran front end for other checking between
definition and use of any kind of routines, for example?

Are you saying that's not how the Fortran front end operates, and the
"SUBROUTINE r_w" and the later "PROGRAM main" do see completly detached "decl
spaces"?  Then indeed, we can't verify this in the Fortran front end, but...

> especially if lto is not enabled. If lto
> is enabled, we could add some more checking in pass oacc_device_lower.

..., as discussed before, something like that is the final goal that I'm
working on, and for that...

> But I
> don't think there's anything else to do in the fortran front end.

..., please implement the changes I asked you to implement in Comment 3, #c3,
or elaborate why that doesn't make sense.


More information about the Gcc-bugs mailing list