[fftw3] add neon support (#45222)

Co-authored-by: Michael Schollerer <michael.schollerer@ifm.com>
Co-authored-by: Billy Robert O'Neal III <bion@microsoft.com>
Co-authored-by: Kai Pastor <dg0yt@darc.de>
This commit is contained in:
mschollerer 2025-05-14 23:07:16 +02:00 committed by GitHub
parent 115846a5b2
commit 64810c6bf2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 93 additions and 3 deletions

73
ports/fftw3/neon.patch Normal file
View File

@ -0,0 +1,73 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index db20caa7..48e724f3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -25,6 +25,7 @@ option (ENABLE_SSE "Compile with SSE instruction set support" OFF)
option (ENABLE_SSE2 "Compile with SSE2 instruction set support" OFF)
option (ENABLE_AVX "Compile with AVX instruction set support" OFF)
option (ENABLE_AVX2 "Compile with AVX2 instruction set support" OFF)
+option (ENABLE_NEON "Compile with NEON instruction set support" OFF)
option (DISABLE_FORTRAN "Disable Fortran wrapper routines" OFF)
@@ -203,9 +204,20 @@ if (ENABLE_AVX2)
endforeach ()
endif ()
+if (ENABLE_NEON)
+ if (ENABLE_LONG_DOUBLE)
+ message (FATAL_ERROR "NEON only works in single or double precision, please disable long double support")
+ endif ()
+ if (ENABLE_QUAD_PRECISION)
+ message (FATAL_ERROR "NEON only works in single or double precision, please disable quad precision support")
+ endif ()
+ set (HAVE_NEON TRUE)
+endif ()
+
if (HAVE_SSE2 OR HAVE_AVX)
set (HAVE_SIMD TRUE)
endif ()
+
file(GLOB fftw_api_SOURCE api/*.c api/*.h)
file(GLOB fftw_dft_SOURCE dft/*.c dft/*.h)
file(GLOB fftw_dft_scalar_SOURCE dft/scalar/*.c dft/scalar/*.h)
@@ -215,6 +227,7 @@ file(GLOB fftw_dft_simd_SOURCE dft/simd/*.c dft/simd
file(GLOB fftw_dft_simd_sse2_SOURCE dft/simd/sse2/*.c dft/simd/sse2/*.h)
file(GLOB fftw_dft_simd_avx_SOURCE dft/simd/avx/*.c dft/simd/avx/*.h)
file(GLOB fftw_dft_simd_avx2_SOURCE dft/simd/avx2/*.c dft/simd/avx2/*.h dft/simd/avx2-128/*.c dft/simd/avx2-128/*.h)
+file(GLOB fftw_dft_simd_neon_SOURCE dft/simd/neon/*.c dft/simd/neon/*.h)
file(GLOB fftw_kernel_SOURCE kernel/*.c kernel/*.h)
file(GLOB fftw_rdft_SOURCE rdft/*.c rdft/*.h)
file(GLOB fftw_rdft_scalar_SOURCE rdft/scalar/*.c rdft/scalar/*.h)
@@ -230,6 +243,7 @@ file(GLOB fftw_rdft_simd_SOURCE rdft/simd/*.c rdft/sim
file(GLOB fftw_rdft_simd_sse2_SOURCE rdft/simd/sse2/*.c rdft/simd/sse2/*.h)
file(GLOB fftw_rdft_simd_avx_SOURCE rdft/simd/avx/*.c rdft/simd/avx/*.h)
file(GLOB fftw_rdft_simd_avx2_SOURCE rdft/simd/avx2/*.c rdft/simd/avx2/*.h rdft/simd/avx2-128/*.c rdft/simd/avx2-128/*.h)
+file(GLOB fftw_rdft_simd_neon_SOURCE rdft/simd/neon/*.c rdft/simd/neon/*.h)
file(GLOB fftw_reodft_SOURCE reodft/*.c reodft/*.h)
file(GLOB fftw_simd_support_SOURCE simd-support/*.c simd-support/*.h)
@@ -283,6 +297,10 @@ if (HAVE_AVX2)
list (APPEND SOURCEFILES ${fftw_dft_simd_avx2_SOURCE} ${fftw_rdft_simd_avx2_SOURCE})
endif ()
+if (HAVE_NEON)
+ list (APPEND SOURCEFILES ${fftw_dft_simd_neon_SOURCE} ${fftw_rdft_simd_neon_SOURCE})
+endif ()
+
set (FFTW_VERSION 3.3.10)
set (PREC_SUFFIX)
diff --git a/cmake.config.h.in b/cmake.config.h.in
index 1f4c5055..8c61b38f 100644
--- a/cmake.config.h.in
+++ b/cmake.config.h.in
@@ -211,7 +211,7 @@
/* #undef HAVE_MPI */
/* Define to enable ARM NEON optimizations. */
-/* #undef HAVE_NEON */
+#cmakedefine HAVE_NEON 1
/* Define if OpenMP is enabled */
#cmakedefine HAVE_OPENMP

View File

@ -14,6 +14,7 @@ vcpkg_extract_source_archive(
fix-openmp.patch
install-subtargets.patch
fix-wrong-version.patch # https://github.com/FFTW/fftw3/commit/0842f00ae6b6e1f3aade155bc0edd17a7313fa6a
neon.patch # https://github.com/FFTW/fftw3/pull/275/commits/262f5cfe23af54930b119bd3653bc25bf2d881da
)
vcpkg_check_features(
@ -34,6 +35,13 @@ set(fftw3_options "")
set(fftw3f_options -DENABLE_FLOAT=ON)
set(fftw3l_options -DENABLE_LONG_DOUBLE=ON -DENABLE_AVX2=OFF -DENABLE_AVX=OFF -DENABLE_SSE2=OFF)
if("neon" IN_LIST FEATURES)
list(APPEND fftw3f_options -DENABLE_NEON=ON)
if(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64")
list(APPEND fftw3_options -DENABLE_NEON=ON)
endif()
endif()
foreach(package_name IN LISTS package_names)
message(STATUS "${package_name}...")
vcpkg_cmake_configure(

View File

@ -1,7 +1,7 @@
{
"name": "fftw3",
"version": "3.3.10",
"port-version": 9,
"port-version": 10,
"description": "FFTW is a C subroutine library for computing the discrete Fourier transform (DFT) in one or more dimensions, of arbitrary input size, and of both real and complex data (as well as of even/odd data, i.e. the discrete cosine/sine transforms or DCT/DST).",
"homepage": "https://www.fftw.org/",
"license": "GPL-2.0-or-later",
@ -24,6 +24,10 @@
"description": "Builds part of the library with avx2, fma, avx, sse2, sse",
"supports": "!arm"
},
"neon": {
"description": "Builds part of the library with neon",
"supports": "(linux | android) & arm"
},
"openmp": {
"description": "Builds openmp enabled lib"
},

View File

@ -2164,7 +2164,7 @@ embree3[core,avx,avx2,avx512,default-features,sse2,sse42](osx) = combination-fai
ffmpeg[all,all-gpl](x64 & android) = feature-fails
ffmpeg[nvcodec,ffplay,opengl](android) = feature-fails
fftw3[openmp](osx) = feature-fails # waits for https://github.com/microsoft/vcpkg/pull/30833
fftw3[openmp](windows) = feature-fails # Linker missing symbols. See https://github.com/microsoft/vcpkg/issues/33322
fftw3[openmp](windows & !static) = feature-fails # Linker missing symbols. See https://github.com/microsoft/vcpkg/issues/33322
flashlight-cpu = fail # CMake Error: INSTALL(EXPORT) given unknown export "flashlightTargets". See https://github.com/microsoft/vcpkg/issues/32098
flashlight-sequence[openmp](osx) = feature-fails # No openmp on osx
freerdp[server](osx) = skip # Uses api removed with macOS 15. Don't get fixed. See https://github.com/FreeRDP/FreeRDP/issues/10558

View File

@ -2810,7 +2810,7 @@
},
"fftw3": {
"baseline": "3.3.10",
"port-version": 9
"port-version": 10
},
"fftwpp": {
"baseline": "2019-12-19",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "98a1c4076fefe0c03872693b7305204b2db65f2c",
"version": "3.3.10",
"port-version": 10
},
{
"git-tree": "d64246f2b42f53756787bd4f886488846a789030",
"version": "3.3.10",