n-bodies: exploring a parallel TBB solution, intro and peek ahead

My vacation weeks have come and gone, plus a few intense weeks of playing catch-up on the work that accumulated while I was away.   Finally though, I have a chance to deliver on a promise made a month ago to share some details on parallelizing the n-body gravitational problem.  I've produced a series of refined versions of the code, attempting to step into all the pitfalls I could find along the way to see what they look like, how I could recognize them, and what actions I could take, if any, to alleviate them.

The code is structured with a simple command processor to enable selection of the cases and to alternate between runs that test performance over a range of n and a variety of techniques for updating the state of the bodies.  We've used the code already in a new class on parallel code writing and analysis techniques, and I expect that this sample might continue to evolve to enable play with other aspects of the problem.

My plan is to write a series of short posts to carefully explore the process that got the code to its current state and beyond.  However, I know there are some people out there who are already well versed in the fundamentals or  like to jump to the end of the book just to see where it's going.  For those, here's an attachment with my source code in its current version.  It requires both the Intel® C++ Compiler V11 (for lambda support) and Intel Threading Building Blocks 2.2 (for the parallel_invoke method).  Otherwise it's a standalone, GUI-less program that should be pretty easy to build.

That's all for now.  Next time we'll start digging into the details of the code. (Hopefully later this week, not a month from now ;-).

For more complete information about compiler optimizations, see our Optimization Notice.