On 12/09/2016 06:56 AM, Alexander Monakov wrote: > On Thu, 8 Dec 2016, Jeff Law wrote: >>> PR fortran/78027 >>> >>> gcc/ >>> * ipa-icf.c (sem_function::parse): Don't process functions with >>> oacc decl attributes, as they may be OpenACC routines. >>> >>> gcc/testsuite/ >>> * c-c++-common/goacc/acc-icf.c: New test. >>> * gfortran.dg/goacc/pr78027.f90: New test. >> This follows the same approach as we do for openmp. This is fine for the >> trunk. > > Normally all offloaded code has either "omp declare target" (most functions) > or > "omp target entrypoint" (only toplevel offloaded code). This used to include > OpenACC functions: they would have "oacc fnattrib" _in_ _addition_ to those > attributes, not _instead_ of them! If something related to a recent OpenACC > patch adds "oacc fnattrib" without at the same time adding "omp declare > target", > it's probable that other places in the compiler may break, not just IPA ICF. > > The explanation and the patch are written as if "oacc fnattrib" can appear > without "omp declare target" -- ttbomk this could never happen before. > > Can this please be cleared up?
It was more so to point out that there were cases where OpenACC offloaded regions may not have omp target attributes. Referring back to case 2 in the original email: 2. Nested offloaded regions inside 'omp declare target' functions do not have 'omp target entrypoint' attributes either. See the logic in omp-low.c:create_omp_child_function. Therefore, something like pr78027.f90 will not work. As I mentioned earlier, this probably should be a parser error. Looking back at the spec, it looks like omp declare target functions cannot have any nested omp target regions in them. A natural extension would be to error on acc parallel and kernels regions inside omp declare and omp target regions inside acc routines. Neither the OpenMP or OpenACC spec mentions anything about interoperability with one another. The OpenACC committee is planning on addressing OpenMP interoperability in 4.0 though. What's a better solution? A) always add an 'omp target entrypoint' attribute for OpenACC parallel and kernels regions, B) generate a parser error for OpenACC/OpenMP target/parallel/kernels regions inside routines/omp declared functions, C) error on -fopenmp -fopenacc or D) leave this patch as-is? > P.S. (and for the record, I'm unhappy that the reason for blacklisting "omp *" > attributes doesn't seem to be documented anywhere -- I see no way to > understand > from looking at this code _why_ the check is there; is it due to issues with > "omp declare simd"? or something else?) That does seem a little strict. I was debating whether this would be valid for OpenACC or not. The tricky part with OpenACC is the launch geometry. But then again, we could always teach IPA-ICF how to check the function attributes for equality among ACC regions. Cesar