By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,719 Members | 1,036 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,719 IT Pros & Developers. It's quick & easy.

subnormal floating point numbers

P: n/a
Hi all,
first of all I beg your pardon if this question has been asked
before, but I was unable to find anything in the past posts.
I have written a piece of code that was supposed to be quite portable,
and uses a lot fp numbers. Everything goes well on PPC cpus, but on
some x86 CPU I get a dramatic loss of performance. After some
investigations I've discovered that the problem is caused by some
numbers becoming subnormal, PPC cpus seems to treat them quietly
without any significant loss of speed whereas on some x86 CPU I get
really very poor results as soon as these "strange" entities begin to
pop out...
Does someone know if there is a way to disable subnormal floating
point numbers, maybe using standard c/c++ libs? I don't need them and
for me it will be just ok to have a small quantity dropped to zero -
in fact, the code is written assuming implicitly that very small
number will eventually become zero.
I hope that there is a simple solution for the problem, apart from
reviewing any very single line of code and putting a lot of
if(issubnormal...) or whatever else...

Thanx in advance to everybody that can/will help me...

May 15 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a
On May 15, 3:27 pm, ultimatewarrior <ultimatecodewarr...@yahoo.it>
wrote:
first of all I beg your pardon if this question has been asked
before, but I was unable to find anything in the past posts.
I have written a piece of code that was supposed to be quite portable,
and uses a lot fp numbers. Everything goes well on PPC cpus, but on
some x86 CPU I get a dramatic loss of performance. After some
investigations I've discovered that the problem is caused by some
numbers becoming subnormal, PPC cpus seems to treat them quietly
without any significant loss of speed whereas on some x86 CPU I get
really very poor results as soon as these "strange" entities begin to
pop out...
Does someone know if there is a way to disable subnormal floating
point numbers, maybe using standard c/c++ libs? I don't need them and
for me it will be just ok to have a small quantity dropped to zero -
in fact, the code is written assuming implicitly that very small
number will eventually become zero.
I hope that there is a simple solution for the problem, apart from
reviewing any very single line of code and putting a lot of
if(issubnormal...) or whatever else...
I don't believe there is anything standard to effect this. I think
you're looking for a compiler switch (e.g., -fn on Sun C++). You
should ask in a group related to your compiler.

Cheers! --M

May 15 '07 #2

P: n/a
ultimatewarrior wrote:
Does someone know if there is a way to disable subnormal floating
point numbers, maybe using standard c/c++ libs?
Just assigning the subnormal to a double variable should force it to 0.

---
Walter Bright
Digital Mars C, C++, D programming language compilers
May 16 '07 #3

P: n/a
Walter Bright wrote:
ultimatewarrior wrote:
>Does someone know if there is a way to disable subnormal floating
point numbers, maybe using standard c/c++ libs?

Just assigning the subnormal to a double variable should force it to 0.
If the subnormal doesn't propagate, this wouldn't solve the problem,
would it?

Regards,

Zeppe
May 16 '07 #4

P: n/a
On 16 Mag, 11:57, Zeppe <zeppe@.remove.all.this.long.comment.email.it>
wrote:
Walter Bright wrote:
ultimatewarrior wrote:
Does someone know if there is a way to disable subnormal floating
point numbers, maybe using standard c/c++ libs?
Just assigning the subnormal to a double variable should force it to 0.

If the subnormal doesn't propagate, this wouldn't solve the problem,
would it?
Well, I guess no. And I cannot change every bit of code in order to
replace any assignement from float to double.

I've probably found a workaround, anyway, using SSE instead of
standard FPU you can control (through the MXCSR register) how to deal
with subnormal numbers, you can instruct the CPU to treat them as
zeros (exactly what I need), unfortunately you need SSE because the
x87 FPU has no control over this (ok, SSE is there from PIII and
AthlonXP so I think I'll drop support for older CPUs...)

Has someone any experience with issues regarding the use of SSE for
floats (instead of the standard FPU)?

(BTW, thanx for your kind answers!)

May 16 '07 #5

P: n/a
"ultimatewarrior" <ul*****************@yahoo.itwrote in message
news:11**********************@k79g2000hse.googlegr oups.com...
Hi all,
first of all I beg your pardon if this question has been asked
before, but I was unable to find anything in the past posts.
I have written a piece of code that was supposed to be quite portable,
and uses a lot fp numbers. Everything goes well on PPC cpus, but on
some x86 CPU I get a dramatic loss of performance. After some
investigations I've discovered that the problem is caused by some
numbers becoming subnormal, PPC cpus seems to treat them quietly
without any significant loss of speed whereas on some x86 CPU I get
really very poor results as soon as these "strange" entities begin to
pop out...
Does someone know if there is a way to disable subnormal floating
point numbers, maybe using standard c/c++ libs? I don't need them and
for me it will be just ok to have a small quantity dropped to zero -
in fact, the code is written assuming implicitly that very small
number will eventually become zero.
I hope that there is a simple solution for the problem, apart from
reviewing any very single line of code and putting a lot of
if(issubnormal...) or whatever else...

Thanx in advance to everybody that can/will help me...
Reading other responses, and your responses to their responses, perhaps you
should use double instead of float. My understanding is that double is
faster than float anyway on (most/all) platforms. It also seems this might
get rid of your subnormal problems. Especially since performance seems to
be an issue it seems like the right thing to do.
May 17 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.