Skip to content

Missing includes for faiss when building for Android x86-64 #113

Description

@DavidVentura

Bug description

faiss does not build on x86-64

How to reproduce

Include marian-dev in a CMake project (in my case, Android) and hit build.

You will get

error: unknown type name '__m128'
  148 | static inline __m128 masked_read(int d, const float *x)
      |               ^

This patch solves the issue

diff --git a/src/3rd_party/faiss/VectorTransform.h b/src/3rd_party/faiss/VectorTransform.h
index f0ed1440..ab34bc93 100644
--- a/src/3rd_party/faiss/VectorTransform.h
+++ b/src/3rd_party/faiss/VectorTransform.h
@@ -21,6 +21,12 @@
 #if defined(__APPLE__) && !defined(__arm64__)
 #include <x86intrin.h>
 #endif
+#if defined(__x86_64__) || defined(_M_X64)
+#include <xmmintrin.h>
+#include <emmintrin.h>
+#include <pmmintrin.h>
+#endif
+

Also reported upstream

Maybe masked_read should be gated by #ifdef __AVX__ instead of #ifdef __SSE__ ?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions