On Mon, Feb 21, 2022 at 06:02:06PM +0100, Tobias Burnus wrote:
> I wonder whether there is a real problem in terms of the ME, but maybe
> there is.
>
> For atomic_default_mem_order: That's purely handle by the FEs by
> setting the default – and just using it when parsing the 'atomic'
> directive, if there is no explicit mem_order.
Well, for !$omp requires atomic_default_mem_order(whatever)
vs. !$omp atomic that is handled purely in the FE and I hope we do it right.
Where ME is involved is
!$omp requires atomic_default_mem_order(whatever) vs.
!$omp declare variant ...atomic_default_mem_order(whatever).
That is handled in omp-generic.cc and right now that is done during
gimplification of a function.
My reading of what gfc_parse_file does is that if I have:
subroutine foo
!$omp requires atomic_default_mem_order(relaxed)
end subroutine foo
subroutine bar
!$omp requires atomic_default_mem_order(acq_rel)
end subroutine bar
subroutine baz
interface
subroutine foo
end subroutine
end interface
interface
subroutine bar
end subroutine
!$omp declare variant (foo) &
!$omp & match (implementation={atomic_default_mem_order(seq_cst)})
end interface
call bar
end subroutine baz
then it will call foo because omp_requires in one function is
OMP_MEMORY_ORDER_RELAXED aka 1 and in another one
OMP_MEMORY_ORDER_ACQ_REL aka 4, and (1 | 4) == OMP_MEMORY_ORDER_SEQ_CST
whenb no !$omp requires is in the baz program unit visible and so
it should just call bar.
And similarly with dynamic_allocators, if I have:
subroutine qux
!$omp requires dynamic_allocators
end subroutine qux
subroutine corge
interface
subroutine garply
end subroutine
!$omp declare variant (quux) &
!$omp & match (implementation={dynamic_allocators})
end interface
call garply
end subroutine corge
I think with the posted patch it would call quux which it should not.
Jakub