• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
ill

Multicore Game Engine

4 posts in this topic

So I'm currently working on a multicore engine with ideas taken from this intel article:
[url="http://software.intel.com/en-us/articles/designing-the-framework-of-a-parallel-game-engine/"]Designing the Framework of a Parallel Game Engine[/url]

I'm still trying to figure out if I should separate my engine into some main asynchronous threads or to keep everything in 1 thread and use only the tasks.

My idea so far is to have the Game/AI/Physics be one main thread. The graphics be another main thread that updates asynchronously from the game. The sound output would be its own thread as well. And each network connection would be its own thread.

I have a pretty good mechanism in the works for keeping them all in synch, but I'm still wondering if this is going to give me the benefits I'm thinking I will get.

Multiple Asynchronous threads:

Pros:
Game loop updates at 60 times per second and is completely asynchronous from graphics or audio...

Cons:
The engine is a bit more complicated and a little harder to keep in synch but not really...

One main thread:

Pros:
A bit simpler. It may or may not perform better.

Cons:
The Game thread will need to have its timestep fixed if things like graphics slow it down to less than 60 FPS.
0

Share this post


Link to post
Share on other sites
I've yet to see a common situation where you can do better than a primary thread and a task pool*. It's extremely hard to get synchronization right across multiple threads especially when they don't have very explicit sync points.

In short, unless you really know you need to mess with fine-grained threading, I'd say do the simple thing and just write a master thread that issues parallelizable work to your task thread pool. It'll be a lot less headache and you can leverage libraries like Intel's TBB et. al. to do the heavy lifting.


*NB for obsessive completeness: there [i]are[/i] situations where you can beat out a task pool using fine-grained threading. It's very difficult, though, and not at all [i]common[/i].
2

Share this post


Link to post
Share on other sites
I actually do have a way to get things staying in synch.

There are explicit synch points in each main thread. They pull in updates at each update from other threads using the system that keeps things in synch. I'm currently working on coding it, but I have it all thought out.

At this point, the simpler thing is to have the split up main threads, for now at least since I already came this far. I might go back to one main thread later though if the performance is more worth it doing it that way, which is what I'm not really sure about...
0

Share this post


Link to post
Share on other sites
There's two reasons to use multiple threads:
A) You've got processor intensive routines that you can run in parallel.
B) You have to call a slow, blocking function, but want it to be asynchronous.

In any case, if you're running more threads than your CPU has 'hardware threads' then it's called [i]over-subscription[/i], and is a waste of performance. The opposite, where you're running less threads than your CPU can handle is called [i]under-subscription[/i], and is a waste of potential. Ideally, your game will make use of the same number of threads that is supported by the CPU ([i]or less, to allow for the OS or other apps[/i]).

[quote name='ill' timestamp='1333410463' post='4927697']My idea so far is to have the Game/AI/Physics be one main thread. The graphics be another main thread that updates asynchronously from the game. The sound output [and networking] would be its own thread as well.[/quote]So you've got a fixed number of 4 threads (assuming one network connection), which means you're targeting quad-core CPU's only. On dual-core, you'll be over-subscribed, and on hex-core you'll be under-subscribed.

Each of your threads above has a very different workload. The Game/AI/Physics thread is going to have a very large workload, the graphics one a mild workload, and the audio/network threads are going to be almost entirely idle. Ideally, each of your threads would have almost identical workloads.

AI/Physics/Graphics are a case of (A) -- you've got a lot of work to do, which can largely be done in parallel. Ideally, you'd split the workload of each of these amongst each of your threads to balance it over the CPU, and use it's full potential.

Networking is a case of (B) above -- instead of wrapping a blocking API in threads to make it asynchronous, just use an asynchronous networking API to begin with -- so you don't need separate threads dedicated solely to networking.
0

Share this post


Link to post
Share on other sites
[quote]There are explicit synch points in each main thread. They pull in updates at each update from other threads using the system that keeps things in synch. I'm currently working on coding it, but I have it all thought out.[/quote]

Downsides of this approach:
- aliasing (similar to moire effect). Since work units are discrete, a long running task or uneven number of work units will cause sporadic delays, sometimes just enough to require one frame more. FPS will therefore jitter. Only solution is to ensure tasks are always small enough, which is difficult to do on diverse hardware (PC). This may be one cause of so-called micro-stutter, though it's more frequently caused by interrupts (USB or poor drivers).
- guaranteed sub-scalar performance. By explicitly syncing, system like that will be consistently sub-optimal. For above reason it may be vastly so, to the point where benefit of threading is lost (there are only 4 threads at best and factor of 4 loss happens quickly)

Above issues can be mitigated, but solutions may quickly become too complex.
-1

Share this post


Link to post
Share on other sites

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