davisking / dlib

A toolkit for making real world machine learning and data analysis applications in C++
http://dlib.net
Boost Software License 1.0
13.57k stars 3.38k forks source link

Remove MMX header #2939

Closed Chainfire closed 7 months ago

Chainfire commented 7 months ago

MMX is not actually used by dlib and including the header breaks SIMD support detection and usage on platforms that support SSE but not MMX, such as emcc

Chainfire commented 7 months ago

When using emcc (Emscripten) to compile to 32-bit WebAssembly with SIMD support (-msse42 -msimd128), support is available for SSE through SSE4.2. These calls are translated (or emulated if not compatible) under the hood to WebAssembly SIMD instructions.

dlib pulls in the MMX intrinsics header as well, but MMX instructions are not supported by emcc, and compilation fails.

I went through the MMX intrinsics header file and searched for all the symbols in the dlib codebase, but could not find any references to any of them. I believe it is not (or perhaps no longer) used. Thus removal shouldn't be a problem, and it fixes SIMD compatibility with emcc.

I have additionally compiled my own code with clang in SSE2 mode and forced SSE2 usage in dlib, and it compiled and worked without issue. SSE4.2 builds kept working as before. However, I did not run the entire dlib test suite.

davisking commented 7 months ago

Cool, yeah shouldn't be needed. Thanks for the PR :D