Jump to page: 1 24  
Page
Thread overview
!!!Please add intrinsics module for DMD DRuntime!!!
Nov 22, 2016
Ilya Yaroshenko
Nov 22, 2016
Ilya Yaroshenko
Nov 22, 2016
Ilya Yaroshenko
Nov 22, 2016
Johan Engelen
Nov 22, 2016
Ilya Yaroshenko
Nov 22, 2016
tsbockman
Nov 22, 2016
Ilya Yaroshenko
Nov 22, 2016
tsbockman
Nov 22, 2016
Ilya Yaroshenko
Nov 22, 2016
ketmar
Nov 23, 2016
Jacob Carlborg
Nov 23, 2016
Walter Bright
Nov 22, 2016
Iain Buclaw
Nov 23, 2016
Walter Bright
Nov 23, 2016
tsbockman
Nov 23, 2016
Ilya Yaroshenko
Nov 23, 2016
Walter Bright
Nov 22, 2016
Ilya Yaroshenko
Nov 23, 2016
Walter Bright
Nov 22, 2016
Daniel Kozak
Nov 22, 2016
Iain Buclaw
Nov 22, 2016
Johan Engelen
Nov 23, 2016
Walter Bright
Nov 23, 2016
Walter Bright
Nov 23, 2016
Ilya Yaroshenko
Nov 23, 2016
Walter Bright
Nov 23, 2016
rikki cattermole
Nov 23, 2016
Jacob Carlborg
Nov 23, 2016
ketmar
Nov 23, 2016
Jacob Carlborg
November 22, 2016
Hey all,

Please add a module (core.intrinsics ?) which will contain all DMD intrinsics similar to ldc.intrinsics. After each DMD release it is not clear what is intrinsics and what is not. I need BSF intrinsics for Better C library Mir Random [1], which should work without linking with DRuntime and Phobos. I can use ldc.intrinsics for LDC, but have no idea about DMD. I want BSR and BSF instructions to be generated instead of current _software_ implementation in core.bitop.

==================
Philosophical Questions:

1. Why hight level stuff like BitRange is in core.bitop, but not in std.bitmanip? If it should be in core, why it is public?

2. Why bsf and bsr do NOT use hardware instructions anymore?
==================

Please ping me for Phobos and DRuntime PRs if they are related to math and numeric issues.

Best regards,
Ilya
November 22, 2016
[1] https://github.com/libmir/mir-random

November 22, 2016
On 11/22/16 8:31 AM, Ilya Yaroshenko wrote:
> Philosophical Questions:
>
> 1. Why hight level stuff like BitRange is in core.bitop, but not in
> std.bitmanip? If it should be in core, why it is public?

I wrote BitRange to help with cycle detection. It was related to using the btc/btr/bt functions on bit arrays (it's meant to wrap such a bit array), so that seemed like a natural place for it. Putting it in std.bitmanip would make it unavailable to druntime.

Why shouldn't it be public?

>
> 2. Why bsf and bsr do NOT use hardware instructions anymore?

They should unless there is no hardware instruction available. I believe the software implementation is only a fallback when this is the case.

-Steve
November 22, 2016
On Tuesday, 22 November 2016 at 16:07:39 UTC, Steven Schveighoffer wrote:
> On 11/22/16 8:31 AM, Ilya Yaroshenko wrote:
>> Philosophical Questions:
>>
>> 1. Why hight level stuff like BitRange is in core.bitop, but not in
>> std.bitmanip? If it should be in core, why it is public?
>
> I wrote BitRange to help with cycle detection. It was related to using the btc/btr/bt functions on bit arrays (it's meant to wrap such a bit array), so that seemed like a natural place for it. Putting it in std.bitmanip would make it unavailable to druntime.
>
> Why shouldn't it be public?
>
>>
>> 2. Why bsf and bsr do NOT use hardware instructions anymore?
>
> They should unless there is no hardware instruction available. I believe the software implementation is only a fallback when this is the case.
>
> -Steve

They are always software  https://github.com/dlang/druntime/blob/master/src/core/bitop.d --Ilya
November 22, 2016
On 11/22/2016 11:28 AM, Ilya Yaroshenko wrote:
> They are always software
> https://github.com/dlang/druntime/blob/master/src/core/bitop.d --Ilya

The intent is to have the compiler detect the pattern and insert the code. dmd does that IIRC (why is asm.dlang.org not working again?) and so does gdc: https://godbolt.org/g/WspkIX. -- Andrei

November 22, 2016
On Tuesday, 22 November 2016 at 16:36:13 UTC, Andrei Alexandrescu wrote:
> On 11/22/2016 11:28 AM, Ilya Yaroshenko wrote:
>> They are always software
>> https://github.com/dlang/druntime/blob/master/src/core/bitop.d --Ilya
>
> The intent is to have the compiler detect the pattern and insert the code. dmd does that IIRC (why is asm.dlang.org not working again?) and so does gdc: https://godbolt.org/g/WspkIX.

LDC too. https://godbolt.org/g/S83b30
(note that cross-module inlining is off by default, something to work on for 1.2.0!)
November 22, 2016
On Tuesday, 22 November 2016 at 16:36:13 UTC, Andrei Alexandrescu wrote:
> On 11/22/2016 11:28 AM, Ilya Yaroshenko wrote:
>> They are always software
>> https://github.com/dlang/druntime/blob/master/src/core/bitop.d --Ilya
>
> The intent is to have the compiler detect the pattern and insert the code. dmd does that IIRC (why is asm.dlang.org not working again?) and so does gdc: https://godbolt.org/g/WspkIX. -- Andrei

GDC and LDC can not detect it, I don't think DMD can. Proof - https://godbolt.org/g/bsAFU8 .
Your link refers to GDC with an old DRuntime, which have bsr intrinsics instead of current software code.

In addition, i need to be sure that an intrinsics function is always inlined (without -inline flag too).
--Ilya
November 22, 2016
On Tuesday, 22 November 2016 at 16:52:40 UTC, Johan Engelen wrote:
> On Tuesday, 22 November 2016 at 16:36:13 UTC, Andrei Alexandrescu wrote:
>> On 11/22/2016 11:28 AM, Ilya Yaroshenko wrote:
>>> They are always software
>>> https://github.com/dlang/druntime/blob/master/src/core/bitop.d --Ilya
>>
>> The intent is to have the compiler detect the pattern and insert the code. dmd does that IIRC (why is asm.dlang.org not working again?) and so does gdc: https://godbolt.org/g/WspkIX.
>
> LDC too. https://godbolt.org/g/S83b30
> (note that cross-module inlining is off by default, something to work on for 1.2.0!)

No, LDC and GDC cannot detect it. Proof - https://godbolt.org/g/bsAFU8 . Current LDC DRuntime uses intrinsics instead of software implementation.

Ilya
November 22, 2016
On Tuesday, 22 November 2016 at 17:07:08 UTC, Ilya Yaroshenko wrote:
> No, LDC and GDC cannot detect it. Proof - https://godbolt.org/g/bsAFU8 . Current LDC DRuntime uses intrinsics instead of software implementation.
>
> Ilya

Your test fails because you aren't actually using `core.bitop`. Intrinsics are detected based on fully qualified names. As soon as you copy `bsf()` and `bsr()` outside of `core.bitop`, the FQN changes and they're not intrinsics anymore.
November 22, 2016
On Tuesday, 22 November 2016 at 18:57:59 UTC, tsbockman wrote:
> On Tuesday, 22 November 2016 at 17:07:08 UTC, Ilya Yaroshenko wrote:
>> No, LDC and GDC cannot detect it. Proof - https://godbolt.org/g/bsAFU8 . Current LDC DRuntime uses intrinsics instead of software implementation.
>>
>> Ilya
>
> Your test fails because you aren't actually using `core.bitop`. Intrinsics are detected based on fully qualified names. As soon as you copy `bsf()` and `bsr()` outside of `core.bitop`, the FQN changes and they're not intrinsics anymore.

Does DMD overrides bodies for bsf and bsr? It would be surprised to me.
« First   ‹ Prev
1 2 3 4