Jump to content
  • Advertisement
  • entries
    205
  • comments
    228
  • views
    113469

Thread Tuning

Sign in to follow this  
Mike Bossy

139 views

For the last couple of days I've been concentrating on getting ready for the Intel multi-threaded contest. The main thing I wanted to do was to figure out exactly how much processor time was being used by each thread to figure out exactly what kind of perf improvement I could expect in my frame rate on a dual core processor. I do plan to have a test run on a dual core before finishing up but I want to get as close to what I want before I do that.

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.
Sign in to follow this  


3 Comments


Recommended Comments

Quote:
Original post by Mike Bossy
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.

Oooh, that's exactly what I'm planning on doing in my engine! I'm glad to see it works well. How encapsulated do you make all the A.I. objects, and are there any tips and potential pitfalls you could point out to me while I work on the design?

Share this comment


Link to comment
Currently my basic game object has a virtual function for AI work. Each game object overrides this function for it's own custom AI work.

The main pitfall I'm having is that this model doesn't work well in the classic OO sense. Basically I need to create a new class for ever game object that has custom AI work. Once I'm done my current game I'll be going back and changing from a virtual function to calling something like a LUA script file instead. Then instead of inheriting from the base class into a new class I can just create a base object and change the name of the script file to call. This also means I don't have to have a re-compile to change game logic.

Let me know how you go about doing your thing and what works.

Share this comment


Link to comment
Yes, that sounds a lot like what I'm planning to do, down to the annoying class definition problem. I think working with Lua script files would work well, and have that on my list of things to do in future versions, but with my present unfamiliarity with this architectural design I plan to put that off until next time (plus I have to learn Lua first; the list of things I have left to learn seems endless!).

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!