[Omp] atomic and flush

Maria Jose Martin Santamaria mariam at udc.es
Tue Nov 16 04:19:51 PST 2004


I have a parallel program with the following structure (simplified):

C$OMP PARALLEL SHARED(INDEX,number_access,N)
C$OMP+PRIVATE(i,re,myid,p)

       myid=OMP_GET_THREAD_NUM()
       p=OMP_GET_NUM_THREADS()

       do i=myid+1,N,p
           re=INDEX(i)
           .....

C$OMP CRITICAL
       number_access(re)=number_access(re)+1
C$OMP END CRITICAL
           .....

       enddo

C$OMP END PARALLEL

If I replace the CRITICAL directive by a ATOMIC directive the program 
does not work. Could it be due to memory inconsistency?. Should I add a 
FLUSH directive when using ATOMIC?. If yes, is it always necessary to 
add a FLUSH directive when using a ATOMIC directive?.

Thanks in advance for your help,

María J. Martín
Computer Architecture Group
University of A Coruña
Spain





More information about the Omp mailing list