Spring is running in SMP

Spring is running in SMP

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

Post Reply
zerver
Spring Developer
Posts: 1358
Joined: 16 Dec 2006, 20:59

Spring is running in SMP

Post by zerver »

The Spring Multithreading version can be downloaded HERE

Hi!

I've been experimenting with multithreading certain parts of the rendering. I have it now up and running (see screenshot) and there is (possibly) a slight performance increase in FPS. At least it uses all the CPUs nicely :mrgreen:

I would like to multithread the Sim as well, but it is horribly difficult since it must produce identical results, no matter in which order processors execute the code. Otherwise the game will desync.

I have not given up yet though. This MT rendering is still good news tho.

/ Z
Attachments
smp.jpg
(254.26 KiB) Downloaded 747 times
Last edited by zerver on 24 Mar 2010, 16:49, edited 1 time in total.
User avatar
Vadi
Posts: 446
Joined: 03 Jan 2008, 14:51

Re: Spring is running in SMP

Post by Vadi »

Forgive the newbieness, but the current spring already does use the cpu's nicely - half of each max, to be exact. (confused :| )

Edit: So now it'll be able to go above halves at times?
User avatar
aegis
Posts: 2456
Joined: 11 Jul 2007, 17:47

Re: Spring is running in SMP

Post by aegis »

the current spring is only using a single thread
BoredJoe
Posts: 139
Joined: 03 Mar 2006, 01:37

Re: Spring is running in SMP

Post by BoredJoe »

You should submit it on mantis or in the dev forum maybe :)
Vadi wrote:Forgive the newbieness, but the current spring already does use the cpu's nicely - half of each max, to be exact. (confused :| )

Edit: So now it'll be able to go above halves at times?
Thats just the same thread switching over from 1 processor to the other , so on average it uses each core by half but its only using 1 at a time.

This doesnt really matter much on intel based multi-cores as they share the same cache, but on amd multi-cores with seperate caches per core its quite bad and can be pretty slow.
zerver
Spring Developer
Posts: 1358
Joined: 16 Dec 2006, 20:59

Re: Spring is running in SMP

Post by zerver »

It matters on any processor really. The shared cache is just a small bottleneck.

On a quad core, Spring is using a single core which means 25% CPU usage - a terrible waste of performance IMO.
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Re: Spring is running in SMP

Post by Kloot »

Nice. There are certain parts of the simulation which are
probably "easier" to make threadsafe or even re-entrant
than others (coldet, path estimation), but even then the
time investment needed to rewrite and test them across
all possible CPU configs would quickly defeat the point. If
you already have any concrete plans it might help to post
them here here so others can pitch in too, the more dev
cores put to work on this the bigger the chance it will get
done. ;)
User avatar
AF
AI Developer
Posts: 20686
Joined: 14 Sep 2004, 11:32

Re: Spring is running in SMP

Post by AF »

As far as I am aware onyl NTai and OTAI have ever made use of threading, and only in their build algorithms. Moving the AI interface into a thread may help prevent slowdown, especially in the AIs with no threading at all such as KAI and AAI.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6238
Joined: 29 Apr 2005, 01:14

Re: Spring is running in SMP

Post by FLOZi »

This sounds like VERY promising work :-)
User avatar
Snipawolf
Posts: 4357
Joined: 12 Dec 2005, 01:49

Re: Spring is running in SMP

Post by Snipawolf »

Go go go! Multiple cores for the win! :P
User avatar
ILMTitan
Spring Developer
Posts: 410
Joined: 13 Nov 2004, 08:35

Re: Spring is running in SMP

Post by ILMTitan »

I agree with Kloot. IMHO, it would be far to difficult and even dangerous to multi-thread the synced code. Threading the unsynced portions, however (as previously mentioned, AIs and display) would be almost pure win.
User avatar
Vadi
Posts: 446
Joined: 03 Jan 2008, 14:51

Re: Spring is running in SMP

Post by Vadi »

Are there any numbers on how much does AI and display actually take up ough? Using 'b', it looks like AI takes up almost nothing, while display quite a bit (up to 50% at times). I was told that's not overly accurate though - so anyone have a better measure?
User avatar
Snipawolf
Posts: 4357
Joined: 12 Dec 2005, 01:49

Re: Spring is running in SMP

Post by Snipawolf »

No idea, but reflections/shadows takes 75 percent or more right at the beginning of the game for me.
User avatar
Vadi
Posts: 446
Joined: 03 Jan 2008, 14:51

Re: Spring is running in SMP

Post by Vadi »

I think it's just shadows. I tried with reflections on / shadows off, and it was only like 5% :?

That's not bad though - remember it's a %. At the start, there isn't a lot of unit logic and etc being done, just the map & landscape.
User avatar
genblood
Posts: 862
Joined: 19 Jan 2005, 03:37

Re: Spring is running in SMP

Post by genblood »

In the next few weeks AMD will be releasing it's AMD Phenom
8000 series to the OEMs. Single core CPUs have been replaced
with 3, 4, and soon to be released 6 core CPUs from Intel. I only
see a plus if the Spring engine takes advantage of the extra
cores.

I figure in the coming months the Spring engine will get multi thread support ...
I think Spring is a great RTS gaming engine and looking forward to new improvements.
User avatar
LordMatt
Posts: 3393
Joined: 15 May 2005, 04:26

Re: Spring is running in SMP

Post by LordMatt »

Am I the only person who has run spring on both single and multi-core CPUs and thinks that normal users won't notice any difference between having multi-core support or not? Spring has been GPU limited on both my Athlon 64 4000+ (with 6800 Ultra) and my quad core conroe 2.4Gz (with 8800GTS). I don't think I've ever seen my CPU usage go above 50% inside of spring at normal game speed.

Adding mutli-core support isn't going to make spring run any faster, and in fact I'd rather spring kept all of it's usage to a single core, rather than maxing out multiple cores (that it isn't even fully utilizing), because I'm often running other things on the other 3 cores. I think the developer time would be better spent optimizing GPU performance.
User avatar
Nemo
Spring 1944 Developer
Posts: 1376
Joined: 30 Jan 2005, 19:44

Re: Spring is running in SMP

Post by Nemo »

LordMatt wrote:Am I the only person who has run spring on both single and multi-core CPUs and thinks that normal users won't notice any difference between having multi-core support or not?
Yes.

Spring has been GPU limited on both my Athlon 64 4000+ (with 6800 Ultra) and my quad core conroe 2.4Gz (with 8800GTS). I don't think I've ever seen my CPU usage go above 50% inside of spring at normal game speed.


The reason for this being that spring is running on a single thread. Namely, it's not using the other core's processing power, but maxing out the single one it has available. Hence the very hard limit on how much usage it shows. I'd have to disagree with you on being GPU limited, unless you've turned all of the settings all the way to max. However, that makes you a very small minority of the spring playerbase - while plenty of users have dual core processors, VERY few have a GPU that can run dynamic water and all the other fancy things at full bore.
Adding mutli-core support isn't going to make spring run any faster,
incorrect - letting spring use all available cores will allow a quad core conroe (like yours) to bring it's full available power to bear on Spring, rather than being restricted to a fourth of that processing power as it is now. once you have a quad core putting everything towards spring, yes, it may then be GPU limited (but that's getting into games with 5k+ units or loads of effects).
and in fact I'd rather spring kept all of it's usage to a single core, rather than maxing out multiple cores (that it isn't even fully utilizing), because I'm often running other things on the other 3 cores. I think the developer time would be better spent optimizing GPU performance.
allowing spring to make use of multiple cores doesn't mean it always will - in windows, at least, there's a button to restrict a program to a single core. allowing spring to make use of multiple cores is a good thing, period. the problem with it until now has been the huge amount of work required to get it there.
User avatar
LordMatt
Posts: 3393
Joined: 15 May 2005, 04:26

Re: Spring is running in SMP

Post by LordMatt »

You didn't address the part where I said it isn't even maxing out one core, ever (on two different CPUs spanning 4 years of CPU technology). Additionally I have to use the FPS widget to turn off graphical options as the game progresses so that spring does not completely run the GPU into the ground, and so that the FPS remains ~30 (above which you will not notice much difference). This, of course, has no effect on CPU usage which never nears max. Making spring run on multiple cores will not increase your FPS or the smoothness of your gameplay if you are GPU limited.

Now it may be that my CPU never maxes out because I never have the slowest CPU ingame, and thus my CPU is never taxed as much as another player's, however making spring multi-threaded will not address this issue either, as one person having old hardware will make the game slow for everyone, regardless if they have fast multi-core CPUs or not.

Thus it would make more sense for devs to optimize GPU processing.
User avatar
Nemo
Spring 1944 Developer
Posts: 1376
Joined: 30 Jan 2005, 19:44

Re: Spring is running in SMP

Post by Nemo »

I guess then it goes to relative gains. Any optimization for GPUs would likely fix things for the highest end users - people who run with full shadows/fancy water/ect. I'd say the number of people who play regularly with those settings is smaller than the number of people who have a decent dual core which they're only getting half-power out of.

Anyways, it ultimately doesn't matter what you or I think "the devs" should work on; they should work on whatever they want to work on so that it has a chance of actually being done.

Edit:
On topic: I second flozi: this sounds hugely promising. keep it up!
User avatar
LordMatt
Posts: 3393
Joined: 15 May 2005, 04:26

Re: Spring is running in SMP

Post by LordMatt »

Well I think ANYONE with a dual core is not CPU limited atm, so my point stands.
Jonanin
Posts: 107
Joined: 13 Jan 2008, 21:34

Re: Spring is running in SMP

Post by Jonanin »

LordMatt wrote:Thus it would make more sense for devs to optimize GPU processing.
Any optimization is a good optimization :D (K, well not when it gives unreadable/messy code and doesn't make much difference at all)

Also, LordMatt, you are contradicting yourself. First you say that you think spring hardly ever maxes out a single core (which it does), and then you say you don't want threading because you don't want it to max out multiple cores (which it won't on your quad core)

If you say it doesn't max out a single core then threading will be fine for you.
Post Reply

Return to “Engine”