__AVX__ Not being defined properly with Cuda 9.0.176 and Visual Studio 2017 15.4.1

AVX is not being defined properly with Cuda 9.0.176 and Visual Studio 2017 15.4.1 in .cu files.

Along with a lot of other host compiler options it seems to that it should be inheriting from the project (for example /std:c++17). I’m worried a lot of options that should be passed on aren’t being too.

As a fix putting /arch:AVX on the .cu files ‘Additional Compiler Options’ line in the CUDAC/C++=>Host property pages does not work correctly as it will also falsely advertise AVX support while compiling the GPU parts of the code.

It appears AVX support for CPU code mixed into .cu files is completely broken :(

My long-standing experience is that it is best to keep host code using SIMD intrinsics and inline assembly out of .cu files, and use it only in the .c or .cpp files of a project. That strategy has worked well for me for many years now.

I don’t know what technical reasons are responsible for observed incompatibilities. You may want to file bug reports with NVIDIA for such issues if simple code segregation doesn’t work for your use case(s).

That’s a shame, I hope it can be better supported in future. Especially with the later versions of AVX coming along quite quickly now.

It seems more a high level toolchain fix needed rather than a low level one from the behaviour I have seen. I will see if I can isolate the problems better and file bugs then - which can be a bit difficult unfortunately as sometimes the compiler errors can be somewhat terse when digging through templates.