New 4.0 constraint on ATOMIC

Discuss the OpenMP 4.0 API Specifications released July 2013 (Read Only)
Forum rules
The OpenMP Forums are now closed to new posts. Please visit Stack Overflow if you are in need of help: https://stackoverflow.com/questions/tagged/openmp
Locked
layzarc
Posts: 4
Joined: Wed Aug 13, 2014 11:55 am

New 4.0 constraint on ATOMIC

Post by layzarc »

The constraint disallowing ATOMIC operations on Fortran ALLOCATABLE variables was added to the OpenMP 4.0 specification since it does not appear in 3.1. Why? This breaks my code (and others?) that has performed flawlessly for almost a decade with various compilers on multiple platforms! I assume the fix is to replace it with a CRITICAL region?

Al Greynolds

layzarc
Posts: 4
Joined: Wed Aug 13, 2014 11:55 am

Re: New 4.0 constraint on ATOMIC

Post by layzarc »

I switched to CRITICAL and my code ran several times slower on one of my platforms. Since before 4.0 there were no problem for my various compilers on multiple platforms to allow ATOMIC on an ALLOCATED variable, seems like a step backwards.

layzarc
Posts: 4
Joined: Wed Aug 13, 2014 11:55 am

Re: New 4.0 constraint on ATOMIC

Post by layzarc »

Just to be sure, this is a code example that gfortran 4.9.1 now says violates the new OpenMP 4.0 constraint on ATOMIC:

module storage
integer,allocatable :: nerrs(:,:)
end module

program atomic
use storage
allocate(nerrs(10,10))
!$omp parallel do
do k=1,10
call uperrs(k,1)
enddo
!$omp end parallel do
stop
contains
subroutine uperrs(i,io)
integer,intent(in) :: i,io
!$omp atomic
nerrs(i,io)=nerrs(i,io)+1
end subroutine
end

Are they correctly interpreting the spec?

layzarc
Posts: 4
Joined: Wed Aug 13, 2014 11:55 am

Re: New 4.0 constraint on ATOMIC

Post by layzarc »

The opinion on other forums I contacted is that this is a misinterpretation by gfortran 4.9.1 of the following admittedly vague OpenMP 4.0 spec wording:

:
x = x operator expr
x = expr operator x
x = intrinsic_procedure_name (x, expr_list)
x = intrinsic_procedure_name (expr_list, x)
In the preceding statements:
* x and v (as applicable) are both scalar variables of intrinsic type.
* x must not be an allocatable variable.
:

Its believed that the intent was that the atomic statement should not automatically allocate or reallocate x as can happen in Fortran2008. Right?

kmcdaniel1985
Posts: 9
Joined: Wed Jun 17, 2015 2:12 pm

Re: New 4.0 constraint on ATOMIC

Post by kmcdaniel1985 »

Sorry you haven't received a reply on this. Am kind of curious if there is a better forum for asking such questions, because your post is of interest to me as well. Not sure why these forums are so dead. Perhaps either lack of interest in those who know willing to reply, or just general lack of knowledge keeping the answers non-existent.

Locked