Re: Speed of math function atan: comparison D and C++

2018-03-06 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 6 March 2018 at 18:41:15 UTC, H. S. Teoh wrote: The fix itself may be straightforward, but how to do it without breaking tons of existing code and provoking user backlash is the tricky part. [snip] Ah, I see what you're saying. People may be depending on the extra accuracy for

Re: Speed of math function atan: comparison D and C++

2018-03-06 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Mar 06, 2018 at 06:05:59PM +, jmh530 via Digitalmars-d-learn wrote: > On Tuesday, 6 March 2018 at 17:51:54 UTC, H. S. Teoh wrote: > > [snip] > > > > I'm not advocating for getting *rid* of 80-bit float support, but > > only to make it *optional* rather than the default, as currently >

Re: Speed of math function atan: comparison D and C++

2018-03-06 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 6 March 2018 at 17:51:54 UTC, H. S. Teoh wrote: [snip] I'm not advocating for getting *rid* of 80-bit float support, but only to make it *optional* rather than the default, as currently done in std.math. T Aren't there two issues: 1) std.math functions that cast to real to pe

Re: Speed of math function atan: comparison D and C++

2018-03-06 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Mar 06, 2018 at 08:12:57AM +0100, Robert M. Münch via Digitalmars-d-learn wrote: > On 2018-03-05 20:11:06 +, H. S. Teoh said: > > > Walter has been adamant that we should always compute std.math.* > > functions with the `real` type, which on x86 maps to the non-IEEE > > 80-bit floats.

Re: Speed of math function atan: comparison D and C++

2018-03-06 Thread Uknown via Digitalmars-d-learn
On Tuesday, 6 March 2018 at 08:20:05 UTC, J-S Caux wrote: On Tuesday, 6 March 2018 at 07:12:57 UTC, Robert M. Münch wrote: On 2018-03-05 20:11:06 +, H. S. Teoh said: [snip] Now, with Uknown's trick of using the C math functions, I can reconsider. It's a bit of a "patch" but at least it wor

Re: Speed of math function atan: comparison D and C++

2018-03-06 Thread J-S Caux via Digitalmars-d-learn
On Tuesday, 6 March 2018 at 07:12:57 UTC, Robert M. Münch wrote: On 2018-03-05 20:11:06 +, H. S. Teoh said: Walter has been adamant that we should always compute std.math.* functions with the `real` type, which on x86 maps to the non-IEEE 80-bit floats. However, 80-bit floats have been de

Re: Speed of math function atan: comparison D and C++

2018-03-06 Thread Andrea Fontana via Digitalmars-d-learn
On Monday, 5 March 2018 at 20:11:06 UTC, H. S. Teoh wrote: Walter has been adamant that we should always compute std.math.* functions with the `real` type T I don't understand why atan(float) returns real and atan(double) return real too. If I'm working with float, why does it return a real?

Re: Speed of math function atan: comparison D and C++

2018-03-05 Thread Robert M. Münch via Digitalmars-d-learn
On 2018-03-05 20:11:06 +, H. S. Teoh said: Walter has been adamant that we should always compute std.math.* functions with the `real` type, which on x86 maps to the non-IEEE 80-bit floats. However, 80-bit floats have been deprecated for a while now, Hi, do you have a reference for this? I

Re: Speed of math function atan: comparison D and C++

2018-03-05 Thread psychoticRabbit via Digitalmars-d-learn
On Monday, 5 March 2018 at 06:01:27 UTC, J-S Caux wrote: So the codes are trivial, simply some check of raw speed: double x = 0.0; for (int a = 0; a < 10; ++a) x += atan(1.0/(1.0 + sqrt(1.0 + a))); for C++ and double x = 0.0; for (int a = 0; a < 1_000_000_000; ++a) x += atan

Re: Speed of math function atan: comparison D and C++

2018-03-05 Thread jmh530 via Digitalmars-d-learn
On Monday, 5 March 2018 at 21:05:19 UTC, bachmeier wrote: I wonder if Ilya has worked on any of this for Mir. Mir has sin and cos, but that's it. It looks like they use llvm intrinsics on LDC and then fall back to phobos' implementation.

Re: Speed of math function atan: comparison D and C++

2018-03-05 Thread bachmeier via Digitalmars-d-learn
On Monday, 5 March 2018 at 20:11:06 UTC, H. S. Teoh wrote: Walter has been adamant that we should always compute std.math.* functions with the `real` type, which on x86 maps to the non-IEEE 80-bit floats. However, 80-bit floats have been deprecated for a while now, and pretty much nobody care

Re: Speed of math function atan: comparison D and C++

2018-03-05 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Mar 05, 2018 at 06:39:21PM +, J-S Caux via Digitalmars-d-learn wrote: [...] > I've tested these two very basic representative codes: > https://www.dropbox.com/s/b5o4i8h43qh1saf/test.cc?dl=0 > https://www.dropbox.com/s/zsaikhdoyun3olk/test.d?dl=0 > > Results: > > C++: > g++ (Apple LLV

Re: Speed of math function atan: comparison D and C++

2018-03-05 Thread bauss via Digitalmars-d-learn
On Monday, 5 March 2018 at 18:39:21 UTC, J-S Caux wrote: But now comes the question: can the D fundamental maths functions be propped up to be as fast as the C ones? Probably, if someone takes the time to look at the bottlenecks.

Re: Speed of math function atan: comparison D and C++

2018-03-05 Thread J-S Caux via Digitalmars-d-learn
On Monday, 5 March 2018 at 09:48:49 UTC, Uknown wrote: Depending on your platform, the size of `double` could be different between C++ and D. Could you check that the size and precision are indeed the same? Also, benchmark method is just as important as benchmark code. Did you use DMD or LDC a

Re: Speed of math function atan: comparison D and C++

2018-03-05 Thread Johan Engelen via Digitalmars-d-learn
On Monday, 5 March 2018 at 06:01:27 UTC, J-S Caux wrote: On Monday, 5 March 2018 at 05:40:09 UTC, rikki cattermole wrote: On 05/03/2018 6:35 PM, J-S Caux wrote: I'm considering shifting a large existing C++ codebase into D (it's a scientific code making much use of functions like atan, log etc

Re: Speed of math function atan: comparison D and C++

2018-03-05 Thread Marc via Digitalmars-d-learn
On Monday, 5 March 2018 at 05:35:28 UTC, J-S Caux wrote: I'm considering shifting a large existing C++ codebase into D (it's a scientific code making much use of functions like atan, log etc). I've compared the raw speed of atan between C++ (Apple LLVM version 7.3.0 (clang-703.0.29)) and D (d

Re: Speed of math function atan: comparison D and C++

2018-03-05 Thread Uknown via Digitalmars-d-learn
On Monday, 5 March 2018 at 06:01:27 UTC, J-S Caux wrote: On Monday, 5 March 2018 at 05:40:09 UTC, rikki cattermole wrote: On 05/03/2018 6:35 PM, J-S Caux wrote: I'm considering shifting a large existing C++ codebase into D (it's a scientific code making much use of functions like atan, log etc

Re: Speed of math function atan: comparison D and C++

2018-03-04 Thread Era Scarecrow via Digitalmars-d-learn
On Monday, 5 March 2018 at 05:40:09 UTC, rikki cattermole wrote: atan should work out to only be a few instructions (inline assembly) from what I've looked at in the source. Also you should post the code you used for each. Should be 3-4 instructions. Load input to the FPU (Optional? Depends

Re: Speed of math function atan: comparison D and C++

2018-03-04 Thread rikki cattermole via Digitalmars-d-learn
On 05/03/2018 7:01 PM, J-S Caux wrote: On Monday, 5 March 2018 at 05:40:09 UTC, rikki cattermole wrote: On 05/03/2018 6:35 PM, J-S Caux wrote: I'm considering shifting a large existing C++ codebase into D (it's a scientific code making much use of functions like atan, log etc). I've compared

Re: Speed of math function atan: comparison D and C++

2018-03-04 Thread J-S Caux via Digitalmars-d-learn
On Monday, 5 March 2018 at 05:40:09 UTC, rikki cattermole wrote: On 05/03/2018 6:35 PM, J-S Caux wrote: I'm considering shifting a large existing C++ codebase into D (it's a scientific code making much use of functions like atan, log etc). I've compared the raw speed of atan between C++ (Appl

Re: Speed of math function atan: comparison D and C++

2018-03-04 Thread rikki cattermole via Digitalmars-d-learn
On 05/03/2018 6:35 PM, J-S Caux wrote: I'm considering shifting a large existing C++ codebase into D (it's a scientific code making much use of functions like atan, log etc). I've compared the raw speed of atan between C++ (Apple LLVM version 7.3.0 (clang-703.0.29)) and D (dmd v2.079.0, also l

Speed of math function atan: comparison D and C++

2018-03-04 Thread J-S Caux via Digitalmars-d-learn
I'm considering shifting a large existing C++ codebase into D (it's a scientific code making much use of functions like atan, log etc). I've compared the raw speed of atan between C++ (Apple LLVM version 7.3.0 (clang-703.0.29)) and D (dmd v2.079.0, also ldc2 1.7.0) by doing long loops of such