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

avx512 changes require -mavx512vl compile flags #1109

Open
pbadari opened this issue May 2, 2024 · 1 comment
Open

avx512 changes require -mavx512vl compile flags #1109

pbadari opened this issue May 2, 2024 · 1 comment
Labels
feature-request A feature should be added or improved. p3 This is a minor priority issue

Comments

@pbadari
Copy link
Contributor

pbadari commented May 2, 2024

Describe the bug

While trying to optimize aws-checksums (AVX512 branch) with avx512 instructions, found that compiling them requires -mavx512vl compile flags.

Expected Behavior

aws-c-common to add -mavx512vl to compile flags if its available.

Current Behavior

Compile failures in aws-checksums AVX512 branch.

In file included from /usr/lib/gcc/x86_64-linux-gnu/11/include/immintrin.h:57,
from /home/badari/aws-checksums/source/intel/intrin/crc32c_sse42_avx512.c:12:
/home/badari/aws-checksums/source/intel/intrin/crc32c_sse42_avx512.c: In function ‘aws_checksums_crc32c_avx512’:
/usr/lib/gcc/x86_64-linux-gnu/11/include/avx512vlintrin.h:7558:1: error: inlining failed in call to ‘always_inline’ ‘_mm_xor_epi64’: target specific option mismatch
7558 | _mm_xor_epi64 (__m128i __A, __m128i __B)
| ^~~~~~~~~~~~~
/home/badari/aws-checksums/source/intel/intrin/crc32c_sse42_avx512.c:144:10: note: called from here
144 | a1 = _mm_xor_epi64(a1, _mm512_castsi512_si128(x0));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Reproduction Steps

Try to build AVX512 branch of aws-checksums project

Possible Solution

diff --git a/cmake/AwsSIMD.cmake b/cmake/AwsSIMD.cmake
index 65fce96c..22126a62 100644
--- a/cmake/AwsSIMD.cmake
+++ b/cmake/AwsSIMD.cmake
@@ -35,6 +35,11 @@ if (USE_CPU_EXTENSIONS)
         set(AVX_CFLAGS "${AWS_AVX512_FLAG} ${AWS_CLMUL_FLAG} ${AVX_CFLAGS}")
     endif()
 
+    check_c_compiler_flag("${AWS_AVX512vL_FLAG}" HAVE_M_AVX512_FLAG)
+    if (HAVE_M_AVX512_FLAG)
+       set(AVX_CFLAGS "${AWS_AVX512vL_FLAG} ${AVX_CFLAGS}")
+    endif()
+
     set(old_flags "${CMAKE_REQUIRED_FLAGS}")
     set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${AVX_CFLAGS} ${WERROR_FLAG}")

Additional Information/Context

No response

aws-c-common version used

latest git

Compiler and version used

gcc version 11.4.0

Operating System and version

Ubuntu 22.04

@pbadari pbadari added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels May 2, 2024
@jmklix
Copy link
Member

jmklix commented May 8, 2024

awslabs/aws-checksums#72

@jmklix jmklix added p3 This is a minor priority issue and removed needs-triage This issue or PR still needs to be triaged. labels May 8, 2024
@jmklix jmklix added feature-request A feature should be added or improved. and removed bug This issue is a bug. labels Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A feature should be added or improved. p3 This is a minor priority issue
Projects
None yet
Development

No branches or pull requests

2 participants