This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
OpenMP and local arrays
- From: "Asher Langton" <langton2 at llnl dot gov>
- To: fortran at gcc dot gnu dot org
- Date: Tue, 31 Jul 2007 17:41:45 -0700
- Subject: OpenMP and local arrays
- Dkim-signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition:x-google-sender-auth; b=rCUhrZf3yIKsQvCKcYzIA8x/d8W2400JvCwZuRxb293BVTWTvnCJZfxTT6G30Ea4ceOQyWr37priOnP82V9P7nSgP0+jJTVdXxEjGHXgWJhxRcxNd3wLy1g4U57MKh20nD7x8IXBpD5jGQtlBRNloXkwyfPGN0IGXyaEPSQ63uA=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:sender:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition:x-google-sender-auth; b=YhC8AWJKCXZoGYZ1UU9Ko+LVH+XvnSDhpIEpjb9btJ2CmzSJFDUCDQAVFHZK3q9eSMlNvn3wxReiQaOPl4Np2XR/ohFYZZ3LQCbfRVVBJWXJoSKhPKIkPUvQCOO1L+vWQgbX/u3+ncEuzsQRsNzQ3koTCX3ToL87qeJLvnvVBAU=
Hi all,
Here's a strange problem involving OpenMP and local arrays that are
treated as static:
program rd
implicit none
integer id
integer omp_get_thread_num
!$omp parallel private (id)
id = omp_get_thread_num()
call foo (id)
!$omp end parallel
end program rd
subroutine foo (id)
implicit none
integer id
real x(100,100)
print *,"thread",id,"loc(x)",loc(x)
end subroutine foo
Using 'ifort -openmp' or 'pgf90 -mp', each thread has its own copy of
the array x. However, with 'gfortran -fopenmp', all of the threads
are competing for the same copy of x. It appears that ifort's
'-openmp' implies '-auto', and pgf90's '-mp' invokes an internal flag
called '-nostatic' (equivalent to '-Mrecursive', I think).
I couldn't find a comparable flag in gfortran to invoke with
'-fopenmp'. The '-fautomatic' flag (which is on by default) is not
the same as ifort's '-auto', is it? It seems to just be the opposite
of '-fno-automatic', but doesn't necessarily make all locally-scoped
variables automatic. Is there any flag that can be set automatically
by -fopenmp to force local variables to be automatic?
Thanks,
Asher