intel / Immintrin-debug

immintrin_dbg.h is an include file, a wrapper around immintrin.h. It implements most of AVX, AVX2, AVX-512 vector intrinsics to enable source level debug of vector code.
BSD 3-Clause "New" or "Revised" License
57 stars 8 forks source link

Support C++ translation units #3

Open hfp opened 5 years ago

hfp commented 5 years ago

Immintrin-debug is implemented in C which is also desired (given that C code should be able to make use of this project). However, using the Immintrin-debug header file in a C++ translation unit will cause at least compiler errors (as C++ is less permissive). Anyhow, a lot of warnings are also present with C code at higher warning levels (let alone extra and/or pedantic warnings).

How to reproduce:

To translate using a C++ translation unit:

To compile with a lot of warning flags:

Immintrin-debug may switch to some more sophisticated function-decoration at least with respect to "static" and "inline" (different meanings in C++ and C; for the latter "inline" for instance was only introduced in C99 and may be emulated prior to this standard).

I understand that not all of the above warnings will be resolved easily (nor they should as effort is not justified). However, it should work with C++ translation units.


Btw, compilers (regardless of C and C++) may or may not allow intrinsics with/without prototype functions plus if prototypes are present they may differ slightly between Intel and GNU intrinsic headers (aka void* vs e.g. float* in some places etc.). For the latter, casts may assume target signature with float* (or stronger type in general) even if say Intel's prototype has void* (assuming the stronger type works with any compiler as type-"promotion" [demotion] to void* is applied automatically and considered safe).

izard commented 5 years ago

Thank you for the bug report Hans! The bug report comes in three parts: 1. C++ compile errors. 2. C89 compatibility. 3. Compile warnings at higher warning levels.

  1. C++ compile error is a recent regression I'll fix with the highest priority.
  2. I don't know how to make it C89 compatible while still having it as a .h file only. (Adding .c file and compile step with changes you suggested will fix it of course, but I can't do that now (can discuss offline))
  3. Then will see if/how I can deal with pedantic warnings.
izard commented 5 years ago

I've committed fixes (type casts) that make it compile for me with c++ icc and gcc (with default warning levels only).

hfp commented 5 years ago

Thank you!

I found some more missing AVX-512 intrinsics:

There are may be more. I will build a more complete list.

izard commented 5 years ago

added __mm512_adn, all 512 blends. Can't add cmp - have to add manually as parser does not process TRUE and FALSE cases in switch.