Skip to content

Conversation

@rrwinterton
Copy link
Contributor

detect AVX10.1 ISA

@facebook-github-bot
Copy link
Contributor

Hi @rrwinterton!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

src/x86/isa.c Outdated
/*
* AVX 10.1 instructions:
*/
isa.avx10_1 = (structured_feature_info1.edx & UINT32_C(1 << 19));
Copy link
Collaborator

Choose a reason for hiding this comment

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

refer a UINT32_C constant like the others
Replace UINT32_C(1 << 19)
with UINT32_C(0x00080000)

To confirm the bits, I look at libyuv AVX10 support

It is in the same register as avxvnniint8
((cpu_einfo7[3] & 0x00000010) ? kCpuHasAVXVNNIINT8 : 0);
((cpu_einfo7[3] & 0x00080000) ? kCpuHasAVX10 : 0)

It looks right except in libyuv it checks for if ((GetXCR0() & 0xe0) == 0xe0) which says the OS supports saving ymm16 to ymm31.
So I think you should also check avx512_regs &&

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason I didn't check for AVX512 is because in the future there may not be 512 on some systems that support AVX10.2 in 256 bit form but that is still TBD. I think it is a good idea for now since we can change this in the future if this is the case.

@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

Copy link
Collaborator

@fbarchard fbarchard left a comment

Choose a reason for hiding this comment

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

Comment about other avx10 is not needed and subject to change.
The 'avx512 registers' is a misnomer. The OSS indicates the OS supports saving 32 vector registers.

src/x86/isa.c Outdated
/*
* AVX 10.1 instructions:
*/
isa.avx10_1 = avx512_regs && !!(structured_feature_info1.edx & UINT32_C(0x00080000));
Copy link
Collaborator

Choose a reason for hiding this comment

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

indent is wrong. Make it the same as lines above

Copy link
Collaborator

Choose a reason for hiding this comment

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

to be clear, you should use 1 tab, not 4 spaces

tools/isa-info.c Outdated
printf("\tAVX512_4VNNIW: %s\n", cpuinfo_has_x86_avx512_4vnniw() ? "yes" : "no");
printf("\tAVX512_4FMAPS: %s\n", cpuinfo_has_x86_avx512_4fmaps() ? "yes" : "no");

//avx10.1 (in future will add other avx10 version)
Copy link
Collaborator

Choose a reason for hiding this comment

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

this comment is not needed and inconsistent with other printf's

tools/isa-info.c Outdated

//avx10.1 (in future will add other avx10 version)
printf("\tAVX10_1: %s\n", cpuinfo_has_x86_avx10_1() ? "yes" : "no");

Copy link
Collaborator

Choose a reason for hiding this comment

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

remove blank lines. avx10_1 is an ISA and should be grouped with the rest

Copy link
Contributor

@malfet malfet Jan 8, 2025

Choose a reason for hiding this comment

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

CI have linter automation that should detect this

@rrwinterton rrwinterton changed the title Added changes to cpuinfo.h, isa.c and isa-info.c Added changes to support AVX 10.1 and AVX 10.2 support Jan 8, 2025
Copy link
Collaborator

@fbarchard fbarchard left a comment

Choose a reason for hiding this comment

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

Change title for this PR to Added changes to support AVX 10.1
Have a follow up PR for 10.2

@malfet
Copy link
Contributor

malfet commented Jan 8, 2025

@rrwinterton can you please put a reference to some public doc on what AVX10 is and list 1-2 CPUs currently support it?

@rrwinterton rrwinterton changed the title Added changes to support AVX 10.1 and AVX 10.2 support Added changes to support AVX 10.1 support Jan 8, 2025
Copy link
Collaborator

@fbarchard fbarchard left a comment

Choose a reason for hiding this comment

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

Looks good to me. If you can, test on real hardware that does not have avx512, but does have avx10.1
SDE doesnt really test the OSSAVE portion correctly, and the only publically released hardware that supports avx10.1 is granite rapids, but that also has avx512, so it doesnt test the OSSAVE.
This test is historically so new cpus can be used with old OS's, where the linux kernel does not support the new registers (32 ymm registers), so the cpuid needs to be turned off.
But the way you have it is safe... if it fails, it will just disable avx10 on a cpu/OS that it should have had it enabled.

Copy link
Contributor

@digantdesai digantdesai left a comment

Choose a reason for hiding this comment

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

Thank you

@digantdesai digantdesai merged commit 8a1772a into pytorch:main Jan 10, 2025
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants