public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
From: Joel Sherrill <joel@rtems.org>
To: Sebastian Huber <sebastian.huber@embedded-brains.de>
Cc: Newlib <newlib@sourceware.org>, Eshan Dhawan <eshandhawan51@gmail.com>
Subject: Re: fenv support vs. SMP systems
Date: Mon, 13 Jul 2020 08:00:22 -0500	[thread overview]
Message-ID: <CAF9ehCUPzqpLDGv7CihHaDaSSMuMj0zDxbYpHAkrmkwMb17U_A@mail.gmail.com> (raw)
In-Reply-To: <d1d42490-7464-2613-09f8-d163583bdb49@embedded-brains.de>

On Mon, Jul 13, 2020 at 1:19 AM Sebastian Huber <
sebastian.huber@embedded-brains.de> wrote:

> Hello,
>
> the new fenv support alters usually some floating-point status and
> control register. This register is usually specific to the processor
> executing the code. In an SMP system, the current approach can lead to
> an inconsistent system if the register is not included in the thread
> context (for example in RTEMS these registers are considered to be
> system wide and are only initialized during the system startup). What do
> I mean with inconsistent system? For example, you set the rounding mode
> on processor A to from X (= default) to Y, then the you migrate to
> processor B and suddenly use the default rounding mode X. Another
> example is to do a division by zero on processor A and then migrate to
> processor B and check the exception flags.
>

That's all true and unfortunately well beyond the definition of fenv():

https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/fenv.h.html

It uses the term "application" and does not use either "process" or
"thread".

The C99 standard has more text but doesn't seem to add anything in this
area. This is from the introductory paragraph but doesn't add much:

""The floating-point environment refers
collectively to any floating-point status flags and control modes supported
by the
implementation.178) A floating-point status flag is a system variable whose
value is set
(but never cleared) when a floating-point exception is raised, which occurs
as a side effect
of exceptional floating-point arithmetic to provide auxiliary
information.179) A floating point
control mode is a system variable whose value may be set by the user to
affect the
subsequent behavior of floating-point arithmetic."

It does use the term "system variable" but that doesn't scope it to process
or
thread.

I hope the control register is at least part of the RTEMS FP context switch
area on all ports. At least then the POSIX term "application" is "thread".

Searching for implementations, I saw no hint that any implementation on
any architecture for an open source OS addressed anything beyond
setting the floating point environment for a thread.

If there is any practice that addresses even an entire process, I am unaware
of it.

--joel

>
> --
> Sebastian Huber, embedded brains GmbH
>
> Address : Dornierstr. 4, D-82178 Puchheim, Germany
> Phone   : +49 89 189 47 41-16
> Fax     : +49 89 189 47 41-09
> E-Mail  : sebastian.huber@embedded-brains.de
> PGP     : Public key available on request.
>
> Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
>

  reply	other threads:[~2020-07-13 13:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-13  6:19 Sebastian Huber
2020-07-13 13:00 ` Joel Sherrill [this message]
2020-07-13 17:16   ` Joseph Myers
2020-07-13 21:03     ` Joel Sherrill
2020-07-14  5:16     ` Sebastian Huber

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=CAF9ehCUPzqpLDGv7CihHaDaSSMuMj0zDxbYpHAkrmkwMb17U_A@mail.gmail.com \
    --to=joel@rtems.org \
    --cc=eshandhawan51@gmail.com \
    --cc=newlib@sourceware.org \
    --cc=sebastian.huber@embedded-brains.de \
    /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).