mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Autotools: Refactor AVX-512 checks (#14831)
* Autotools: Refactor AVX-512 checks - CS synced - checks wrapped in AC_CACHE_CHECK - CPP macros PHP_HAVE_AVX512_SUPPORTS and PHP_HAVE_AVX512_VBMI_SUPPORTS are now either defined to 1 or undefined to avoid manual defining on Windows (previously they should be either 0 or 1) * [skip ci] Add basic macros help texts
This commit is contained in:
@@ -141,6 +141,8 @@ PHP 8.4 INTERNALS UPGRADE NOTES
|
||||
- Symbols PHP_FPM_SYSTEMD, PHP_FPM_USER, and PHP_FPM_GROUP removed.
|
||||
- Symbol PTHREADS has been removed.
|
||||
- Symbol HAVE_STRPTIME_DECL_FAILS has been removed (use HAVE_DECL_STRPTIME).
|
||||
- Symbols PHP_HAVE_AVX512_SUPPORTS and PHP_HAVE_AVX512_VBMI_SUPPORTS are now
|
||||
either defined to 1 or undefined.
|
||||
- M4 macro PHP_DEFINE (atomic includes) removed (use AC_DEFINE and config.h).
|
||||
- M4 macro PHP_WITH_SHARED has been removed (use PHP_ARG_WITH).
|
||||
- M4 macro PHP_STRUCT_FLOCK has been removed (use AC_CHECK_TYPES).
|
||||
|
||||
@@ -180,7 +180,7 @@ static inline int zend_cpu_supports_avx2(void) {
|
||||
return __builtin_cpu_supports("avx2");
|
||||
}
|
||||
|
||||
#if PHP_HAVE_AVX512_SUPPORTS
|
||||
#ifdef PHP_HAVE_AVX512_SUPPORTS
|
||||
ZEND_NO_SANITIZE_ADDRESS
|
||||
static inline int zend_cpu_supports_avx512(void) {
|
||||
#if PHP_HAVE_BUILTIN_CPU_INIT
|
||||
@@ -192,7 +192,7 @@ static inline int zend_cpu_supports_avx512(void) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if PHP_HAVE_AVX512_VBMI_SUPPORTS
|
||||
#ifdef PHP_HAVE_AVX512_VBMI_SUPPORTS
|
||||
ZEND_NO_SANITIZE_ADDRESS
|
||||
static inline int zend_cpu_supports_avx512_vbmi(void) {
|
||||
#if PHP_HAVE_BUILTIN_CPU_INIT
|
||||
|
||||
@@ -675,7 +675,7 @@ extern "C++" {
|
||||
# define ZEND_INTRIN_AVX2_FUNC_DECL(func)
|
||||
#endif
|
||||
|
||||
#if PHP_HAVE_AVX512_SUPPORTS && defined(HAVE_FUNC_ATTRIBUTE_TARGET) || defined(ZEND_WIN32)
|
||||
#if defined(PHP_HAVE_AVX512_SUPPORTS) && defined(HAVE_FUNC_ATTRIBUTE_TARGET) || defined(ZEND_WIN32)
|
||||
#define ZEND_INTRIN_AVX512_RESOLVER 1
|
||||
#endif
|
||||
|
||||
@@ -695,7 +695,7 @@ extern "C++" {
|
||||
# define ZEND_INTRIN_AVX512_FUNC_DECL(func)
|
||||
#endif
|
||||
|
||||
#if PHP_HAVE_AVX512_VBMI_SUPPORTS && defined(HAVE_FUNC_ATTRIBUTE_TARGET)
|
||||
#if defined(PHP_HAVE_AVX512_VBMI_SUPPORTS) && defined(HAVE_FUNC_ATTRIBUTE_TARGET)
|
||||
#define ZEND_INTRIN_AVX512_VBMI_RESOLVER 1
|
||||
#endif
|
||||
|
||||
|
||||
94
build/php.m4
94
build/php.m4
@@ -2750,56 +2750,60 @@ AC_DEFUN([PHP_PATCH_CONFIG_HEADERS], [
|
||||
dnl
|
||||
dnl PHP_CHECK_AVX512_SUPPORTS
|
||||
dnl
|
||||
AC_DEFUN([PHP_CHECK_AVX512_SUPPORTS], [
|
||||
AC_MSG_CHECKING([for avx512 supports in compiler])
|
||||
save_CFLAGS="$CFLAGS"
|
||||
CFLAGS="-mavx512f -mavx512cd -mavx512vl -mavx512dq -mavx512bw $CFLAGS"
|
||||
|
||||
AC_LINK_IFELSE([AC_LANG_SOURCE([[
|
||||
#include <immintrin.h>
|
||||
int main(void) {
|
||||
__m512i mask = _mm512_set1_epi32(0x1);
|
||||
char out[32];
|
||||
_mm512_storeu_si512(out, _mm512_shuffle_epi8(mask, mask));
|
||||
return 0;
|
||||
}]])], [
|
||||
have_avx512_supports=1
|
||||
AC_MSG_RESULT([yes])
|
||||
], [
|
||||
have_avx512_supports=0
|
||||
AC_MSG_RESULT([no])
|
||||
])
|
||||
|
||||
CFLAGS="$save_CFLAGS"
|
||||
|
||||
AC_DEFINE_UNQUOTED([PHP_HAVE_AVX512_SUPPORTS],
|
||||
[$have_avx512_supports], [Whether the compiler supports AVX512])
|
||||
dnl Check whether the compiler supports the AVX-512 extensions and define
|
||||
dnl PHP_HAVE_AVX512_SUPPORTS to 1 if found. Note that this is a compiler check,
|
||||
dnl not a runtime check where additional adjustments are done in the C code.
|
||||
dnl
|
||||
AC_DEFUN([PHP_CHECK_AVX512_SUPPORTS],
|
||||
[AC_CACHE_CHECK([whether compiler supports AVX-512],
|
||||
[php_cv_have_avx512],
|
||||
[save_CFLAGS="$CFLAGS"
|
||||
CFLAGS="-mavx512f -mavx512cd -mavx512vl -mavx512dq -mavx512bw $CFLAGS"
|
||||
AC_LINK_IFELSE([AC_LANG_SOURCE([[
|
||||
#include <immintrin.h>
|
||||
int main(void) {
|
||||
__m512i mask = _mm512_set1_epi32(0x1);
|
||||
char out[32];
|
||||
_mm512_storeu_si512(out, _mm512_shuffle_epi8(mask, mask));
|
||||
return 0;
|
||||
}]])],
|
||||
[php_cv_have_avx512=yes],
|
||||
[php_cv_have_avx512=no])
|
||||
CFLAGS="$save_CFLAGS"
|
||||
])
|
||||
AS_VAR_IF([php_cv_have_avx512], [yes],
|
||||
[AC_DEFINE([PHP_HAVE_AVX512_SUPPORTS], [1],
|
||||
[Define to 1 if the compiler supports AVX-512.])])
|
||||
])
|
||||
|
||||
dnl
|
||||
dnl PHP_CHECK_AVX512_VBMI_SUPPORTS
|
||||
dnl
|
||||
AC_DEFUN([PHP_CHECK_AVX512_VBMI_SUPPORTS], [
|
||||
AC_MSG_CHECKING([for avx512 vbmi supports in compiler])
|
||||
save_CFLAGS="$CFLAGS"
|
||||
CFLAGS="-mavx512f -mavx512cd -mavx512vl -mavx512dq -mavx512bw -mavx512vbmi $CFLAGS"
|
||||
AC_LINK_IFELSE([AC_LANG_SOURCE([[
|
||||
#include <immintrin.h>
|
||||
int main(void) {
|
||||
__m512i mask = _mm512_set1_epi32(0x1);
|
||||
char out[32];
|
||||
_mm512_storeu_si512(out, _mm512_permutexvar_epi8(mask, mask));
|
||||
return 0;
|
||||
}]])], [
|
||||
have_avx512_vbmi_supports=1
|
||||
AC_MSG_RESULT([yes])
|
||||
], [
|
||||
have_avx512_vbmi_supports=0
|
||||
AC_MSG_RESULT([no])
|
||||
])
|
||||
CFLAGS="$save_CFLAGS"
|
||||
AC_DEFINE_UNQUOTED([PHP_HAVE_AVX512_VBMI_SUPPORTS],
|
||||
[$have_avx512_vbmi_supports], [Whether the compiler supports AVX512 VBMI])
|
||||
dnl Check whether the compiler supports the AVX-512 extensions with the VBMI
|
||||
dnl instruction set and define PHP_HAVE_AVX512_VBMI_SUPPORTS to 1 if found. Note
|
||||
dnl that this is a compiler check, not a runtime check where additional
|
||||
dnl adjustments are done in the C code.
|
||||
dnl
|
||||
AC_DEFUN([PHP_CHECK_AVX512_VBMI_SUPPORTS],
|
||||
[AC_CACHE_CHECK([whether compiler supports AVX-512 VBMI],
|
||||
[php_cv_have_avx512vbmi],
|
||||
[save_CFLAGS="$CFLAGS"
|
||||
CFLAGS="-mavx512f -mavx512cd -mavx512vl -mavx512dq -mavx512bw -mavx512vbmi $CFLAGS"
|
||||
AC_LINK_IFELSE([AC_LANG_SOURCE([[
|
||||
#include <immintrin.h>
|
||||
int main(void) {
|
||||
__m512i mask = _mm512_set1_epi32(0x1);
|
||||
char out[32];
|
||||
_mm512_storeu_si512(out, _mm512_permutexvar_epi8(mask, mask));
|
||||
return 0;
|
||||
}]])],
|
||||
[php_cv_have_avx512vbmi=yes],
|
||||
[php_cv_have_avx512vbmi=no])
|
||||
CFLAGS="$save_CFLAGS"
|
||||
])
|
||||
AS_VAR_IF([php_cv_have_avx512vbmi], [yes],
|
||||
[AC_DEFINE([PHP_HAVE_AVX512_VBMI_SUPPORTS], [1],
|
||||
[Define to 1 if the compiler supports AVX-512 VBMI.])])
|
||||
])
|
||||
|
||||
dnl
|
||||
|
||||
Reference in New Issue
Block a user