Skip to contentSkip to conversation

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

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

lore
Share & tools
lore
#0 lore raw

v7 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 v6 -> v7:
- re-order patches
- reword promopts ('none' -> 'double')
- fix SSE2 (not available for long-double, only 'double') (Gwenhael)
- force use of NEON when available, not when suer-selected (Thomas)
- generate a single library with threads

Changes v5 -> v6:
- architecture optimisations are not available for all precisions (Thomas, Gwenhael)

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 c511ca937d4627df7d601a999945faa20fe4cc8d:

network-manager: add hash file (2015-03-16 14:19:30 +0100)

are available in the git repository at:

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

for you to fetch changes up to d316f0f87e1a502eef6d85b9a4d515ad1da8c5ae:

package/fftw: enable OpenMP if the compiler has that (2015-03-16 17:26:49 +0100)

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

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

 package/fftw/Config.in | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++
 package/fftw/fftw.mk   | 29 ++++++++++++++++++++++
 2 files changed, 96 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 v7 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; reword
prompts (default is not 'none' but 'double')
]

Cc guillaume william brs <[email protected]>
---
 package/fftw/Config.in | 41 +++++++++++++++++++++++++++++++++++++++++
 package/fftw/fftw.mk   |  4 ++++
 2 files changed, 45 insertions(+)
package/fftw/Config.in +41 -0
index 36f849f..4cefa28 100644
@@ -9,3 +9,44 @@ config BR2_PACKAGE_FFTW
 	  double precision.
 
 	  http://www.fftw.org
+
+if BR2_PACKAGE_FFTW
+
+choice
+	prompt "fftw precision"
+	default BR2_PACKAGE_FFTW_PRECISION_DOUBLE
+	help
+	  Selects fftw precision
+
+config BR2_PACKAGE_FFTW_PRECISION_SINGLE
+	bool "single"
+	help
+	  Compile fftw in single precision, i.e. use 'float' for floating
+	  point type.
+
+config BR2_PACKAGE_FFTW_PRECISION_DOUBLE
+	bool "double"
+	help
+	  Compile fftw in double precision (the default), i.e. use 'double'
+	  for floating point type.
+
+config BR2_PACKAGE_FFTW_PRECISION_LONG_DOUBLE
+	bool "long double"
+	# 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, i.e. use 'long double'
+	  for floating point type.
+
+config BR2_PACKAGE_FFTW_PRECISION_QUAD
+	bool "quad"
+	# 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, i.e. use '__float128' for
+	  floating point type.
+
+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 v7 2/7 package/fftw: add option for fast maths

In reply to Yann E. MORIN

Use FFTW_CFLAGS as intermediate variable, since we're going to need it in a later patch (about NEON optimisations).

[based on a patch by Guillaume]
Cc guillaume william brs <[email protected]>
Cc Gwenhael Goavec-Merou <[email protected]>

---
Changes v6 -> v7:
- use intermediate FFTW_CFLAGS
- reorder patch

---
 package/fftw/Config.in | 13 +++++++++++++
 package/fftw/fftw.mk   |  7 +++++++
 2 files changed, 20 insertions(+)
package/fftw/Config.in +13 -0
index 4cefa28..4a0706a 100644
@@ -49,4 +49,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 +7 -0
index 78d36e9..c05012a 100644
@@ -14,4 +14,11 @@ 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
 
+FFTW_CFLAGS = $(TARGET_CFLAGS)
+ifeq ($(BR2_PACKAGE_FFTW_FAST),y)
+FFTW_CFLAGS += -Ofast
+endif
+
+FFTW_CONF_OPTS += CFLAGS="$(FFTW_CFLAGS)"
+
 $(eval $(autotools-package))
Signature · 1 line
1.9.1
#3 lore raw

PATCH v7 3/7 package/fftw: add x86 optimisations

In reply to Yann E. MORIN
Cc Gwenhael Goavec-Merou <[email protected]>
Cc guillaume william brs <[email protected]>

---
Changes v6 -> v7:
- SSE2 not possible with long-double, but is with double precision

Changes v5 -> v6:
- SSE/SSE2 can't be enabled for all precisions (Gwenhael)

---
 package/fftw/Config.in | 9 +++++++++
 package/fftw/fftw.mk   | 4 ++++
 2 files changed, 13 insertions(+)
package/fftw/Config.in +9 -0
index 4a0706a..7feadd8 100644
@@ -12,6 +12,12 @@ config BR2_PACKAGE_FFTW
 
 if BR2_PACKAGE_FFTW
 
+config BR2_PACKAGE_FFTW_USE_SSE
+	bool
+
+config BR2_PACKAGE_FFTW_USE_SSE2
+	bool
+
 choice
 	prompt "fftw precision"
 	default BR2_PACKAGE_FFTW_PRECISION_DOUBLE
@@ -20,12 +26,15 @@ choice
 
 config BR2_PACKAGE_FFTW_PRECISION_SINGLE
 	bool "single"
+	select BR2_PACKAGE_FFTW_USE_SSE if BR2_X86_CPU_HAS_SSE
+	select BR2_PACKAGE_FFTW_USE_SSE2 if BR2_X86_CPU_HAS_SSE2
 	help
 	  Compile fftw in single precision, i.e. use 'float' for floating
 	  point type.
 
 config BR2_PACKAGE_FFTW_PRECISION_DOUBLE
 	bool "double"
+	select BR2_PACKAGE_FFTW_USE_SSE2 if BR2_X86_CPU_HAS_SSE2
 	help
 	  Compile fftw in double precision (the default), i.e. use 'double'
 	  for floating point type.
package/fftw/fftw.mk +4 -0
index c05012a..daa3cc2 100644
@@ -19,6 +19,10 @@ ifeq ($(BR2_PACKAGE_FFTW_FAST),y)
 FFTW_CFLAGS += -Ofast
 endif
 
+# x86 optimisations
+FFTW_CONF_OPTS += $(if $(BR2_PACKAGE_FFTW_USE_SSE),--enable,--disable)-sse
+FFTW_CONF_OPTS += $(if $(BR2_PACKAGE_FFTW_USE_SSE2),--enable,--disable)-sse2
+
 FFTW_CONF_OPTS += CFLAGS="$(FFTW_CFLAGS)"
 
 $(eval $(autotools-package))
Signature · 1 line
1.9.1
#4 lore raw

PATCH v7 4/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]>

---
Changes v6 -> v7:
- force NEON FPU when available, not when user-selected (Thomas)

Changes v5 -> v6:
- NEON can't be used by all precisions (Gwenhael)

---
 package/fftw/Config.in | 4 ++++
 package/fftw/fftw.mk   | 4 ++++
 2 files changed, 8 insertions(+)
package/fftw/Config.in +4 -0
index 7feadd8..d9a65d5 100644
@@ -18,6 +18,9 @@ config BR2_PACKAGE_FFTW_USE_SSE
 config BR2_PACKAGE_FFTW_USE_SSE2
 	bool
 
+config BR2_PACKAGE_FFTW_USE_NEON
+	bool
+
 choice
 	prompt "fftw precision"
 	default BR2_PACKAGE_FFTW_PRECISION_DOUBLE
@@ -28,6 +31,7 @@ config BR2_PACKAGE_FFTW_PRECISION_SINGLE
 	bool "single"
 	select BR2_PACKAGE_FFTW_USE_SSE if BR2_X86_CPU_HAS_SSE
 	select BR2_PACKAGE_FFTW_USE_SSE2 if BR2_X86_CPU_HAS_SSE2
+	select BR2_PACKAGE_FFTW_USE_NEON if BR2_ARM_CPU_HAS_NEON && !BR2_ARM_SOFT_FLOAT
 	help
 	  Compile fftw in single precision, i.e. use 'float' for floating
 	  point type.
package/fftw/fftw.mk +4 -0
index daa3cc2..154f522 100644
@@ -23,6 +23,10 @@ endif
 FFTW_CONF_OPTS += $(if $(BR2_PACKAGE_FFTW_USE_SSE),--enable,--disable)-sse
 FFTW_CONF_OPTS += $(if $(BR2_PACKAGE_FFTW_USE_SSE2),--enable,--disable)-sse2
 
+# ARM optimisations
+FFTW_CONF_OPTS += $(if $(BR2_PACKAGE_FFTW_USE_NEON),--enable,--disable)-neon
+FFTW_CFLAGS += $(if $(BR2_PACKAGE_FFTW_USE_NEON),-mfpu=neon)
+
 FFTW_CONF_OPTS += CFLAGS="$(FFTW_CFLAGS)"
 
 $(eval $(autotools-package))
Signature · 1 line
1.9.1
#5 lore raw

PATCH v7 5/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 154f522..3acde57 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 v7 6/7 package/fftw: enable threads when the toolchain 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]>

---
Changes v6 -> v7:
- generate a single library with thread support included (otherwise thread support is in another library)
- fix typo in commit title

---
 package/fftw/fftw.mk | 7 +++++++
 1 file changed, 7 insertions(+)
package/fftw/fftw.mk +7 -0
index 3acde57..aea3910 100644
@@ -29,6 +29,13 @@ FFTW_CONF_OPTS += $(if $(BR2_PACKAGE_FFTW_USE_SSE2),--enable,--disable)-sse2
 FFTW_CONF_OPTS += $(if $(BR2_PACKAGE_FFTW_USE_NEON),--enable,--disable)-neon
 FFTW_CFLAGS += $(if $(BR2_PACKAGE_FFTW_USE_NEON),-mfpu=neon)
 
+# Generic optimisations
+ifeq ($(BR2_TOOLCHAIN_HAS_THREADS),y)
+FFTW_CONF_OPTS += --enable-threads --with-combined-threads
+else
+FFTW_CONF_OPTS += --disable-threads
+endif
+
 FFTW_CONF_OPTS += CFLAGS="$(FFTW_CFLAGS)"
 
 $(eval $(autotools-package))
Signature · 1 line
1.9.1
#7 lore raw

PATCH v7 7/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.

---
Changes v6 -> v7:
- treat openmp like all other options

---
 package/fftw/fftw.mk | 1 +
 1 file changed, 1 insertion(+)
package/fftw/fftw.mk +1 -0
index aea3910..1148909 100644
@@ -35,6 +35,7 @@ FFTW_CONF_OPTS += --enable-threads --with-combined-threads
 else
 FFTW_CONF_OPTS += --disable-threads
 endif
+FFTW_CONF_OPTS += $(if $(BR2_GCC_ENABLE_OPENMP),--enable,--disable)-openmp
 
 FFTW_CONF_OPTS += CFLAGS="$(FFTW_CFLAGS)"
 
Signature · 1 line
1.9.1
#8 lore raw

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

In reply to Yann E. MORIN

Dear Yann E. MORIN,

Quoted 10 lines · Yann E. MORIN

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

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

Series applied, thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com