Spring is running in SMP - Page 9

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

Re: Spring is running in SMP

Post by zerver »

Roughly 15-20% when you have many units on screen and/or high terrain detail. It does not seem to benefit much from more than 2 cores since a single thread makes all the GL calls anyway.

The real gain would come from multithreading the Sim which is, to say the least, utterly difficult.
User avatar
clericvash
Posts: 1394
Joined: 05 Oct 2004, 01:05

Re: Spring is running in SMP

Post by clericvash »

Well some good optimization is better than none, good job, can't wait to see the benefits when it is all released.
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Re: Spring is running in SMP

Post by Tobi »

zerver wrote:Roughly 15-20% when you have many units on screen and/or high terrain detail. It does not seem to benefit much from more than 2 cores since a single thread makes all the GL calls anyway.

The real gain would come from multithreading the Sim which is, to say the least, utterly difficult.
Have you thought about (imho) most obvious design of running two main loops (in 2 threads), one for rendering and one for sim.

Then pick right granularity of locking to prevent stuff like rendering a unit in render thread while it is being deleted and the memory reused in sim thread.

(Could pick some parts of sim and use separate locks for each, so e.g. units can't be rendered while units are being simulated, projectiles can't be rendered while projectiles are being simulated etc.; or could pick a lock per unit/projectile, or some combination of both.)

I don't think the fact that this, from users point of view, introduces inconsistent reads (ie. some units may be one frame in future compared to other units) is a significant problem.

In any case keep synced simulation entirely in one thread, I don't want to know how painful MT + sync debugging would be.
zerver
Spring Developer
Posts: 1358
Joined: 16 Dec 2006, 20:59

Re: Spring is running in SMP

Post by zerver »

Yes, now that most (all?) GL calls seem to be removed from the sim, it would be possible to do something like that.

Some units rendered one frame ahead could make the animations a bit jerky. Not a big deal, but I'd prefer a solution that did not have this problem.
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Re: Spring is running in SMP

Post by Tobi »

Then pick locking granularity that solves this, ie. don't render any units while any unit is being simulated.

Then worst that could happen is that e.g. projectiles are rendered one frame ahead/back from units.
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Re: Spring is running in SMP

Post by Tobi »

btw zerver check buildbot after you commit
http://buildbot.no-ip.org:8010/waterfall
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

Re: Spring is running in SMP

Post by imbaczek »

request adding a -D_GML_ buildbot, since I get really bogus errors on gcc 4.3/mingw:

Code: Select all

rts/lib/gml/gml.cpp:156: error: invalid conversion from 'GLUquadric* (*)()' to 'GLUquadric* (*)()'
line number is offset somewhat, the culprit is this piece of code:

Code: Select all

gmlSingleItemServer<GLUquadric *, GLUquadric *(GML_GLAPIENTRY *)(void)> gmlQuadricServer(&gluNewQuadric, 100, 25);
edit: removing GML_GLAPIENTRY helps with this one, looks like a gcc wart.
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Spring is running in SMP

Post by jK »

Q: would it be possible to remove any linking to gml.h if GML isn't used?
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

Re: Spring is running in SMP

Post by imbaczek »

issues left to fix which I have no idea how to:

Code: Select all

rts\Rendering\UnitModels\s3oParser.cpp: In member function 'void CS3OParser::DrawSub(SS3O*)':
rts\Rendering\UnitModels\s3oParser.cpp:302: error: 'GML_FUNCTION_NOT_IMPLEMENTED' was not declared in this scope
rts\Rendering\GL\VertexArray.cpp: In member function 'void CVertexArray::DrawArrays(int, int)':
rts\Rendering\GL\VertexArray.cpp:64: error: 'GML_FUNCTION_NOT_IMPLEMENTED' was not declared in this scope
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Re: Spring is running in SMP

Post by Tobi »

imbaczek wrote:request adding a -D_GML_ buildbot, since I get really bogus errors on gcc 4.3/mingw:
What is the configure commandline? (can it be done with scons configure?)

If it can only be done with cmake: I didnt create any cmake builder yet but I can do it, in particular if someone points me to accurate instructions on how to build it with it.
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

Re: Spring is running in SMP

Post by imbaczek »

it can't, I hardcoded that in my SConstruct.
Auswaschbar
Spring Developer
Posts: 1254
Joined: 24 Jun 2007, 08:34

Re: Spring is running in SMP

Post by Auswaschbar »

It doesn't compile:

Code: Select all

spring/trunk/rts/lib/gml/gml.cpp:145: Fehler: keine passende Funktion für Aufruf von »gmlSingleItemServer<unsigned int, GLhandleARB (*)()>::gmlSingleItemServer(GLuint (**)(), int, int)«
spring/trunk/rts/lib/gml/gmlcls.h:804: Anmerkung: Kandidaten sind: gmlSingleItemServer<T, C>::gmlSingleItemServer(C, int, int) [with T = unsigned int, C = GLhandleARB (*)()]
spring/trunk/rts/lib/gml/gmlcls.h:794: Anmerkung:                  gmlSingleItemServer<unsigned int, GLhandleARB (*)()>::gmlSingleItemServer(const gmlSingleItemServer<unsigned int, GLhandleARB (*)()>&)
and lots of similar errors. Using gcc 4.3.1 (without _GML_).
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

Re: Spring is running in SMP

Post by imbaczek »

I thought I fixed these in r6121 and r6122 - please check those out and try similar measures. Much of the issue stems from the fact that gcc can't properly handle attributes of functions in template arguments (I guess).
Auswaschbar
Spring Developer
Posts: 1254
Joined: 24 Jun 2007, 08:34

Re: Spring is running in SMP

Post by Auswaschbar »

imbaczek wrote:I thought I fixed these in r6121 and r6122 - please check those out and try similar measures. Much of the issue stems from the fact that gcc can't properly handle attributes of functions in template arguments (I guess).
It was your change that broke it, when i replace

Code: Select all

#if defined(__GNUC__) && (__GNUC__ >= 4) && (__GNUC_MINOR__ < 3)
with

Code: Select all

#if 0
in gml.cpp and gml.h it works ;). Are you sure this stuff is needed?
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

Re: Spring is running in SMP

Post by imbaczek »

Auswaschbar wrote:It was your change that broke it, when i replace

Code: Select all

#if defined(__GNUC__) && (__GNUC__ >= 4) && (__GNUC_MINOR__ < 3)
with

Code: Select all

#if 0
in gml.cpp and gml.h it works ;). Are you sure this stuff is needed?
Yes, but maybe only on Windows, don't have any Linux box with gcc 4.3. BTW, my commit was actually:

Code: Select all

	#if defined(__GNUC__) && (__GNUC__ >= 4) && (__GNUC_MINOR__ >= 3)
if you had < instead of >=, that may have been it.
Auswaschbar
Spring Developer
Posts: 1254
Joined: 24 Jun 2007, 08:34

Re: Spring is running in SMP

Post by Auswaschbar »

imbaczek wrote:
Auswaschbar wrote:It was your change that broke it, when i replace

Code: Select all

#if defined(__GNUC__) && (__GNUC__ >= 4) && (__GNUC_MINOR__ < 3)
with

Code: Select all

#if 0
in gml.cpp and gml.h it works ;). Are you sure this stuff is needed?
Yes, but maybe only on Windows, don't have any Linux box with gcc 4.3. BTW, my commit was actually:

Code: Select all

	#if defined(__GNUC__) && (__GNUC__ >= 4) && (__GNUC_MINOR__ >= 3)
if you had < instead of >=, that may have been it.
I inserted that "<" to test if it works. When cross-compiling with gcc 4.3.1, I also have to insert "#if 0" to make it work.
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

Re: Spring is running in SMP

Post by imbaczek »

that's bad. fix it so it works for linux crosscompiles, I'll wait for gcc 4.3.1 official mingw release and then we'll consider options we have.
Auswaschbar
Spring Developer
Posts: 1254
Joined: 24 Jun 2007, 08:34

Re: Spring is running in SMP

Post by Auswaschbar »

Do you know how to check the last version number for gcc?
4.3.1 -> "1"?
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

Re: Spring is running in SMP

Post by imbaczek »

__GNUC_PATCHLEVEL__ IIRC.
Satirik
Lobby Developer
Posts: 1688
Joined: 16 Mar 2007, 18:27

Re: Spring is running in SMP

Post by Satirik »

so will 0.77 support multi core cpu ? if yes will it be two different exe ? or the same one with an option to enable disable or ... ?
Post Reply

Return to “Engine”