Introduce a separate check and conditional for AVX512BW build (#2083)

Separate checks for AVX512f and AVX512BW
  Make AVX512BW cmake instructions nested within AVX512F support.
This commit is contained in:
Dmitri Smirnov 2019-10-10 16:14:00 -07:00 committed by GitHub
parent 2ba705ed99
commit af9dbb70f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 43 additions and 28 deletions

View file

@ -189,23 +189,20 @@ else()
# We have to run all 3 checks
check_cxx_compiler_flag("-mavx512f" HAS_AVX512F)
if(HAS_AVX512F)
set(AVX512_NEEDED "-mavx512f")
endif()
check_cxx_compiler_flag("-mavx512bw" HAS_AVX512BW)
if(HAS_AVX512BW)
set(AVX512_NEEDED "${AVX512_NEEDED} -mavx512bw")
set(CMAKE_REQUIRED_FLAGS "-mavx512f")
else()
set(CMAKE_REQUIRED_FLAGS "")
endif()
set(CMAKE_REQUIRED_FLAGS ${AVX512_NEEDED})
check_cxx_source_compiles("
int main() {
asm(\"vpxord %zmm0,%zmm0,%zmm0\");
return 0;
}"
AVX512_COMPILES
AVX512F_COMPILES
)
if(AVX512_COMPILES)
if(AVX512F_COMPILES)
set(mlas_platform_srcs_avx512f
${ONNXRUNTIME_ROOT}/core/mlas/lib/x86_64/DgemmKernelAvx512F.S
${ONNXRUNTIME_ROOT}/core/mlas/lib/x86_64/SgemmKernelAvx512F.S
@ -215,22 +212,40 @@ else()
if(HAS_AVX512F)
set_source_files_properties(${mlas_platform_srcs_avx512f} PROPERTIES COMPILE_FLAGS "-mavx512f")
endif()
set(mlas_platform_srcs_avx512bw
${ONNXRUNTIME_ROOT}/core/mlas/lib/x86_64/QgemmU8S8KernelAvx512BW.S
${ONNXRUNTIME_ROOT}/core/mlas/lib/x86_64/QgemvU8S8KernelAvx512BW.S
${ONNXRUNTIME_ROOT}/core/mlas/lib/x86_64/QgemmU8S8KernelAvx512Vnni.S
${ONNXRUNTIME_ROOT}/core/mlas/lib/x86_64/QgemvU8S8KernelAvx512Vnni.S
${ONNXRUNTIME_ROOT}/core/mlas/lib/x86_64/QgemmU8U8KernelAvx512BW.S
${ONNXRUNTIME_ROOT}/core/mlas/lib/x86_64/QgemmU8U8KernelAvx512Vnni.S
)
# AVX512BW support is only available if AVX512F support is present.
check_cxx_compiler_flag("-mavx512bw" HAS_AVX512BW)
if(HAS_AVX512BW)
set_source_files_properties(${mlas_platform_srcs_avx512bw} PROPERTIES COMPILE_FLAGS "-mavx512bw")
set(CMAKE_REQUIRED_FLAGS "-mavx512bw")
endif()
else()
# Disable platform support for AVX512.
set_source_files_properties(${mlas_common_srcs} PROPERTIES COMPILE_FLAGS "-DMLAS_AVX512_UNSUPPORTED")
endif()
check_cxx_source_compiles("
int main() {
asm(\"vpmaddwd %zmm0,%zmm0,%zmm0\");
return 0;
}"
AVX512BW_COMPILES
)
if(AVX512BW_COMPILES)
set(mlas_platform_srcs_avx512bw
${ONNXRUNTIME_ROOT}/core/mlas/lib/x86_64/QgemmU8S8KernelAvx512BW.S
${ONNXRUNTIME_ROOT}/core/mlas/lib/x86_64/QgemvU8S8KernelAvx512BW.S
${ONNXRUNTIME_ROOT}/core/mlas/lib/x86_64/QgemmU8S8KernelAvx512Vnni.S
${ONNXRUNTIME_ROOT}/core/mlas/lib/x86_64/QgemvU8S8KernelAvx512Vnni.S
${ONNXRUNTIME_ROOT}/core/mlas/lib/x86_64/QgemmU8U8KernelAvx512BW.S
${ONNXRUNTIME_ROOT}/core/mlas/lib/x86_64/QgemmU8U8KernelAvx512Vnni.S
)
if(HAS_AVX512BW)
set_source_files_properties(${mlas_platform_srcs_avx512bw} PROPERTIES COMPILE_FLAGS "-mavx512bw")
endif()
else() # AVX512BW_COMPILES
#
set_source_files_properties(${mlas_common_srcs} PROPERTIES COMPILE_FLAGS "-DMLAS_AVX512BW_UNSUPPORTED")
endif() # AVX512BW_COMPILES
else() # AVX512F_COMPILES
set_source_files_properties(${mlas_common_srcs} PROPERTIES COMPILE_FLAGS "-DMLAS_AVX512F_UNSUPPORTED")
endif() # AVX512F_COMPILES
set(mlas_platform_srcs
${mlas_platform_srcs_sse2}

View file

@ -191,7 +191,7 @@ Return Value:
this->TanhKernelRoutine = MlasTanhKernelFma3;
this->ErfKernelRoutine = MlasErfKernelFma3;
#if !defined(MLAS_AVX512_UNSUPPORTED)
#if !defined(MLAS_AVX512F_UNSUPPORTED)
//
// Check if the processor supports AVX512F features and the
@ -211,10 +211,10 @@ Return Value:
this->PoolFloatKernel[MlasAveragePoolingIncludePad] = MlasPoolAverageIncludePadFloatKernelAvx512F;
this->NchwcBlockSize = 16;
this->PreferredBufferAlignment = 64;
//
// Check if the processor supports AVX512BW.
//
#if !defined(MLAS_AVX512BW_UNSUPPORTED)
if ((Cpuid7[1] & 0x40000000) != 0) {
@ -233,18 +233,18 @@ Return Value:
this->GemmU8U8Kernel = MlasGemmU8U8KernelAvx512Vnni;
}
}
#endif // MLAS_AVX512BW_UNSUPPORTED
}
#endif
#endif // MLAS_AVX512F_UNSUPPORTED
}
#endif
#endif // MLAS_TARGET_AMD64
}
}
#endif
#endif // MLAS_TARGET_AMD64_IX86
}