[Omp] critical directive or openmp_*_lock library routines?
Shah, Sanjiv
sanjiv.shah at intel.com
Fri Jun 30 04:28:32 PDT 2006
Hi Daniel,
There should be no performance difference between using CRITICAL and
omp_lock. However, CRITICAL is global across the program whereas with
omp_locks, you can control who else has access to that lock.
Sanjiv
--
Sanjiv, 217-403-4244
-----Original Message-----
From: omp-bounces at openmp.org [mailto:omp-bounces at openmp.org] On Behalf
Of Daniel Franke
Sent: Friday, June 30, 2006 6:23 AM
To: omp at openmp.org
Subject: [Omp] critical directive or openmp_*_lock library routines?
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
_______________________________________________
Omp mailing list
Omp at openmp.org
http://openmp.org/mailman/listinfo/omp
More information about the Omp
mailing list