Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29541 Discussions

Issue with !$OMP ATOMIC UPDATE CAPTURE

OP1
New Contributor III
73 Views

The following code (compiled on Windows with ifx 2026.0.0 and using the compiler option \Qopenmp) freezes after the first WRITE statement, usually after a small number of iterations on the loop index I. I can't figure out what is wrong here, and I am inclined to report this as a bug.

This is a showstopper for us, thus any alternative to the pattern shown here would be very much appreciated!

 

PROGRAM OMP_ATOMIC_TEST
USE OMP_LIB
IMPLICIT NONE

INTEGER :: I, ERROR
INTEGER, SAVE :: ERROR_LOCAL, ERROR_TEMP
!$OMP THREADPRIVATE(ERROR_LOCAL, ERROR_TEMP)

CALL OMP_SET_NUM_THREADS(10)

DO I = 1, 20 ! The purpose of this loop is to demonstrate the issue, it is unrelated
             ! to the following PARALLEL region. The code will freeze for some value
             ! of I, after having issued the first WRITE statement, and inside the
             ! ATOMIC UPDATE CAPTURE region.

    !$OMP PARALLEL

        IF (OMP_GET_THREAD_NUM() == 1) THEN

            WRITE(*, *) 'Begin ATOMIC CAPTURE region ', I
            !$OMP ATOMIC UPDATE CAPTURE
                ERROR_TEMP = ERROR ! Capture
                ERROR      = 1     ! Update
            !$OMP END ATOMIC
            ERROR_LOCAL = ERROR_TEMP
            WRITE(*, *) 'End ATOMIC CAPTURE region'

        END IF

    !$OMP END PARALLEL

END DO


END PROGRAM OMP_ATOMIC_TEST

 

0 Kudos
0 Replies
Reply