Using AVX intrinsics with LDC
kinke
noone at nowhere.com
Tue May 15 18:23:16 UTC 2018
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).
More information about the digitalmars-d-ldc
mailing list