[Users] Fortran OpenMP parallel do
Erik Schnetter
schnetter at cct.lsu.edu
Tue Oct 29 19:53:33 CDT 2013
I have just found several instances of "OpenMP parallel do" constructs in GRHydro that did not mark loop variables as private. This is a severe parallelization error that can lead to wrong results in ways that are very difficult to debug.
I wonder why the compiler does not flag this. I suggest a code review before the release.
While it is true that the loop index of the loop that is parallelized (usually only the outermost loop) does, in Fortran, not have to be declared as private, all other loop indices still have to be declared as private. In C, all loop indices have to be declared as private. Personally, I find it simplest to just declare all loop indices as private.
This is correct:
!$OMP PARALLEL DO PRIVATE(i,j,k)
do k=1,nz
do j=1,ny
do i=1,nx
And this would be wrong:
!$OMP PARALLEL DO
do k=1,nz
do j=1,ny
do i=1,nx
-erik
--
Erik Schnetter <schnetter at cct.lsu.edu>
http://www.perimeterinstitute.ca/personal/eschnetter/
My email is as private as my paper mail. I therefore support encrypting
and signing email messages. Get my PGP key from http://pgp.mit.edu/.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 203 bytes
Desc: Message signed with OpenPGP using GPGMail
Url : http://lists.einsteintoolkit.org/pipermail/users/attachments/20131029/1363294a/attachment.bin
More information about the Users
mailing list