(no subject)

Sep 12, 2006 01:41

Parallelizing stuff with OpenMP is really easy! And it works good!

I spent about 10 minutes tweaking my particle system to use OpenMP, and it runs about 1.63 times as fast as the singlethreaded version did on my Core Duo. Toggling on OpenMP is an almost free* instant performance gain.

Some basic numbers:
Test case is a particle system with a target count of 16500 particles. 500 new particles are created each frame until the limit is reached, at which point the system begins removing 500 particles per frame as well to stabilize the numbers. The particles are updated in parallel, and each particle can collide with surfaces and bounce off them (read: i'm doing collision tests between each particle and the obstructions around it, but not between particles).
I'm using software rendering since OpenMP and my OpenGL drivers don't seem to get along.
With OpenMP off, the average framerate is 22fps.
With OpenMP on (and as far as I can tell, it's using two threads - two cores), the average framerate is 36fps.
I'm pretty sure that with a higher particle count, simpler particle algorithm, and some basic optimizations I could probably get even more out of OpenMP. But for a 15 minute experiment, this is pretty impressive. Except for a few crashes at first due to some Schoolboy Threading Mistakes(tm), getting my particle engine working under OpenMP was painless.

* It requires you to add a link manifest to your app/library and distribute vcomp.dll, but at least vcomp.dll is small.

Edit: Found my OpenGL problem (I was accidentally doing a draw call per particle... oops!) and it now runs about equivalently under OpenGL - I'm CPU limited on the particle system. :)

code

Previous post Next post
Up