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
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion win32/build/config.w32
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ ARG_WITH("test-ini-ext-exclude", "Comma separated list of shared extensions to \
be excluded from the test.ini", "no");

ARG_ENABLE("native-intrinsics", "Comma separated list of intrinsic optimizations to enable. \
Available instruction set names are sse, sse2, sse3, ssse3, sse4.1, sse4.2, avx, avx2. \
Available instruction set names are sse, sse2, sse3, ssse3, sse4.1, sse4.2, avx, avx2, avx512. \
SSE and SSE2 are enabled by default. The best instruction set specified will \
automatically enable all the older instruction sets. Note, that the produced binary \
might not work properly, if the chosen instruction sets are not available on the target \
Expand Down
17 changes: 9 additions & 8 deletions win32/build/confutils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3331,8 +3331,6 @@ function toolset_setup_common_cflags()
function toolset_setup_intrinsic_cflags()
{
var default_enabled = "sse2";
/* XXX AVX and above needs to be reflected in /arch, for now SSE4.2 is
the best possible optimization.*/
var avail = WScript.CreateObject("Scripting.Dictionary");
avail.Add("sse", "__SSE__");
avail.Add("sse2", "__SSE2__");
Expand All @@ -3341,7 +3339,7 @@ function toolset_setup_intrinsic_cflags()
avail.Add("sse4.1", "__SSE4_1__");
avail.Add("sse4.2", "__SSE4_2__");
/* From oldest to newest. */
var scale = new Array("sse", "sse2", "sse3", "ssse3", "sse4.1", "sse4.2", "avx", "avx2");
var scale = new Array("sse", "sse2", "sse3", "ssse3", "sse4.1", "sse4.2", "avx", "avx2", "avx512");

if (VS_TOOLSET) {
if ("disabled" == PHP_NATIVE_INTRINSICS) {
Expand All @@ -3367,9 +3365,9 @@ function toolset_setup_intrinsic_cflags()
AC_DEFINE(avail.Item(list[i]), 1);
}

/* All means all. __AVX__ and __AVX2__ are defined by compiler. */
ADD_FLAG("CFLAGS","/arch:AVX2");
configure_subst.Add("PHP_SIMD_SCALE", "AVX2");
/* All means all. __AVX__, __AVX2__, and __AVX512*__ are defined by compiler. */
ADD_FLAG("CFLAGS","/arch:AVX512");
configure_subst.Add("PHP_SIMD_SCALE", "AVX512");
} else {
var list = PHP_NATIVE_INTRINSICS.split(",");
var j = 0;
Expand All @@ -3378,7 +3376,7 @@ function toolset_setup_intrinsic_cflags()
var it = list[i].toLowerCase();
if (scale[k] == it) {
j = k > j ? k : j;
} else if (!avail.Exists(it) && "avx2" != it && "avx" != it) {
} else if (!avail.Exists(it) && "avx512" != it && "avx2" != it && "avx" != it) {
WARNING("Unknown intrinsic name '" + it + "' ignored");
}
}
Expand All @@ -3395,7 +3393,10 @@ function toolset_setup_intrinsic_cflags()
/* There is no explicit way to enable intrinsics between SSE3 and SSE4.2.
The declared macros therefore won't affect the code generation,
but will enable the guarded code parts. */
if ("avx2" == scale[j]) {
if ("avx512" == scale[j]) {
ADD_FLAG("CFLAGS","/arch:AVX512");
j -= 3;
} else if ("avx2" == scale[j]) {
ADD_FLAG("CFLAGS","/arch:AVX2");
j -= 2;
} else if ("avx" == scale[j]) {
Expand Down
Loading