* continuing after a floating point exception (FPE) and maximizing FP performance using ccc and gcc
@ 2000-03-17 5:00 Jeff Graham
2000-03-20 5:00 ` Xiaozhou Qiu
0 siblings, 1 reply; 2+ messages in thread
From: Jeff Graham @ 2000-03-17 5:00 UTC (permalink / raw)
Hello everyone,
I am using the latest ccc with its libcmpla on a dec alpha lx154 (21164a)
running
RH Linux 6.0 (several kernels from 2.2-5 to 2.2.13. I also have the latest gcc
2.95
that I can use if it helps solve my problem.
My problem is this: I am doing many,many,many floating point calculations in
generated mathematical formulae
that may trigger floating point exceptions in log,exp,ln,pow,etc. Often these
generated formulae
cause floating point exceptions midway through their evaluation. But I must
continue the evaluation to completion
(I want to simply "skip" the failed function in the formula and passthrough the
prior value).
Here is a contrived example:
a formula may look like: cos( tan (log(x)))
If tan() fails, then I want cos() to receive the value log(x) (i.e., i want tan
to passthrough the value log(x) to cos().
QUESTION 1:
What combination of compiler flags, libraries, and code technique (catch the
fp signal?)
can I use the meet the following criteria (or close as possible):
1. allows me to catch a FPE, reset something, then continue on with the
rest of the formula
(is this even possible? if the fpu triggers a fpe, is it still usable
afterwards?)
There is some documentation in Chapter 10 of the ccc manual about
catching a FPE that I will
try soon. Has anyone done this?
and/or
2. allows me to predict a FPE (domain,range,overflow,underflow) so that
it never occurs so that
I can reset something, then continue. How exactly do you test for
log,exp,ln,pow,etc ?
My guess is that you must use -ieee for cccc. Then, can I just check the
results for NaN, Inf, etc?
I prefer #2, and have pursued this somewhat, but I still get FPEs because I have
not found the right
combinations of tests on the function arguments to log,exp,pow,ln,tan, and all
the trig functions.
Also, there is code I am not responsible for that also may trigger the fpe,
which is why catching the
signals is appealing.
Of course, my runs take literally weeks at a time, so a solution that causes a
big performance hit is
not a good option.
QUSTION 2: What is the best combination of compiler flags to get fastest FP
performance using
ccc? gcc?
Thanks a lot for all your replies!
Jeff
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: continuing after a floating point exception (FPE) and maximizing FP performance using ccc and gcc
2000-03-17 5:00 continuing after a floating point exception (FPE) and maximizing FP performance using ccc and gcc Jeff Graham
@ 2000-03-20 5:00 ` Xiaozhou Qiu
0 siblings, 0 replies; 2+ messages in thread
From: Xiaozhou Qiu @ 2000-03-20 5:00 UTC (permalink / raw)
Hello,
I've never done something like handling the float point exception. There is
exception
handling mechanism in ccc. I think the Chapter 10 of the programmer's guide
helps.
It mention you can define a structured exception handler like:
try
try-body
}
except ( exception-filter)
exception-handler
}
I think you can also handle the signals to handle the exceptions.
If you want, you can come over to the mailing list
http://www.iol.unh.edu/linux/C/discussion.html
Feng
Jeff Graham <jgraham@lincom-asg.com> wrote in message
news:38D23368.E3CEC095@lincom-asg.com...
> Hello everyone,
>
> I am using the latest ccc with its libcmpla on a dec alpha lx154 (21164a)
> running
> RH Linux 6.0 (several kernels from 2.2-5 to 2.2.13. I also have the
latest gcc
> 2.95
> that I can use if it helps solve my problem.
>
>
> My problem is this: I am doing many,many,many floating point calculations
in
> generated mathematical formulae
> that may trigger floating point exceptions in log,exp,ln,pow,etc. Often
these
> generated formulae
> cause floating point exceptions midway through their evaluation. But I
must
> continue the evaluation to completion
> (I want to simply "skip" the failed function in the formula and
passthrough the
> prior value).
>
> Here is a contrived example:
> a formula may look like: cos( tan (log(x)))
>
> If tan() fails, then I want cos() to receive the value log(x) (i.e., i
want tan
> to passthrough the value log(x) to cos().
>
>
>
> QUESTION 1:
> What combination of compiler flags, libraries, and code technique
(catch the
> fp signal?)
> can I use the meet the following criteria (or close as possible):
>
> 1. allows me to catch a FPE, reset something, then continue on
with the
> rest of the formula
> (is this even possible? if the fpu triggers a fpe, is it still
usable
> afterwards?)
>
> There is some documentation in Chapter 10 of the ccc manual about
> catching a FPE that I will
> try soon. Has anyone done this?
>
>
> and/or
>
> 2. allows me to predict a FPE (domain,range,overflow,underflow) so
that
> it never occurs so that
> I can reset something, then continue. How exactly do you test for
> log,exp,ln,pow,etc ?
>
> My guess is that you must use -ieee for cccc. Then, can I just
check the
> results for NaN, Inf, etc?
>
>
>
> I prefer #2, and have pursued this somewhat, but I still get FPEs because
I have
> not found the right
> combinations of tests on the function arguments to log,exp,pow,ln,tan, and
all
> the trig functions.
>
> Also, there is code I am not responsible for that also may trigger the
fpe,
> which is why catching the
> signals is appealing.
>
>
> Of course, my runs take literally weeks at a time, so a solution that
causes a
> big performance hit is
> not a good option.
>
>
> QUSTION 2: What is the best combination of compiler flags to get fastest
FP
> performance using
> ccc? gcc?
>
>
> Thanks a lot for all your replies!
> Jeff
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2000-03-20 5:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2000-03-17 5:00 continuing after a floating point exception (FPE) and maximizing FP performance using ccc and gcc Jeff Graham
2000-03-20 5:00 ` Xiaozhou Qiu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox