OpenMP "atomic capture" problem

OpenMP "atomic capture" problem


the ifort compiler (version 13.1.0) refuses to compile the following code:

program t
  type b
    integer :: s
  end type b
  integer :: v
  type(b) :: x
  !$omp atomic capture
  v = x%s
  x%s = x%s+1
  !$omp end atomic
end program t

giving the following error message:

t.f90(11): error #7926: This statement is not a valid OpenMP* ATOMIC update-statement.
v = x%s
t.f90(12): error #8550: An OpenMP* ATOMIC capture-statement is expected
x%s = x%s+1
t.f90(10): internal error: Please visit '' for assistance.
!$omp atomic capture
[ Aborting due to internal error. ]
compilation aborted for t.f90 (code 1)

As far as I can understand the OpenMP 3.1 standard, the code should be compliant and, in fact, it goes through gfortran 4.7 with no problems. Note that, even if I change the order of the two instructions in the atomic construct (i.e., the update first and the capture second) nothing changes.

Is this a compiler bug or am I missing something?



publicaciones de 4 / 0 nuevos
Último envío
Para obtener más información sobre las optimizaciones del compilador, consulte el aviso sobre la optimización.

I will escalate the issue to engineering.  Thanks for the small test case

Hello Alfredo

this very problem has been reported before ( issue # DPD200233147) and gwill be fixed in a release later this year.


One of your runtime libraries migh have a function performing the (atomic) XCHGADD (the specific function name will vary with library). This might get you by. On Windows you have in kernel32 the function InterlockedExchangeAdd, Linux may have different module, same function, different function name.

Jim Dempsey

Deje un comentario

Por favor inicie sesión para agregar un comentario. ¿No es socio? Únase ya