www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - How about a cross-compiler SIMD module?

reply Stefanos Baziotis <sdi1600105 di.uoa.gr> writes:
As part of my GSoC project, I wanted to use SIMD intrinsics. But 
I could not find a way to write cross-compiler code. That 
includes core.simd, but also intel-intrinsics.
Specifically intel-intrinsics is a great library, but it could 
not be used in GDC (at least I did not find a way) and it seems 
LDC focused.

So, I wrote a mini SIMD module [1]. This is not very general as 
it was targeted only for the Dmem* utilities. But then I thought, 
why not make such a module in the druntime?

In the link, you can see for example a simple store function. 
Also, it shows
the best I got as far as how to answer the question "Is SIMD 
supported?" across
compilers.

[1] 
https://github.com/dlang/druntime/pull/2687/files#diff-c2fcd73761ae6659ef91245ce1195b6dR70
Aug 02 2019
next sibling parent reply Guillaume Piolat <first.last gmail.com> writes:
On Friday, 2 August 2019 at 14:56:58 UTC, Stefanos Baziotis wrote:
 Specifically intel-intrinsics is a great library, but it could 
 not be used in GDC (at least I did not find a way) and it seems 
 LDC focused.
Hello, The reason is that no one stepped up to add this support for GDC intel-intrinsics, but it is on the roadmap for next year. I can't contribute to D OSS all day, since I need to put out products made with D too ; so users of intel-intrinsics have to be patient or contribute themselves. Do not underestimate the sheer amount of work needed to make "cross-compiler SIMD module".
Aug 02 2019
parent reply Stefanos Baziotis <sdi1600105 di.uoa.gr> writes:
On Friday, 2 August 2019 at 20:38:37 UTC, Guillaume Piolat wrote:
 Hello,

 The reason is that no one stepped up to add this support for 
 GDC intel-intrinsics, but it is on the roadmap for next year. I 
 can't contribute to D OSS all day, since I need to put out 
 products made with D too ;
Hello Guillaume, Don't take this as criticism to intel-intrinsics. On the contrary, I mention it here and there as it is the best SIMD library for D I know (apart from core.simd). However, I feel like this should be part of druntime core and not an external library since core.simd already exists but is not cross-compiler.
 Do not underestimate the sheer amount of work needed to make 
 "cross-compiler SIMD module".
I agree, although I probably don't know all the hurdles since I have not made one. I proposed the idea and I'm willing to put time on it, if the community wants it. It doesn't necessarily mean that I will be able to do it myself. I invite people who have more experience (like you) to give advice and / or help.
 so users of intel-intrinsics have to be patient or contribute 
 themselves.
If the community is not positive on that, then my plan is to contribute to intel-intrinsics. Best, Stefanos
Aug 02 2019
parent reply Guillaume Piolat <first.last gmail.com> writes:
On Friday, 2 August 2019 at 20:59:04 UTC, Stefanos Baziotis wrote:
 However, I feel like this should be part of druntime core and 
 not an external
 library since core.simd already exists but is not 
 cross-compiler.
Well yes what you did makes a lot of sense, since it's druntime that will have to implement memcpy/memset/etc. So there is indeed a need for something in druntime. (intel-intrinsics is Boost-licensed and one can use any part of it, but it's not like is has been "approved" in terms of DUB popularity (which I feel is a necessary first step, along with GDC support)).
Aug 03 2019
parent Stefanos Baziotis <sdi1600105 di.uoa.gr> writes:
On Saturday, 3 August 2019 at 10:01:37 UTC, Guillaume Piolat 
wrote:
 On Friday, 2 August 2019 at 20:59:04 UTC, Stefanos Baziotis

 Well yes what you did makes a lot of sense, since it's druntime 
 that will have to implement memcpy/memset/etc. So there is 
 indeed a need for something in druntime.
Apart from memset, memcpy etc., I think that if we are to have a simd module, that makes sense to be cross-compiler. On the other hand, people seem to like the idea to add them separately on LDC and GDC versions. I don't know.
 (intel-intrinsics is Boost-licensed and one can use any part of 
 it, but it's not like is has been "approved" in terms of DUB 
 popularity (which I feel is a necessary first step, along with 
 GDC support)).
Well, it seems like a sane way to do SIMD. I hope it goes well. Stefanos
Aug 03 2019
prev sibling parent reply kinke <noone nowhere.com> writes:
On Friday, 2 August 2019 at 14:56:58 UTC, Stefanos Baziotis wrote:
 But then I thought, why not make such a module in the druntime?
Johan suggests implementing some small core.simd subset (load/storeUnaligned, prefetch) in the LDC and GDC druntime flavours instead: https://github.com/ldc-developers/ldc/issues/3121
Aug 02 2019
parent Stefanos Baziotis <sdi1600105 di.uoa.gr> writes:
On Saturday, 3 August 2019 at 00:13:09 UTC, kinke wrote:
 Johan suggests implementing some small core.simd subset 
 (load/storeUnaligned, prefetch) in the LDC and GDC druntime 
 flavours instead:
 https://github.com/ldc-developers/ldc/issues/3121
Yes, that could be done as well.
Aug 03 2019