Let’s take the body interaction code I laid out last time, combine it with the other parts laid out previously and run it. Dropping the fleshed out program into a Microsoft Visual Studio* project, I quickly rediscover something:
Oops, that’s right. bodies007.cpp relies on language extensions available in the Intel® Compiler version 11, some early arrivals from the C++0x standard. Fortunately, it’s pretty easy to switch compilers.
|With the Intel C++ Compiler installed in Visual Studio from either of the regular distribution packages, the Compiler Professional Edition or Intel Parallel Composer, switching compilers is just a click away.|
|OK, two clicks. I did try to build already, so I’ll let the system clean up the project files.|
|Viola!!! The project now uses the Intel C++ compiler.|
One more configuration setting to enable C++0x support:
And now it compiles!
Dropping the serial code into the test program I’ve prepared gives access to a simple command processor that allows me to select that kernel for one of several tests. A simple ramp, testing the algorithm with varying values of n, can be launched by putting this in the command line: select serial
Looks like the time it takes to complete the simulation (I’m running 1000 time steps for each body-count) is going up more than four times for every doubling of the number of bodies; in fact, if I plot it on a logarithmic scale, I can see the exponential growth:
Clearly this is an algorithm that has plenty of work to divide, if I can just figure out a way to do it.
Next time: serial body hot spots