Skip to content

Commit

Permalink
fix: Update DetectArchitecture.cmake to only search for required CPU-…
Browse files Browse the repository at this point in the history
…flags. (#816)
  • Loading branch information
RealTimeChris authored Aug 28, 2023
1 parent ab0e35d commit d3884ca
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions cmake/DetectArchitecture.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,32 +25,32 @@ endfunction()

if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(INSTRUCTION_SETS
"T_AVX?/arch:AVX?auto result = _mm_testz_ps(__m128{}, __m128{})"
"T_AVX2?/arch:AVX2?auto result = _mm256_add_epi32(__m256i{}, __m256i{})"
"T_AVX512?/arch:AVX512?auto result = _mm512_add_ps(__m512i{}, __m512i{}).auto result2 = _mm512_cmplt_epu8_mask(__m512i{}, __m512i{})"
"T_AVX?/arch:AVX?__m128i value{}#auto result = _mm_extract_epi32(value, 0)"
"T_AVX2?/arch:AVX2?__m256i value{}#auto result = _mm256_extract_epi32(value, 0)"
"T_AVX512?/arch:AVX512?int32_t result[16]#const _mm512i& value{}#_mm512_store_si512(result, value)"
)
else()
set(INSTRUCTION_SETS
"T_AVX?-mavx.-mpclmul.-mbmi?auto result = _mm_testz_ps(__m128{}, __m128{})"
"T_AVX2?-mavx2.-mavx.-mpclmul.-mbmi?auto result = _mm256_add_epi32(__m256i{}, __m256i{})"
"T_AVX512?-mavx512bw.-mavx512f.-mavx2.-mavx.-mpclmul.-mbmi?auto result = _mm512_add_ps(__m512i{}, __m512i{}).auto result2 = _mm512_cmplt_epu8_mask(__m512i{}, __m512i{})"
)
"T_AVX?-mavx?__m128i value{}#auto result = _mm_extract_epi32(value, 0)"
"T_AVX2?-mavx2?__m256i value{}#auto result = _mm256_extract_epi32(value, 0)"
"T_AVX512?-mavx512f?int32_t result[16]#const _mm512i& value{}#_mm512_store_si512(result, value)"
)
endif()

set(CMAKE_REQUIRED_FLAGS_SAVE "${CMAKE_REQUIRED_FLAGS}")

set(AVX_NAME "T_Fallback")
if ((${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64") OR (${CMAKE_SYSTEM_PROCESSOR} MATCHES "i386"))

foreach(INSTRUCTION_SET IN LISTS INSTRUCTION_SETS)
string(REPLACE "?" ";" CURRENT_LIST "${INSTRUCTION_SET}")
list(GET CURRENT_LIST 0 INSTRUCTION_SET_NAME)
list(GET CURRENT_LIST 1 INSTRUCTION_SET_FLAG)
string(REPLACE "." ";" INSTRUCTION_SET_FLAG "${INSTRUCTION_SET_FLAG}")
list(GET CURRENT_LIST 2 INSTRUCTION_SET_INTRINSIC)
string(REPLACE "." ";" INSTRUCTION_SET_INTRINSIC "${INSTRUCTION_SET_INTRINSIC}")
check_instruction_set("${INSTRUCTION_SET_NAME}" "${INSTRUCTION_SET_FLAG}" "${INSTRUCTION_SET_INTRINSIC}")
endforeach()
foreach(INSTRUCTION_SET IN LISTS INSTRUCTION_SETS)
string(REPLACE "?" ";" CURRENT_LIST "${INSTRUCTION_SET}")
list(GET CURRENT_LIST 0 INSTRUCTION_SET_NAME)
list(GET CURRENT_LIST 1 INSTRUCTION_SET_FLAG)
string(REPLACE "." ";" INSTRUCTION_SET_FLAG "${INSTRUCTION_SET_FLAG}")
list(GET CURRENT_LIST 2 INSTRUCTION_SET_INTRINSIC)
string(REPLACE "#" ";" INSTRUCTION_SET_INTRINSIC "${INSTRUCTION_SET_INTRINSIC}")
check_instruction_set("${INSTRUCTION_SET_NAME}" "${INSTRUCTION_SET_FLAG}" "${INSTRUCTION_SET_INTRINSIC}")
endforeach()

string(REPLACE "T_" "" AVX_DISPLAY ${AVX_NAME})
message(STATUS "Detected ${CMAKE_SYSTEM_PROCESSOR} SSE type: ${AVX_DISPLAY}")
Expand Down

0 comments on commit d3884ca

Please sign in to comment.