public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "anlauf at gmx dot de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/64432] [5 Regression] SYSTEM_CLOCK(COUNT_RATE=rate) wrong result for integer(4)::rate
Date: Mon, 29 Dec 2014 15:04:00 -0000	[thread overview]
Message-ID: <bug-64432-4-AdiHieHC1w@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-64432-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64432

--- Comment #5 from Harald Anlauf <anlauf at gmx dot de> ---
(In reply to Francois-Xavier Coudert from comment #4)
> I'm not sure this is a bug, but this was definitely by design (as the
> comment indicates). I think this is allowed by the successive standards
> (which are, in any case, very weakly worded).

Well, let's see: the standard says:

  COUNT RATE (optional) shall be an integer or real scalar. It is an
    INTENT (OUT) argument. It is assigned a processor-dependent approximation
    to the number of processor clock counts per second, or zero if there is
    no clock.

You're right, it does not say anything about consistency.
Nevertheless, I would prefer if a program that always uses
e.g. default integer == integer(4), the low-resolution (msec)
version continues to be used consistently.  That's what other
compilers do and what gfortran <= 4.9 did.

Also, the presence of a second argument (see comment #1) should
not change the behavior.

OTOH, it is the responsibility of a user to consistently use
arguments of the same type and kind to get consistent behavior.
(I.e. not mixing integer and real or integer(4) and integer(8)).
I do take care of that.

> The root of the problem is that we want to allow for SYSTEM_CLOCK to return
> high-precision values for large integer kinds, and fall back to
> lower-precision results that fit in fewer bytes for smaller integer kinds.

How is this fallback done?  Do you truncate the resolution?
E.g. high res. -> low res.: divide count_rate and count by 1000?

> Thus, one should call SYSTEM_CLOCK once with all the necessary arguments,
> and not multiple times with varying argument types.

Note that I did *not* call SYSTEM_CLOCK with varying argument types.

You're probably not aware of existing (f95) code that deals with
the problem of wrapping, which is always present (count does not
necessarily start with 0 at start of the program), although not
very likely with integer(8)... ;-)

> The only other consistent option I can see would be to simply go for
> high-resolution results in all cases, but that would mean that SYSTEM_CLOCK
> with 32-bit integers would wrap around in less than an hour.

No, that doesn't make sense.

> If you have another idea, please post a list of what you think should happen
> in all various cases (all possible combinations of arguments have to be
> allowed).

Let's see:

- For any number of arguments present (1, 2 or 3)
  - always integer(4): msec resolution (as before)
  - always integer(>=8): usec resolution (or whatever is possible)
  - always real: I don't care, but I think it might be a good idea
    to use the same as for integer of a compatible kind.
  - different types and/or kinds: I don't care, since one should
    expect problems (wrapping or truncation) anyway.

But presence of non-presence should never make a difference
if consistent types and kinds are used.


  parent reply	other threads:[~2014-12-29 15:04 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-29 10:44 [Bug fortran/64432] New: " anlauf at gmx dot de
2014-12-29 11:14 ` [Bug fortran/64432] " anlauf at gmx dot de
2014-12-29 11:18 ` anlauf at gmx dot de
2014-12-29 11:20 ` janus at gcc dot gnu.org
2014-12-29 11:21 ` janus at gcc dot gnu.org
2014-12-29 14:13 ` fxcoudert at gcc dot gnu.org
2014-12-29 15:04 ` anlauf at gmx dot de [this message]
2014-12-29 15:23 ` anlauf at gmx dot de
2014-12-30  9:48 ` Joost.VandeVondele at mat dot ethz.ch
2014-12-30 10:05 ` Joost.VandeVondele at mat dot ethz.ch
2015-01-04 21:47 ` anlauf at gmx dot de
2015-01-04 21:56 ` anlauf at gmx dot de
2015-01-04 22:04 ` fxcoudert at gcc dot gnu.org
2015-01-04 22:53 ` anlauf at gmx dot de
2015-01-09 11:20 ` rguenth at gcc dot gnu.org
2015-01-09 14:12 ` jakub at gcc dot gnu.org
2015-01-19 20:49 ` anlauf at gmx dot de
2015-02-11 21:20 ` jvdelisle at gcc dot gnu.org
2015-02-13 22:31 ` anlauf at gmx dot de
2015-02-15  4:59 ` jvdelisle at gcc dot gnu.org
2015-02-16  3:14 ` jvdelisle at gcc dot gnu.org
2015-02-16 12:04 ` anlauf at gmx dot de
2015-02-16 20:04 ` jvdelisle at gcc dot gnu.org
2015-02-18  4:21 ` jvdelisle at gcc dot gnu.org
2015-02-18 20:04 ` anlauf at gmx dot de
2015-02-18 20:12 ` anlauf at gmx dot de
2015-02-19 16:32 ` jvdelisle at gcc dot gnu.org
2015-02-20 17:11 ` jvdelisle at gcc dot gnu.org
2015-02-20 22:14 ` anlauf at gmx dot de
2015-02-22 12:06 ` dominiq at lps dot ens.fr
2015-02-22 12:56 ` dominiq at lps dot ens.fr
2015-02-22 17:11 ` jvdelisle at gcc dot gnu.org
2015-02-26 17:44 ` jvdelisle at gcc dot gnu.org
2015-03-15 21:29 ` anlauf at gmx dot de
2015-03-17  1:02 ` jvdelisle at gcc dot gnu.org
2015-03-17  1:05 ` jvdelisle at gcc dot gnu.org
2015-03-17  1:22 ` jvdelisle at gcc dot gnu.org
2015-03-17 21:16 ` anlauf at gmx dot de
2015-03-17 22:33 ` jvdelisle at gcc dot gnu.org
2015-03-18  1:47 ` jvdelisle at gcc dot gnu.org
2015-03-20  7:38 ` jvdelisle at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-64432-4-AdiHieHC1w@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).