www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Aggressive conditional inlining with ldc only, not dmd

reply =?UTF-8?B?Tm9yZGzDtnc=?= <per.nordlow gmail.com> writes:
Is there a way to make ldc do more aggressive inlining other than

     pragma(inline, true)

?

Reason for asking is that

https://github.com/nordlow/phobos-next/blob/master/src/open_hashmap_or_hashset.d

achieves much better performance when I qualify some inner loop 
functions with

     pragma(inline, true)

instead of

     pragma(inline)

eventhough I compile with -release -inline -nobounds flags.

Unfortunately these functions cannot be inlined by dmd in release 
mode so my code either runs slower than possible or it cannot be 
built by dmd in release mode.

And I haven't found a way to conditionally qualify these inner 
loop functions with `pragma(inline, true)` for the ldc case only.
Mar 25 2018
next sibling parent reply kinke <noone nowhere.com> writes:
On Sunday, 25 March 2018 at 22:09:43 UTC, Nordlöw wrote:
 And I haven't found a way to conditionally qualify these inner 
 loop functions with `pragma(inline, true)` for the ldc case 
 only.
From https://dlang.org/spec/pragma.html#inline: 'If inside a function, it affects the function it is enclosed by.' So: void foo() { version(LDC) pragma(inline, true); // affects foo() ... }
Mar 25 2018
parent =?UTF-8?B?Tm9yZGzDtnc=?= <per.nordlow gmail.com> writes:
On Sunday, 25 March 2018 at 22:30:50 UTC, kinke wrote:
 void foo()
 {
     version(LDC) pragma(inline, true); // affects foo()
     ...
 }
Wonderful, thanks!
Mar 25 2018
prev sibling parent reply Rene Zwanenburg <renezwanenburg gmail.com> writes:
On Sunday, 25 March 2018 at 22:09:43 UTC, Nordlöw wrote:
 eventhough I compile with -release -inline -nobounds flags.
Just to make sure: are you passing -O as well?
Mar 26 2018
parent reply =?UTF-8?B?Tm9yZGzDtnc=?= <per.nordlow gmail.com> writes:
On Monday, 26 March 2018 at 16:02:30 UTC, Rene Zwanenburg wrote:
 On Sunday, 25 March 2018 at 22:09:43 UTC, Nordlöw wrote:
 eventhough I compile with -release -inline -nobounds flags.
Just to make sure: are you passing -O as well?
Yes I am, thanks, via the dub spec buildType "release-nobounds" { dflags "-mcpu=native" "-O3" buildOptions "releaseMode" "optimize" "noBoundsCheck" "inline" } I didn't measure any significant difference between -O and -O3. Is each optimization level `x` in `-Ox` defined in the same way for clang and ldc? If so, where's the best documentation for it?
Mar 26 2018
parent reply jmh530 <john.michael.hall gmail.com> writes:
On Monday, 26 March 2018 at 18:47:17 UTC, Nordlöw wrote:
 Yes I am, thanks, via the dub spec

 buildType "release-nobounds" {
           dflags "-mcpu=native" "-O3"
           buildOptions "releaseMode" "optimize" "noBoundsCheck" 
 "inline"
 }

 I didn't measure any significant difference between -O and -O3.

 Is each optimization level `x` in `-Ox` defined in the same way 
 for clang and ldc? If so, where's the best documentation for it?
https://wiki.dlang.org/Using_LDC -O is equivalent to -O3
Mar 26 2018
parent =?UTF-8?B?Tm9yZGzDtnc=?= <per.nordlow gmail.com> writes:
On Monday, 26 March 2018 at 21:11:12 UTC, jmh530 wrote:
 Is each optimization level `x` in `-Ox` defined in the same 
 way for clang and ldc? If so, where's the best documentation 
 for it?
https://wiki.dlang.org/Using_LDC
Thx!
Mar 26 2018