Re: Inlining Code Test

2010-12-20 Thread Don
Nick Voronin wrote: On Sat, 18 Dec 2010 02:17:46 +0100 Don nos...@nospam.com wrote: Nick Voronin wrote: btw, is there no explicit alignment for variables in D at all? align(8) double d; compiles if d is global, but it does nothing. That's a regression. Large globals are always aligned to a

Re: Inlining Code Test

2010-12-18 Thread Nick Voronin
On Sat, 18 Dec 2010 02:17:46 +0100 Don nos...@nospam.com wrote: Nick Voronin wrote: btw, is there no explicit alignment for variables in D at all? align(8) double d; compiles if d is global, but it does nothing. That's a regression. Large globals are always aligned to a 16-byte boundary

Re: Inlining Code Test

2010-12-17 Thread Nick Voronin
Looks like alignment of local variables is somewhat broken. import std.stdio; void main() { int a; double d; writeln(a, , d); } testdl.exe 12FE70 12FE78 testdl 12FE74 12FE7C It's not like double is not aligned, otherwise it would be placed right after int, 4

Re: Inlining Code Test

2010-12-17 Thread bearophile
Nick Voronin: Looks like alignment of local variables is somewhat broken. This is a very nice bug. If not already present then please add it to Bugzilla. If you don't want to add it, then I will add it myself. I have modified your code like this: import core.stdc.stdio: printf; void main() {

Re: Inlining Code Test

2010-12-17 Thread Nick Voronin
I found this on bugzilla. http://d.puremagic.com/issues/show_bug.cgi?id=2278 So it's not really a bug. Yet there is no simple workaround. And gap between int and double looks strange when stack frame itself is unaligned. btw, is there no explicit alignment for variables in D at all? align(8)

Re: Inlining Code Test

2010-12-17 Thread bearophile
Nick Voronin: I found this on bugzilla. http://d.puremagic.com/issues/show_bug.cgi?id=2278 So it's not really a bug. It's borderline a performance bug. You may add that code to the issue 2278 as further examples. Bye, bearophile

Re: Inlining Code Test

2010-12-17 Thread Don
Nick Voronin wrote: I found this on bugzilla. http://d.puremagic.com/issues/show_bug.cgi?id=2278 So it's not really a bug. Yet there is no simple workaround. And gap between int and double looks strange when stack frame itself is unaligned. Interestingly, since I filed that bug, DMD for

Re: Inlining Code Test

2010-12-17 Thread Nick Voronin
On Sat, 18 Dec 2010 04:17:46 +0300, Don nos...@nospam.com wrote: Interestingly, since I filed that bug, DMD for MacOSX was created, which ensures that the stack stays aligned in the way I described! So the DMD backend is perfectly capable of doing it now. I added some examples to that

Re: Inlining Code Test

2010-12-16 Thread Nick Voronin
On Mon, 13 Dec 2010 01:50:50 +0300, Craig Black craigbla...@cox.net wrote: The following program illustrates the problems with inlining in the dmd compiler. Perhaps with some more work I can reduce it to a smaller test case. I was playing around with a simple Array template, and noticed

Re: Inlining Code Test

2010-12-14 Thread Craig Black
Iain Buclaw ibuc...@ubuntu.com wrote in message news:ie6ahr$1co...@digitalmars.com... == Quote from Craig Black (craigbla...@cox.net)'s article Testing your C++ program (altered getCycle() for GCC) Times I get: --- Sorting with Array: 46869.159840 Sorting with pointers: 38688.937320

Re: Inlining Code Test

2010-12-13 Thread Iain Buclaw
== Quote from Craig Black (craigbla...@cox.net)'s article If the problem is not inlining, then why does the same code in C++ does not suffer from this performance limitation (when compiled with Visual C++ 2008)? #include stdio.h #include assert.h #include stdlib.h template class T T min(T

Re: Inlining Code Test

2010-12-13 Thread Craig Black
Testing your C++ program (altered getCycle() for GCC) Times I get: --- Sorting with Array: 46869.159840 Sorting with pointers: 38688.937320 17.453316 percent faster Sorting with Array: 46631.903760 Sorting with pointers: 38520.609360 17.394302 percent faster Sorting with Array:

Re: Inlining Code Test

2010-12-13 Thread Iain Buclaw
== Quote from Craig Black (craigbla...@cox.net)'s article Testing your C++ program (altered getCycle() for GCC) Times I get: --- Sorting with Array: 46869.159840 Sorting with pointers: 38688.937320 17.453316 percent faster Sorting with Array: 46631.903760 Sorting with

Inlining Code Test

2010-12-12 Thread Craig Black
The following program illustrates the problems with inlining in the dmd compiler. Perhaps with some more work I can reduce it to a smaller test case. I was playing around with a simple Array template, and noticed that similar C++ code performs much better. This is due, at least in part, to

Re: Inlining Code Test

2010-12-12 Thread Iain Buclaw
== Quote from Craig Black (craigbla...@cox.net)'s article The following program illustrates the problems with inlining in the dmd compiler. Perhaps with some more work I can reduce it to a smaller test case. I was playing around with a simple Array template, and noticed that similar C++ code

Re: Inlining Code Test

2010-12-12 Thread Andrej Mitrovic
My crappy old Pentium 4 has gone totally mad: Sorting with Array.opIndex: 45080 Sorting with pointers: 45608 4.092e+16 percent faster (??) Compiled with dmd -profile -O -release -inline -noboundscheck On 12/13/10, Iain Buclaw ibuc...@ubuntu.com wrote: == Quote from Craig Black

Re: Inlining Code Test

2010-12-12 Thread Craig Black
If the problem is not inlining, then why does the same code in C++ does not suffer from this performance limitation (when compiled with Visual C++ 2008)? #include stdio.h #include assert.h #include stdlib.h template class T T min(T a, T b) { return a b ? a : b; } template class T T max(T a,

Re: Inlining Code Test

2010-12-12 Thread Craig Black
Try it without -profile. That tends to slow everything down to a halt. -Craig Andrej Mitrovic andrej.mitrov...@gmail.com wrote in message news:mailman.948.1292198993.21107.digitalmar...@puremagic.com... My crappy old Pentium 4 has gone totally mad: Sorting with Array.opIndex: 45080 Sorting

Re: Inlining Code Test

2010-12-12 Thread Andrej Mitrovic
Ye that's better: Sorting with Array.opIndex: 2859 Sorting with pointers: 1765 38.2651 percent faster And it only took 2 seconds. With profile it takes a full minute. On 12/13/10, Craig Black craigbla...@cox.net wrote: Try it without -profile. That tends to slow everything down to a halt.