mirror of git://gcc.gnu.org/git/gcc.git
re PR libfortran/41157 (dtime not consistent in times reported)
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. From-SVN: r151072
This commit is contained in:
parent
1ed659c18d
commit
4551438c75
|
@ -1,3 +1,10 @@
|
||||||
|
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.
|
||||||
|
|
||||||
2009-08-24 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
|
2009-08-24 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
|
||||||
|
|
||||||
* configure.ac (AC_PREREQ): Bump to 2.64.
|
* configure.ac (AC_PREREQ): Bump to 2.64.
|
||||||
|
|
|
@ -38,9 +38,10 @@ iexport_proto(dtime_sub);
|
||||||
void
|
void
|
||||||
dtime_sub (gfc_array_r4 *t, GFC_REAL_4 *result)
|
dtime_sub (gfc_array_r4 *t, GFC_REAL_4 *result)
|
||||||
{
|
{
|
||||||
static GFC_REAL_4 tu = 0.0, ts = 0.0, tt = 0.0;
|
|
||||||
GFC_REAL_4 *tp;
|
GFC_REAL_4 *tp;
|
||||||
long user_sec, user_usec, system_sec, system_usec;
|
long user_sec, user_usec, system_sec, system_usec;
|
||||||
|
static long us = 0, uu = 0, ss = 0 , su = 0;
|
||||||
|
GFC_REAL_4 tu, ts, tt;
|
||||||
|
|
||||||
if (((GFC_DESCRIPTOR_EXTENT(t,0))) < 2)
|
if (((GFC_DESCRIPTOR_EXTENT(t,0))) < 2)
|
||||||
runtime_error ("Insufficient number of elements in TARRAY.");
|
runtime_error ("Insufficient number of elements in TARRAY.");
|
||||||
|
@ -48,15 +49,19 @@ dtime_sub (gfc_array_r4 *t, GFC_REAL_4 *result)
|
||||||
__gthread_mutex_lock (&dtime_update_lock);
|
__gthread_mutex_lock (&dtime_update_lock);
|
||||||
if (__time_1 (&user_sec, &user_usec, &system_sec, &system_usec) == 0)
|
if (__time_1 (&user_sec, &user_usec, &system_sec, &system_usec) == 0)
|
||||||
{
|
{
|
||||||
tu = (GFC_REAL_4)(user_sec + 1.e-6 * user_usec) - tu;
|
tu = (GFC_REAL_4) ((user_sec - us) + 1.e-6 * (user_usec - uu));
|
||||||
ts = (GFC_REAL_4)(system_sec + 1.e-6 * system_usec) - ts;
|
ts = (GFC_REAL_4) ((system_sec - ss) + 1.e-6 * (system_usec - su));
|
||||||
tt = tu + ts;
|
tt = tu + ts;
|
||||||
|
us = user_sec;
|
||||||
|
uu = user_usec;
|
||||||
|
ss = system_sec;
|
||||||
|
su = system_usec;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tu = (GFC_REAL_4)-1.0;
|
tu = -1;
|
||||||
ts = (GFC_REAL_4)-1.0;
|
ts = -1;
|
||||||
tt = (GFC_REAL_4)-1.0;
|
tt = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
tp = t->data;
|
tp = t->data;
|
||||||
|
|
|
@ -51,6 +51,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_SYS_TYPES_H
|
||||||
|
#include <sys/types.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
/* The most accurate way to get the CPU time is getrusage (). */
|
/* The most accurate way to get the CPU time is getrusage (). */
|
||||||
#if defined (HAVE_GETRUSAGE) && defined (HAVE_SYS_RESOURCE_H)
|
#if defined (HAVE_GETRUSAGE) && defined (HAVE_SYS_RESOURCE_H)
|
||||||
# include <sys/resource.h>
|
# include <sys/resource.h>
|
||||||
|
@ -112,7 +116,7 @@ __time_1 (long *user_sec, long *user_usec, long *system_sec, long *system_usec)
|
||||||
{
|
{
|
||||||
#if defined (HAVE_GETRUSAGE) && defined (HAVE_SYS_RESOURCE_H)
|
#if defined (HAVE_GETRUSAGE) && defined (HAVE_SYS_RESOURCE_H)
|
||||||
struct rusage usage;
|
struct rusage usage;
|
||||||
getrusage (0, &usage);
|
getrusage (RUSAGE_SELF, &usage);
|
||||||
|
|
||||||
*user_sec = usage.ru_utime.tv_sec;
|
*user_sec = usage.ru_utime.tv_sec;
|
||||||
*user_usec = usage.ru_utime.tv_usec;
|
*user_usec = usage.ru_utime.tv_usec;
|
||||||
|
|
Loading…
Reference in New Issue