Skip to contentSkip to conversation

package/fftw: add a bunch of optimisations (branch yem/fftw)

PATCH Superseded Yann E. MORIN 2 participants 9 messages Mar 16, 2015

v5 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v5 cover package/fftw: add a bunch of optimisations (branch yem/fftw)

Hello All!

This series aggregates misc optimisation patches for out fftw package, based on work by Gwenhael and Guillaume.

Thanks to both for their previous work! :-)

Changes v4 -> v5:
- use --disable-XXX in first patch
- add architecture optimisations for x86 and ARM
- add other optimisations (threads, openMP, fast maths)

Regards,
Yann E. MORIN.

The following changes since commit cc96e8a523f1b72ef9c3da095d0e957888090051:

qt: remove postgresql introduced uclibc dependency for the PostgresSQL support (2015-03-15 19:13:59 +0100)

are available in the git repository at:

git://git.busybox.net/~ymorin/git/buildroot yem/fftw

for you to fetch changes up to 984522fc4ea6415f68d5a560cc3a56e5cca08694:

package/fftw: add option for fast maths (2015-03-16 01:26:14 +0100)

----------------------------------------------------------------
Gwenhael Goavec-Merou (1):
fftw: add compile precision option

Yann E. MORIN (6):
package/fftw: add x86 optimisations package/fftw: add ARM optimisations package/fftw: disable fortran
package/fftw: enable threads when the tooclhain has them package/fftw: enable OpenMP if the compiler has that package/fftw: add option for fast maths

 package/fftw/Config.in | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++
 package/fftw/fftw.mk   | 21 +++++++++++++++++++++
 2 files changed, 72 insertions(+)
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#1 lore raw

PATCH v5 1/7 fftw: add compile precision option

From: Gwenhael Goavec-Merou <[email protected]>

fftw has options to select compile precision between single, long-double and quad. These options are exclusives. This patch adds choice to select precision option.

[yann.morin.1998 at free.fr: use --disable-XXX when not enabled]
Cc guillaume william brs <[email protected]>
---
 package/fftw/Config.in | 38 ++++++++++++++++++++++++++++++++++++++
 package/fftw/fftw.mk   |  4 ++++
 2 files changed, 42 insertions(+)
package/fftw/Config.in +38 -0
index 36f849f..7fa2c4c 100644
@@ -9,3 +9,41 @@ config BR2_PACKAGE_FFTW
 	  double precision.
 
 	  http://www.fftw.org
+
+if BR2_PACKAGE_FFTW
+
+choice
+	prompt "fftw precision"
+	default BR2_PACKAGE_FFTW_PRECISION_NONE
+	help
+	  Selects fftw precision
+
+config BR2_PACKAGE_FFTW_PRECISION_NONE
+	bool "none"
+	help
+	  no compile precision selected
+
+config BR2_PACKAGE_FFTW_PRECISION_SINGLE
+	bool "single precision"
+	help
+	  compile fftw in single precision
+
+config BR2_PACKAGE_FFTW_PRECISION_LONG_DOUBLE
+	bool "long double precision"
+	# long-double precision require long-double trigonometric routines
+	depends on !(BR2_TOOLCHAIN_BUILDROOT_UCLIBC && \
+		(BR2_arm || BR2_mips || BR2_mipsel))
+
+	help
+	  compile fftw in long-double precision
+
+config BR2_PACKAGE_FFTW_PRECISION_QUAD
+	bool "quad precision"
+	# quad-precision needs to have a gcc with libquadmath
+	depends on (BR2_i386 || BR2_x86_64) && BR2_USE_WCHAR
+	help
+	  compile fftw in quadruple precision if available
+
+endchoice
+
+endif
package/fftw/fftw.mk +4 -0
index 3b302df..78d36e9 100644
@@ -10,4 +10,8 @@ FFTW_INSTALL_STAGING = YES
 FFTW_LICENSE = GPLv2+
 FFTW_LICENSE_FILES = COPYING
 
+FFTW_CONF_OPTS += $(if $(BR2_PACKAGE_FFTW_PRECISION_SINGLE),--enable,--disable)-single
+FFTW_CONF_OPTS += $(if $(BR2_PACKAGE_FFTW_PRECISION_LONG_DOUBLE),--enable,--disable)-long-double
+FFTW_CONF_OPTS += $(if $(BR2_PACKAGE_FFTW_PRECISION_QUAD),--enable,--disable)-quad-precision
+
 $(eval $(autotools-package))
Signature · 1 line
1.9.1
#2 lore raw

PATCH v5 2/7 package/fftw: add x86 optimisations

In reply to Yann E. MORIN
Cc Gwenhael Goavec-Merou <[email protected]>
Cc guillaume william brs <[email protected]>
---
 package/fftw/fftw.mk | 4 ++++
 1 file changed, 4 insertions(+)
package/fftw/fftw.mk +4 -0
index 78d36e9..fd21fd4 100644
@@ -14,4 +14,8 @@ FFTW_CONF_OPTS += $(if $(BR2_PACKAGE_FFTW_PRECISION_SINGLE),--enable,--disable)-
 FFTW_CONF_OPTS += $(if $(BR2_PACKAGE_FFTW_PRECISION_LONG_DOUBLE),--enable,--disable)-long-double
 FFTW_CONF_OPTS += $(if $(BR2_PACKAGE_FFTW_PRECISION_QUAD),--enable,--disable)-quad-precision
 
+# x86 optimisations
+FFTW_CONF_OPTS += $(if $(BR2_X86_CPU_HAS_SSE),--enable,--disable)-sse
+FFTW_CONF_OPTS += $(if $(BR2_X86_CPU_HAS_SSE2),--enable,--disable)-sse2
+
 $(eval $(autotools-package))
Signature · 1 line
1.9.1
#3 lore raw

PATCH v5 3/7 package/fftw: add ARM optimisations

In reply to Yann E. MORIN
[based on a patch by Guillaume]
Cc guillaume william brs <[email protected]>
Cc Gwenhael Goavec-Merou <[email protected]>
---
 package/fftw/fftw.mk | 3 +++
 1 file changed, 3 insertions(+)
package/fftw/fftw.mk +3 -0
index fd21fd4..856adad 100644
@@ -18,4 +18,7 @@ FFTW_CONF_OPTS += $(if $(BR2_PACKAGE_FFTW_PRECISION_QUAD),--enable,--disable)-qu
 FFTW_CONF_OPTS += $(if $(BR2_X86_CPU_HAS_SSE),--enable,--disable)-sse
 FFTW_CONF_OPTS += $(if $(BR2_X86_CPU_HAS_SSE2),--enable,--disable)-sse2
 
+# ARM optimisations
+FFTW_CONF_OPTS += $(if $(BR2_ARM_CPU_HAS_NEON),--enable,--disable)-neon
+
 $(eval $(autotools-package))
Signature · 1 line
1.9.1
#4 lore raw

PATCH v5 3/7 package/fftw: add ARM optimisations

Dear Yann E. MORIN
On Mon, 16 Mar 2015 01:31:43 +0100
"Yann E. MORIN" <[email protected]> wrote:

[SNIP

package/fftw/fftw.mk FFTW_CONF_OPTS += $(if $(BR2_PACKAGE_FFTW_PRECISION_QUAD),--enable,--disable)-qu · line 24

Quoted 5 lines
package/fftw/fftw.mk +3 -0
+# ARM optimisations
+FFTW_CONF_OPTS += $(if $(BR2_ARM_CPU_HAS_NEON),--enable,--disable)-neon
+
 $(eval $(autotools-package))

--enable-neon must be enabled only if --enable-single is enabled. Without this, configure fails.

Something like :

ifeq ($(BR2_ARM_CPU_HAS_NEON)$(BR2_PACKAGE_FFTW_PRECISION_SINGLE),yy) FFTW_CONF_OPTS += --enable-neon
else
FFTW_CONF_OPTS += --disable-neon
endif
must be used

Regards.
Gwenhael Goavec-Merou

#5 lore raw

PATCH v5 4/7 package/fftw: disable fortran

In reply to Yann E. MORIN

We do not have any fortran package and we do not build a fortran compiler.

Still, an external toolchain may have a fortran compiler and that is totally useless to us, since we anyway have no fortran package...

So, entirely disable fortran support; that will at least slightly speed up the build in case an external toolchain has a fortran compiler.

[based on a patch by Guillaume]
Cc guillaume william brs <[email protected]>
Cc Gwenhael Goavec-Merou <[email protected]>
---
 package/fftw/fftw.mk | 2 ++
 1 file changed, 2 insertions(+)
package/fftw/fftw.mk +2 -0
index 856adad..0d15945 100644
@@ -10,6 +10,8 @@ FFTW_INSTALL_STAGING = YES
 FFTW_LICENSE = GPLv2+
 FFTW_LICENSE_FILES = COPYING
 
+FFTW_CONF_OPTS = --disable-fortran
+
 FFTW_CONF_OPTS += $(if $(BR2_PACKAGE_FFTW_PRECISION_SINGLE),--enable,--disable)-single
 FFTW_CONF_OPTS += $(if $(BR2_PACKAGE_FFTW_PRECISION_LONG_DOUBLE),--enable,--disable)-long-double
 FFTW_CONF_OPTS += $(if $(BR2_PACKAGE_FFTW_PRECISION_QUAD),--enable,--disable)-quad-precision
Signature · 1 line
1.9.1
#6 lore raw

PATCH v5 5/7 package/fftw: enable threads when the tooclhain has them

In reply to Yann E. MORIN
[based on a patch by Guillaume]
Cc guillaume william brs <[email protected]>
Cc Gwenhael Goavec-Merou <[email protected]>
---
 package/fftw/fftw.mk | 3 +++
 1 file changed, 3 insertions(+)
package/fftw/fftw.mk +3 -0
index 0d15945..7b4e64a 100644
@@ -23,4 +23,7 @@ FFTW_CONF_OPTS += $(if $(BR2_X86_CPU_HAS_SSE2),--enable,--disable)-sse2
 # ARM optimisations
 FFTW_CONF_OPTS += $(if $(BR2_ARM_CPU_HAS_NEON),--enable,--disable)-neon
 
+# Generic optimisations
+FFTW_CONF_OPTS += $(if $(BR2_TOOLCHAIN_HAS_THREADS),--enable-threads,--disable-threads)
+
 $(eval $(autotools-package))
Signature · 1 line
1.9.1
#7 lore raw

PATCH v5 6/7 package/fftw: enable OpenMP if the compiler has that

In reply to Yann E. MORIN

Unfortunately, this is limited to internal toolchains; we currently have no way to know if an external toolchain has support for OpenMP.

Cc guillaume william brs <[email protected]>
Cc Gwenhael Goavec-Merou <[email protected]>
---
 package/fftw/fftw.mk | 1 +
 1 file changed, 1 insertion(+)
package/fftw/fftw.mk +1 -0
index 7b4e64a..8ae0824 100644
@@ -25,5 +25,6 @@ FFTW_CONF_OPTS += $(if $(BR2_ARM_CPU_HAS_NEON),--enable,--disable)-neon
 
 # Generic optimisations
 FFTW_CONF_OPTS += $(if $(BR2_TOOLCHAIN_HAS_THREADS),--enable-threads,--disable-threads)
+FFTW_CONF_OPTS += $(if $(BR2_GCC_ENABLE_OPENMP),--enable-openmp,--disable-openmp)
 
 $(eval $(autotools-package))
Signature · 1 line
1.9.1
#8 lore raw

PATCH v5 7/7 package/fftw: add option for fast maths

In reply to Yann E. MORIN
[based on a patch by Guillaume]
Cc guillaume william brs <[email protected]>
Cc Gwenhael Goavec-Merou <[email protected]>
---
 package/fftw/Config.in | 13 +++++++++++++
 package/fftw/fftw.mk   |  4 ++++
 2 files changed, 17 insertions(+)
package/fftw/Config.in +13 -0
index 7fa2c4c..365cbb4 100644
@@ -46,4 +46,17 @@ config BR2_PACKAGE_FFTW_PRECISION_QUAD
 
 endchoice
 
+config BR2_PACKAGE_FFTW_FAST
+	bool "optimise for speed over accuracy"
+	help
+	  Optimise for fast math functions, at the expense of accuracy.
+
+	  Say 'y' if you need speed and can live with inaccuracies in
+	  the results. Say 'n' (the default) if accuracy is of utmost
+	  importance.
+
+	  This basically uses gcc's -Ofast optimisation level, which in
+	  turn is basically using gcc's -ffast-math. See the gcc manual
+	  for what this means.
+
 endif
package/fftw/fftw.mk +4 -0
index 8ae0824..ecf3e76 100644
@@ -27,4 +27,8 @@ FFTW_CONF_OPTS += $(if $(BR2_ARM_CPU_HAS_NEON),--enable,--disable)-neon
 FFTW_CONF_OPTS += $(if $(BR2_TOOLCHAIN_HAS_THREADS),--enable-threads,--disable-threads)
 FFTW_CONF_OPTS += $(if $(BR2_GCC_ENABLE_OPENMP),--enable-openmp,--disable-openmp)
 
+ifeq ($(BR2_PACKAGE_FFTW_FAST),y)
+FFTW_CONF_OPTS += CFLAGS="$(TARGET_CFLAGS) -Ofast"
+endif
+
 $(eval $(autotools-package))
Signature · 1 line
1.9.1