Skip to content

Support AVX-512 builds on Windows #15159

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

Merged
merged 1 commit into from
Aug 22, 2024
Merged

Support AVX-512 builds on Windows #15159

merged 1 commit into from
Aug 22, 2024

Conversation

cmb69
Copy link
Member

@cmb69 cmb69 commented Jul 29, 2024

"Since limited support for /arch:AVX512 was added in Visual Studio 2017, and expanded in Visual Studio 2019"[1], we can safely offer this option, since PHP 8.4 is supposed to build with Visual Studio 2022, and it is unlikely that someone tries to build PHP 8.4 with Visual Studio, requesting AVX-512 support.

[1] https://learn.microsoft.com/en-us/cpp/build/reference/arch-x64?view=msvc-170


Note that this merely enables people to build for AVX-512; it doesn't change the default (that is still used for official Windows builds), nor does it update CI (which uses AVX2; I don't think AVX-512 is supported on hosted GH runners).

Also note that a full PHP build for AVX-512 succeeded, but apparently not even php -i can be run. Coreinfo reports here:

AVX-512-F       -       Supports AVX-512 Foundation instructions
AVX-512-DQ      -       Supports AVX-512 double and quadword instructions
AVX-512-IFAMA   -       Supports AVX-512 integer Fused multiply-add instructions
AVX-512-PF      -       Supports AVX-512 prefetch instructions
AVX-512-ER      -       Supports AVX-512 exponential and reciprocal instructions
AVX-512-CD      -       Supports AVX-512 conflict detection instructions
AVX-512-BW      -       Supports AVX-512 byte and word instructions
AVX-512-VL      -       Supports AVX-512 vector length instructions

I'll look into this.

"Since limited support for `/arch:AVX512` was added in Visual Studio
2017, and expanded in Visual Studio 2019"[1], we can safely offer this
option, since PHP 8.4 is supposed to build with Visual Studio 2022, and
it is unlikely that someone tries to build PHP 8.4 with Visual Studio,
requesting AVX-512 support.

[1] <https://learn.microsoft.com/en-us/cpp/build/reference/arch-x64?view=msvc-170>
@cmb69
Copy link
Member Author

cmb69 commented Jul 29, 2024

The problem is that vcvtusi2sd is not supported on my machine ("illegal instruction"), so apparently Coreinfo is wrong about my AVX-512F support. If somebody could run some tests, fine; otherwise I suggest to merge this PR.

@TimWolla
Copy link
Member

so apparently Coreinfo is wrong about my AVX-512F support

I can't help with Windows, but what CPU are you using?

@cmb69
Copy link
Member Author

cmb69 commented Jul 29, 2024

[…], but what CPU are you using?

It's an AMD Ryzen 5 2400G. Actually, I was surprised that it supported AVX-512, but, hey, would have been cool. :)

And to clarify, the issue had nothing to do with PHP's AVX-512 support, but rather is due to compile time optimization of

zend_hrtime_timer_scale = (double)ZEND_NANO_IN_SEC / (zend_hrtime_t)tf.QuadPart;

@Disservin
Copy link
Contributor

which uses AVX2; I don't think AVX-512 is supported on hosted GH runners

I think some runners have avx512 but this isn't stable. Rather what one should do is use https://github.com/petarpetrovt/setup-sde and use the sde to emulate it. It's been great for testing avx512 builds.

@cmb69
Copy link
Member Author

cmb69 commented Aug 7, 2024

Rather what one should do is use https://github.com/petarpetrovt/setup-sde and use the sde to emulate it. It's been great for testing avx512 builds.

Interesting, thanks! I assume that the tests runs would be rather slow, so likely something for nightly builds only. And it may make more sense to use that for a Linux build, given that the official Windows binaries are still restricted to SSE2. @iluuu1994, what do you think?

@Disservin
Copy link
Contributor

Interesting, thanks! I assume that the tests runs would be rather slow, so likely something for nightly builds only.

in my CI it seems to be twice as slow as the avx2 build

Are you aware that this currently fails because of missing gh command? (not sure what caddy is used for)
https://github.com/php/php-src/actions/runs/10150594501/job/28068047388#step:8:20

@iluuu1994
Copy link
Member

I have no experience with Intel SDE, so I can't provide any helpful comments. A nightly build for this seems reasonable.

@cmb69
Copy link
Member Author

cmb69 commented Aug 21, 2024

Are you aware that this currently fails because of missing gh command?

Thanks for mentioning that! I have now forwarded to #13296 (comment).

@cmb69
Copy link
Member Author

cmb69 commented Aug 22, 2024

I have filed #15540 as separate ticket, and going to merge this soon; doesn't make sense to not enable explicit support for AVX-512 while we already support dynamic AVX-512 detection (and to my knowledge there is no code which only supports compile time AVX-512 in php-src).

@cmb69 cmb69 merged commit e5a3027 into php:master Aug 22, 2024
9 of 11 checks passed
@cmb69 cmb69 deleted the cmb/avx512 branch August 22, 2024 11:07
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.

4 participants