-
Notifications
You must be signed in to change notification settings - Fork 3.9k
fix: add runtime check for AVX512-FP16 support instead of relying on compiler version #28236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -774,11 +774,29 @@ else() | |
| ${MLAS_SRC_DIR}/rotary_embedding_kernel_avx2.cpp | ||
| ${MLAS_SRC_DIR}/rotary_embedding_kernel_avx2.cpp | ||
| ) | ||
| if(CMAKE_CXX_COMPILER_VERSION GREATER_EQUAL 13.1 AND NOT(APPLE)) | ||
|
|
||
| include(CheckCSourceCompiles) | ||
|
|
||
| set(MLAS_OLD_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") | ||
| if(CMAKE_REQUIRED_FLAGS) | ||
| set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -mavx512fp16") | ||
| else() | ||
| set(CMAKE_REQUIRED_FLAGS "-mavx512fp16") | ||
| endif() | ||
| check_c_source_compiles(" | ||
| int main() { | ||
| __asm__ volatile(\"vcvtneeph2ps %ymm0, %ymm1\"); | ||
| return 0; | ||
| } | ||
| " COMPILER_SUPPORTS_AVX512FP16) | ||
| set(CMAKE_REQUIRED_FLAGS "${MLAS_OLD_CMAKE_REQUIRED_FLAGS}") | ||
|
|
||
| if(COMPILER_SUPPORTS_AVX512FP16 AND NOT APPLE) | ||
| set(mlas_platform_srcs_avx2 | ||
| ${mlas_platform_srcs_avx2} | ||
| ${MLAS_SRC_DIR}/x86_64/cvtfp16Avx.S | ||
| ) | ||
|
hariharans29 marked this conversation as resolved.
|
||
| list(APPEND mlas_private_compile_definitions MLAS_SUPPORTS_AVX512FP16) | ||
| endif() | ||
|
Comment on lines
+799
to
800
|
||
|
|
||
| message(STATUS "CMAKE_CXX_COMPILER_ID: ${CMAKE_CXX_COMPILER_ID}") | ||
|
|
@@ -997,4 +1015,4 @@ if (NOT onnxruntime_ORT_MINIMAL_BUILD) | |
| endif() | ||
| endif() | ||
|
|
||
| endif() | ||
| endif() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -527,14 +527,14 @@ Return Value: | |
| } | ||
|
|
||
| #ifndef __APPLE__ | ||
| #if (defined(_MSC_VER) && (_MSC_VER >= 1933)) || (defined(__GNUC__) && (__GNUC__ >= 13)) | ||
| #if defined(MLAS_SUPPORTS_AVX512FP16) | ||
| // | ||
| // Check if the processor supports AVX NE CONVERT. | ||
| // | ||
| if ((Cpuid7_1[3] & (0b1 << 5)) != 0) { | ||
| this->CastF16ToF32Kernel = &MlasCastF16ToF32KernelAvx; | ||
| } | ||
| #endif // (defined(_MSC_VER) && (_MSC_VER >= 1933)) || (defined(__GNUC__) && (__GNUC__ >= 13)) | ||
| #endif // MLAS_SUPPORTS_AVX512FP16 | ||
|
Comment on lines
529
to
+537
|
||
|
|
||
|
|
||
| // | ||
|
|
@@ -671,7 +671,7 @@ Return Value: | |
| } | ||
| else{ | ||
| this->ErfFP16KernelRoutine = MlasNeonErfFP16Kernel; | ||
| this->GeluFP16KernelRoutine = MlasNeonGeluFP16Kernel; | ||
| this->GeluFP16KernelRoutine = MlasNeonGeluFP16Kernel; | ||
| } | ||
| #else | ||
| this->ErfFP16KernelRoutine = MlasNeonErfFP16Kernel; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feature is consumed by C++ sources (
platform.cpp), but the probe usesCheckCSourceCompiles. UsingCheckCXXSourceCompiles(and the corresponding include) makes the probe match the actual compilation environment (C++ compiler, flags, and frontend), and avoids coupling this logic to the presence/configuration of the C language in the build.