NikiTo said:
Thing is, we need a solid reason to do anything. And i haven't heard of a game that has 8000 zombies. Is there a game with even 800 zombies?
Dying Light, Days Gone, or this Epic Battle Simulator stuff, if non zombies are allowed. Maybe less zombies than 8000, but better animation and gfx for the former examples.
NikiTo said:
Multithreading uses semaphores and lot of extra code to can work, so having two cores doesn't mean the speed of execution will double.
Semaphores, Mutexes, etc… that's not the problem. Those are just the necessary primitives to synchronize stuff.
The problem is a very different one, and because it is not obvious i recommend to get used to MT even if not seemingly totally necessary, for learning purposes.
So what i mean for example are things like this:
You wanna multithread some solver for game physics constraints or UV parametrization for tools.
To do this you'll end up replacing faster gauss seidel method with slower jacobi method (i hope the terms are right - i'm no math guy).
Gauss Seidel means to update a variable immideatly according to its current solution, Jacobi means to cache solutions in a temporary buffer, leave all variables as is and change them in one go after the full iteration over all variables is done.
Only the latter is order independent and can be multithreaded. A solver often takes twice the time to converge, but if you have more cores than two it is worth it.
A similar problem is dividing huge workloads into chunks. If you want to multithread, you may need to enlarge the chunks my a margin of overlap so full adjacency information is present.
For volumetric workloads (blur, cubic filter, etc.) this overlap can have the same volume than the inner region you are interested in.
Again you want more cores than two to make this a real win.
This is what marketing won't tell you, and the reason dual core processors often struggle to beat single cores significantly with real workloads - they only manage to keep the system more responsive to for the user (which is fine).
Now we have 8 cores and 16 threads. This is reason enough to utilize the power. We have to learn how to do it. Gfx drivers will not do this for us, because they do only a small percentage of a game.
And it is worth it. I get an average speedup of 7 with 8 cores, and i got 3.5 with 4 cores on 10 years older CPU.
This difference in performance is the difference between working and useless software more often than not.
SyncViews said:
I guess there are 2 levels of multi-threading to consider as well. You could put all your rendering/animation/etc. logic on one single thread separate from other game stuff (and maybe split some of the other stuff into other threads as well), rather than have nearly the entire game be a single thread. And you can go beyond that and have the rendering itself use multiple threads, but one thread can already do a lot of rendering if that is all it is doing.
Yes, and this is the least we should do because it's almost zero extra work.
It won't teach you parallel programming, but it's a good start.
This often leads me to the question: Should i parallelize the workload, accepting more work / slower algorithm is necessary? Or should i do completely different workloads on different cores, leading to worse cache utilization and CPU saturation but avoiding the extra work?
But so far i never compared those two options and i don't know what the difference could be.