public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/33445]  New: openmp invalid multi-thread runtime result (-ffree-form only!)
@ 2007-09-15 19:48 fred2 at qnet dot com
  2007-09-15 19:52 ` [Bug fortran/33445] " fred2 at qnet dot com
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: fred2 at qnet dot com @ 2007-09-15 19:48 UTC (permalink / raw)
  To: gcc-bugs

fortran code using openmp fails at runtime for multiple threads under
-ffree-form (but NOT -ffixed-form).
possibly due solely to treatment of continuation characters?

(tested only under gcc 4.1.2 (fedora core 7)

$ gcc -v
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --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 --with-cpu=generic
--host=x86_64-redhat-linux
Thread model: posix
gcc version 4.1.2 20070502 (Red Hat 4.1.2-12)

error vs. compilation flags:

source_file     gfortran_flags          OMP_NUM_THREADS run_time_result
(stdout)

md.f            (none)                  N/A (serial)    ok
md.f            -fopenmp                1               ok
md.f            -fopenmp                2               ok

mdfree.f        -ffree-form             N/A (serial)    ok
mdfree.f        -fopenmp -ffree-form    1               ok
mdfree.f        -fopenmp -ffree-form    2               NaN

mdfree.f90      (none)                  N/A (serial)    ok
mdfree.f90      -fopenmp                1               ok
mdfree.f90      -fopenmp                2               NaN



md.f is from http://www.openmp.org/drupal/samples/md.html
(note: nsteps is reduced from 1000 to 100 to speed up testing).

mdfree.f replaces the fixed-form continuation characters (in column 6) w/
the free-form (&):

$ diff md.f mdfree.f
41,42c41,42
<       call compute(nparts,ndim,box,position,velocity,mass,
<      .                                      force,potential,kinetic)
---
>       call compute(nparts,ndim,box,position,velocity,mass, &
>                                             force,potential,kinetic)
47,48c47,48
<           call compute(nparts,ndim,box,position,velocity,mass,
<      .                                      force,potential,kinetic)
---
>           call compute(nparts,ndim,box,position,velocity,mass, &
>                                             force,potential,kinetic)

mdfree.f90 is just renamed mdfree.f.


-- 
           Summary: openmp invalid multi-thread runtime result (-ffree-form
                    only!)
           Product: gcc
           Version: 4.1.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: fred2 at qnet dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33445


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug fortran/33445] openmp invalid multi-thread runtime result (-ffree-form only!)
  2007-09-15 19:48 [Bug fortran/33445] New: openmp invalid multi-thread runtime result (-ffree-form only!) fred2 at qnet dot com
@ 2007-09-15 19:52 ` fred2 at qnet dot com
  2007-09-17  6:41 ` burnus at gcc dot gnu dot org
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: fred2 at qnet dot com @ 2007-09-15 19:52 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from fred2 at qnet dot com  2007-09-15 19:52 -------
Created an attachment (id=14209)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=14209&action=view)
fixed-form source code (runs correctly). see bug description to duplicate error

this attachment (and bug description) was incorrectly omitted from bug 33444


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33445


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug fortran/33445] openmp invalid multi-thread runtime result (-ffree-form only!)
  2007-09-15 19:48 [Bug fortran/33445] New: openmp invalid multi-thread runtime result (-ffree-form only!) fred2 at qnet dot com
  2007-09-15 19:52 ` [Bug fortran/33445] " fred2 at qnet dot com
@ 2007-09-17  6:41 ` burnus at gcc dot gnu dot org
  2007-09-17  6:55 ` burnus at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-09-17  6:41 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from burnus at gcc dot gnu dot org  2007-09-17 06:40 -------
*** Bug 33444 has been marked as a duplicate of this bug. ***


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33445


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug fortran/33445] openmp invalid multi-thread runtime result (-ffree-form only!)
  2007-09-15 19:48 [Bug fortran/33445] New: openmp invalid multi-thread runtime result (-ffree-form only!) fred2 at qnet dot com
  2007-09-15 19:52 ` [Bug fortran/33445] " fred2 at qnet dot com
  2007-09-17  6:41 ` burnus at gcc dot gnu dot org
@ 2007-09-17  6:55 ` burnus at gcc dot gnu dot org
  2007-09-17  7:16 ` jakub at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-09-17  6:55 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from burnus at gcc dot gnu dot org  2007-09-17 06:55 -------
Looking at the dump (GCC 4.3), one sees for the fixed-format code:

     #pragma omp parallel default(shared) reduction(+:kin) reduction(+:pot)
private(d) private(rij) private(k) private(j) private(i)
        {
          {
            #pragma omp for nowait
            for (i = 1; i <= D.982; i = i + 1)

and for the free format, one finds:

      D.982 = *np;
      #pragma omp parallel private(k) private(j)
        {
          {
            #pragma omp for private(i) nowait
            for (i = 1; i <= D.982; i = i + 1)

In the source:

!$omp  parallel do
!$omp& default(shared)
!$omp& private(i,j,k,rij,d)
!$omp& reduction(+ : pot, kin)
      do i=1,np


-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu dot
                   |                            |org, burnus at gcc dot gnu
                   |                            |dot org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
           Keywords|                            |openmp, wrong-code
      Known to fail|                            |4.2.0 4.3.0
   Last reconfirmed|0000-00-00 00:00:00         |2007-09-17 06:55:32
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33445


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug fortran/33445] openmp invalid multi-thread runtime result (-ffree-form only!)
  2007-09-15 19:48 [Bug fortran/33445] New: openmp invalid multi-thread runtime result (-ffree-form only!) fred2 at qnet dot com
                   ` (2 preceding siblings ...)
  2007-09-17  6:55 ` burnus at gcc dot gnu dot org
@ 2007-09-17  7:16 ` jakub at gcc dot gnu dot org
  2007-09-17  7:40 ` burnus at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu dot org @ 2007-09-17  7:16 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from jakub at gcc dot gnu dot org  2007-09-17 07:16 -------
Why do you think that is a bug?
Please read OpenMP 2.5, 2.1.1 (Fixed Source Form Directives) and 2.1.2
(Free Source Form Directives).  Continuation is done very differently between
fixed and free form.  So, what are you citing above is a valid fixed form
continuation, but not a valid free form continuation:

10
11
12

2.1.2 has:
Continued directive lines must have an ampersand as the last nonblank character
on the line, prior to any comment placed inside the directive. Continuation
directive lines can have an ampersand after the directive sentinel with
optional white space before and after the ampersand.
while 2.1.1 has:
Initial directive lines must have a space or zero in column 6, and continuation
directive lines must have a character other than a space or a zero in column 6.


-- 

jakub at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |WAITING


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33445


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug fortran/33445] openmp invalid multi-thread runtime result (-ffree-form only!)
  2007-09-15 19:48 [Bug fortran/33445] New: openmp invalid multi-thread runtime result (-ffree-form only!) fred2 at qnet dot com
                   ` (3 preceding siblings ...)
  2007-09-17  7:16 ` jakub at gcc dot gnu dot org
@ 2007-09-17  7:40 ` burnus at gcc dot gnu dot org
  2007-09-17  8:53 ` [Bug fortran/33445] Diagnose "!$OMP&" as an error in free format unless it is a continuation line burnus at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-09-17  7:40 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from burnus at gcc dot gnu dot org  2007-09-17 07:40 -------
How about giving a diagnostic as ifort does:

fortcom: Error: test2.f90, line 93: Syntax error, found '&' when expecting one
of: <LABEL> <END-OF-STATEMENT> ; BLOCK BLOCKDATA PROGRAM TYPE COMPLEX BYTE
CHARACTER ...
!$omp& default(shared)
-------^

or like SUNF95 does:

!$omp& default(shared)
     ^
"test2.f90", Line = 93, Column = 6: ERROR: Unexpected syntax: "OpenMP directive
keyword" was expected but found "&".


-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|wrong-code                  |accepts-invalid


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33445


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug fortran/33445] Diagnose "!$OMP&" as an error in free format unless it is a continuation line
  2007-09-15 19:48 [Bug fortran/33445] New: openmp invalid multi-thread runtime result (-ffree-form only!) fred2 at qnet dot com
                   ` (4 preceding siblings ...)
  2007-09-17  7:40 ` burnus at gcc dot gnu dot org
@ 2007-09-17  8:53 ` burnus at gcc dot gnu dot org
  2007-09-19 13:18 ` fxcoudert at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-09-17  8:53 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from burnus at gcc dot gnu dot org  2007-09-17 08:53 -------
Jakub Jelinek wrote (in PR 33439, but seemingly regarding this PR):
> Pedantically this is not a bug.  If an omp sentinel doesn't have the desired
> form, it should be handled as a normal comment.  As the preceeding line
> doesn't end with &, then !$omp& is not a valid omp sentinel (as !$omp needs to
> be followed by a space) and thus it is the same as say
> ! $ omp & something
> That said, perhaps we could issue some diagnostics, because it is likely
> a user error rather than intent.

As this PR shows, this user error happens easily, if one converts a fixed-form
into a free-form code. Thus I'm in favour of printing a warning or - as ifort
and sunf95 do - an error.


-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |NEW
   Last reconfirmed|2007-09-17 06:55:32         |2007-09-17 08:53:10
               date|                            |
            Summary|openmp invalid multi-thread |Diagnose "!$OMP&" as an
                   |runtime result (-ffree-form |error in free format unless
                   |only!)                      |it is a continuation line


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33445


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug fortran/33445] Diagnose "!$OMP&" as an error in free format unless it is a continuation line
  2007-09-15 19:48 [Bug fortran/33445] New: openmp invalid multi-thread runtime result (-ffree-form only!) fred2 at qnet dot com
                   ` (5 preceding siblings ...)
  2007-09-17  8:53 ` [Bug fortran/33445] Diagnose "!$OMP&" as an error in free format unless it is a continuation line burnus at gcc dot gnu dot org
@ 2007-09-19 13:18 ` fxcoudert at gcc dot gnu dot org
  2007-09-19 13:46 ` burnus at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-09-19 13:18 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from fxcoudert at gcc dot gnu dot org  2007-09-19 13:18 -------
(In reply to comment #6)
> As this PR shows, this user error happens easily, if one converts a fixed-form
> into a free-form code. Thus I'm in favour of printing a warning or - as ifort
> and sunf95 do - an error.

Only a warning, please. Not an error for code that is, strictly speaking,
valid.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33445


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug fortran/33445] Diagnose "!$OMP&" as an error in free format unless it is a continuation line
  2007-09-15 19:48 [Bug fortran/33445] New: openmp invalid multi-thread runtime result (-ffree-form only!) fred2 at qnet dot com
                   ` (6 preceding siblings ...)
  2007-09-19 13:18 ` fxcoudert at gcc dot gnu dot org
@ 2007-09-19 13:46 ` burnus at gcc dot gnu dot org
  2007-09-19 14:11 ` jakub at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-09-19 13:46 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from burnus at gcc dot gnu dot org  2007-09-19 13:46 -------
(In reply to comment #6)
> > Pedantically this is not a bug. If an omp sentinel doesn't have the desired
> > form, it should be handled as a normal comment.

I cannot find anything about this in the OpenMP spec; I think the behaviour of
the compiler is undefined as this is invalid syntax. I don't find anything
which indicates that this has to/should/would be treated as comment.

(In reply to comment #7)
> Only a warning, please. Not an error for code that is, strictly speaking,
> valid.
I am actually in favour of an error unless someone can points out the part of
the spec which implies this is valid or a pice of code which shows that it
would be sensible to accept "!OMP$&" + garbage as comment.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33445


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug fortran/33445] Diagnose "!$OMP&" as an error in free format unless it is a continuation line
  2007-09-15 19:48 [Bug fortran/33445] New: openmp invalid multi-thread runtime result (-ffree-form only!) fred2 at qnet dot com
                   ` (7 preceding siblings ...)
  2007-09-19 13:46 ` burnus at gcc dot gnu dot org
@ 2007-09-19 14:11 ` jakub at gcc dot gnu dot org
  2007-09-22  1:37 ` patchapp at dberlin dot org
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu dot org @ 2007-09-19 14:11 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from jakub at gcc dot gnu dot org  2007-09-19 14:11 -------
Well, it is the Fortran standard that says free form comments start with !
And then OpenMP2.5 2.1.2 goes on and says certain forms of comments are not
to be treated as comments, but OpenMP directives etc.
One of them is !$omp followed by space, one of them is
!$omp& if the previous line was an openmp directive line ending with &.
Or !$ followed by space (for conditional compilation).
Anything else is a comment.
So an error would be wrong.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33445


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug fortran/33445] Diagnose "!$OMP&" as an error in free format unless it is a continuation line
  2007-09-15 19:48 [Bug fortran/33445] New: openmp invalid multi-thread runtime result (-ffree-form only!) fred2 at qnet dot com
                   ` (8 preceding siblings ...)
  2007-09-19 14:11 ` jakub at gcc dot gnu dot org
@ 2007-09-22  1:37 ` patchapp at dberlin dot org
  2007-09-22 14:21 ` burnus at gcc dot gnu dot org
  2007-09-22 14:28 ` burnus at gcc dot gnu dot org
  11 siblings, 0 replies; 13+ messages in thread
From: patchapp at dberlin dot org @ 2007-09-22  1:37 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from patchapp at dberlin dot org  2007-09-22 01:37 -------
Subject: Bug number PR33445

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is
http://gcc.gnu.org/ml/gcc-patches/2007-09/msg01683.html


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33445


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug fortran/33445] Diagnose "!$OMP&" as an error in free format unless it is a continuation line
  2007-09-15 19:48 [Bug fortran/33445] New: openmp invalid multi-thread runtime result (-ffree-form only!) fred2 at qnet dot com
                   ` (9 preceding siblings ...)
  2007-09-22  1:37 ` patchapp at dberlin dot org
@ 2007-09-22 14:21 ` burnus at gcc dot gnu dot org
  2007-09-22 14:28 ` burnus at gcc dot gnu dot org
  11 siblings, 0 replies; 13+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-09-22 14:21 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from burnus at gcc dot gnu dot org  2007-09-22 14:21 -------
Subject: Bug 33445

Author: burnus
Date: Sat Sep 22 14:20:57 2007
New Revision: 128670

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=128670
Log:
2007-09-22  Tobias Burnus  <burnus@net-b.de>

        PR fortran/33445
        * scanner.c (skip_free_comments): Warn if !$OMP& is used
        if no OpenMP directive is to be continued.

2007-09-22  Tobias Burnus  <burnus@net-b.de>

        PR fortran/33445
        * gfortran.dg/gomp/free-2.f90: New.
        * gfortran.dg/gomp/appendix-a/a.31.1.f90: Add missing &.
        * gfortran.dg/gomp/omp_parse1.f90: Add dg-warning.


Added:
    trunk/gcc/testsuite/gfortran.dg/gomp/free-2.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/scanner.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.31.1.f90
    trunk/gcc/testsuite/gfortran.dg/gomp/omp_parse1.f90


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33445


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug fortran/33445] Diagnose "!$OMP&" as an error in free format unless it is a continuation line
  2007-09-15 19:48 [Bug fortran/33445] New: openmp invalid multi-thread runtime result (-ffree-form only!) fred2 at qnet dot com
                   ` (10 preceding siblings ...)
  2007-09-22 14:21 ` burnus at gcc dot gnu dot org
@ 2007-09-22 14:28 ` burnus at gcc dot gnu dot org
  11 siblings, 0 replies; 13+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-09-22 14:28 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #12 from burnus at gcc dot gnu dot org  2007-09-22 14:27 -------
FIXED on the trunk (GCC 4.3.0).

For the example of the initial bug report, it prints now such messages:

!$omp& default(shared)
     1
Warning: !$OMP at (1) starts a commented line as it neither is followed by a
space nor is a continuation line


-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33445


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2007-09-22 14:28 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-15 19:48 [Bug fortran/33445] New: openmp invalid multi-thread runtime result (-ffree-form only!) fred2 at qnet dot com
2007-09-15 19:52 ` [Bug fortran/33445] " fred2 at qnet dot com
2007-09-17  6:41 ` burnus at gcc dot gnu dot org
2007-09-17  6:55 ` burnus at gcc dot gnu dot org
2007-09-17  7:16 ` jakub at gcc dot gnu dot org
2007-09-17  7:40 ` burnus at gcc dot gnu dot org
2007-09-17  8:53 ` [Bug fortran/33445] Diagnose "!$OMP&" as an error in free format unless it is a continuation line burnus at gcc dot gnu dot org
2007-09-19 13:18 ` fxcoudert at gcc dot gnu dot org
2007-09-19 13:46 ` burnus at gcc dot gnu dot org
2007-09-19 14:11 ` jakub at gcc dot gnu dot org
2007-09-22  1:37 ` patchapp at dberlin dot org
2007-09-22 14:21 ` burnus at gcc dot gnu dot org
2007-09-22 14:28 ` burnus at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).