diff mbox

[v2,1/1] fftw: add compile precision option

Message ID 1426242302-3676-1-git-send-email-gwenj@trabucayre.com
State Changes Requested
Headers show

Commit Message

Gwenhael Goavec-Merou March 13, 2015, 10:25 a.m. UTC
From: Gwenhael Goavec-Merou <gwenhael.goavec-merou@trabucayre.com>

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.

Signed-off-by: Gwenhael Goavec-Merou <gwenhael.goavec-merou@trabucayre.com>
---
Changes v1 -> v2:
 * FFTW_CONFIGURE_OPTS -> FFTW_CONF_OPTS
---
 package/fftw/Config.in | 32 ++++++++++++++++++++++++++++++++
 package/fftw/fftw.mk   | 10 ++++++++++
 2 files changed, 42 insertions(+)

Comments

Thomas Petazzoni March 13, 2015, 10:25 p.m. UTC | #1
Dear Gwenhael Goavec-Merou,

On Fri, 13 Mar 2015 11:25:02 +0100, Gwenhael Goavec-Merou wrote:
> From: Gwenhael Goavec-Merou <gwenhael.goavec-merou@trabucayre.com>
> 
> 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.

Unfortunately, the quad precision support doesn't build, because not
all toolchains have libquadmath in gcc:

checking for sinq in -lquadmath... no
configure: error: quad precision requires libquadmath for quad-precision trigonometric routines

And the long double precision support also doesn't build:

checking for cosl... (cached) no
configure: error: long-double precision requires long-double trigonometric routines

This was generated by the following defconfig:

BR2_arm=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y
BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y
BR2_TOOLCHAIN_EXTERNAL_URL="http://autobuild.buildroot.org/toolchains/tarballs/br-arm-full-2014.11.tar.bz2"
BR2_TOOLCHAIN_EXTERNAL_HEADERS_3_17=y
BR2_TOOLCHAIN_EXTERNAL_LARGEFILE=y
BR2_TOOLCHAIN_EXTERNAL_INET_IPV6=y
BR2_TOOLCHAIN_EXTERNAL_LOCALE=y
# BR2_TOOLCHAIN_EXTERNAL_HAS_THREADS_DEBUG is not set
BR2_TOOLCHAIN_EXTERNAL_INET_RPC=y
BR2_TOOLCHAIN_EXTERNAL_CXX=y
BR2_INIT_NONE=y
BR2_SYSTEM_BIN_SH_NONE=y
# BR2_PACKAGE_BUSYBOX is not set
BR2_PACKAGE_FFTW=y
BR2_PACKAGE_FFTW_PRECISION_SINGLE=y
# BR2_TARGET_ROOTFS_TAR is not set

Also, I see that FFTW has some NEON, Altivec, MMX and SSE/SSE2
optimizations. Maybe it would make sense to enable them when the CPU
supports them. However, beware that many of those optimizations only
work in "single precision" mode.

Note: if your only need is "single precision" mode, then I wouldn't
mind receiving a patch that allows enabling only this mode. People
interested in long double and quad precision can enable such options
later.

Best regards,

Thomas Petazzoni
Gwenhael Goavec-Merou March 14, 2015, 7:39 a.m. UTC | #2
Dear Thomas Petazzoni

On Fri, 13 Mar 2015 23:25:21 +0100
Thomas Petazzoni <thomas.petazzoni@free-electrons.com> wrote:

> Dear Gwenhael Goavec-Merou,
> 
> On Fri, 13 Mar 2015 11:25:02 +0100, Gwenhael Goavec-Merou wrote:
> > From: Gwenhael Goavec-Merou <gwenhael.goavec-merou@trabucayre.com>
> > 
> > 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.
> 
> Unfortunately, the quad precision support doesn't build, because not
> all toolchains have libquadmath in gcc:
> 
> checking for sinq in -lquadmath... no
> configure: error: quad precision requires libquadmath for quad-precision trigonometric routines
> 
> And the long double precision support also doesn't build:
> 
> checking for cosl... (cached) no
> configure: error: long-double precision requires long-double trigonometric routines
> 
> This was generated by the following defconfig:
> 
It's true. libquadmath is only enabled on x86 and x86_64. I must add a depend
on BR2_i386 || BR2_x86_64.

[SNIP]
> 
> Also, I see that FFTW has some NEON, Altivec, MMX and SSE/SSE2
> optimizations. Maybe it would make sense to enable them when the CPU
> supports them. However, beware that many of those optimizations only
> work in "single precision" mode.
> 
Yes. I plan to add these optimizations but that's for a future patch.
[SNIP]

Regards 
Gwen
diff mbox

Patch

diff --git a/package/fftw/Config.in b/package/fftw/Config.in
index 36f849f..f35179b 100644
--- a/package/fftw/Config.in
+++ b/package/fftw/Config.in
@@ -9,3 +9,35 @@  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"
+	help
+	  compile fftw in long-double precision
+
+config BR2_PACKAGE_FFTW_PRECISION_QUAD
+	bool "quad precision"
+	help
+	  compile fftw in quadruple precision if available
+
+endchoice
+
+endif
diff --git a/package/fftw/fftw.mk b/package/fftw/fftw.mk
index 3b302df..68ddc35 100644
--- a/package/fftw/fftw.mk
+++ b/package/fftw/fftw.mk
@@ -10,4 +10,14 @@  FFTW_INSTALL_STAGING = YES
 FFTW_LICENSE = GPLv2+
 FFTW_LICENSE_FILES = COPYING
 
+ifeq ($(BR2_PACKAGE_FFTW_PRECISION_SINGLE),y)
+FFTW_CONF_OPTS += --enable-single
+endif
+ifeq ($(BR2_PACKAGE_FFTW_PRECISION_LONG_DOUBLE),y)
+FFTW_CONF_OPTS += --enable-long-double
+endif
+ifeq ($(BR2_PACKAGE_FFTW_PRECISION_QUAD),y)
+FFTW_CONF_OPTS += --enable-quad-precision
+endif
+
 $(eval $(autotools-package))