Add a build patch for Windows ARM64EC (#19898)

### Description
Add a patch for Windows ARM64EC


### Motivation and Context
Will need more changes in onnxruntime/core/common/cpuid_arch_definition.h and onnxruntime/core/common/cpuid_info.cc
This commit is contained in:
Changming Sun 2024-03-14 08:50:42 -07:00 committed by GitHub
parent ea4a5eea18
commit 1fb6cbddee
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 39 additions and 7 deletions

View file

@ -305,13 +305,23 @@ if (CPUINFO_SUPPORTED)
set(CPUINFO_BUILD_UNIT_TESTS OFF CACHE INTERNAL "")
set(CPUINFO_BUILD_MOCK_TESTS OFF CACHE INTERNAL "")
set(CPUINFO_BUILD_BENCHMARKS OFF CACHE INTERNAL "")
FetchContent_Declare(
pytorch_cpuinfo
URL ${DEP_URL_pytorch_cpuinfo}
URL_HASH SHA1=${DEP_SHA1_pytorch_cpuinfo}
FIND_PACKAGE_ARGS NAMES cpuinfo
)
if(onnxruntime_target_platform STREQUAL "ARM64EC")
message("Applying a patch for Windows ARM64EC in cpuinfo")
FetchContent_Declare(
pytorch_cpuinfo
URL ${DEP_URL_pytorch_cpuinfo}
URL_HASH SHA1=${DEP_SHA1_pytorch_cpuinfo}
PATCH_COMMAND ${Patch_EXECUTABLE} -p1 < ${PROJECT_SOURCE_DIR}/patches/cpuinfo/9bb12d342fd9479679d505d93a478a6f9cd50a47.patch
FIND_PACKAGE_ARGS NAMES cpuinfo
)
else()
FetchContent_Declare(
pytorch_cpuinfo
URL ${DEP_URL_pytorch_cpuinfo}
URL_HASH SHA1=${DEP_SHA1_pytorch_cpuinfo}
FIND_PACKAGE_ARGS NAMES cpuinfo
)
endif()
set(ONNXRUNTIME_CPUINFO_PROJ pytorch_cpuinfo)
endif()

View file

@ -0,0 +1,22 @@
diff --git a/include/cpuinfo.h b/include/cpuinfo.h
index c46b65e..8b83a64 100644
--- a/include/cpuinfo.h
+++ b/include/cpuinfo.h
@@ -18,7 +18,7 @@
#define CPUINFO_ARCH_X86 1
#endif
-#if defined(__x86_64__) || defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64)
+#if defined(__x86_64__) || (defined(_M_X64) && !defined(_M_ARM64EC)) || (defined(_M_AMD64) && !defined(_M_ARM64EC))
#define CPUINFO_ARCH_X86_64 1
#endif
@@ -26,7 +26,7 @@
#define CPUINFO_ARCH_ARM 1
#endif
-#if defined(__aarch64__) || defined(_M_ARM64)
+#if defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC)
#define CPUINFO_ARCH_ARM64 1
#endif