From: Dan Pop <Dan.Pop@cern.ch>
To: linux-ia64@vger.kernel.org
Subject: Re: [Linux-ia64] avoiding float underflow software assist
Date: Mon, 09 Oct 2000 15:37:35 +0000 [thread overview]
Message-ID: <marc-linux-ia64-105590678205558@msgid-missing> (raw)
In-Reply-To: <marc-linux-ia64-105590678205556@msgid-missing>
On Mon, 9 Oct 2000, Pete Wyckoff wrote:
> This little code snippet causes floating-point underflow during the
> multiplication.
>
> float f, g;
> f = 1.3e-23;
> g = f * f;
>
> The kernel handler catches the fault and fixes it up, but that's quite
> slow.
>
> Is there a way to have the hardware automatically ignore this condition
> and force the result to zero on its own?
>
> I've tried playing with fesetround() and fesetenv() to see if I could
> manage it, to no avail.
Try this code and see if it helps. You don't have to explicitly call
the function, it will be automatically executed before main().
#include <stdio.h>
#include <asm/fpu.h>
#define MYFPSF_DEFAULT (FPSF_PC (0x3) | FPSF_RC (FPRC_NEAREST) | FPSF_FTZ)
#define MYFPSR_DEFAULT (FPSR_TRAP_VD | FPSR_TRAP_DD | FPSR_TRAP_ZD \
| FPSR_TRAP_OD | FPSR_TRAP_UD | FPSR_TRAP_ID \
| FPSR_S0 (MYFPSF_DEFAULT) \
| FPSR_S1 (FPSF_DEFAULT | FPSF_TD | FPSF_WRE) \
| FPSR_S2 (MYFPSF_DEFAULT | FPSF_TD) \
| FPSR_S3 (MYFPSF_DEFAULT | FPSF_TD))
void __attribute__((constructor)) ftz(void)
{
register unsigned long st = MYFPSR_DEFAULT;
__asm__ __volatile__ (";; mov.m ar.fpsr=%0;;" :: "r"(st));
fprintf(stderr, "Flush to zero enabled for S0, S2 and S3.\n");
}
Dan
next prev parent reply other threads:[~2000-10-09 15:37 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-10-09 15:12 [Linux-ia64] avoiding float underflow software assist Pete Wyckoff
2000-10-09 15:23 ` Saxena, Sunil
2000-10-09 15:37 ` Dan Pop [this message]
2000-10-09 16:02 ` David Mosberger
2000-10-09 16:03 ` Pete Wyckoff
2000-10-09 16:44 ` Jes Sorensen
2000-10-09 17:21 ` Dan Pop
2000-10-09 17:31 ` David Mosberger
2000-10-11 23:10 ` Pete Wyckoff
2000-10-12 16:13 ` Jes Sorensen
2000-10-17 22:40 ` Cary Coutant
2000-10-17 22:53 ` Cary Coutant
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=marc-linux-ia64-105590678205558@msgid-missing \
--to=dan.pop@cern.ch \
--cc=linux-ia64@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.