Skip to content

Commit

Permalink
Add a build patch for Windows ARM64EC (#19898)
Browse files Browse the repository at this point in the history
### 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
  • Loading branch information
snnn authored Mar 14, 2024
1 parent ea4a5ee commit 1fb6cbd
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 7 deletions.
24 changes: 17 additions & 7 deletions cmake/external/onnxruntime_external_deps.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 1fb6cbd

Please sign in to comment.