One of the perks Intel gave the entrants was limited time licenses to it's development and profiling tools. I'd never had the opportunity to use VTune before but man is it amazingly powerful. It allows you to look at threads, modules, etc. and drill down into the functions being called in each, the amount of time spent in each function call, etc. all without having to add any extra profiling data to your code. Pretty sweet and powerful.
The multithreading contest is judged on framerate improvements between a single core and multi-core machine. With that in mind I decided to run a couple of tests:
1. Keep my engine running as is, which has the renderer and physics engine running as fast as they can and the rest of the threads running around 30 times a second.
2. Have all of my threads run flat out and suck up CPU time. The idea being that if my renderer is already using up 99% of the CPU then it's not going to see that much of an improvement on a dual core machine as it already isn't waiting around for the CPU.
With my current game I have 7 main threads running. They are:
Renderer, Physics, AI, Animation, Event Manager, Audio Manager, Input Manager
In the first test where only the Renderer and Physics threads we running hot I saw the following CPU usage:
Renderer - 81%
Physics - 8%
Rest - <1%
This was pretty much what I expected and don't want for my contest entry. In this scenario the Renderer is only waiting 19% of the time, which means the max improvement I'm looking at is 19%.
In the second test I got the following results:
Renderer - 69.11%
Physics - 7.41%
AI - 7.21%
Animation - 6.76%
Event Manager - 1.56%
Audio Manager - 0.67%
Input Manager - 0.34%
This is more what I was looking for. This gives me a potential 30% improvement in frame rate on a dual core setup if I am CPU bound, which I believe I am. What is more interesting about these numbers is that I have a potential perf problem in my Animation manager. The only thing that thread is doing is updating animation data of my objects. But here's the kicker, I have a grand total of 1 object the currently has animation data associated with it. Definitely something I will be checking out.
For those wondering what kind of AI I have in a card game, I actually have the cards determine when they should be spinning around and when they can safely kill themselves after they've left the playing area. My engine is designed in a way that it's really easy to handle having all game logic separated into the actual game objects. That way all logic can easily be encapsulated into small chunks.