public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/35355]  New: Result of call cpu_time(x) can decrease or give non credible values with repeated calls
@ 2008-02-24 22:54 edunlop at utvinternet dot ie
  2008-02-24 22:56 ` [Bug fortran/35355] " edunlop at utvinternet dot ie
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: edunlop at utvinternet dot ie @ 2008-02-24 22:54 UTC (permalink / raw)
  To: gcc-bugs

Inconsistent or odd "call cpu_time(x)" behaviour on the current release of
gfortran. I am using the 32 bit Mingw version of gfortran.

C:\>gfortran -v
Using built-in specs.
Target: i386-pc-mingw32
Configured with: ../trunk/configure --prefix=/mingw
--enable-languages=c,fortran --with-gmp=/home/FX/local --with-ld=/mingw/bin/ld
--with-as=/mingw/bin/as --disable-werror --enable-bootstrap --enable-threads
--disable-nls --build=i386-pc-mingw32 --enable-libgomp --disable-shared
Thread model: win32
gcc version 4.3.0 20080127 (experimental) [trunk revision 131883] (GCC)

The "call cpu_time(x)" operations worked perfectly under a fairly recent
previous release of gfortran (sorry, I no longer have the version info).

I have declared x as follows:-

integer,parameter :: pr=selected_real_kind(6,37)
real(kind=pr) :: x

Unfortunately my code is very lengthy - but I could send it as an example if
really necessary.

Edmund Dunlop.


-- 
           Summary: Result of call cpu_time(x) can decrease or give non
                    credible values with repeated calls
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: edunlop at utvinternet dot ie


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


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

* [Bug fortran/35355] Result of call cpu_time(x) can decrease or give non credible values with repeated calls
  2008-02-24 22:54 [Bug fortran/35355] New: Result of call cpu_time(x) can decrease or give non credible values with repeated calls edunlop at utvinternet dot ie
@ 2008-02-24 22:56 ` edunlop at utvinternet dot ie
  2008-03-01 16:06 ` jvdelisle at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: edunlop at utvinternet dot ie @ 2008-02-24 22:56 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from edunlop at utvinternet dot ie  2008-02-24 22:55 -------
Inconsistent or odd "call cpu_time(x)" behaviour on the current release of
gfortran. I am using the 32 bit Mingw version of gfortran.

C:\>gfortran -v
Using built-in specs.
Target: i386-pc-mingw32
Configured with: ../trunk/configure --prefix=/mingw
--enable-languages=c,fortran --with-gmp=/home/FX/local --with-ld=/mingw/bin/ld
--with-as=/mingw/bin/as --disable-werror --enable-bootstrap --enable-threads
--disable-nls --build=i386-pc-mingw32 --enable-libgomp --disable-shared
Thread model: win32
gcc version 4.3.0 20080127 (experimental) [trunk revision 131883] (GCC)

The "call cpu_time(x)" operations worked perfectly under a fairly recent
previous release of gfortran (sorry, I no longer have the version info).

I have declared x as follows:-

integer,parameter :: pr=selected_real_kind(6,37)
real(kind=pr) :: x

Unfortunately my code is very lengthy - but I could send it as an example if
really necessary.

Edmund Dunlop.


-- 


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


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

* [Bug fortran/35355] Result of call cpu_time(x) can decrease or give non credible values with repeated calls
  2008-02-24 22:54 [Bug fortran/35355] New: Result of call cpu_time(x) can decrease or give non credible values with repeated calls edunlop at utvinternet dot ie
  2008-02-24 22:56 ` [Bug fortran/35355] " edunlop at utvinternet dot ie
@ 2008-03-01 16:06 ` jvdelisle at gcc dot gnu dot org
  2008-03-01 16:49 ` [Bug libfortran/35355] " fxcoudert at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2008-03-01 16:06 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from jvdelisle at gcc dot gnu dot org  2008-03-01 16:06 -------
Are you using your own build of gfortran on mingw or one obtained from
elsewhere and where?

Are the time intervals so short that you could be seeing roundoff?

Could the time intervals be wrapping around?

The last modification to cpu_time was in 12-25-2007.  Do you have an idea when
this last worked for you?


-- 


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


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

* [Bug libfortran/35355] Result of call cpu_time(x) can decrease or give non credible values with repeated calls
  2008-02-24 22:54 [Bug fortran/35355] New: Result of call cpu_time(x) can decrease or give non credible values with repeated calls edunlop at utvinternet dot ie
  2008-02-24 22:56 ` [Bug fortran/35355] " edunlop at utvinternet dot ie
  2008-03-01 16:06 ` jvdelisle at gcc dot gnu dot org
@ 2008-03-01 16:49 ` fxcoudert at gcc dot gnu dot org
  2008-03-01 16:53 ` [Bug libfortran/35355] [4.3/4.4 regression] CPU_TIME gives wrong values on mingw fxcoudert at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2008-03-01 16:49 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from fxcoudert at gcc dot gnu dot org  2008-03-01 16:49 -------
I've built new binaries today and I can also see it  :(

$ cat a.f90
implicit none
integer, parameter :: pr = selected_real_kind (6,37)
real(kind=pr) :: t
integer ,parameter :: n = 1000
real :: x(n,n), y(n,n), z(n,n)

call cpu_time(t)
print *, t
call flush()
z = matmul(x,y)
call cpu_time(t)
print *, t
call flush()
z = matmul(x,y)
call cpu_time(t)
print *, t
call flush()
z = matmul(x,y)
call cpu_time(t)
print *, t
call flush()
end

$ gfortran.exe a.f90 && a
  0.46875000    
   8.5625000    
   8.5937500    
   17.000000    

I've spotted the issue: the Windows FILETIME structure stores time as a "number
of 100-nanosecond intervals". So, to get to our usual microseconds, we need to
divide by 10 (we're not loosing any precision, because Windows doesn't have
100ns resolution anyway). But, Daniel's 2007-12-25 patch reworked the code and
remove the division by 10. Thus, we're now storing tens of microseconds in the
usec variables, which leads to wrong results in the end.

A possible patch is:

Index: time_1.h
===================================================================
--- time_1.h    (revision 132800)
+++ time_1.h    (working copy)
@@ -104,10 +104,10 @@
                   &kernel_time.ft, &user_time.ft);

   *user_sec = user_time.ulltime / 10000000;
-  *user_usec = user_time.ulltime % 10000000;
+  *user_usec = (user_time.ulltime % 10000000) / 10;

   *system_sec = kernel_time.ulltime / 10000000;
-  *system_usec = kernel_time.ulltime % 10000000;
+  *system_usec = (kernel_time.ulltime % 10000000) / 10;
   return 0;
 }


-- 

fxcoudert at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dfranke at gcc dot gnu dot
                   |                            |org, fxcoudert at gcc dot
                   |                            |gnu dot org
             Status|UNCONFIRMED                 |NEW
          Component|fortran                     |libfortran
     Ever Confirmed|0                           |1
 GCC target triplet|                            |i586-pc-mingw32
           Keywords|                            |patch, wrong-code
   Last reconfirmed|0000-00-00 00:00:00         |2008-03-01 16:49:05
               date|                            |
   Target Milestone|---                         |4.3.0


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


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

* [Bug libfortran/35355] [4.3/4.4 regression] CPU_TIME gives wrong values on mingw
  2008-02-24 22:54 [Bug fortran/35355] New: Result of call cpu_time(x) can decrease or give non credible values with repeated calls edunlop at utvinternet dot ie
                   ` (2 preceding siblings ...)
  2008-03-01 16:49 ` [Bug libfortran/35355] " fxcoudert at gcc dot gnu dot org
@ 2008-03-01 16:53 ` fxcoudert at gcc dot gnu dot org
  2008-03-01 18:03 ` jvdelisle at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2008-03-01 16:53 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from fxcoudert at gcc dot gnu dot org  2008-03-01 16:52 -------
This change is built and tested on i586-pc-mingw32. If approved, we should try
to get it into 4.3.0 if it's still possible.


-- 

fxcoudert at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |4.3.0 4.4.0
      Known to work|                            |4.2.0
            Summary|Result of call cpu_time(x)  |[4.3/4.4 regression]
                   |can decrease or give non    |CPU_TIME gives wrong values
                   |credible values with        |on mingw
                   |repeated calls              |


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


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

* [Bug libfortran/35355] [4.3/4.4 regression] CPU_TIME gives wrong values on mingw
  2008-02-24 22:54 [Bug fortran/35355] New: Result of call cpu_time(x) can decrease or give non credible values with repeated calls edunlop at utvinternet dot ie
                   ` (3 preceding siblings ...)
  2008-03-01 16:53 ` [Bug libfortran/35355] [4.3/4.4 regression] CPU_TIME gives wrong values on mingw fxcoudert at gcc dot gnu dot org
@ 2008-03-01 18:03 ` jvdelisle at gcc dot gnu dot org
  2008-03-01 22:11 ` jvdelisle at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2008-03-01 18:03 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from jvdelisle at gcc dot gnu dot org  2008-03-01 18:02 -------
Patch is approved for trunk.  I agree it should go to 4.3.


-- 


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


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

* [Bug libfortran/35355] [4.3/4.4 regression] CPU_TIME gives wrong values on mingw
  2008-02-24 22:54 [Bug fortran/35355] New: Result of call cpu_time(x) can decrease or give non credible values with repeated calls edunlop at utvinternet dot ie
                   ` (4 preceding siblings ...)
  2008-03-01 18:03 ` jvdelisle at gcc dot gnu dot org
@ 2008-03-01 22:11 ` jvdelisle at gcc dot gnu dot org
  2008-03-01 22:16 ` jvdelisle at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2008-03-01 22:11 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from jvdelisle at gcc dot gnu dot org  2008-03-01 22:11 -------
Subject: Bug 35355

Author: jvdelisle
Date: Sat Mar  1 22:10:30 2008
New Revision: 132807

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=132807
Log:
2008-03-01  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>

        PR libfortran/35355
        * intrinsics/time_1.h (__time_1): Fix calculation of user_usec
        for mingw.

Modified:
    branches/gcc-4_3-branch/libgfortran/ChangeLog
    branches/gcc-4_3-branch/libgfortran/intrinsics/time_1.h


-- 


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


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

* [Bug libfortran/35355] [4.3/4.4 regression] CPU_TIME gives wrong values on mingw
  2008-02-24 22:54 [Bug fortran/35355] New: Result of call cpu_time(x) can decrease or give non credible values with repeated calls edunlop at utvinternet dot ie
                   ` (5 preceding siblings ...)
  2008-03-01 22:11 ` jvdelisle at gcc dot gnu dot org
@ 2008-03-01 22:16 ` jvdelisle at gcc dot gnu dot org
  2008-03-02  2:21 ` jvdelisle at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2008-03-01 22:16 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from jvdelisle at gcc dot gnu dot org  2008-03-01 22:16 -------
Subject: Bug 35355

Author: jvdelisle
Date: Sat Mar  1 22:15:31 2008
New Revision: 132808

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=132808
Log:
2008-03-01  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>

        PR libfortran/35355
        * intrinsics/time_1.h (__time_1): Fix calculation of user_usec
        for mingw.

Modified:
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/intrinsics/time_1.h


-- 


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


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

* [Bug libfortran/35355] [4.3/4.4 regression] CPU_TIME gives wrong values on mingw
  2008-02-24 22:54 [Bug fortran/35355] New: Result of call cpu_time(x) can decrease or give non credible values with repeated calls edunlop at utvinternet dot ie
                   ` (6 preceding siblings ...)
  2008-03-01 22:16 ` jvdelisle at gcc dot gnu dot org
@ 2008-03-02  2:21 ` jvdelisle at gcc dot gnu dot org
  2008-03-02 11:00 ` e-dunlop at versanet dot de
  2008-03-02 18:44 ` dfranke at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2008-03-02  2:21 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from jvdelisle at gcc dot gnu dot org  2008-03-02 02:20 -------
Fixed on 4.3 and 4.4


-- 

jvdelisle at gcc dot gnu dot org changed:

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


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


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

* [Bug libfortran/35355] [4.3/4.4 regression] CPU_TIME gives wrong values on mingw
  2008-02-24 22:54 [Bug fortran/35355] New: Result of call cpu_time(x) can decrease or give non credible values with repeated calls edunlop at utvinternet dot ie
                   ` (7 preceding siblings ...)
  2008-03-02  2:21 ` jvdelisle at gcc dot gnu dot org
@ 2008-03-02 11:00 ` e-dunlop at versanet dot de
  2008-03-02 18:44 ` dfranke at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: e-dunlop at versanet dot de @ 2008-03-02 11:00 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from e-dunlop at versanet dot de  2008-03-02 11:00 -------
Subject: Fw: Bug libfortran/35355

Many thanks for your input into the repair of my reported bug. Your work is 
really appreciated - and the process is so much better than (commercial) 
Intel.

Best wishes, Edmund Dunlop. 


-- 


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


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

* [Bug libfortran/35355] [4.3/4.4 regression] CPU_TIME gives wrong values on mingw
  2008-02-24 22:54 [Bug fortran/35355] New: Result of call cpu_time(x) can decrease or give non credible values with repeated calls edunlop at utvinternet dot ie
                   ` (8 preceding siblings ...)
  2008-03-02 11:00 ` e-dunlop at versanet dot de
@ 2008-03-02 18:44 ` dfranke at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: dfranke at gcc dot gnu dot org @ 2008-03-02 18:44 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from dfranke at gcc dot gnu dot org  2008-03-02 18:43 -------
Sorry for the regression and many thank for fixing it so quickly!
(I was out of town over the weekend, so I couldn't participate here.)


-- 


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


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

end of thread, other threads:[~2008-03-02 18:44 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-24 22:54 [Bug fortran/35355] New: Result of call cpu_time(x) can decrease or give non credible values with repeated calls edunlop at utvinternet dot ie
2008-02-24 22:56 ` [Bug fortran/35355] " edunlop at utvinternet dot ie
2008-03-01 16:06 ` jvdelisle at gcc dot gnu dot org
2008-03-01 16:49 ` [Bug libfortran/35355] " fxcoudert at gcc dot gnu dot org
2008-03-01 16:53 ` [Bug libfortran/35355] [4.3/4.4 regression] CPU_TIME gives wrong values on mingw fxcoudert at gcc dot gnu dot org
2008-03-01 18:03 ` jvdelisle at gcc dot gnu dot org
2008-03-01 22:11 ` jvdelisle at gcc dot gnu dot org
2008-03-01 22:16 ` jvdelisle at gcc dot gnu dot org
2008-03-02  2:21 ` jvdelisle at gcc dot gnu dot org
2008-03-02 11:00 ` e-dunlop at versanet dot de
2008-03-02 18:44 ` dfranke 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).