Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Red Ant

Member Since 14 Feb 2001
Offline Last Active Jan 28 2015 04:47 AM

Topics I've Started

Optimizing floating point computations (simulating electric motors)

29 April 2012 - 06:31 AM

Hi,

I have a C++ module consisting of a bunch of functions containing quite complicated floating point math computations that get run over and over again in a tight loop. Profiling has shown that the program spends a substantial amount of CPU time running these floating point computations. Floating point multiplications and std::sin() / cos() / tan(), etc. seem to be a lot more expensive than I thought. We're already compiling with -xO4 (which is the second highest optimization level on our compiler).

In the past few days I've been trying to optimize these computations as much as I can. I've actually had some success as some of our simulation tests scenarios have gone down from roughly 60 seconds to about 50 seconds. Not an astronomical improvement but nothing to be sneezed at either.

The way I've been going about this is to mainly break up complex computations that reuse the same expression over and over. So instead of evaluating the same expression many times over, I just evaluate it once and then feed the result into the computations that depended on the original expression. The downside to this is that readability of the calculations has suffered badly. Also, it's pretty tenuous work and I have to take great care not to accidentally mess up any of the rather complicated calculations.

So I was wondering if there are any fancy mechanisms or tools that can be fed a series of complicated math expressions and that will try to automatically identify and remove any redundant calculations to optimize the computations as much as possible. Does such a thing exist or am I stuck with handcrafted optimizations?

[C++] Are compilers allowed to optimize ...

20 December 2011 - 10:36 AM

the following function away?

template < typename FloatType >
inline const bool is_NaN( FloatType number )
{
	// A NaN doesn't compare equal to anything, not even itself.
	return number != number;
}

Obviously, I intend to use this to test a floating point variable for NaN (not a number) ... can't use std::isnan() because our compiler doesn't support C++11. My worry is that the compiler might optimize the whole call away, on account of comparing a number to itself being so unbelievably stupid. <_<

How many of you use OpenGL / DirectX directly as opposed to

08 July 2010 - 10:46 PM

middleware such as OpenSceneGraph and why? Personally I don't particularly enjoy graphics and GUI programming ... I find them to be really mundane tasks and I'd love to have as much of this boring (to me anyway) work taken off my shoulders as possible, which is why I utilize higher-level libraries where ever possible. I much prefer the designing data structures / algorithms stage of writing an application. Hell, if it was somehow possible, I'd be perfectly happy with just pressing a button and having some magical tool write all my GUI code for me without me ever having touch a single line of GUI-related code. :)

I'm still seeing a lot of people use OpenGL and DirectX directly, though, without any off-the-shelf high-level library, and I'm wondering why. Is it performance concerns? Do people find high-level libraries too restrictive, too much bother somehow? Or is ir just that people enjoy writing games from scratch, i.e. doing it all by themselves without any help in the form of code written by others?

I'm admittedly not particularly experienced in the field of grpahics programming, so maybe my perception is even completely wrong ...

Program performance analysis - making sense of the time metrics

24 June 2010 - 01:50 AM

Hey guys,

I'm currently trying to profile a rather huge C++ application (with some C code sprinkled in here and there) using the built-in profiler that comes with Sun Studio 11. A small part of the program is actively maintained by myself, so I know all about that part, but the majority of the program has been written by dozens of other people, many of whom have long left our project and moved on to something else.

Anyway, I've ran the program and the profiler has successfully collected all the relevant performance data. I've spent the past 2 hours looking at the results, trying to find a clue about where time is being wasted.

The profiler offers me the following time metrics:

- user CPU time (time spent in actual user code)
- kernel CPU time (time spent in system calls)
- wall time (total wall time spent in a function)
- wait CPU (program was waiting for CPU to become available)
- user lock (time spent waiting for some kind of user lock)
- sync wait (time spent waiting ... not sure how this is different from user lock time)
- other wait (time spent waiting for other stuff ... presumably I/O and stuff like that)

Each metric comes in 2 versions, exclusive and inclusive.

Now the problem I have is, I don't know how to interpret these metrics. :( For instance, I can see that function_A() takes up 1,200 seconds of inclusive user CPU time ... but I have no information about how many times the function is actually getting called and I'm not sure if it's a problem that it takes up that much time or if that's just to be expected. Obviously it's not enough to know how much time a certain function is taking up, one also has to have an idea of how much time it should be using.

I guess my question is how do people actually use the information provided by a profiler to find performance bottlenecks in their programs? Any ideas?

Installing Microsoft's "Application Verifier" on Windows 7

20 February 2010 - 06:51 AM

Does anyone get that to work? I've previously installed it on Windows XP with no problems, but I can't get it to install on Windows 7 (64 bit version). When I try the "ApplicationVerifier.x86.msi" installer, I get an error message saying "This package cannot be installed on 64-bit windows. Use the package for 64-bit windows which installs both 32-bit and 64-bit Appverifier." Fine, so I tried the "ApplicationVerifier.ia64.msi" installer. Unfortunately it too gives me an error message "Dieses Installationspaket wird auf dieser Plattform nicht unterstützt. Wenden Sie sich an Hersteller des Produkts." (This installation package is not supported on this platform. Contact the manufacturer of the product.) Microsoft's documentation claims that AppVerifier is compatible with Windows 7. http://msdn.microsoft.com/en-us/library/dd371695%28VS.85%29.aspx "Clients - Windows XP | Windows Vista | Windows 7" What to do, what to do? :-(

PARTNERS