• 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
madRenEGadE

TBB and some custom threads

2 posts in this topic

Hello all, long time since I was last active here but now I want to do some engine programming again after a long absence.

My engine should be based on jobs which are executed by Intel's TBB. My design is similar to the one Intel uses in Smoke.

The job system itself is working but there are two things I want to do in 2 separate threads. The first one is creating textures etc. (With a shared OpenGL context) and the second one is rendering.

Now to my questions:
1. Are such job systems in general state of the art? I ask because I was out of engine programming for some time.

2. Is it a good idea to make the 2 extra threads? My thoughts behind this idea were that using dedicated threads for those two tasks reduces permant calls to MakeCurrent because in the "normal" job system I would not know in which thread the task is running the next time.

3. Is the performance of TBB's job scheduling affected by my custom threads? The number oft threads TBB creates is based on the number of CPU cores so my two tasks "steal" some processing power. But I think that the job stealing in TBB will handle this, am I right?
0

Share this post


Link to post
Share on other sites
I think threads and tasks/jobs are orthogonal concepts and you should use both.
Threads express mandatory parallelism. Tasks express the opportunity for parallelism.
(cnf. Structured Parallel Programming)

For example you could use a networking thread so it can block on incoming connections.
Updating game entities could be expressed using tasks, so it's up to TBB to distribute the work
among available processors for optimal performance.

I wouldn't worry too much about stealing processing power from TBB with your own threads. The OS
does a good job allocating time slices for each threads.

You want to have more threads than cores anyways because tasks block from time to time, waiting for
memory or file io.

You find some good slides from Dice here:
http://dice.se/publications/parallel-graphics-in-frostbite-current-future/
0

Share this post


Link to post
Share on other sites
Parallel graphics are difficult and error prone, and for an individual they are probably not worth the effort.

I'll recommend caution.

1. Is it state of the art? Some games have used it to a limited extent.

2. Is it a good idea? For an individual or a small team, probably not unless you are extremely niche. For a large organization with an 8-figure budget, possibly, with care.

3. Is TBB affected by other threads? Yes, if you have enough work. There are only so much resources to go around. As long as you stay below saturation things will generally be fine. Once it begins to hit saturation on any resource, additional work causes problems. CPU time is only one resource; caches, branch prediction tables, communication buses, and many other resource limits exist and will all cause performance to plummet once their limits are hit. 

Now for some hopefully more useful notes.

Do a thought experiment on what you propose. You might be able to assign multiple CPU threads to the task. Now you have <b>two</b> sources fighting to send data across <b>one</b> bus to <b>one</b> graphics card, also fighting over <b>one</b> graphics context with a shared state. All that resource contention is not good for performance if anything comes close to saturation. Even if you do try some naive parallel techniques, generally the drivers will end up de-parallelizing your work back to serial operations, costing even more time. You need to find things that the drivers won't convert back to a serial process, that can be done without resource contention, and that will still work well on low spec machines.

I'm not trying to say threads are bad. They are an added complexity to the engine and a frequent source of bugs to novices, yet threads are useful in many things. All the major engines use threads as a form of damage control; when something dies you kill the thread and restart whatever was running on it. That is a great feature, but it requires some serious engineering efforts to build and debug. All the engines I've used over the past five years have basically run game code with invisibly-threaded systems. The game object code feels like it is single theaded, and is also usually processed sequentially, but it exists within its own thread. It is possible that multiple game object threads are running concurrently, but they are isolated in such a way that they don't stomp on each other. This also take significant engineering skill and effort.

Games need to still run acceptably on minimum spec machines, and typically min-spec still includes single processor machines from the P4 era which ended 2008 and Core 2 era which ended in 2011 where single-processor chips were common. While you can take advantage of certain parallel algorithms on games for non-critical processing if your hardware supports it, it is still too early to rely on them overmuch. Way too many low-spec machines only have one processor, or have their second processor busy working on spewing viruses or other malware or whatever other thousands of programs the user has running at the time.

You can rely on threads for many things, such as containment and organization, as well as non-critical things like crazy-intense particle systems and smoothly-drawn cloth. But it is still too early for mainstream games to put game-critical processing into mandatory multiprocessed tasks. Be very cautious about anything that requires parallel processing, including parallel rendering.
2

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