Skip to content

Commit e5a3027

Browse files
committed
Support AVX-512 builds on Windows (GH-15159)
"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>
2 parents 450740c + 2f17f15 commit e5a3027

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

UPGRADING

+2
Original file line numberDiff line numberDiff line change
@@ -1020,6 +1020,8 @@ PHP 8.4 UPGRADE NOTES
10201020
12. Windows Support
10211021
========================================
10221022

1023+
* Native AVX-512 builds are now supported (--enable-native-intrinsics=avx512).
1024+
10231025
========================================
10241026
13. Other Changes
10251027
========================================

win32/build/config.w32

+1-1
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ ARG_WITH("test-ini-ext-exclude", "Comma separated list of shared extensions to \
393393
be excluded from the test.ini", "no");
394394

395395
ARG_ENABLE("native-intrinsics", "Comma separated list of intrinsic optimizations to enable. \
396-
Available instruction set names are sse, sse2, sse3, ssse3, sse4.1, sse4.2, avx, avx2. \
396+
Available instruction set names are sse, sse2, sse3, ssse3, sse4.1, sse4.2, avx, avx2, avx512. \
397397
SSE and SSE2 are enabled by default. The best instruction set specified will \
398398
automatically enable all the older instruction sets. Note, that the produced binary \
399399
might not work properly, if the chosen instruction sets are not available on the target \

win32/build/confutils.js

+9-8
Original file line numberDiff line numberDiff line change
@@ -3338,8 +3338,6 @@ function toolset_setup_common_cflags()
33383338
function toolset_setup_intrinsic_cflags()
33393339
{
33403340
var default_enabled = "sse2";
3341-
/* XXX AVX and above needs to be reflected in /arch, for now SSE4.2 is
3342-
the best possible optimization.*/
33433341
var avail = WScript.CreateObject("Scripting.Dictionary");
33443342
avail.Add("sse", "__SSE__");
33453343
avail.Add("sse2", "__SSE2__");
@@ -3348,7 +3346,7 @@ function toolset_setup_intrinsic_cflags()
33483346
avail.Add("sse4.1", "__SSE4_1__");
33493347
avail.Add("sse4.2", "__SSE4_2__");
33503348
/* From oldest to newest. */
3351-
var scale = new Array("sse", "sse2", "sse3", "ssse3", "sse4.1", "sse4.2", "avx", "avx2");
3349+
var scale = new Array("sse", "sse2", "sse3", "ssse3", "sse4.1", "sse4.2", "avx", "avx2", "avx512");
33523350

33533351
if (VS_TOOLSET) {
33543352
if ("disabled" == PHP_NATIVE_INTRINSICS) {
@@ -3374,9 +3372,9 @@ function toolset_setup_intrinsic_cflags()
33743372
AC_DEFINE(avail.Item(list[i]), 1);
33753373
}
33763374

3377-
/* All means all. __AVX__ and __AVX2__ are defined by compiler. */
3378-
ADD_FLAG("CFLAGS","/arch:AVX2");
3379-
configure_subst.Add("PHP_SIMD_SCALE", "AVX2");
3375+
/* All means all. __AVX__, __AVX2__, and __AVX512*__ are defined by compiler. */
3376+
ADD_FLAG("CFLAGS","/arch:AVX512");
3377+
configure_subst.Add("PHP_SIMD_SCALE", "AVX512");
33803378
} else {
33813379
var list = PHP_NATIVE_INTRINSICS.split(",");
33823380
var j = 0;
@@ -3385,7 +3383,7 @@ function toolset_setup_intrinsic_cflags()
33853383
var it = list[i].toLowerCase();
33863384
if (scale[k] == it) {
33873385
j = k > j ? k : j;
3388-
} else if (!avail.Exists(it) && "avx2" != it && "avx" != it) {
3386+
} else if (!avail.Exists(it) && "avx512" != it && "avx2" != it && "avx" != it) {
33893387
WARNING("Unknown intrinsic name '" + it + "' ignored");
33903388
}
33913389
}
@@ -3402,7 +3400,10 @@ function toolset_setup_intrinsic_cflags()
34023400
/* There is no explicit way to enable intrinsics between SSE3 and SSE4.2.
34033401
The declared macros therefore won't affect the code generation,
34043402
but will enable the guarded code parts. */
3405-
if ("avx2" == scale[j]) {
3403+
if ("avx512" == scale[j]) {
3404+
ADD_FLAG("CFLAGS","/arch:AVX512");
3405+
j -= 3;
3406+
} else if ("avx2" == scale[j]) {
34063407
ADD_FLAG("CFLAGS","/arch:AVX2");
34073408
j -= 2;
34083409
} else if ("avx" == scale[j]) {

0 commit comments

Comments
 (0)