https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127257
Bug ID: 127257
Summary: [OpenMP] Implicit declare target: Internal functions
must inherit the device_type of the parent
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Keywords: openmp
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: burnus at gcc dot gnu.org
Target Milestone: ---
Currently, internal procedures are only implicitly typed to be 'declare target'
but they do not inherit the 'device_type'.
Likewise, inconsistent 'device_type' are not diagnosed.
* Note that device_type != any is only possible by an explicit
'declare target' directive, i.e. handling the implicit marking
as 'declare target' also works in the front end.
Example:
subroutine f()
!$omp declare target enter(f) device_type(nohost)
call bar()
contains
subroutine bar
end subroutine bar
end
This currently gives the following, i.e. the internal procedure does not have
the 'nohost' property.
gfortran -fopenmp -fdump-tree-gimple
__attribute__((omp declare target (device_type(nohost))))
__attribute__((fn spec (". ")))
void f ()
{
static void bar (void);
bar ();
}
__attribute__((omp declare target))
__attribute__((fn spec (". ")))
void bar ()
{
}
*****
However, for the following:
module m
contains
subroutine outer()
call inner()
contains
subroutine inner
!$omp declare target enter(inner) device_type(nohost)
end
end subroutine outer
subroutine caller
!$omp target
call outer()
!$omp end target
end subroutine caller
end
'outer' gets implicitly 'declare target device_type(any)' and no error is
diagnosed that the enclosed procedure 'inner' has a different device_type.