Multithreading

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Multithreading

Postby Firefly » Wed Nov 02, 2011 8:27 pm

I'm trying to work out how to get the best performance out of Newton and have been looking at the multi-threading options available.

Are there any advantages of running NewtonUpdate in a separate thread? I noticed it is done in one of the example applications. How does this relate to NewtonSetThreadsCount and NewtonSetMultiThreadSolverOnSingleIsland?

Should I run NewtonUpdate in it's own thread and have 1-2 other threads running inside Newton too?


Cheers.
Firefly
 
Posts: 32
Joined: Wed Jan 17, 2007 4:58 am

Re: Multithreading

Postby Julio Jerez » Wed Nov 02, 2011 9:07 pm

in core 200 seting Set Thread count to two or maybe three gives the best overall peformance

in core 300, the higher the thread count the better performance if you have the hardwere.
I core 300 you can set thread count to say 8 and that will be good for almost all kind of CPUs.
The problem is that core 300 is not completed yet.
also setting single islan muticore yeild better perfomence when teh is lot of stacking in core 300.
this is also true for core 200 but the solve becode more unstable.

running in separate thread is good for you applcation but itr does no really make Newton faster, The reason the demo show newton running in separate threads because doing that
you will have to implement a way for smooth iteplantion since the graphics and the simulation will be out of phase.

core 300: 4 or 8 threads, plus single island mutithread on and also rinng it is own thread will be good.
core 200: 2 threads, plus single insland mutithread off, and also rinng it is own thread will be good.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Multithreading

Postby Firefly » Wed Nov 02, 2011 10:02 pm

Thanks for clarifying Julio.

I'm using a fixed time step as proposed in this article http://gafferongames.com/game-physics/fix-your-timestep/. Therefore I have an interpolation value available to smooth out the graphics.

I'll move to core 300 when it becomes the standard for Newton. Any estimate on when that will be?
Firefly
 
Posts: 32
Joined: Wed Jan 17, 2007 4:58 am

Re: Multithreading

Postby pHySiQuE » Wed Nov 02, 2011 10:26 pm

You can run NewtonUpdate on a separate thread so that all your physics are processing while the rest of your game renders graphics and other stuff. You just have to be careful about how you make changes to bodies and stuff, like you can't change a body's mass while physics are running on a separate thread. You have to wait until the thread finishes and then sync with it and make all your changes.
pHySiQuE
 
Posts: 608
Joined: Fri Sep 02, 2011 9:54 pm

Re: Multithreading

Postby Firefly » Wed Nov 02, 2011 11:57 pm

pHySiQuE wrote:You can run NewtonUpdate on a separate thread so that all your physics are processing while the rest of your game renders graphics and other stuff. You just have to be careful about how you make changes to bodies and stuff, like you can't change a body's mass while physics are running on a separate thread. You have to wait until the thread finishes and then sync with it and make all your changes.


In the sample it seems to StopExecution/ContinueExecution when doing any modification to the NewtonWorld object. This isn't really a great way I don't think. Can you explain a little more on how you would wait for the thread to finish and how to sync? I'm guessing there'd be the need for some kind of locking/mutex/critical section?
Firefly
 
Posts: 32
Joined: Wed Jan 17, 2007 4:58 am


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron