Gfortran OpenMP SINGLE vs MASTER

Matt Fago fago@earthlink.net
Wed Dec 30 16:41:00 GMT 2009


I seem to have run into an issue with OMP SINGLE on gfortran 4.3.0. For 
the code snippet:

!$OMP SINGLE
        write(*,*) " -- work --", omp_get_thread_num()
        ! Do things that must only be done once
!$OMP END SINGLE

about half-way through the program execution I start getting output from
each thread. Perhaps memory corruption (stomping on libgomp), but valgrind
does not show anything. If I change it to MASTER everything works ok. 
Intel Fortran and FSF gcc 4.4.0 also works ok (neither would be surprising 
if it were a memory issue).

While the original code is proprietary, I seem to have come up with a
reproducer, attached. Compiled simply with 'gfortran -fopenmp single-issue.f'
it seems to me that the output should be similar to:

  [...]
  -- work --           0
  5.07060315875970166E+032
  [...]

which is what I get from gfortran 4.4, but the compiler in question (after 
a while) gives:

  [...]
  -- work --           2
  -- work --           6
  -- work --           1
  -- work --           0
  -- work --           3
  -- work --           4
  -- work --           7
  -- work --           5
  2.23157245055165944E+036
  [...]

As shown below, this is with gfortran 4.3.0 from Fedora 9. As Fedora 9 is 
no longer supported, asking at RedHat would probably not be useful. Does 
someone have a build of fsf gcc 4.3.X that they could test on (or 
should I build one), or is 4.5 so close that it is probably best to just
switch to gfortran 4.4? Alternatively, perhaps I'm just very confused about
something...

I can also certainly open a bug (I didn't find a previous report), but 
thought it best to ask first, due to the issue with Redhat and the 
impending 4.5.


Thank you,
Matt


This is on gfortran -v:

Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info 
--with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared 
--enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit 
--disable-libunwind-exceptions --enable-languages=c,c++,objc,obj-c++,java,fortran,ada 
--enable-java-awt=gtk --disable-dssi --enable-plugin 
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile 
--enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar 
--disable-libjava-multilib --with-cpu=generic --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.3.0 20080428 (Red Hat 4.3.0-8) (GCC)



-------------- next part --------------
A non-text attachment was scrubbed...
Name: single-issue.f
Type: application/octet-stream
Size: 1196 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20091230/1d0d75b1/attachment.obj>


More information about the Fortran mailing list