[Omp] critical directive or openmp_*_lock library routines?
Daniel Franke
franke.daniel at gmail.com
Fri Jun 30 04:23:20 PDT 2006
Hi all.
I'm new to openmp programming an wondered whether there's a
significant difference (or preference) between a CRITICAL directive
and the openmp_*_lock library routines.
I would like to serialize the access to a specfic variable (or an I/O
unit). Assume a fortran module containing several subroutines that
write messages to unit fd.
[...]
!$OMP CRITICAL
WRITE (UNIT=fd,*) 'this will not be garbled by multiple threads'
!$OMP END CRITICAL
[...]
[...]
OMP_SET_LOCK(fdmutex)
WRITE (UNIT=fd,*) 'this will neither be garbled by multiple threads'
OMP_UNSET_LOCK(fdmutex)
[...]
The lock variable fdmutex is assumed to be a private variable within
the containing module and was initialzed by OMP_INIT_LOCK.
Which of both methods is preferable if the subroutine is regularly
called? Are there any other (non-OMP) methods of mutexes/locking
available in fortran? (I'm using the intel fortran compiler ifort as
well as gfortran from gcc. The latter has no omp implementation yet.)
Thanks in advance!
With kind regards
Daniel
More information about the Omp
mailing list