OpenImageIO icon indicating copy to clipboard operation
OpenImageIO copied to clipboard

[BUG] SIMD support does not work correctly when building with MSVC

Open jessey-git opened this issue 1 month ago • 0 comments

Describe the bug

Broadly speaking there are two issues here:

  • MSVC's /arch switch only supports the following items[1]: AVX|AVX2|AVX512
  • MSVC does not define __SSE4_2__, or similar, meaning all of the machinery inside simd.h is unused[2]

[1] https://learn.microsoft.com/en-us/cpp/build/reference/arch-x64?view=msvc-170 Trying to use USE_SIMD="sse4.2" will result in the following warnings during build:

cl : command line  warning D9002: ignoring unknown option '/arch:sse4.2'

[2] When using USE_SIMD="sse4.2" The cmake output says that things are happening:

-- Building with C++17, downstream minimum C++17
-- Compiling with SIMD level sse4.2
-- SIMD feature: sse4.2

But trying the resulting binaries results in the following attribute values:

hw:simd = sse2,sse3,ssse3,sse41,sse42,avx,avx2,fma,f16c,popcnt,rdrand
build:simd = sse2

OpenImageIO version and dependencies 2.5.x and master

I'll see if I can make a fix to untangle but it's a bit complicated.

jessey-git avatar May 15 '24 20:05 jessey-git