* [Bug libfortran/41157] dtime not consistent in times reported
2009-08-24 16:59 [Bug libfortran/41157] New: dtime not consistent in times reported fkrogh#gcc at mathalacarte dot com
@ 2009-08-24 17:20 ` kargl at gcc dot gnu dot org
2009-08-24 17:34 ` fkrogh#gcc at mathalacarte dot com
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: kargl at gcc dot gnu dot org @ 2009-08-24 17:20 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from kargl at gcc dot gnu dot org 2009-08-24 17:19 -------
(In reply to comment #0)
> The following code was compiled with
> gfortran -g -o test_dtime test_dtime.f
>
> The code is given by (very similar to that given in the info file for gfortran
>
> program test_dtime
> integer(8) :: i, j, k
> real, dimension(2) :: tarray
> real :: result
> real :: accum
> call dtime(tarray, result)
> print '(''tarray,result:'', 1P, 3E20.11)', tarray, result
> do i=1,100000000 ! Just a delay
> j = i * i - i
> end do
> call dtime(tarray, result)
> print '(''tarray,result:'', 1P, 3E20.11)', tarray, result
> accum = 0.e0 ! Should accumulate 10 times previous tarray(1)
> call dtime(tarray, result)
> do k=1, 10
> do i=1,100000000 ! Just a delay
> j = i * i - i
> end do
> call dtime(tarray, result)
> accum = accum + tarray(1)
> end do
> print '(''accum ='', 1P, E20.11 )', accum
> end program test_dtime
>
> The resulting output is
>
> tarray,result: 9.99000039883E-04 9.99000039883E-04 1.99800007977E-03
> tarray,result: 3.86941999197E-01 0.00000000000E+00 3.86941999197E-01
> accum = 1.35349416733E+01
>
> Note that accum should be close to 10 times the value the tarray(1) above, that
> is, close to 3.8. I have no idea where the 13.5... came from.
>
Why should it be close to 3.8?
dtime returns the time since the start of the process?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41157
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libfortran/41157] dtime not consistent in times reported
2009-08-24 16:59 [Bug libfortran/41157] New: dtime not consistent in times reported fkrogh#gcc at mathalacarte dot com
2009-08-24 17:20 ` [Bug libfortran/41157] " kargl at gcc dot gnu dot org
@ 2009-08-24 17:34 ` fkrogh#gcc at mathalacarte dot com
2009-08-24 17:45 ` dominiq at lps dot ens dot fr
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: fkrogh#gcc at mathalacarte dot com @ 2009-08-24 17:34 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from fkrogh#gcc at mathalacarte dot com 2009-08-24 17:34 -------
I had thought that was the case as well. But when I started getting some
negative times by subtracting the previous value from the current one in the
first location of the array I looked at the info file and found
Subsequent invocations of `DTIME' return values accumulated since
the previous invocation.
I modified the code to compute the times between invocations. The code now
looks like
program test_dtime
integer(8) :: i, j, k
real, dimension(2) :: tarray
real :: result
real :: accum, tarray1
real :: ptimes(10)
call dtime(tarray, result)
print '(''tarray,result:'', 1P, 3E20.11)', tarray, result
do i=1,100000000 ! Just a delay
j = i * i - i
end do
call dtime(tarray, result)
print '(''tarray,result:'', 1P, 3E20.11)', tarray, result
accum = 0.e0 ! Should accumulate 10 times previous tarray(1)
call dtime(tarray, result)
tarray1 = tarray(1)
do k=1, 10
do i=1,100000000 ! Just a delay
j = i * i - i
end do
call dtime(tarray, result)
ptimes(k) = tarray(1) - tarray1
tarray1 = tarray(1)
accum = accum + tarray(1)
end do
print '(''accum ='', 1P, E20.11 )', accum
print '(''ptimes ='', 1P, (3E20.11))', ptimes
end program test_dtime
And the output is
tarray,result: 0.00000000000E+00 9.99000039883E-04 9.99000039883E-04
tarray,result: 3.80941987038E-01 3.00000002608E-03 3.83941978216E-01
accum = 1.34219570160E+01
ptimes = 7.64882981777E-01 -3.78940939903E-01 7.60881841183E-01
-3.77939820290E-01 7.63881921768E-01 -3.80940914154E-01
7.63882875443E-01 -3.78940820694E-01 7.61881709099E-01
-3.78939628601E-01
There is a pattern here, but why? If dtime is getting overflows in times less
than a few seconds, there is a problem as well.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41157
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libfortran/41157] dtime not consistent in times reported
2009-08-24 16:59 [Bug libfortran/41157] New: dtime not consistent in times reported fkrogh#gcc at mathalacarte dot com
2009-08-24 17:20 ` [Bug libfortran/41157] " kargl at gcc dot gnu dot org
2009-08-24 17:34 ` fkrogh#gcc at mathalacarte dot com
@ 2009-08-24 17:45 ` dominiq at lps dot ens dot fr
2009-08-24 18:16 ` dominiq at lps dot ens dot fr
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: dominiq at lps dot ens dot fr @ 2009-08-24 17:45 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from dominiq at lps dot ens dot fr 2009-08-24 17:45 -------
> dtime returns the time since the start of the process?
The manual says:
Subsequent invocations of DTIME return values accumulated since the previous
invocation.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41157
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libfortran/41157] dtime not consistent in times reported
2009-08-24 16:59 [Bug libfortran/41157] New: dtime not consistent in times reported fkrogh#gcc at mathalacarte dot com
` (2 preceding siblings ...)
2009-08-24 17:45 ` dominiq at lps dot ens dot fr
@ 2009-08-24 18:16 ` dominiq at lps dot ens dot fr
2009-08-24 19:41 ` kargl at gcc dot gnu dot org
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: dominiq at lps dot ens dot fr @ 2009-08-24 18:16 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from dominiq at lps dot ens dot fr 2009-08-24 18:16 -------
If I am not mistaken, the dtime behavior change between 4.2 and 4.3.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41157
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libfortran/41157] dtime not consistent in times reported
2009-08-24 16:59 [Bug libfortran/41157] New: dtime not consistent in times reported fkrogh#gcc at mathalacarte dot com
` (3 preceding siblings ...)
2009-08-24 18:16 ` dominiq at lps dot ens dot fr
@ 2009-08-24 19:41 ` kargl at gcc dot gnu dot org
2009-08-24 19:41 ` kargl at gcc dot gnu dot org
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: kargl at gcc dot gnu dot org @ 2009-08-24 19:41 UTC (permalink / raw)
To: gcc-bugs
--
kargl at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |kargl at gcc dot gnu dot org
|dot org |
Status|NEW |ASSIGNED
Last reconfirmed|2009-08-24 19:40:51 |2009-08-24 19:41:06
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41157
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libfortran/41157] dtime not consistent in times reported
2009-08-24 16:59 [Bug libfortran/41157] New: dtime not consistent in times reported fkrogh#gcc at mathalacarte dot com
` (4 preceding siblings ...)
2009-08-24 19:41 ` kargl at gcc dot gnu dot org
@ 2009-08-24 19:41 ` kargl at gcc dot gnu dot org
2009-08-24 20:54 ` kargl at gcc dot gnu dot org
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: kargl at gcc dot gnu dot org @ 2009-08-24 19:41 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from kargl at gcc dot gnu dot org 2009-08-24 19:40 -------
Confirmed.
I have a patch.
--
kargl at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2009-08-24 19:40:51
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41157
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libfortran/41157] dtime not consistent in times reported
2009-08-24 16:59 [Bug libfortran/41157] New: dtime not consistent in times reported fkrogh#gcc at mathalacarte dot com
` (5 preceding siblings ...)
2009-08-24 19:41 ` kargl at gcc dot gnu dot org
@ 2009-08-24 20:54 ` kargl at gcc dot gnu dot org
2009-08-25 1:47 ` kargl at gcc dot gnu dot org
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: kargl at gcc dot gnu dot org @ 2009-08-24 20:54 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from kargl at gcc dot gnu dot org 2009-08-24 20:53 -------
Patch is here:
http://gcc.gnu.org/ml/gcc-patches/2009-08/msg01311.html
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41157
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libfortran/41157] dtime not consistent in times reported
2009-08-24 16:59 [Bug libfortran/41157] New: dtime not consistent in times reported fkrogh#gcc at mathalacarte dot com
` (6 preceding siblings ...)
2009-08-24 20:54 ` kargl at gcc dot gnu dot org
@ 2009-08-25 1:47 ` kargl at gcc dot gnu dot org
2009-08-25 3:30 ` kargl at gcc dot gnu dot org
2009-08-25 3:33 ` kargl at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: kargl at gcc dot gnu dot org @ 2009-08-25 1:47 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from kargl at gcc dot gnu dot org 2009-08-25 01:47 -------
Subject: Bug 41157
Author: kargl
Date: Tue Aug 25 01:47:23 2009
New Revision: 151072
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=151072
Log:
2009-08-24 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/41157
* dtime.c (dtime_sub): Fix computing time increment.
* time_1.h: Add <sys/types.h> header. Use RUSAGE_SELF macro instead
of a hardcoded 0.
Modified:
trunk/libgfortran/ChangeLog
trunk/libgfortran/intrinsics/dtime.c
trunk/libgfortran/intrinsics/time_1.h
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41157
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libfortran/41157] dtime not consistent in times reported
2009-08-24 16:59 [Bug libfortran/41157] New: dtime not consistent in times reported fkrogh#gcc at mathalacarte dot com
` (7 preceding siblings ...)
2009-08-25 1:47 ` kargl at gcc dot gnu dot org
@ 2009-08-25 3:30 ` kargl at gcc dot gnu dot org
2009-08-25 3:33 ` kargl at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: kargl at gcc dot gnu dot org @ 2009-08-25 3:30 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from kargl at gcc dot gnu dot org 2009-08-25 03:30 -------
Subject: Bug 41157
Author: kargl
Date: Tue Aug 25 03:30:25 2009
New Revision: 151073
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=151073
Log:
2009-08-24 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/41157
* dtime.c (dtime_sub): Fix computing time increment.
* time_1.h: Add <sys/types.h> header. Use RUSAGE_SELF macro instead
of a hardcoded 0.
Modified:
branches/gcc-4_4-branch/libgfortran/ChangeLog
branches/gcc-4_4-branch/libgfortran/intrinsics/dtime.c
branches/gcc-4_4-branch/libgfortran/intrinsics/time_1.h
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41157
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libfortran/41157] dtime not consistent in times reported
2009-08-24 16:59 [Bug libfortran/41157] New: dtime not consistent in times reported fkrogh#gcc at mathalacarte dot com
` (8 preceding siblings ...)
2009-08-25 3:30 ` kargl at gcc dot gnu dot org
@ 2009-08-25 3:33 ` kargl at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: kargl at gcc dot gnu dot org @ 2009-08-25 3:33 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from kargl at gcc dot gnu dot org 2009-08-25 03:33 -------
Fixed on trunk and 4.4.
Thanks for the bug report.
--
kargl at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
Target Milestone|--- |4.4.3
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41157
^ permalink raw reply [flat|nested] 11+ messages in thread