-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
emsdk/upstream/emscripten/cache/sysroot/include/compat/emmintrin.h is not lib/clang/19/include/**/emmintrin.h #22226
Comments
The I'm guess we simply have not updated it in a while and we need to add the missing _mm_setr_epi64 declaration. @tlively do you know about the history of these two files? |
@sbc100 Thanks for the prompt response. If it's not too involved, I can push a PR. |
@sbc100 So, I got a working solution. I'm now formalizing the patch in Additionally, I'm looking at the definitions, emscripten/system/include/compat/emmintrin.h Lines 1180 to 1196 in c890466
char , short , int , long , long long . It seems to be that it's better to transition them to their int8_t , int16_t , int32_t , int64_t , and __m64 specific types, in order to provide more portable and readable code. @tlively or @juj do you have any suggestions on this?
I understand that static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
_mm_setr_epi64(__m64 q0, __m64 q1) out was the fact that |
I would be fine with using the
|
@tlively or @sbc100 do you have an idea why the conditional in #7924 (was the PR it was removed):
was based on the |
These headers are only ever included in Emscripten builds, so |
Originally when I wrote 128-bit SSE,SSE2, ... support, I did not add any of the old legacy 64-bit MMX support, which is considered obsolete: https://www.phoronix.com/news/LLVM-Clang-MMX-Intrinsics-SSE2 and https://groups.google.com/g/llvm-dev/c/7FEDyVe2ipQ/m/PY4F6hElAgAJ?pli=1 The reason was that Wasm SIMD128 did not support any 64-bit intrinsics. Note that there is a little bit of overlap with 128-bit SSE* and 64-bit MMX, as the SSE* instruction sets also added (for completeness) some 64-bit MMX registers instructions in them: https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#ig_expand=5740&techs=SSE_ALL&text=__m64 so as result, not "faking" 64-bit intrinsics resulted in those SSE/SSE2/SSE3 functions being dropped out that had a I don't oppose adding support to 64-bit MMX functions, emulated by 128-bit Wasm SIMD128. That is the path that LLVM is taking as well, as mentioned in the above phoronix link. |
@gblikas I think you might be taking the wrong approach with all this. OpenCV has support for WebAssembly SIMD and does not require SSE or SSE2 mappings/emulation. The problem is that when building OpenCV for Emscripten, The solution to your problem is to disable SSE by passing the following options to CMake:
Hope this helps! |
For anyone working close on OpenCV, it would actually be amazing to read a writeup of how the SSE path vs handwritten Wasm SIMD path vs a ARM Neon path compilation in Emscripten works out with performance. That is, since Emscripten supports all of those, users can choose which SIMD backend to target. It would be a really nice investigation to see "here's how much of a performance difference there is if you use Wasm SIMD instead of SSE" in different OpenCV tasks. |
Well, the SSE path for OpenCV is broken at the moment with some necessary functions missing (see #22243). I haven't tried the NEON path yet. |
@allsey87 Totally right. Sorry for the long delay; after seeing your comment, I went through and modified the opencv4 portfile to support building Emscripten. In doing so, many of the flags don't work or result in broken builds related to what you mention:
Also, there are some threading issues once you do build it - |
@juj I'm not close to the project, but am taking a stab at it. I've just finished my internal deployment, and am looking to do comparative analysis. Might be slow, but I'll get there. |
@allsey87 I opended #22243 which might be irrelevant now... I also haven't heard anything back from OpenCV on how they actually use Emscripten internally... Their documentation says one thing, then the github runners another, then the internal Intel whatever you call it says another. See opencv/opencv#25956. |
I'm going to close this comment until I hear back from the opencv team and finalize my own internal testing against Emscripten 2.0.13 (documented OpenCV deps) and Emscripten latest (what OpenCV looks to be running?...). |
I'm looking to narrow down a build issue. I am compiling opencv4 via
and have modified a bad header to
#include <emmintrin.h>
as it is a missed dependency. I did this because the documentation for Using SIMD with WebAssembly indicates that_mm_setr_epi64
should be available via#include <emmintrin.h>
. Judging by my error's output:and
it appears as if the included header
emmintrin.h
from**/upstream/emscripten/cache/sysroot/include/compat/emmintrin.h
is not the same as any of thelib/clang/19/include/**/emmintrin.h
headers.I'm not sure what
emscripten/cache/sysroot
is, so this issue is most-likley user error. However,$ grep -lR "_mm_setr_epi64" emsdk emsdk/upstream/emscripten/test/sse/test_sse2.cpp emsdk/upstream/emscripten/test/sse/benchmark_sse2.cpp emsdk/upstream/lib/clang/19/include/emmintrin.h emsdk/upstream/lib/clang/19/include/ppc_wrappers/emmintrin.h
does show that
_mm_setr_epi64
should be found inemsdk/upstream/lib/clang/19/include/**/emmintrin.h
. Is there a known work around for this?ng theIf this issue is better suited for the opencv repository, or vcpkg, I'll move the issue over there. However I believe this is an
#include
issue with emscripten-core.Potentially Related issue
Version Info
The text was updated successfully, but these errors were encountered: