mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
Fix CPU_INTEL flag error on windows (#30564)
Summary:
${CMAKE_HOST_SYSTEM_PROCESSOR} get processor name by `uname -p` on linux and `%PROCESSOR_ARCHITECTURE%` on windows
1. %PROCESSOR_ARCHITECTURE% has value in (AMD64|IA64|ARM64) for 64-bit processor, and (x86) for 32-bit processor
2. `uname -p` has value like "(x86_64|i[3-6]+86)"
We cannot tell intel cpu from other cpus by ${CMAKE_HOST_SYSTEM_PROCESSOR}. It is the architecture, not provider.
i. e. Intel CPU i7-9700K CPU on windows get "AMD64"
reference:
[MSDN](https://docs.microsoft.com/zh-cn/windows/win32/winprog64/wow64-implementation-details?redirectedfrom=MSDN)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/30564
Differential Revision: D18763031
Pulled By: ezyang
fbshipit-source-id: 11ae20e66b4b89bde1dcf4df6177606a3374c671
This commit is contained in:
parent
e6000a7c04
commit
8ee61e0be4
|
|
@ -81,12 +81,24 @@ if(APPLE)
|
|||
set(CMAKE_MACOSX_RPATH ON)
|
||||
endif()
|
||||
|
||||
if (${CMAKE_HOST_SYSTEM_PROCESSOR} MATCHES "(x86_64|i[3-6]+86)")
|
||||
set(CPU_INTEL ON)
|
||||
if (WIN32)
|
||||
# On Windows, CMAKE_HOST_SYSTEM_PROCESSOR is calculated through `PROCESSOR_ARCHITECTURE`,
|
||||
# which only has the value of `x86` or `AMD64`. We cannot infer whether it's a Intel CPU
|
||||
# or not. However, the environment variable `PROCESSOR_IDENTIFIER` could be used.
|
||||
if ($ENV{PROCESSOR_IDENTIFIER} MATCHES "Intel")
|
||||
set(CPU_INTEL ON)
|
||||
else ()
|
||||
set(CPU_INTEL OFF)
|
||||
endif ()
|
||||
else ()
|
||||
set(CPU_INTEL OFF)
|
||||
if (${CMAKE_HOST_SYSTEM_PROCESSOR} MATCHES "(x86_64|i[3-6]+86)")
|
||||
set(CPU_INTEL ON)
|
||||
else ()
|
||||
set(CPU_INTEL OFF)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
|
||||
# For non-supported platforms, turn USE_DISTRIBUTED off by default.
|
||||
# It is not tested and likely won't work without additional changes.
|
||||
if(NOT LINUX)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user