A place to discuss everything related to Newton Dynamics.
Moderators: Sascha Willems, walaber
by Julio Jerez » Thu Aug 20, 2009 3:02 pm
The narrow phase Is the part that calculate the actual contacts, it make sense that in your game it will be almost zero, because you do not have too many dynamics bodies and they rarely collide.
You will be supririce how fast it really is.
The broadPhase is the part that determine it two bodies are close enough that new contacts need to be calculated, in you level it takes more time because the world is populated with so many static bodies and the engines cannot know without doing a check.
In 1.53 this was very fast because there were two list, one for active and one for inactive, but it is a nightmare to keep track of the logistic,
It is not friendly to multithreaded because it does a huge number of lock/unlock when bodies moves from active to inactive or the other way, it is just bad.
We can fix that when we use the Scene collision.
Once we implement the scene collision it should be almost like Narrow Phase.
But I liek to see what else is wroung before that.
The Blue is the overhead of the collision system and is the sum of the NarrowPhase, the broadPhase plus the Call to force and torque call back and the logic that check if the Body is at Rest,
I will add another counter to sample the calls to force and torque call back because it look like you are doing a lot of work there and it is coming as part of the overhead of the collision.
This is why I ask you if you are calling Invalidate of NewtonBodySetFreezeState from a Newton Update.
Are you doing lot of work in the Force and torque callback,
The avareage amound of time is just too hight, there most be something in the call back or in the collision system overhead that is not acounted for.
I will check tonight with this new infomation.
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by Marc » Thu Aug 20, 2009 3:16 pm
My Force and Torque callbakc is rather minimalistic:
- Code: Select all
void PhysicsApplyForceAndTorque_ZUnit (const NewtonBody* body, dFloat timestep, int threadIndex)
{
CUZUnit * u = (CUZUnit *)NewtonBodyGetUserData(body);
NewtonBodyAddForce(body, u->f.p);
}
I calculate the force I want to apply in my ai code and save it. Later in the callback, I just set it. No calculations there. I also Invalidate the cache outside of callbacks.
-

Marc
-
- Posts: 281
- Joined: Sun Mar 14, 2004 4:07 pm
- Location: Germany
-
by Marc » Thu Aug 20, 2009 3:18 pm
But I have usercollisions. Are they counted already? There is the heightmap and for a few things, there is a usercollision that basically maps to an opcode collision. I did that back then when I didn't know about making collision unique to make them world independent. I do that for the buildings, so basically one + the mines, which are limited to 8 or 10, so at max there are 11 user collisions like that in the scene if you don't build additional buildings.
-

Marc
-
- Posts: 281
- Joined: Sun Mar 14, 2004 4:07 pm
- Location: Germany
-
by hpesoj » Thu Aug 20, 2009 4:16 pm
[Faster maths comment] In x87 mode, I measure version 2.08 to be about 35% faster than 2.07

. In simd mode there's barely any change, although of course simd mode used to be ~88% faster than x87, but is now only ~40% faster.
-
hpesoj
-
- Posts: 90
- Joined: Sun Jan 09, 2005 4:36 pm
- Location: Cambridge/Bristol, UK
by Marc » Thu Aug 20, 2009 4:33 pm
I made an ingame perfgraph:

I don't speak ogre fluently so it's only white lines right now and they also seem to change the color slightly according to the angle to the sun/lightsource - this could be seen as a feature though

You can toggle it with 'P' (n was already taken so I choose newton"P"erfgraph) in the following sequence:
off => all graphs => just collision graphs => just dynamics graphs => off ...
The horizontal bars indicate 10ms.
You can also save a newtonperfgraph.csv by pressing 'O' - I used that for plotting the previous graphs in excel.
I'll publish it in a few minutes, then you can get it by running update.exe.
-

Marc
-
- Posts: 281
- Joined: Sun Mar 14, 2004 4:07 pm
- Location: Germany
-
by Marc » Thu Aug 20, 2009 5:09 pm
done.

-

Marc
-
- Posts: 281
- Joined: Sun Mar 14, 2004 4:07 pm
- Location: Germany
-
by Julio Jerez » Thu Aug 20, 2009 5:20 pm
hpesoj wrote:[Faster maths comment] In x87 mode, I measure version 2.08 to be about 35% faster than 2.07

. In simd mode there's barely any change, although of course simd mode used to be ~88% faster than x87, but is now only ~40% faster.
Un tin tin Y un Tin Tan,
The SSE is normal because the code uses intrisics already. and it seems VS can do a really good job as converting intrisics to optimized code.
GCC is really really bad at that. In some cases GCC comes out with slower code.
Only in very long streams of calculation you can see a marginal performance gain with GCC using SSE.
But having the X87 code being fast for me is very good, because If I can get a compiler that can come close to SSE perfomance I would like to get rid of the Intrisics and state wit the CPP code only.
Visual Studio is campable to issue SSE code in 32 bit, but I am forced to keep it in pentium 2 binary because of the people who use Newton for mutiplayer code.
Anyway I am glad I am not the only one twho can verified the performance gains. 30% is nothing to be shy off.
Some comercial engine make a press release and declare new Technology breaktrought belive me.

-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by Julio Jerez » Thu Aug 20, 2009 5:21 pm
Marc wrote:done.

Ok I will try tonigh.
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by Marc » Thu Aug 20, 2009 7:55 pm
Julio Jerez wrote:Visual Studio is campable to issue SSE code in 32 bit, but I am forced to keep it in pentium 2 binary because of the people who use Newton for mutiplayer code.
If you want to support really old hardware that's true, but I could go for SSE as a requirement for my game I guess. PCs with CPUS that don't know SSE probably are too slow anyways. I'm not sure though about which sse would be ok as a minimum must have. I have no idea since when AMD or Intel had which SSE version in which cpu. I'm just using x87 right now because when I enabled sse there was no noticable speed gain for my scene setup - maybe now with the timing functionality I added a few hours back I could see it. I'll have to try.
Which version of sse does newton require for platformarchitecture 1 ?
-

Marc
-
- Posts: 281
- Joined: Sun Mar 14, 2004 4:07 pm
- Location: Germany
-
by Marc » Thu Aug 20, 2009 8:34 pm
-

Marc
-
- Posts: 281
- Joined: Sun Mar 14, 2004 4:07 pm
- Location: Germany
-
by Julio Jerez » Thu Aug 20, 2009 10:23 pm
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by Julio Jerez » Thu Aug 20, 2009 10:39 pm
Ok I click update, and it downloaded a bunch of files but Now I keep getting these messages
Connecting ...
Connection failed
and it does not let me test anyhing
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by Marc » Thu Aug 20, 2009 11:11 pm
Oh yeah, the server crashed. I have to investigate that tomorrow. For now I just started it again. Just try it again.
The csv file is a simple text file format that contains the values of the performance graph. Excel and OpenOffice can read it and you can plot graphs that way. Gnuplot can also handle it.
-

Marc
-
- Posts: 281
- Joined: Sun Mar 14, 2004 4:07 pm
- Location: Germany
-
by Julio Jerez » Fri Aug 21, 2009 12:07 am
I found a bug in the profiler , you are right the Narrow Phase was always reporting zero.
I fixed now and I will put anothe update in a few minute,
you will have to add that to the code so that the profiler is more representative of what is happening.
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by Julio Jerez » Fri Aug 21, 2009 12:33 am
Ok Get 2.08 again and integrate the new DLL.
make sure you make the changes so that the conters are correct.
How do I show the counters in the game?
I hit the leter p and nothing happens
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
Return to General Discussion
Who is online
Users browsing this forum: No registered users and 1 guest