Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Setting AVX512 vector to zero/non-zero causes signal SIGILL

On Godbolt, this executes fine:

volatile __m512i v = _mm512_set_epi64(1, 0, 0, 0, 0, 0, 0, 0);
    

but all zeros does not:

 volatile __m512i v = _mm512_set_epi64(0, 0, 0, 0, 0, 0, 0, 0);

It produces signal SIGILL. Illegal instruction?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Why is this?

I’m using clang 18.1 with flags -std=c++23 -O0 -mavx512vl.

In fact, if I change optimization level, the effect seems to invert. So i’d just like to know why setting different inputs can caused these issues?

>Solution :

You got an AWS instance that doesn’t support AVX-512.
You sometimes get Zen 3 (-march=znver3).

It varies from run to run and I don’t know of any way to request a specific instance type. You can use -march=native and #ifdef __AVX512F__ so your test gets omitted if not supported.

The instance types I remember seeing in the past are Cascade Lake, Ice Lake, and Zen 3. There might now be newer Intel and maybe newer AMD in the mix.


Neither of those vector constants needs a 512-bit instruction to materialize in a register (but might anyway with optimization disabled). But both will use a single 512-bit store to init the volatile so both versions should make asm that uses an AVX-512 instruction. As you can see from the asm on Godbolt using a ZMM register.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading