From 83584eab1b561ac4be25da110c20d2d92371b9df Mon Sep 17 00:00:00 2001 From: Janne Blomqvist Date: Mon, 15 Apr 2013 15:43:15 +0300 Subject: PR 56919 Improve SYSTEM_CLOCK intrinsic on Windows. frontend ChangeLog: 2013-04-15 Janne Blomqvist PR fortran/56919 * intrinsics.texi (SYSTEM_CLOCK): Update documentation. libgfortran ChangeLog: 2013-04-15 Janne Blomqvist PR fortran/56919 * intrinsics/time_1.h: Check __CYGWIN__ in addition to __MINGW32__. * intrinsics/system_clock.c (GF_CLOCK_MONOTONIC): Check _POSIX_MONOTONIC_CLOCK as well. (system_clock_4): Use GetTickCount on Windows. (system_clock_8): Use QueryPerformanceCounter and QueryPerformanceCounterFrequency on Windows. From-SVN: r197968 --- gcc/fortran/ChangeLog | 5 +++++ gcc/fortran/intrinsic.texi | 49 ++++++++++++++++++++++++++++------------------ 2 files changed, 35 insertions(+), 19 deletions(-) (limited to 'gcc') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 262f257..012d531 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2013-04-15 Janne Blomqvist + + PR fortran/56919 + * intrinsics.texi (SYSTEM_CLOCK): Update documentation. + 2013-04-15 Tobias Burnus * class.c (gfc_find_intrinsic_vtab): Removed unused var. diff --git a/gcc/fortran/intrinsic.texi b/gcc/fortran/intrinsic.texi index 8c0edc7..d5ff9a0 100644 --- a/gcc/fortran/intrinsic.texi +++ b/gcc/fortran/intrinsic.texi @@ -12038,27 +12038,38 @@ and should considered in new code for future portability. @item @emph{Description}: Determines the @var{COUNT} of a processor clock since an unspecified time in the past modulo @var{COUNT_MAX}, @var{COUNT_RATE} determines -the number of clock ticks per second. If the platform supports a high -resolution monotonic clock, that clock is used and can provide up to -nanosecond resolution. If a high resolution monotonic clock is not -available, the implementation falls back to a potentially lower -resolution realtime clock. - -@var{COUNT_RATE} is system dependent and can vary depending on the kind of the -arguments. For @var{kind=4} arguments, @var{COUNT} usually represents -milliseconds, while for @var{kind=8} arguments, @var{COUNT} typically -represents micro- or nanoseconds. @var{COUNT_MAX} usually equals -@code{HUGE(COUNT_MAX)}. - -If there is no clock, @var{COUNT} is set to @code{-HUGE(COUNT)}, and -@var{COUNT_RATE} and @var{COUNT_MAX} are set to zero. - -When running on a platform using the GNU C library (glibc), or a -derivative thereof, the high resolution monotonic clock is available -only when linking with the @var{rt} library. This can be done -explicitly by adding the @code{-lrt} flag when linking the +the number of clock ticks per second. If the platform supports a +monotonic clock, that clock is used and can, depending on the platform +clock implementation, provide up to nanosecond resolution. If a +monotonic clock is not available, the implementation falls back to a +realtime clock. + +@var{COUNT_RATE} is system dependent and can vary depending on the +kind of the arguments. For @var{kind=4} arguments, @var{COUNT} +represents milliseconds, while for @var{kind=8} arguments, @var{COUNT} +typically represents micro- or nanoseconds depending on resolution of +the underlying platform clock. @var{COUNT_MAX} usually equals +@code{HUGE(COUNT_MAX)}. Note that the millisecond resolution of the +@var{kind=4} version implies that the @var{COUNT} will wrap around in +roughly 25 days. In order to avoid issues with the wrap around and for +more precise timing, please use the @var{kind=4} version. + +If there is no clock, or querying the clock fails, @var{COUNT} is set +to @code{-HUGE(COUNT)}, and @var{COUNT_RATE} and @var{COUNT_MAX} are +set to zero. + +When running on a platform using the GNU C library (glibc) version +2.16 or older, or a derivative thereof, the high resolution monotonic +clock is available only when linking with the @var{rt} library. This +can be done explicitly by adding the @code{-lrt} flag when linking the application, but is also done implicitly when using OpenMP. +On the Windows platform, the version with @var{kind=4} arguments uses +the @code{GetTickCount} function, whereas the @var{kind=8} version +uses @code{QueryPerformanceCounter} and +@code{QueryPerformanceCounterFrequency}. For more information, and +potential caveats, please see the platform documentation. + @item @emph{Standard}: Fortran 95 and later -- cgit v1.1