SSE denormals

Started by
11 comments, last by thatguyfromthething 8 years, 11 months ago

If your process does the exact same task at 8% vs at 92%, the 92% version will finish much faster (and you could call this “high performance”).

Although watching these topics is funny in a way, I thought I'd point out that this isn't true in cases where the rate at which the work is done is fixed. In audio (or vsynced graphics for that matter) the rate at which the work has to be done is provided externally, so a process using a lower percentage of CPU power is definitely more efficient. However, it does so by using a higher percentage of CPU power for a shorter time (with fewer cache misses, using SIMD etc.).

But that doesn't change the fact that looking at the CPU monitor is almost entirely useless for profiling. Learn to use a profiler or at least time the code doing the actual work with a timer in your program.

Advertisement

You can also look into _controlfp_s to fiddle with the SSE floating point behaviour.

Are you actually using SSE instructions in your filter though? Setting the SSE register to round to zero won't help if you're not...

If you're using regular floats (not SSE value), then you're probably looking for something like fesetenv to set the flush/round mode...
This will depend on your compiler...
e.g. on MSVC you'd use https://msdn.microsoft.com/en-us/library/e9b52ceh.aspx

To verify your hypthesis that denormals are actually your problem, you can check for them like this:


#include <cmath>
if ( std::fpclassify( your_float_here ) == FP_SUBNORMAL ) printf("found a denormal!\n");

If your compiler is very old, it might provide it's own custom fpclassify function. Check it's documentation.

Also read this:
http://stackoverflow.com/questions/2219244/dealing-with-floating-point-exceptions

You probably want to enable the "underflow exception", which will trigger if any of your math ever produces a denormal float. You can then fix your code so that it doesn't happen.
In my experience with games (where performance is also a large concern), this is often used to find causes of denormal numbers and fix that code before shipping the game.

I don't know anything about Borland but I see no reason why denormalized numbers would be a problem.

CPU's often decide to run 100 to 1000 times slower when you give them a denormalized float. Their existence in your data sets can be a massive performance pitfall.

[edit]

p.s. can everyone in this thread please try not to be so damn rude to each other. Yes you. You're being rude. Stahp.

It's probably working already, just not having much effect. Especially since your data won't really be random. I really doubt it is going to do much if anything in a case like this.

Also, profilers are a terrible way to look at performance anyway. Especially at a very low level like this.

This is my thread. There are many threads like it, but this one is mine.

This topic is closed to new replies.

Advertisement