Compiling With Double Precision

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Re: Compiling With Double Precision

Postby Julio Jerez » Mon Dec 16, 2013 2:13 pm

Oh sorry, I forget to reply to this.
When I try to apply the patch, I found too many change on eth type defines, for example you change so functions to take explicit types float and double.
Like these functions
Code: Select all
   void TransformTriplex (float* const dst, dgInt32 dstStrideInBytes,  const float* const src, dgInt32 srcStrideInBytes, dgInt32 count) const;
   void TransformTriplex (double* const dst, dgInt32 dstStrideInBytes,  const dgFloat64* const src, dgInt32 srcStrideInBytes, dgInt32 count) const;
   void TransformTriplex (double* const dst, dgInt32 dstStrideInBytes,  const float* const src, dgInt32 srcStrideInBytes, dgInt32 count) const;

That’s not what I had in mind, in my mind the change be a single define in command lines, and the code should compile correctly.
I though a making the build and make the nesseray change, but I was busy with the destruction and automatic uvUnWrap code for the Appling the texture to the chunks.
Let us do this, give a day or two to bring the destruction code to stable point, make the project with double in a separate branch.
Basically all that is needed to do is to make the
-full implementation of the dgVector using dgFloat64 and
-Define dgFloat32 to be double,
-compile and put if def out to all of the function that will conflict because they take explicit dgFloa32 and dgFloat64 and parameters
That about a weekend of work, I will do that and you do the test.
Bu I cannot take that patch that explicitly declares function to take float and double, because that make the code no cross plalform.
Is that OK?
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Compiling With Double Precision

Postby nicokruithof » Mon Dec 16, 2013 3:15 pm

Sure, that is fine. Let me know when you're ready. It wasn't clear to me how to get the code compiling, too bad I chose the wrong direction.

While at it, would it be possible to change the __USE_DOUBLE_PRECISION to something more specific like NEWTON_USE_DOUBLE?
nicokruithof
 
Posts: 14
Joined: Tue Dec 03, 2013 3:25 am

Re: Compiling With Double Precision

Postby Julio Jerez » Wed Dec 18, 2013 12:18 pm

ok this is what I have so far.
I changed the define to _NEWTON_USE_DOUBLE
I define that in the command line of all subproject, in a local branch
almost everything compile except for few functions that the prototype signature resolve to the same thing like these ones
Code: Select all
   void TransformTriplex (dgFloat32* const dst, dgInt32 dstStrideInBytes,
                     const dgFloat32* const src, dgInt32 srcStrideInBytes, dgInt32 count) const;

#ifndef _NEWTON_USE_DOUBLE
   void TransformTriplex (dgFloat64* const dst, dgInt32 dstStrideInBytes,
                     const dgFloat64* const src, dgInt32 srcStrideInBytes, dgInt32 count) const;

   void TransformTriplex (dgFloat64* const dst, dgInt32 dstStrideInBytes,
                     const dgFloat32* const src, dgInt32 srcStrideInBytes, dgInt32 count) const;
#endif



the dlls all compile, so ta is good, but I now have to fix some funtions the dVector, that make asumption that the atomic data type is float
this is an examp0le
Code: Select all
   DG_INLINE dgVector TestZero() const
   {
      const dgInt32* const a = (dgInt32*)&m_x;
      return dgVector ((a[0] == 0) ? dgInt32 (0xffffffff) : dgInt32 (0),
                   (a[1] == 0) ? dgInt32 (0xffffffff) : dgInt32 (0),
                   (a[2] == 0) ? dgInt32 (0xffffffff) : dgInt32 (0),
                    (a[3] == 0) ? dgInt32 (0xffffffff) : dgInt32 (0));
   }


I also nee to redefine these constant
Code: Select all
dgVector dgVector::m_triplexMask (0xffffffff, 0xffffffff, 0xffffffff, 0);
dgVector dgVector::m_signMask (0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff);


and I believe that all it need.
I will do that tomorrow, and after that I will write the SS2 vetison fo eth dgVector, that will make the double just as fast as the float.
the reason is that the dgVector using float function to emulate simd code, so is much slower tha the simd class, by when I make the dgVector usin SSE that will go away.

if you sync you will see that the change are very minor so far
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Compiling With Double Precision

Postby nicokruithof » Wed Dec 18, 2013 3:30 pm

That sounds good. I had changed the constants in the diff I sent you, but then I still didn't get collisions. So something was still wrong.

We'll probably need the SSE instructions because we are switching to double because we are getting floating point rounding errors because our models are becoming larger. And bigger models also mean more compute power ;)
nicokruithof
 
Posts: 14
Joined: Tue Dec 03, 2013 3:25 am

Re: Compiling With Double Precision

Postby Julio Jerez » Wed Dec 18, 2013 3:48 pm

nicokruithof wrote:I had changed the constants in the diff I sent you, but then I still didn't get collisions. So something was still wrong.

changing the const is not enough, ther are soem funtion that use soem const that were nodefined. do not no worry I will fix in teh tow day.

I will see if I add a simpel demo to test the functionality is correct. Maybe there are some special codee that need to be updated
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Compiling With Double Precision

Postby nicokruithof » Sat Dec 28, 2013 2:06 pm

It seems that some of the posts in this thread are missing.
nicokruithof
 
Posts: 14
Joined: Tue Dec 03, 2013 3:25 am

Re: Compiling With Double Precision

Postby Julio Jerez » Sat Dec 28, 2013 8:17 pm

missing?
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Compiling With Double Precision

Postby nicokruithof » Sun Dec 29, 2013 4:10 am

Hmmm. Strange. Yesterday the last part of the conversation was missing. Now it has reappeared. Maybe something was wrong with my cache.
nicokruithof
 
Posts: 14
Joined: Tue Dec 03, 2013 3:25 am

Re: Compiling With Double Precision

Postby nicokruithof » Thu Jan 23, 2014 2:58 pm

Hi Julio,

Can you give an update of the current status?

Nico
nicokruithof
 
Posts: 14
Joined: Tue Dec 03, 2013 3:25 am

Re: Compiling With Double Precision

Postby pHySiQuE » Sat May 24, 2014 8:15 pm

I'm moving my engine to double precision now. We have some flight sims and stuff that needs it. Unless 32-bit floats are still significantly faster on 64-bit CPUs, I say focus on the future.
pHySiQuE
 
Posts: 608
Joined: Fri Sep 02, 2011 9:54 pm

Re: Compiling With Double Precision

Postby nicokruithof » Wed Jun 04, 2014 1:47 am

Do you mean that you are to use Newton with double precision for your flight sims? Or did you switch to another physics engine?
nicokruithof
 
Posts: 14
Joined: Tue Dec 03, 2013 3:25 am

Re: Compiling With Double Precision

Postby Julio Jerez » Mon Jul 07, 2014 11:33 am

I resume work on the engine now.
I will complete the double precision project this Saturday.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Compiling With Double Precision

Postby nicokruithof » Mon Feb 02, 2015 4:11 am

Hi Julio,

It's been a while since we updated newton on our side, can you give an update on this post?

Nico
nicokruithof
 
Posts: 14
Joined: Tue Dec 03, 2013 3:25 am

Re: Compiling With Double Precision

Postby donggas90 » Sun May 17, 2015 4:51 am

I had compiled the Newton with double.
You should add _NEWTON_USE_DOUBLE at preprocessor options in project properties.
Then build it.
You will encounter several errors such as duplicated definition and ambiguous symbols.

First, duplicated definition.
Some functions did not consider double what using dFloat64.
You can fix it just to surround #ifndef _NEWTON_USE_DOUBLE ~ #endif block.

Second, ambiguous symbols.
Some float literals did not consider double what wrote as naked single literal such as 1.0f.
Thus some math function templates cannot be generated because parameter types are not same.
You can fix it just to cover literal by dFloat(). As a example, 1.0f to dFloat(1.0f).

Cheers.
donggas90
 
Posts: 9
Joined: Mon May 11, 2015 12:02 pm
Location: Busan, Republic of Korea

Re: Compiling With Double Precision

Postby nicokruithof » Mon May 18, 2015 3:03 pm

Yes, I managed to do that as well, but had problems with sse instructions for vector operations if I remember correctly.

Did you run a small example using doubles as the core number type?

Nico
nicokruithof
 
Posts: 14
Joined: Tue Dec 03, 2013 3:25 am

PreviousNext

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron