Re: gdc or ldc for faster programs?

2022-03-10 Thread Chris Piker via Digitalmars-d-learn
On Tuesday, 25 January 2022 at 20:04:04 UTC, Adam D Ruppe wrote: Not surprising at all: gdc is excellent and underrated in the community. The performance metrics are just a bonus. Gdc is the main reason I can get my worksite to take D seriously since we're a traditional unix shop (solaris ->

Re: gdc or ldc for faster programs?

2022-03-09 Thread Iain Buclaw via Digitalmars-d-learn
On Monday, 31 January 2022 at 10:33:49 UTC, Siarhei Siamashka wrote: I wonder if GDC can do the same? GDC as a front-end doesn't dictate what the optimization passes are doing, nor does it have any real control what each level means. It is only ensured that semantic doesn't break because of

Re: gdc or ldc for faster programs?

2022-01-31 Thread Siarhei Siamashka via Digitalmars-d-learn
On Monday, 31 January 2022 at 08:54:16 UTC, Patrick Schluter wrote: -O3 often chooses longer code and unrollsmore agressively inducing higher miss rates in the instruction caches. -O2 can beat -O3 in some cases when code size is important. One of the historical reasons for favoring -O2 optimiz

Re: gdc or ldc for faster programs?

2022-01-31 Thread Elronnd via Digitalmars-d-learn
On Monday, 31 January 2022 at 08:54:16 UTC, Patrick Schluter wrote: -O3 often chooses longer code and unrollsmore agressively inducing higher miss rates in the instruction caches. -O2 can beat -O3 in some cases when code size is important. That is generally true. My point is that GCC and Clan

Re: gdc or ldc for faster programs?

2022-01-31 Thread Patrick Schluter via Digitalmars-d-learn
On Tuesday, 25 January 2022 at 22:41:35 UTC, Elronnd wrote: On Tuesday, 25 January 2022 at 22:33:37 UTC, H. S. Teoh wrote: interesting because idivl is known to be one of the slower instructions, but gdc nevertheless considered it not worthwhile to replace it, whereas ldc seems obsessed about

Re: gdc or ldc for faster programs?

2022-01-30 Thread Salih Dincer via Digitalmars-d-learn
On Saturday, 29 January 2022 at 18:28:06 UTC, Ali Çehreli wrote: On 1/29/22 10:04, Salih Dincer wrote: > Could you also try the following > code with the same configurations? The program you posted with 2 million random values: ldc 1.9 seconds gdc 2.3 seconds dmd 2.8 seconds I understand such

Re: gdc or ldc for faster programs?

2022-01-29 Thread Siarhei Siamashka via Digitalmars-d-learn
On Saturday, 29 January 2022 at 18:28:06 UTC, Ali Çehreli wrote: (And now we know gdc can go about 7% faster with additional command line switches.) No, we don't know this yet ;-) That's just what I said and I may be bullshitting. Or the configuration of my computer is significantly different

Re: gdc or ldc for faster programs?

2022-01-29 Thread max haughton via Digitalmars-d-learn
On Saturday, 29 January 2022 at 18:28:06 UTC, Ali Çehreli wrote: On 1/29/22 10:04, Salih Dincer wrote: > Could you also try the following code with the same configurations? The program you posted with 2 million random values: ldc 1.9 seconds gdc 2.3 seconds dmd 2.8 seconds I understand such s

Re: gdc or ldc for faster programs?

2022-01-29 Thread Ali Çehreli via Digitalmars-d-learn
On 1/29/22 10:04, Salih Dincer wrote: > Could you also try the following code with the same configurations? The program you posted with 2 million random values: ldc 1.9 seconds gdc 2.3 seconds dmd 2.8 seconds I understand such short tests are not definitive but to have a rough idea between tw

Re: gdc or ldc for faster programs?

2022-01-29 Thread Salih Dincer via Digitalmars-d-learn
On Wednesday, 26 January 2022 at 18:00:41 UTC, Ali Çehreli wrote: For completeness (and noise :/) here is the final version of the program: Could you also try the following code with the same configurations? ```d struct LongScale { struct ShortStack { short[] stack; size_t ind

Re: gdc or ldc for faster programs?

2022-01-28 Thread Siarhei Siamashka via Digitalmars-d-learn
On Friday, 28 January 2022 at 18:02:27 UTC, Iain Buclaw wrote: For example, druntime depends on this behaviour. Template: https://github.com/dlang/druntime/blob/a0ad8c42c15942faeeafb016e81a360113ae1b6b/src/rt/config.d#L46-L58 Ouch. From where I stand, this looks like some really ugly hack ab

Re: gdc or ldc for faster programs?

2022-01-28 Thread Iain Buclaw via Digitalmars-d-learn
On Thursday, 27 January 2022 at 20:28:40 UTC, Siarhei Siamashka wrote: On Thursday, 27 January 2022 at 18:12:18 UTC, Johan Engelen wrote: But the language requires ODR, so we can emit templates as weak_odr, telling the optimizer and linker that the symbols should be merged _and_ that ODR can be

Re: gdc or ldc for faster programs?

2022-01-27 Thread Siarhei Siamashka via Digitalmars-d-learn
On Thursday, 27 January 2022 at 18:12:18 UTC, Johan Engelen wrote: But the language requires ODR, so we can emit templates as weak_odr, telling the optimizer and linker that the symbols should be merged _and_ that ODR can be assumed to hold (i.e. inlining is OK). Thanks! This was also my impr

Re: gdc or ldc for faster programs?

2022-01-27 Thread Johan Engelen via Digitalmars-d-learn
On Thursday, 27 January 2022 at 16:46:59 UTC, Ali Çehreli wrote: What I know is that weak symbols can be overridden by strong symbols during linking. Which means, if a function body is inlined which also has a weak symbol, some part of the program may be using the inlined definition and some

Re: gdc or ldc for faster programs?

2022-01-27 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Jan 27, 2022 at 08:46:59AM -0800, Ali Çehreli via Digitalmars-d-learn wrote: [...] > I see that template instantiations are linked through weak symbols: > > $ nm deneme | grep foo > [...] > 00021380 W _D6deneme__T3fooTiZQhFNaNbNiNfZv > > What I know is that weak symbols can be ov

Re: gdc or ldc for faster programs?

2022-01-27 Thread Ali Çehreli via Digitalmars-d-learn
On 1/26/22 11:07, Siarhei Siamashka wrote: > On Wednesday, 26 January 2022 at 18:41:51 UTC, Iain Buclaw wrote: >> The D language shot itself in the foot by requiring templates to have >> weak semantics. >> >> If DMD and LDC inline weak functions, that's their bug. > > As I already mentioned in the

Re: gdc or ldc for faster programs?

2022-01-26 Thread Siarhei Siamashka via Digitalmars-d-learn
On Wednesday, 26 January 2022 at 18:41:51 UTC, Iain Buclaw wrote: The D language shot itself in the foot by requiring templates to have weak semantics. If DMD and LDC inline weak functions, that's their bug. As I already mentioned in the bugzilla, it would be really useful to see a practical

Re: gdc or ldc for faster programs?

2022-01-26 Thread Iain Buclaw via Digitalmars-d-learn
On Wednesday, 26 January 2022 at 18:39:07 UTC, Siarhei Siamashka wrote: It's not DMD doing a good job here, but GDC11 shooting itself in the foot by requiring additional esoteric command line options if you really want to produce optimized binaries. The D language shot itself in the foot by

Re: gdc or ldc for faster programs?

2022-01-26 Thread Siarhei Siamashka via Digitalmars-d-learn
On Wednesday, 26 January 2022 at 18:00:41 UTC, Ali Çehreli wrote: ldc shines with sprintf. And dmd suprises by being a little bit faster than gdc! (?) ldc (2.098.0): ~6.2 seconds dmd (2.098.1): ~7.4 seconds gdc (2.076.?): ~7.5 seconds Again, here are the versions of the compilers that are read

Re: gdc or ldc for faster programs?

2022-01-26 Thread Iain Buclaw via Digitalmars-d-learn
On Wednesday, 26 January 2022 at 11:43:39 UTC, forkit wrote: On Wednesday, 26 January 2022 at 11:25:47 UTC, Iain Buclaw wrote: Whenever I've watched talks/demos where benchmarks were the central topic, GDC has always blown LDC out the water when it comes to matters of math. .. https://dlan

Re: gdc or ldc for faster programs?

2022-01-26 Thread Ali Çehreli via Digitalmars-d-learn
ldc shines with sprintf. And dmd suprises by being a little bit faster than gdc! (?) ldc (2.098.0): ~6.2 seconds dmd (2.098.1): ~7.4 seconds gdc (2.076.?): ~7.5 seconds Again, here are the versions of the compilers that are readily available on my system: > ldc: LDC - the LLVM D compiler (1.

Re: gdc or ldc for faster programs?

2022-01-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/26/22 7:06 AM, Johan wrote: Couldn't test with LDC 1.6 (dlang2.076), because it is too old and not running on M1/Monterey (?). There was a range of macos dmd binaries that did not work after a certain MacOS. I think it had to do with the hack for TLS that apple changed, so it no longer

Re: gdc or ldc for faster programs?

2022-01-26 Thread Ali Çehreli via Digitalmars-d-learn
On 1/26/22 04:06, Johan wrote: > The stdlib makes a huge difference in performance. > Ali's program uses string manipulation, Yes, on the surface, I thought my inner loop had just / and % but of course there is that formattedWrite. I will change the code to use sprintf into a static buffer (in

Re: gdc or ldc for faster programs?

2022-01-26 Thread Johan via Digitalmars-d-learn
On Wednesday, 26 January 2022 at 11:25:47 UTC, Iain Buclaw wrote: On Wednesday, 26 January 2022 at 04:28:25 UTC, Ali Çehreli wrote: On 1/25/22 16:15, Johan wrote: > On Tuesday, 25 January 2022 at 19:52:17 UTC, Ali Çehreli wrote: >> >> I am using compilers installed by Manjaro Linux's package sys

Re: gdc or ldc for faster programs?

2022-01-26 Thread forkit via Digitalmars-d-learn
On Wednesday, 26 January 2022 at 11:25:47 UTC, Iain Buclaw wrote: Whenever I've watched talks/demos where benchmarks were the central topic, GDC has always blown LDC out the water when it comes to matters of math. .. https://dlang.org/blog/2020/05/14/lomutos-comeback/

Re: gdc or ldc for faster programs?

2022-01-26 Thread Iain Buclaw via Digitalmars-d-learn
On Wednesday, 26 January 2022 at 04:28:25 UTC, Ali Çehreli wrote: On 1/25/22 16:15, Johan wrote: > On Tuesday, 25 January 2022 at 19:52:17 UTC, Ali Çehreli wrote: >> >> I am using compilers installed by Manjaro Linux's package system: >> >> ldc: LDC - the LLVM D compiler (1.28.0): >> based on D

Re: gdc or ldc for faster programs?

2022-01-25 Thread Ali Çehreli via Digitalmars-d-learn
On 1/25/22 16:15, Johan wrote: > On Tuesday, 25 January 2022 at 19:52:17 UTC, Ali Çehreli wrote: >> >> I am using compilers installed by Manjaro Linux's package system: >> >> ldc: LDC - the LLVM D compiler (1.28.0): >> based on DMD v2.098.0 and LLVM 13.0.0 >> >> gdc: dc (GCC) 11.1.0 >> >> dmd: D

Re: gdc or ldc for faster programs?

2022-01-25 Thread Johan via Digitalmars-d-learn
On Tuesday, 25 January 2022 at 19:52:17 UTC, Ali Çehreli wrote: I am using compilers installed by Manjaro Linux's package system: ldc: LDC - the LLVM D compiler (1.28.0): based on DMD v2.098.0 and LLVM 13.0.0 gdc: dc (GCC) 11.1.0 dmd: DMD64 D Compiler v2.098.1 What phobos version is gdc

Re: gdc or ldc for faster programs?

2022-01-25 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Jan 25, 2022 at 11:01:57PM +, forkit via Digitalmars-d-learn wrote: > On Tuesday, 25 January 2022 at 20:01:18 UTC, Johan wrote: > > > > Tough to say. Of course DMD is not a serious contender, but I > > believe the difference between GDC and LDC is very small and really > > in the detai

Re: gdc or ldc for faster programs?

2022-01-25 Thread forkit via Digitalmars-d-learn
On Tuesday, 25 January 2022 at 20:01:18 UTC, Johan wrote: Tough to say. Of course DMD is not a serious contender, but I believe the difference between GDC and LDC is very small and really in the details, i.e. you'll have to look at assembly to find out the delta. Have you tried `--enable-cro

Re: gdc or ldc for faster programs?

2022-01-25 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Jan 25, 2022 at 10:41:35PM +, Elronnd via Digitalmars-d-learn wrote: > On Tuesday, 25 January 2022 at 22:33:37 UTC, H. S. Teoh wrote: > > interesting because idivl is known to be one of the slower > > instructions, but gdc nevertheless considered it not worthwhile to > > replace it, whe

Re: gdc or ldc for faster programs?

2022-01-25 Thread Ali Çehreli via Digitalmars-d-learn
On 1/25/22 14:33, H. S. Teoh wrote: > This is very interesting Fascinating code generation and investigation! :) Ali

Re: gdc or ldc for faster programs?

2022-01-25 Thread Elronnd via Digitalmars-d-learn
On Tuesday, 25 January 2022 at 22:33:37 UTC, H. S. Teoh wrote: interesting because idivl is known to be one of the slower instructions, but gdc nevertheless considered it not worthwhile to replace it, whereas ldc seems obsessed about avoid idivl at all costs. Interesting indeed. Two remarks:

Re: gdc or ldc for faster programs?

2022-01-25 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Jan 25, 2022 at 01:30:59PM -0800, Ali Çehreli via Digitalmars-d-learn wrote: [...] > I posted the program to have more eyes on the assembly. ;) [...] I tested the code locally, and observed, just like Ali did, that the LDC version is unambiguously slower than the gdc version by a small ma

Re: gdc or ldc for faster programs?

2022-01-25 Thread Ali Çehreli via Digitalmars-d-learn
On 1/25/22 12:42, H. S. Teoh wrote: >> For a test run for 2 million numbers: >> >> ldc: ~0.95 seconds >> gdc: ~0.79 seconds >> dmd: ~1.77 seconds > > For measurements under 1 second, I'm skeptical of the accuracy, because > there could be all kinds of background noise, CPU interrupts and stuff >

Re: gdc or ldc for faster programs?

2022-01-25 Thread Ali Çehreli via Digitalmars-d-learn
On 1/25/22 12:59, Daniel N wrote: Maybe you can try --ffast-math on ldc. Did not make a difference. Ali

Re: gdc or ldc for faster programs?

2022-01-25 Thread Ali Çehreli via Digitalmars-d-learn
On 1/25/22 12:01, Johan wrote: Have you tried `--enable-cross-module-inlining` with LDC? Tried now. Makes no difference that I can sense, likely because there is only one module anyway. :) (But I guess it works over Phobos modules too.) Ali

Re: gdc or ldc for faster programs?

2022-01-25 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Jan 25, 2022 at 08:04:04PM +, Adam D Ruppe via Digitalmars-d-learn wrote: > On Tuesday, 25 January 2022 at 19:52:17 UTC, Ali Çehreli wrote: > > ldc: ~0.95 seconds > > gdc: ~0.79 seconds > > dmd: ~1.77 seconds > > Not surprising at all: gdc is excellent and underrated in the > communit

Re: gdc or ldc for faster programs?

2022-01-25 Thread Ali Çehreli via Digitalmars-d-learn
On 1/25/22 11:52, Ali Çehreli wrote: > a program I wrote about spelling-out parts of a number Here is the program as a single module: module spellout.spellout; // This program was written as a code kata to spell out // certain parts of integers as in "1 million 2 thousand // 42". Note that thi

Re: gdc or ldc for faster programs?

2022-01-25 Thread Daniel N via Digitalmars-d-learn
On Tuesday, 25 January 2022 at 20:04:04 UTC, Adam D Ruppe wrote: On Tuesday, 25 January 2022 at 19:52:17 UTC, Ali Çehreli wrote: ldc: ~0.95 seconds gdc: ~0.79 seconds dmd: ~1.77 seconds Maybe you can try --ffast-math on ldc.

Re: gdc or ldc for faster programs?

2022-01-25 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Jan 25, 2022 at 11:52:17AM -0800, Ali Çehreli via Digitalmars-d-learn wrote: > Sorry for being vague and not giving the code here but a program I > wrote about spelling-out parts of a number (in Turkish) as in "1 > milyon 42" runs much faster with gdc. > > The program integer-divides the

Re: gdc or ldc for faster programs?

2022-01-25 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 25 January 2022 at 19:52:17 UTC, Ali Çehreli wrote: ldc: ~0.95 seconds gdc: ~0.79 seconds dmd: ~1.77 seconds Not surprising at all: gdc is excellent and underrated in the community.

Re: gdc or ldc for faster programs?

2022-01-25 Thread Johan via Digitalmars-d-learn
On Tuesday, 25 January 2022 at 19:52:17 UTC, Ali Çehreli wrote: I am not experienced with dub but I used --build=release-nobounds and verified that -O3 is used for both compilers. (I also tried building manually with GNU 'make' with e.g. -O5 and the results were similar.) `-O5` does not do

gdc or ldc for faster programs?

2022-01-25 Thread Ali Çehreli via Digitalmars-d-learn
Sorry for being vague and not giving the code here but a program I wrote about spelling-out parts of a number (in Turkish) as in "1 milyon 42" runs much faster with gdc. The program integer-divides the number in a loop to find quotients and adds the word next to it. One obvious optimization mi