Why aren’t more video games optimised for multi-core CPUs?

1.32K viewsOther

It is common for modern video games to be badly optimised due to, partly, inefficient usage of multiple cores on a CPUs.

I’d assume that developers know this, but don’t have the time to rectify this.

So, therefore, what are the difficulties in utilising various cores of a CPU effectively? Why does it require so much focus, money, or perhaps time to implement?

In: Other

18 Answers

Anonymous 0 Comments

No standard amount of cores. If you tightly wrote programs to rely on them it won’t run without them.

Anonymous 0 Comments

Because it’s really, really, hard. In video games a lot of calculations depend on prior calculations. Things like drawing a scene have to be done sequentially. You can’t start shading until you do light. And you can’t do lighting until you calculate the Z buffer. So finding what things in your game actually can be done in parallel requires a lot of knowledge, both of the game itself and the underlying engine.

And that’s before you get into how many cores you do support. Sure maybe you could use a 2nd core, but what about a 4th? Not everyone playing is going to have a 4th core. Maybe that time is spent better optimizing the game as a whole then specifically only optimizing it for when there are extra cores.

Anonymous 0 Comments

Because it is really really difficult. In a game you are basically dealing with the state of the world and things changing that. Now if you have more then one CPU doing things you get situations like this.

CPU1: Reads the world state

CPU2: Reads the world state

CPU1: Changes how the world is based on the state that it read.

CPU2: Changes how the world is based on the state that it read.

Now because CPU2 didn’t see the changes that CPU1 did its own changes to the word state will be wrong. This is called a race condition. Minecraft makes use of a multithreaded system for example and quite a few of the glitches Minecraft has is by exploting the ways threads updarte.

Anonymous 0 Comments

Concurrency issues, sometimes game logic breaks if some things don’t happen in a certain order, and sometimes coordinating different threads is even harder than just running things linearly.

The example from an old programming book is that you’re making a model plane. You need to make each wing by gluing on flaps and landing gear, so you can make it a bit faster if you ask your friend to do one wing while you do the other. Then it comes to gluing the wings one at a time to the fuselage, well only one part of that can happen at a time, more people can’t help. Also if I brought in 100 people into your lounge, the plane-making effort would not go 100x faster.

Anonymous 0 Comments

There are many reasons. CPU cores are much more complex and powerful than GPU cores (you also generally have much fewer of them, I.e. 4-8 vs the 100s or 1000s in a gpu). CPU cores are generally used for complicated calculations, such as math for physics systems in games. Multicore programming can be very complicated. There are some calculations that cannot be done in parallel, and some that benefit greatly from parallel processing. It’s up to the developer to decide if/when to parallelize, which can be very challenging and time consuming. Another challenge is making sure your parallel code runs on many different types of processor cores. 

  To add to this, many devs use engines such as unreal, godot, unity, etc. These engines abstract away much of the low level complexity of the application itself. Many devs who use these tools literally never think of parallel processing, memory management, and what the processor is physically doing. This can lead to a game that “works” but is very poorly optimized. It’s kind of like building a house with duct tape, then having to go back and replace the duct tape with nails, screws, and other proper fasteners once you start running into issues.  

I’m not saying devs who use these engines are bad developers, but prebuilt game engines do make games very easy to make, even for an inexperienced developer. Modern PCs are extremely fast, and most of the time, inefficient code will run just fine and nobody will notice unless it’s a high-spec game or other critical app

Anonymous 0 Comments

Most modern games are, could you provide some examples of video games that aren’t?

Some people talking about multiple CPUs instead of CPU cores, question is about cores and threads.

There also is very little need for multi core support in games that can run just fine in single core.

Anonymous 0 Comments

Most of the games are written on Unreal Engine and Unity. If those game engines did not implemented usage of multiple cores, you won’t get options to use it. In future, you might get multi-core ability, but you need to add some code to use it in the game.

AAA games has budget to write custom game engine. Now it depends on company to implement multi-core code. If company implemented efficient usage of 4 cores, when people start getting 6 or more cores, code most likely won’t use more than it was anticipated to run.

In general, multi-core code could get ugly and misused very fast, so in regular software development world it is hidden into more safe abstractions and concepts(like co-routines and asynchronous code)

Anonymous 0 Comments

This is the deceiving nature of parallelization and multi-core CPUs.

First you need to realize that not every computational problem can be solved in parallel. This means that your application will always be limited by the aspects that solve these sequential problems. This leads to a very underwhelming realization that most computer programs cannot utilize all your CPU cores and instead use mainly a single core.

Example from Wikipedia: You have an applikation that takes 20h to solve a problem using a single core. Lets assume that 95% of the problem can be parallelized, which is a ridiculous amount. Now we use the new Intel i9 120000k with a bazillion cores and let it loose on our program. It will still take at least an hour, since this part of the problem does not benefit from more cores.

https://en.wikipedia.org/wiki/Amdahl%27s_law

Video games are not an exception. Most video games operate with a game loop where the player input gets parsed, the game state updated. This is hard to parallelize since each execution of the loop is dependent on the result of the previous execution.

Anonymous 0 Comments

So first i’ll need to explain why CPUs have multiple cores, and what advantage they actually provide.

You can think of any given program (including video games) as a set of instructions, progressing from step one to step two and so on. I’m going to break out the old PB&J sandwich metaphor. Consider the following instructions:

Step 1: place bread on table

Step 2: apply peanut butter

Step 3: apply jelly

Step 4: apply bread

That is four steps, and you do them in that order. But do you really have to apply the peanut butter before you apply the jelly? If you had an extra set of hands you could apply the peanut butter and the jelly at the same time. Consider this revised process, with two people called a & b:

Step 1ab: place bread on table (both of them do this)

Step 2a: apply peanut butter

Step 2b: apply jelly

Step 3a: combine jelly slice and peanut butter slice

Now, thanks to having a second set of hands, there’s now only 3 steps, because our original steps 2&3 have been split up and are being done in paralell at the same time. Multiple CPU cores are essentially those “extra hands” that let us do this. However, there are limitations to this. For example, we obviously can’t combine the slices at the same time the pb&j is being applied to them. So no matter how many more extra hands we have, we can’t really split this up any more than it already is.

Another pitfall with paralellism is what’s called a race condition. Say in the above metaphor that we end up applying the peanut butter (step 2a) faster than the jelly (step 2b). If we jump straight into step 3a, before step 2b is done, then we’ll have a mess on our hands. So we need person a to wait for person b to finish before continuing. You usually don’t get this wait behavior for free in programming, and if you forget to tell the program to wait, it won’t and you can get some really weird bugs as a result.

Paralell programming can improve the performance and efficiency of a program, but it has limitations and presents additional challenges.

How this all relates to videogames is that there are a lot of processes that videogames rely on which can’t really be done in paralell, or can’t be done easily in paralell. There are still some things that can be done in paralell, and are becoming more common. For example, rendering is usually done in a seperate thread on a lot of newer games. This allows the physics, logic, input, and networking parts of the game to be decoupled from rendering so they won’t lag or slow down when the GPU is struggling. This helps resolve a lot of the issues related to network lag and tunneling (stuff getting stuck inside of or teleporting through walls).

Another reason why multicore support isn’t as common is because many popular game engines are relatively old and have been around since before multicore CPUs were a thing. They’ve just been updated over time as new technology becomes available. The problem though is that the execution model is one of the major core components of a game engine, so it is very difficult to add multicore support to an engine that wasn’t originally designed for it from the ground up.

Edit: an inconsistency.

Anonymous 0 Comments

>It is common for modern video games to be badly optimised due to, partly, inefficient usage of multiple cores on a CPUs.

Are they though? People like to claim that Starfield is badly optimised but it isn’t, it is just really demanding. A lot of modern games are actually pretty good about using more CPU cores if you have them – for example, BF2042 can easily push a 8 core CPU to 100% utilisation on 64 player servers. The big issue for modern games is when they are designed for the consoles and then ported to PC with zero regard for optmisations for the much wider variety of hardware found.

>I’d assume that developers know this, but don’t have the time to rectify this.

Optimisations require you to start planning for them when you start development. If you wait until you are done then you are going to end up having to rewrite whole swaths of your code which takes a lot of time and can introduce numerous bugs and glitches which further increases the required time. This is why console ports tend to perform poorly on PCs despite PCs often being more powerful – i.e. they are designed with optimisations for the consoles in mind rather than more broader optimisations that you would find on PC (e.g. a lack of graphics options due to the known performance of the console GPUs).

>So, therefore, what are the difficulties in utilising various cores of a CPU effectively?

How to utilise multiple CPU cores is a solved problem these days – you need to go back 15+ years to see how bad people were at optimising for multiple CPU cores. You can break your program into tasks which you can spread around CPU cores as threads and you use locks to protect data that you are using from other tasks who want to change that data. The problem is that you have two kinds of tasks, tasks that can be completed in parallel with each other and tasks that need to be completed sequentially because each task depends on the results of the previous task or from multiple previous tasks. It is the sequential tasks that can only run on a single CPU core with zero parallisation possibilities and are your limiting factor when it comes to performance scaling.