Skip to content

Commit

Permalink
Fix bad vcplmulq detection and update simd feature tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanHenson committed Feb 5, 2024
1 parent ddb7d02 commit 8cac3d7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
2 changes: 2 additions & 0 deletions cmake/AwsFeatureTests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ if(MINGW)
set(USE_CPU_EXTENSIONS OFF)
endif()

set(AWS_USE_CPU_EXTENSIONS USE_CPU_EXTENSIONS)

if(NOT CMAKE_CROSSCOMPILING)
check_c_source_runs("
#include <stdbool.h>
Expand Down
8 changes: 5 additions & 3 deletions cmake/AwsSIMD.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,20 @@ else()
endif()

if (USE_CPU_EXTENSIONS)
set(AVX_CFLAGS ${AWS_SSE4_2_FLAG})

check_c_compiler_flag(${AWS_AVX2_FLAG} HAVE_M_AVX2_FLAG)
if (HAVE_M_AVX2_FLAG)
set(AVX_CFLAGS ${AWS_AVX2_FLAG})
set(AVX_CFLAGS "${AWS_AVX2_FLAG} ${AVX_CFLAGS}")
endif()

check_c_compiler_flag("${AWS_AVX512_FLAG} ${AWS_CLMUL_FLAG}" HAVE_M_AVX512_FLAG)
if (HAVE_M_AVX512_FLAG)
set(AVX_CFLAGS "${AVX_CFLAGS} ${AWS_AVX512_FLAG} ${AWS_CLMUL_FLAG} ${AWS_SSE4_2_FLAG}")
set(AVX_CFLAGS "${AWS_AVX512_FLAG} ${AWS_CLMUL_FLAG} ${AVX_CFLAGS}")
endif()

set(old_flags "${CMAKE_REQUIRED_FLAGS}")
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${AVX_CFLAGS}")
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${AVX_CFLAGS} ${WERROR_FLAG}")

check_c_source_compiles("
#include <immintrin.h>
Expand Down
1 change: 1 addition & 0 deletions include/aws/common/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@
#cmakedefine AWS_ARCH_ARM64
#cmakedefine AWS_ARCH_INTEL
#cmakedefine AWS_ARCH_INTEL_X64
#cmakedefine AWS_USE_CPU_EXTENSIONS

#endif
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 8cac3d7

Please sign in to comment.