From de784397758cca4ba4de4d1f7a3cf5986a7e2136 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Mon, 4 Jan 2021 01:28:23 +0800 Subject: [PATCH 1/2] cmake: drop duplicated variable not_arch_x32 replicates ${_support_x64}. and a variable starts with "not" is just difficult to parse. so drop it. Signed-off-by: Kefu Chai --- cmake/modules/CheckNasm.cmake | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/cmake/modules/CheckNasm.cmake b/cmake/modules/CheckNasm.cmake index 32e0085c978..8ec728edc2f 100644 --- a/cmake/modules/CheckNasm.cmake +++ b/cmake/modules/CheckNasm.cmake @@ -14,10 +14,9 @@ macro(check_nasm_support _object_format _support_x64 _support_x64_and_avx2 _supp #error x32 #endif int main() {} - " not_arch_x32) + " ${_support_x64}) set(CMAKE_REQUIRED_QUIET ${save_quiet}) - if(not_arch_x32) - set(${_support_x64} TRUE) + if(${_support_x64}) execute_process(COMMAND nasm -f ${object_format} -i ${CMAKE_SOURCE_DIR}/src/isa-l/include/ ${CMAKE_SOURCE_DIR}/src/isa-l/erasure_code/gf_vect_dot_prod_avx2.asm @@ -38,12 +37,12 @@ macro(check_nasm_support _object_format _support_x64 _support_x64_and_avx2 _supp if(NOT rt) set(${_support_x64_and_avx512} TRUE) endif(NOT rt) - endif(not_arch_x32) + endif(${_support_x64}) endif(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64|x86_64") endif(NOT no_nasm) if(no_nasm) message(STATUS "Could NOT find nasm") - elseif(NOT not_arch_x32) + elseif(NOT ${_support_x64}) message(STATUS "Found nasm: but x86_64 with x32 ABI is not supported") endif() if(${_support_x64_and_avx512}) From d72c9205dc0923ea4b5b1be5d389c56fe7d23a1d Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Mon, 4 Jan 2021 01:15:54 +0800 Subject: [PATCH 2/2] cmake: only display the result of checking nasm once if nasm is able to emit AVX512 instructions, we can assume that it's able to generate AVX2 instructions as well. so no need to print "Found nasm" multiple times. and by chaining mutual exclusive branches with "elseif", we can have better readability. Signed-off-by: Kefu Chai --- cmake/modules/CheckNasm.cmake | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/cmake/modules/CheckNasm.cmake b/cmake/modules/CheckNasm.cmake index 8ec728edc2f..8a45bf38bfb 100644 --- a/cmake/modules/CheckNasm.cmake +++ b/cmake/modules/CheckNasm.cmake @@ -26,7 +26,7 @@ macro(check_nasm_support _object_format _support_x64 _support_x64_and_avx2 _supp ERROR_QUIET) if(NOT rc) set(${_support_x64_and_avx2} TRUE) - endif(NOT rc) + endif() execute_process(COMMAND nasm -D HAVE_AS_KNOWS_AVX512 -f ${object_format} -i ${CMAKE_SOURCE_DIR}/src/isa-l/include/ ${CMAKE_SOURCE_DIR}/src/isa-l/erasure_code/gf_vect_dot_prod_avx512.asm @@ -36,7 +36,7 @@ macro(check_nasm_support _object_format _support_x64 _support_x64_and_avx2 _supp ERROR_QUIET) if(NOT rt) set(${_support_x64_and_avx512} TRUE) - endif(NOT rt) + endif() endif(${_support_x64}) endif(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64|x86_64") endif(NOT no_nasm) @@ -44,14 +44,11 @@ macro(check_nasm_support _object_format _support_x64 _support_x64_and_avx2 _supp message(STATUS "Could NOT find nasm") elseif(NOT ${_support_x64}) message(STATUS "Found nasm: but x86_64 with x32 ABI is not supported") - endif() - if(${_support_x64_and_avx512}) + elseif(${_support_x64_and_avx512}) message(STATUS "Found nasm: best -- capable of assembling AVX512") - endif() - if(${_support_x64_and_avx2}) + elseif(${_support_x64_and_avx2}) message(STATUS "Found nasm: better -- capable of assembling AVX2") - endif() - if(${_support_x64}) + elseif(${_support_x64}) message(STATUS "Found nasm: good -- capable of assembling x86_64") endif() endmacro()