Double Precision [SOLVED]

Report any bugs here and we'll post fixes

Moderators: Sascha Willems, Thomas

Double Precision [SOLVED]

Postby MeltingPlastic » Sun Feb 10, 2019 10:04 pm

Hi Julio,

When I turn double precision on in the cmake - I get linker errors when linking to the custom joint library. Any Ideas what could cause this?

Thanks!
Last edited by MeltingPlastic on Mon Feb 18, 2019 2:13 pm, edited 1 time in total.
MeltingPlastic
 
Posts: 198
Joined: Fri Feb 07, 2014 11:30 pm

Re: Double Precision

Postby Julio Jerez » Sun Feb 10, 2019 10:30 pm

My guess is that you are linking the plugins.
The plugins do no use double yet. turn the off.
The paraller solev still works, becau seth Vcetor class in he core engien supports double and floats.

The class in teh plugin inoy support float, I will make the AVX suport double some time but I will no waste time of SSE simd for dowubl in teh plugion, since it will be a waste. since SSE can onl do two double and the overheard just will bekae even at best.
AVX is better since irt can do 4 double at a time.

just deslect all plugion and use the default paraller solver.
Julio Jerez
Moderator
Moderator
 
Posts: 10847
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Double Precision

Postby Julio Jerez » Sun Feb 10, 2019 11:37 pm

ok I quickly added the double version of class class dgSoaFloat for the AVX.
It is very eassy since ther are not more than a dozen functions to convert
I have no tested It just compile.

I now have to do the followin.
1-test it.
2-do the same for teh AVX2
3-Add Stub function to the SSE plugin, and have it return false since I will not really do anything while AVX will really take advantage of double.

I am tire now, and I will be out next week. but if I have a chance I will commit it

meantime diseclect the plugins when building with double.
Julio Jerez
Moderator
Moderator
 
Posts: 10847
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Double Precision

Postby Julio Jerez » Fri Feb 15, 2019 10:48 am

ok I now commited the avx and avx2 with double precision.
late over the weekend I will mak eteh sse4.2 also support double so that is all orthogonal.
The only difference is that teh SSE will solve 4 joint per tick instead of 8 liek the avx does.
so that requres some changes to the plugion in addintion to writing the simd vector class.
but is all worth sinmce AMD cpu are so popuplar and the are better at SSE4 than at avx.

If you sync,
for double you can check avx and avx2
for single you can check avx, avx2 and sse4.2

and the system by defual will pick the best according to the vendor literature, each plugin repert an score, teh higher the value the better the architecture accordin to the vendor.

for example an intell will report 5 for avx2, 4 for avx, 3 for SSE4, and 1 for defualt solver
for example an amd will report 3 for avx2, 4 for avx, and 5 for SSE4, and 1 for default solver
Julio Jerez
Moderator
Moderator
 
Posts: 10847
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Double Precision

Postby MeltingPlastic » Fri Feb 15, 2019 1:16 pm

The Speedups for Double Sound Great!

I am having problems linking to the Custom Joint Lib even with avx, sse, etc.. turned off.

whats weird is that I can turn double off and everything works. This is with the Urho3D repo.
MeltingPlastic
 
Posts: 198
Joined: Fri Feb 07, 2014 11:30 pm

Re: Double Precision

Postby MeltingPlastic » Fri Feb 15, 2019 1:29 pm

Also on a sperate note - I just submitted 2 issues using the master branch:

https://github.com/MADEAPPS/newton-dynamics/issues/143
https://github.com/MADEAPPS/newton-dynamics/issues/144

Also - just saw the roller coaster joint - super cool - gives me alot of ideas :D
MeltingPlastic
 
Posts: 198
Joined: Fri Feb 07, 2014 11:30 pm

Re: Double Precision

Postby Julio Jerez » Fri Feb 15, 2019 2:53 pm

the animation linking I just made a clean build and test the animations, I did no have any problems.

make sure you delete all the legacy build directories, the plugins are copied to those directories, if you has an old dll that was complied but is logically bogus, it will load because there are dynamically loaded not linked.
notice that the destination folder for single precision is: ..\demosSandbox\Release\newtonPlugins
and the for double precision is: ..\demosSandbox\Release\newtonPlugins\Release_double

and the high level code is responsible for passing the proper path, for the sandboxDemo the loading is like this

Code: Select all
#ifdef _DEBUG
   #ifdef _NEWTON_USE_DOUBLE
      strcat(plugInPath, "/newtonPlugins/debug_double");
   #else
      strcat(plugInPath, "/newtonPlugins/debug");
   #endif
#else
   #ifdef _NEWTON_USE_DOUBLE
      strcat(plugInPath, "/newtonPlugins/release_double");
   #else
      strcat(plugInPath, "/newtonPlugins/release");
   #endif
#endif
   NewtonLoadPlugins(m_world, plugInPath);


on the first issue in GitHub, is that a real problem?
I notice than in Linux is automatics, but I kind of like that is visual studio you have to explicitly build the install to copy the file, else it keep doing each time to do clean and build which I do a lot.

the second issue is fixed.

on the speed up with double, this has been a mystery to me for more than 20 years.
I know that all indicators: bandwidth, floating point throughput and code size point to that double should be slower, in fact literally 50% slower, but every time I made same code run using double and single precision I get the surprise that double end up been faster and I have no explanation as to why that is.
Julio Jerez
Moderator
Moderator
 
Posts: 10847
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Double Precision

Postby MeltingPlastic » Fri Feb 15, 2019 3:56 pm

No the first issue is not really a real problem, just a nicety for newcomers.

I figure out my issue - I was not defining _NEWTON_DOUBLE in my upperlevel project. Thus newton was built with double - but the upper level project would evaluate the headers without doubles - resulting in linker errors.
MeltingPlastic
 
Posts: 198
Joined: Fri Feb 07, 2014 11:30 pm

Re: Double Precision

Postby MeltingPlastic » Fri Feb 15, 2019 4:32 pm

Now I am getting a crash related to terrain: https://github.com/MADEAPPS/newton-dynamics/issues/145
MeltingPlastic
 
Posts: 198
Joined: Fri Feb 07, 2014 11:30 pm

Re: Double Precision

Postby Julio Jerez » Fri Feb 15, 2019 4:42 pm

Does it happens in
- single provision
- single thread mode

What demo?
There are some demos that are crashing because I change the .ngd file format in order to import FBX files.
There was a until that I use for versions updates, but it was a wxwidget app that is not supported anymore, so those old msg files are are all lost.
My guess is that that demos is chashing loading one of those.
Julio Jerez
Moderator
Moderator
 
Posts: 10847
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Double Precision

Postby MeltingPlastic » Fri Feb 15, 2019 4:52 pm

The Demo is User Heightfield collision mesh.

it works in single precision mode + multithreaded.
MeltingPlastic
 
Posts: 198
Joined: Fri Feb 07, 2014 11:30 pm

Re: Double Precision

Postby Julio Jerez » Fri Feb 15, 2019 6:16 pm

oh is fixed now, my mistake, when costing a vector of float to a vector on integers I forget that the function actually expect to load the integer to the register, no a float rounded to an integer so I chneg the code to this.

Code: Select all
      dgInt64 w = _mm_cvtsd_si32(_mm_shuffle_pd(temp.m_typeHigh, temp.m_typeHigh, PERMUT_MASK_DOUBLE(1, 1)));
//      return dgBigVector(_mm_set_pd(*(dgFloat32*)&y, *(dgFloat32*)&x), _mm_set_pd(*(dgFloat32*)&w, *(dgFloat32*)&z));
      return dgBigVector(y, x, w, z);
      return dgBigVector(_mm_set_pd(*(dgFloat32*)&y, *(dgFloat32*)&x), _mm_set_pd(*(dgFloat32*)&w, *(dgFloat32*)&z));


and added a constructor to deal with the casting, by that function is use on the terrain, so that was a mistake, I reverted the change, since in the end the function si no use at all by the SIMD double class because is not SSE it is AVX.
Thanks

so you like that roller coaster little demo, thats one of these little thing that a General robust set of Joint can do without much effort.
That demo was there for a long time, and I made a change that broke it for a while, the I went to work on the optimization and have many joint commented out.
But now that I re enabled I am bringing them all back.
I hope you can make some with it. :D

The next demos that I will rename is the capsule player controller and the soft bodies.
Julio Jerez
Moderator
Moderator
 
Posts: 10847
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Double Precision

Postby Julio Jerez » Sat Feb 16, 2019 2:45 pm

al right now all plugin support double precision.
Julio Jerez
Moderator
Moderator
 
Posts: 10847
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Double Precision

Postby MeltingPlastic » Sat Feb 16, 2019 3:21 pm

Wow this is Great!
MeltingPlastic
 
Posts: 198
Joined: Fri Feb 07, 2014 11:30 pm


Return to Bugs and Fixes

Who is online

Users browsing this forum: No registered users and 1 guest