Skip to content
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

[CpuInductor] Enable NEON ISA detection on Linux ARM #129075

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 7 additions & 20 deletions torch/_inductor/codecache.py
Original file line number Diff line number Diff line change
Expand Up @@ -1302,18 +1302,7 @@ class VecISA:
#include <ATen/cpu/vec/vec.h>
#endif

#ifdef __APPLE__
// Fix Mac OS UT failed.
__attribute__((aligned(64))) float in_out_ptr0[16] = {0.0};
#else
#if defined(_WIN32)
#define __at_align__ __declspec(align(64))
#else
#define __at_align__ __attribute__((aligned(64)))
#endif

__at_align__ float in_out_ptr0[16] = {0.0};
#endif
alignas(64) float in_out_ptr0[16] = {0.0};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xuhancn Does it work on Windows?

Copy link
Contributor Author

@malfet malfet Jun 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jgong5 Is there a CI to test it on Windows? But at least godbolt believes it is supported even by a pretty old MSVC: https://godbolt.org/z/Tr6Wa9WE6

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xuhancn told me alignas is not always supported. @xuhancn can you confirm?

Copy link
Collaborator

@xuhancn xuhancn Jun 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xuhancn told me alignas is not always supported. @xuhancn can you confirm?

@jgong5 If it not support Windows, I will fix it later.


extern "C" void __avx_chk_kernel() {
auto tmp0 = at::vec::Vectorized<float>(1);
Expand Down Expand Up @@ -1506,12 +1495,11 @@ def _check_and_append_supported_isa(
# we only cache some key isa information.
@functools.lru_cache(None)
def valid_vec_isa_list() -> List[VecISA]:
isa_list: List[VecISA] = []
if sys.platform == "darwin" and platform.processor() == "arm":
return [VecNEON()]
isa_list.append(VecNEON())

isa_list: List[VecISA] = []
cur_os = sys.platform
if cur_os != "linux" and cur_os != "win32":
if sys.platform not in ["linux", "win32"]:
return isa_list

arch = platform.machine()
Expand All @@ -1528,17 +1516,16 @@ def valid_vec_isa_list() -> List[VecISA]:
if re.search(r"[\^ ]+vxe[\$ ]+", group):
isa_list.append(VecZVECTOR())
break
return isa_list

if arch == "x86_64" or arch == "AMD64":
elif arch == "aarch64":
isa_list.append(VecNEON())
elif arch in ["x86_64", "AMD64"]:
"""
arch value is x86_64 on Linux, and the value is AMD64 on Windows.
"""
_cpu_supported_x86_isa = x86_isa_checker()
for isa in supported_vec_isa_list:
if str(isa) in _cpu_supported_x86_isa and isa:
isa_list.append(isa)
return isa_list

return isa_list

Expand Down
Loading