The Newton engine is now Open source with a zlib license.

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Re: The Newton engine is now Open source with a zlib license

Postby Overhertz » Thu Feb 17, 2011 10:05 am

so.. in newton 3 if this is the case if i was writing a game from another language how would i add the external force without a callback? (just curious as to how it will be - as the example you provided is for a c++ user linking the lib file)
Ziron Programming Language
Download the Assembler HERE
User avatar
Overhertz
 
Posts: 112
Joined: Mon Jul 06, 2009 11:19 am

Re: The Newton engine is now Open source with a zlib license

Postby JernejL » Thu Feb 17, 2011 10:19 am

You simply can't do it outside the callback.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1451
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: The Newton engine is now Open source with a zlib license

Postby Julio Jerez » Thu Feb 17, 2011 10:22 am

Good question, I do not know.

I am guessing you can make the modification on you side,
That is the idea of having the source, there will alway be users with different tweaking requierements.
Julio Jerez
Moderator
Moderator
 
Posts: 10989
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: The Newton engine is now Open source with a zlib license

Postby Overhertz » Thu Feb 17, 2011 10:47 am

so for each new newton, the function and code will need to be re-added and compiled. ok. then i guess we will stick just with 2.31 unless we really need to update, without the callback i get a 200fps increase, and for my companies upcoming game, speed and optimisations is everything :)
Ziron Programming Language
Download the Assembler HERE
User avatar
Overhertz
 
Posts: 112
Joined: Mon Jul 06, 2009 11:19 am

Re: The Newton engine is now Open source with a zlib license

Postby Julio Jerez » Thu Feb 17, 2011 11:41 am

OverHetz you are getting too far ahead of yourself. What still do not even have the final update.

one thing I am still not clear, is how it is that a simple callback is producing that much a of a difference in performance.
200 fps seem too execive to me.
Julio Jerez
Moderator
Moderator
 
Posts: 10989
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: The Newton engine is now Open source with a zlib license

Postby Overhertz » Thu Feb 17, 2011 11:48 am

Julio Jerez wrote:OverHetz you are getting too far ahead of yourself. What still do not even have the final update.

one thing I am still not clear, is how it is that a simple callback is producing that much a of a difference in performance.
200 fps seem too execive to me.


think about it like this. 60 fps - 60 callbacks which then call another function that is 2 calls, so 1 obj - 120 calls, also push and pop operations, now 1000 cubes, thats 120 x 1000 = 120000, removing 1 call halves this, 120000 / 2 = 60000 - you technically remove 2 calls since a call to the callback and the callbacks call to addforce (not to mension the call to SetForce inside newton are inline macros, they are optimised and do not use call at all, so thereforce really by getting rid of the callback, the call operations are removed 100%), not only but reducing more than just call, but several push and pop also, if this was called directly in c++ with linked lib, the compiler would optimise the calls by using registers and jmp, but from an external application it will uses push and call. now get some CPU documentation from intel website and check how many cycles each operation take, then disassemble a compiled application both with and without the call and check the difference in operations. note the application for testing must not directly link the newton lib file and use only the c interface.

and finally lets do a complete step by step calulation....
1 box - 60 callback calls per second, so 60 addforce calls per second = 120 calls per second
1 box * 10,000 = 1,200,000 calls per second
Ziron Programming Language
Download the Assembler HERE
User avatar
Overhertz
 
Posts: 112
Joined: Mon Jul 06, 2009 11:19 am

Re: The Newton engine is now Open source with a zlib license

Postby PJani » Thu Feb 17, 2011 12:17 pm

Overhertz wrote:
Julio Jerez wrote:OverHetz you are getting too far ahead of yourself. What still do not even have the final update.

one thing I am still not clear, is how it is that a simple callback is producing that much a of a difference in performance.
200 fps seem too execive to me.


think about it like this. 60 fps - 60 callbacks which then call another function that is 2 calls, so 1 obj - 120 calls, also push and pop operations, now 1000 cubes, thats 120 x 1000 = 120000, removing 1 call halves this, 120000 / 2 = 60000 (not to mesion the call to SetForce inside newton are inline macros, they are optimised and do not use call at all, so thereforce really by getting rid of the callback, the call operations are removed 100%), not only but reducing more than just call, but several push and pop also, if this was called directly in c++ with linked lib, the compiler would optimise the calls by using registers and jmp, but from an external application it will uses push and call. now get some CPU documentation from intel website and check how many cycles each operation take, then disassemble a compiled application both with and without the call and check the difference in operations. note the application for testing must not directly link the newton lib file and use only the c interface.


Overhertz you forgot Pipelines in modern cpus! With pipelines instructions take exacly(or more because of pipeline dangers) the length of pipeline cycles to finish(if you have 10 instructions in pipeline you will need 10 cycles ideally to finish them all and CPI can teoreticly be 1)!

Your idea maybe makes things 0.01% faster, but makes developing prone to errors(i can tell you that from my java toy physics engine)!
This type of optimisation is like squizing a dry lemon.

More instructions CAN BE sometimes FASTER!
Last edited by PJani on Thu Feb 17, 2011 12:19 pm, edited 1 time in total.
| i7-5930k@4.2Ghz, EVGA 980Ti FTW, 32GB RAM@3000 |
| Dell XPS 13 9370, i7-8550U, 16GB RAM |
| Ogre 1.7.4 | VC++ 9 | custom OgreNewt, Newton 300 |
| C/C++, C# |
User avatar
PJani
 
Posts: 448
Joined: Mon Feb 02, 2009 7:18 pm
Location: Slovenia

Re: The Newton engine is now Open source with a zlib license

Postby Overhertz » Thu Feb 17, 2011 12:19 pm

i think you better go review pipelines > http://en.wikipedia.org/wiki/Pipeline_(computing)
you are absolutly missing the point, and adding extra functionality to remove useless callbacks is not "prone to errors" that is rubbish, unless the programmer is a complete idiot,

also note i did not mension more instructions but how long instructions take to complete.
Ziron Programming Language
Download the Assembler HERE
User avatar
Overhertz
 
Posts: 112
Joined: Mon Jul 06, 2009 11:19 am

Re: The Newton engine is now Open source with a zlib license

Postby PJani » Thu Feb 17, 2011 12:30 pm

Overhertz wrote:i think you better go review that > http://en.wikipedia.org/wiki/Pipeline_(computing)


?
I know exacly how pipelines work, with all pipeline dangers(WAR;WAW,RAW,...;inserting bubbles, branch prediction, L1,L2,L3 caches)...

julio made this decision because of modular programming and still newton is almost the fastest physics engine under the sun!
| i7-5930k@4.2Ghz, EVGA 980Ti FTW, 32GB RAM@3000 |
| Dell XPS 13 9370, i7-8550U, 16GB RAM |
| Ogre 1.7.4 | VC++ 9 | custom OgreNewt, Newton 300 |
| C/C++, C# |
User avatar
PJani
 
Posts: 448
Joined: Mon Feb 02, 2009 7:18 pm
Location: Slovenia

Re: The Newton engine is now Open source with a zlib license

Postby PJani » Thu Feb 17, 2011 12:35 pm

Overhertz wrote:you are absolutly missing the point, and adding extra functionality to remove useless callbacks is not "prone to errors" that is rubbish, unless the programmer is a complete idiot,

also note i did not mension more instructions but how long instructions take to complete.


you have the source you can remove callbacks i am not saying you shouldn't!

on modern cpus all instructions should take almost the same time to complete.
| i7-5930k@4.2Ghz, EVGA 980Ti FTW, 32GB RAM@3000 |
| Dell XPS 13 9370, i7-8550U, 16GB RAM |
| Ogre 1.7.4 | VC++ 9 | custom OgreNewt, Newton 300 |
| C/C++, C# |
User avatar
PJani
 
Posts: 448
Joined: Mon Feb 02, 2009 7:18 pm
Location: Slovenia

Re: The Newton engine is now Open source with a zlib license

Postby Overhertz » Thu Feb 17, 2011 12:52 pm

not all instructions since they are split into groups, many instructions need to wait on others, and in this instance, using the call back there is several pushes, pops and calls, and without newton will only then be using jmp ops, it is much more than 0.01%

some psuedo code for you to think about

Code: Select all
proc1 {
  push ebp
  mov ebp, esp
  add esp, FFFFFFFCh
  mov eax, [ebp+08h]
  inc eax
  mov esp, ebp
  pop ebp
  ret
}

proc2 {
  inc eax
  ret
}

caller {
  //type 1 external
  push 5
  call proc1
  //eax is result


  //type 2 internal
  mov eax, 5
  jmp proc2
  //eax is result
}
Ziron Programming Language
Download the Assembler HERE
User avatar
Overhertz
 
Posts: 112
Joined: Mon Jul 06, 2009 11:19 am

Re: The Newton engine is now Open source with a zlib license

Postby Julio Jerez » Thu Feb 17, 2011 1:26 pm

Overhertz you are not complety off,
The idea of adding a const force is not bad. I actually like it

and also the things you mention about the instructions, you are right in part.
yes elimination few callbacks may make some thing faster, is some places bu tthe cost I do not think is a high as you estimate.
must modern CPUs have branch prediction table that make the cost of a call back efectivally zero.
however you are correct in that it still spend time passing argumnet on the stack.

I will add the const force because it is a good idea for interface.
basically instead for initalizing the next acceleration to zero is initalizes it to a const value.
Julio Jerez
Moderator
Moderator
 
Posts: 10989
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: The Newton engine is now Open source with a zlib license

Postby PJani » Thu Feb 17, 2011 1:27 pm

i know that pipeline must wait some instructions()!

the problem here is there is much more other "junk" which makes this tiny problem irrelevant!

You can make two versions of newton now when src is available! And then profile the difference! and then you can make assumptions, like this part is bad we need to replace it!
The theory is never the SAME as practical thing, i have seen weird stuff with much much more instructions and FASTER than with lesser instructions!
| i7-5930k@4.2Ghz, EVGA 980Ti FTW, 32GB RAM@3000 |
| Dell XPS 13 9370, i7-8550U, 16GB RAM |
| Ogre 1.7.4 | VC++ 9 | custom OgreNewt, Newton 300 |
| C/C++, C# |
User avatar
PJani
 
Posts: 448
Joined: Mon Feb 02, 2009 7:18 pm
Location: Slovenia

Re: The Newton engine is now Open source with a zlib license

Postby PJani » Thu Feb 17, 2011 1:28 pm

Julio Jerez wrote:I will add the const force because it is a good idea for interface.
basically instead for initalizing the next acceleration to zero is initalize it to a const value.


I like this part!
| i7-5930k@4.2Ghz, EVGA 980Ti FTW, 32GB RAM@3000 |
| Dell XPS 13 9370, i7-8550U, 16GB RAM |
| Ogre 1.7.4 | VC++ 9 | custom OgreNewt, Newton 300 |
| C/C++, C# |
User avatar
PJani
 
Posts: 448
Joined: Mon Feb 02, 2009 7:18 pm
Location: Slovenia

Re: The Newton engine is now Open source with a zlib license

Postby Overhertz » Thu Feb 17, 2011 1:31 pm

lol, well i'm glad it will be added since it will save me to keep adding it, but the only reason i insist is it is best for everyone to benifit from performance increase, also i do not estimate the performance difference, since i compiled the changes anyways and i tested it live on my engine, so i "know" for sure it is better. and i am running a "MODERN" cpu "lol" unless you will tell me a quad core is old
Ziron Programming Language
Download the Assembler HERE
User avatar
Overhertz
 
Posts: 112
Joined: Mon Jul 06, 2009 11:19 am

PreviousNext

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 12 guests