Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
May 15, 2018 Using AVX intrinsics with LDC | ||||
---|---|---|---|---|
| ||||
Hello, I'm a beginner in D (I come from C++/Python), but I'm having great fun learning the language reading Ali's book. I'm using LDC as compiler, and I would like to use intrinsics, but I have difficulties to find the Intel intrinsics equivalent. Here are the functions I'm looking for : _mm_cvtsi64x_si128 _mm256_sll_epi64 _mm256_movemask_epi8 Is there a way to call them ? Is there an Intel intrinsics to LDC intrinsics guide somewhere ? Thanks for your help ! |
May 15, 2018 Re: Using AVX intrinsics with LDC | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jeff | On Tuesday, 15 May 2018 at 17:21:49 UTC, Jeff wrote: > Hello, > I'm a beginner in D (I come from C++/Python), but I'm having great fun learning the language reading Ali's book. I'm using LDC as compiler, and I would like to use intrinsics, but I have difficulties to find the Intel intrinsics equivalent. Here are the functions I'm looking for : > > _mm_cvtsi64x_si128 > _mm256_sll_epi64 > _mm256_movemask_epi8 > > Is there a way to call them ? Is there an Intel intrinsics to LDC intrinsics guide somewhere ? > Thanks for your help ! Hi, you'll want to have a look at LDC's `import/ldc/gccbuiltins_x86.di` file (auto-generated from corresponding LLVM x86 intrinsics). Make sure to enable extended instruction sets via something like `-mattr=+avx2` (or simply `-mcpu=native`). _mm256_movemask_epi8 => __builtin_ia32_pmovmskb256 _mm256_sll_epi64 => __builtin_ia32_psllqi256 I didn't find the corresponding declaration for _mm_cvtsi64x_si128 (__builtin_ia32_vzeroupper strangely takes no args). You can always resort to LLVM assembly though (grep for `__asm` in import directory to see some examples in druntime/Phobos). |
May 16, 2018 Re: Using AVX intrinsics with LDC | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jeff | On Tuesday, 15 May 2018 at 17:21:49 UTC, Jeff wrote:
> _mm_cvtsi64x_si128
If it zero extends 64-bit integer to 128-bit integer, it's done by movq instruction. I suppose simple assignment should do it.
|
May 16, 2018 Re: Using AVX intrinsics with LDC | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kagamin | On Wednesday, 16 May 2018 at 10:36:01 UTC, Kagamin wrote: > On Tuesday, 15 May 2018 at 17:21:49 UTC, Jeff wrote: >> _mm_cvtsi64x_si128 > > If it zero extends 64-bit integer to 128-bit integer, it's done by movq instruction. I suppose simple assignment should do it. That's enough indeed: https://run.dlang.io/is/1wJ7mA [And vzeroupper is unrelated, and no args are correct.] |
May 16, 2018 Re: Using AVX intrinsics with LDC | ||||
---|---|---|---|---|
| ||||
Posted in reply to kinke | On Wednesday, 16 May 2018 at 13:11:46 UTC, kinke wrote:
> On Wednesday, 16 May 2018 at 10:36:01 UTC, Kagamin wrote:
>> On Tuesday, 15 May 2018 at 17:21:49 UTC, Jeff wrote:
>>> _mm_cvtsi64x_si128
>>
>> If it zero extends 64-bit integer to 128-bit integer, it's done by movq instruction. I suppose simple assignment should do it.
>
> That's enough indeed: https://run.dlang.io/is/1wJ7mA
> [And vzeroupper is unrelated, and no args are correct.]
Thanks, it works perfectly ! Also I discover run.dlang.io, nice to quickly check the ASM output :)
|
May 16, 2018 Re: Using AVX intrinsics with LDC | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jeff | On Wednesday, 16 May 2018 at 19:34:32 UTC, Jeff wrote: > Also I discover run.dlang.io, nice to quickly check the ASM output :) You might like https://d.godbolt.org better if you don't need to execute the code. -Johan |
May 23, 2018 Re: Using AVX intrinsics with LDC | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jeff | On Tuesday, 15 May 2018 at 17:21:49 UTC, Jeff wrote: > Hello, > I'm a beginner in D (I come from C++/Python), but I'm having great fun learning the language reading Ali's book. I'm using LDC as compiler, and I would like to use intrinsics, but I have difficulties to find the Intel intrinsics equivalent. Here are the functions I'm looking for : > > _mm_cvtsi64x_si128 > _mm256_sll_epi64 > _mm256_movemask_epi8 > > Is there a way to call them ? Is there an Intel intrinsics to LDC intrinsics guide somewhere ? > Thanks for your help ! I've started doing such a translation as a library here: http://code.dlang.org/packages/intel-intrinsics However, no AVX yet |
Copyright © 1999-2021 by the D Language Foundation