1

I am using visual studio 2022 community edittion and c++. I am using instrinsics caculations. But when I am using this it throws exception:

#pragma align(64)
    double a[10] = {1,2,3,4,5,6,7,8,9,10};
    double b[10];
    __m512d m = _mm512_load_pd(&a[0]);
    _mm512_store_pd(&b[0], m);

What I am doing wrong?

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
Vladimir Yanakiev
  • 1,240
  • 1
  • 16
  • 25
  • 3
    Are you using a processor that supports those instructions? My Core i9 does not. – BoP Sep 06 '22 at 13:16
  • Try using `alignas(64) double a[10] ...` and `alignas(64) double b[10]` – NathanOliver Sep 06 '22 at 13:16
  • Why not write portable C++ and tell your compiler to target a certain CPU or instruction set (and enable optimization)? I'd be surprised if it generates worse code than you do by hand - in fact, I'd generally expect it to do *better*. – Jesper Juhl Sep 06 '22 at 13:20
  • 1
    @JesperJuhl clearly you haven't worked on vectorized code very much – user253751 Sep 06 '22 at 13:29
  • @user253751 Actually I have, and we deleted most of our use of intrinsics a few years ago, since the compilers got good enough that it no longer made sense to keep anything but the generic C++ version. The difference ended up being negligible performance wise, but the maintenance overhead was significant. – Jesper Juhl Sep 06 '22 at 13:31
  • @NathanOliver: MSVC doesn't emit alignment-required instructions, except with legacy SSE when it folds an aligned-load into a memory source operand for an ALU instruction. Even if you use alignment-required intrinsics, it still uses `vmovdqu` or `vmovupd`, so you can't verify alignment even if you wanted to. And that would result in a different fault that illegal instruction. – Peter Cordes Sep 06 '22 at 13:38
  • 1
    Illegal instruction faults on AVX-512 are essentially always from running on a CPU without AVX-512. (Or a VM without it enabled.) Closing as a duplicate; it can get reopened if the cause is somehow something else. – Peter Cordes Sep 06 '22 at 13:40

0 Answers0