Skip to content

Commit

Permalink
Add -mavx512vl option if using AVX512
Browse files Browse the repository at this point in the history
Fix s_has_vpclmulqdq() to look for the correct bit to detect VPCLMULQDQ
  • Loading branch information
root committed Jan 25, 2024
1 parent 901405e commit 52d2aa7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 7 additions & 2 deletions cmake/AwsSIMD.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,14 @@ if (USE_CPU_EXTENSIONS)
set(AVX_CFLAGS "/arch:AVX512 /arch:AVX2")
endif()
else()
check_c_compiler_flag("-mavx512f -mvpclmulqdq" HAVE_M_AVX512_FLAG)
check_c_compiler_flag("-mavx512vl -mvpclmulqdq" HAVE_M_AVX512_FLAG)
if (HAVE_M_AVX512_FLAG)
set(AVX_CFLAGS "-mavx512f -mvpclmulqdq -mpclmul -mavx -mavx2 -msse4.2")
set(AVX_CFLAGS "-mavx512vl -mvpclmulqdq -mpclmul -mavx -mavx2 -msse4.2")
else()
check_c_compiler_flag("-mavx512f -mvpclmulqdq" HAVE_M_AVX512_FLAG)
if (HAVE_M_AVX512_FLAG)
set(AVX_CFLAGS "-mavx512f -mvpclmulqdq -mpclmul -mavx -mavx2 -msse4.2")
endif()
endif()
endif()

Expand Down
4 changes: 2 additions & 2 deletions source/arch/intel/cpuid.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ static bool s_has_bmi2(void) {
static bool s_has_vpclmulqdq(void) {
uint32_t abcd[4];
/* Check VPCLMULQDQ:
* CPUID.(EAX=07H, ECX=0H):ECX.VPCLMULQDQ[bit 20]==1 */
uint32_t vpclmulqdq_mask = (1 << 20);
* CPUID.(EAX=07H, ECX=0H):ECX.VPCLMULQDQ[bit 10]==1 */
uint32_t vpclmulqdq_mask = (1 << 10);
aws_run_cpuid(7, 0, abcd);
if ((abcd[2] & vpclmulqdq_mask) != vpclmulqdq_mask) {
return false;
Expand Down

0 comments on commit 52d2aa7

Please sign in to comment.