[Bug libfortran/41157] dtime not consistent in times reported

2009-08-24 Thread kargl at gcc dot gnu dot org


--- 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,1  ! 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,1! 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.9939883E-04   9.9939883E-04   1.9987977E-03
 tarray,result:   3.86941999197E-01   0.000E+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



[Bug libfortran/41157] dtime not consistent in times reported

2009-08-24 Thread fkrogh#gcc at mathalacarte dot com


--- 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,1  ! 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,1! 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.000E+00   9.9939883E-04   9.9939883E-04
tarray,result:   3.80941987038E-01   3.0002608E-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



[Bug libfortran/41157] dtime not consistent in times reported

2009-08-24 Thread dominiq at lps dot ens dot fr


--- 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



[Bug libfortran/41157] dtime not consistent in times reported

2009-08-24 Thread dominiq at lps dot ens dot fr


--- 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



[Bug libfortran/41157] dtime not consistent in times reported

2009-08-24 Thread kargl at gcc dot gnu dot org


--- 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|-00-00 00:00:00 |2009-08-24 19:40:51
   date||


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



[Bug libfortran/41157] dtime not consistent in times reported

2009-08-24 Thread kargl at gcc dot gnu dot org


-- 

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



[Bug libfortran/41157] dtime not consistent in times reported

2009-08-24 Thread kargl at gcc dot gnu dot org


--- 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=gccview=revrev=151072
Log:
2009-08-24  Steven G. Kargl  ka...@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



[Bug libfortran/41157] dtime not consistent in times reported

2009-08-24 Thread kargl at gcc dot gnu dot org


--- 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=gccview=revrev=151073
Log:
2009-08-24  Steven G. Kargl  ka...@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



[Bug libfortran/41157] dtime not consistent in times reported

2009-08-24 Thread kargl at gcc dot gnu dot org


--- 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