Skip to content
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

Disable the NEON optimisations on gcc <= 8 #3869

Closed
wants to merge 11 commits into from

Conversation

JAicewizard
Copy link
Contributor

GCC7 doesnt support all the necessary NEON intrinsics, which is really a shame. However this means that for aarch64 GCC cannot compile faiss with neon intrinsics, so we should avoid using them.

This is similar to #3860, build issues on GCC7, which I need. This one is a bit uglier, since GCC7 does support NEON just not all of the intrinsics.

GCC7 doesnt support all the neccesary NEON intrinsics, which is really a shame.
However this means that for aarch64 GCC cannot compile faiss with neon intrinsics,
so we should avoid using them.
@alexanderguzhva
Copy link
Contributor

alexanderguzhva commented Sep 17, 2024

@JAicewizard this should not affect clang, correct? because clang may pretend in certain situations

@JAicewizard
Copy link
Contributor Author

I just checked on CC explorer here and even with the oldest aarch64 clang there were no issues. So there might be an old clang compiler that doesn't work, but I am not in a position to test all of them. I suspect they were just always supported.

@facebook-github-bot
Copy link
Contributor

@junjieqi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@junjieqi
Copy link
Contributor

@JAicewizard we received bunch of errors internally. In case, you already know the issue before I look into it.

fbcode/faiss/impl/ScalarQuantizer.cpp:712:25: error: unknown type name 'float32x4x2_t'
[CONTEXT]   712 |     FAISS_ALWAYS_INLINE float32x4x2_t
[CONTEXT]       |                         ^
fbcode/faiss/impl/ScalarQuantizer.cpp:714:9: error: unknown type name 'uint8x8_t'; did you mean 'uint8_t'?
[CONTEXT]   714 |         uint8x8_t x8 = vld1_u8((const uint8_t*)(code + i));
[CONTEXT]       |         ^~~~~~~~~
fbcode/faiss/impl/ScalarQuantizer.cpp:714:24: error: use of undeclared identifier 'vld1_u8'
[CONTEXT]   714 |         uint8x8_t x8 = vld1_u8((const uint8_t*)(code + i));
[CONTEXT]       |                        ^
fbcode/faiss/impl/ScalarQuantizer.cpp:715:9: error: unknown type name 'uint16x8_t'; did you mean 'uint16_t'?
[CONTEXT]   715 |         uint16x8_t y8 = vmovl_u8(x8); // convert uint8 -> uint16
[CONTEXT]       |         ^~~~~~~~~~
fbcode/faiss/impl/ScalarQuantizer.cpp:715:25: error: use of undeclared identifier 'vmovl_u8'
[CONTEXT]   715 |         uint16x8_t y8 = vmovl_u8(x8); // convert uint8 -> uint16
[CONTEXT]       |                         ^
fbcode/faiss/impl/ScalarQuantizer.cpp:716:9: error: unknown type name 'uint16x4_t'
[CONTEXT]   716 |         uint16x4_t y8_0 = vget_low_u16(y8);
[CONTEXT]       |         ^
fbcode/faiss/impl/ScalarQuantizer.cpp:716:27: error: use of undeclared identifier 'vget_low_u16'
[CONTEXT]   716 |         uint16x4_t y8_0 = vget_low_u16(y8);
[CONTEXT]       |                           ^
fbcode/faiss/impl/ScalarQuantizer.cpp:717:9: error: unknown type name 'uint16x4_t'
[CONTEXT]   717 |         uint16x4_t y8_1 = vget_high_u16(y8);
[CONTEXT]       |         ^
fbcode/faiss/impl/ScalarQuantizer.cpp:717:27: error: use of undeclared identifier 'vget_high_u16'
[CONTEXT]   717 |         uint16x4_t y8_1 = vget_high_u16(y8);
[CONTEXT]       |                           ^
fbcode/faiss/impl/ScalarQuantizer.cpp:719:9: error: unknown type name 'float32x4_t'
[CONTEXT]   719 |         float32x4_t z8_0 = vcvtq_f32_u32(
[CONTEXT]       |         ^
fbcode/faiss/impl/ScalarQuantizer.cpp:721:9: error: unknown type name 'float32x4_t'
[CONTEXT]   721 |         float32x4_t z8_1 = vcvtq_f32_u32(vmovl_u16(y8_1));
[CONTEXT]       |         ^
fbcode/faiss/impl/ScalarQuantizer.cpp:724:33: error: use of undeclared identifier 'vmovq_n_f32'
[CONTEXT]   724 |         return {vsubq_f32(z8_0, vmovq_n_f32(128.0)),
[CONTEXT]       |                                 ^
fbcode/faiss/impl/ScalarQuantizer.cpp:725:33: error: use of undeclared identifier 'vmovq_n_f32'
[CONTEXT]   725 |                 vsubq_f32(z8_1, vmovq_n_f32(128.0))};

@JAicewizard
Copy link
Contributor Author

This should be fixed now

@junjieqi
Copy link
Contributor

github action failed. @JAicewizard could you help fix them before I import again? Thanks!

@facebook-github-bot
Copy link
Contributor

@junjieqi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@JAicewizard
Copy link
Contributor Author

I pushed some changes, but I don't think they will fix the error on your end. If anyone could post them I can look into it

@junjieqi
Copy link
Contributor

@JAicewizard here is some errors. Thanks for your patience.

fbcode/faiss/impl/ScalarQuantizer.cpp:62:9: error: expected unqualified-id
   62 |         vld1q_f32_x2(const float32_t* __a) {
      |         ^
fbcode/third-party-buck/platform010-aarch64/build/llvm-fb/17/lib/clang/stable/include/arm_neon.h:9823:28: note: expanded from macro 'vld1q_f32_x2'
 9823 | #define vld1q_f32_x2(__p0) __extension__ ({ \
      |                            ^

@JAicewizard
Copy link
Contributor Author

@junjieqi Does this still occur? or only on the previous iteration. Currently there is no such code on line 62 so this should be fixed

@facebook-github-bot
Copy link
Contributor

@junjieqi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@junjieqi merged this pull request in 1ee7561.

asadoughi added a commit that referenced this pull request Oct 7, 2024
Seeing if this changes the ARM CI run time to go back to
under 1 hour, currently taking over 3 hours to run.

This reverts commit 1ee7561.
aalekhpatel07 pushed a commit to aalekhpatel07/faiss that referenced this pull request Oct 17, 2024
Summary:
GCC7 doesnt support all the necessary NEON intrinsics, which is really a shame. However this means that for aarch64 GCC cannot compile faiss with neon intrinsics, so we should avoid using them.

This is similar to facebookresearch#3860, build issues on GCC7, which I need. This one is a bit uglier, since GCC7 does support NEON just not all of the intrinsics.

Pull Request resolved: facebookresearch#3869

Reviewed By: asadoughi

Differential Revision: D63081962

Pulled By: junjieqi

fbshipit-source-id: 69827cd447dd405b3ef70d651996f9ad00b6213e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants