package/armadillo: allows to select between clapack, lapack or openblas
PATCH v2 1/1 package/armadillo: allows to select between clapack, lapack or openblas
From: Gwenhael Goavec-Merou <[email protected]>
armadillo can use clapack, lapack or openblas as BLAS and LAPACK provider. This patch
- adds hidden variable to check dependencies/requirement for each of them
- a choice to select wich implementation to use, by default use on clapack when it's possible, else lapack, otherwhise openblas
---
Changes v1 -> v2:
- add openblas as blas provider
--- package/armadillo/Config.in | 50 ++++++++++++++++++++++++++++++++-- package/armadillo/armadillo.mk | 11 +++++++- 2 files changed, 57 insertions(+), 4 deletions(-)
package/armadillo/Config.in +47 -3
@@ -1,3 +1,12 @@ +config BR2_PACKAGE_ARMADILLO_CLAPACK_SUPPORTS + bool + default y if (!BR2_m68k_cf && (!BR2_powerpc || BR2_TOOLCHAIN_USES_GLIBC)) + +config BR2_PACKAGE_ARMADILLO_LAPACK_SUPPORTS + bool + default y if BR2_TOOLCHAIN_HAS_FORTRAN && \ + BR2_PACKAGE_OPENBLAS_ARCH_SUPPORTS + comment "armadillo needs a toolchain w/ C++" depends on !BR2_INSTALL_LIBSTDCPP depends on !BR2_powerpc
@@ -10,11 +19,46 @@ comment "armadillo needs a glibc toolchain w/ C++" config BR2_PACKAGE_ARMADILLO bool "armadillo" depends on BR2_INSTALL_LIBSTDCPP - depends on !BR2_powerpc || BR2_TOOLCHAIN_USES_GLIBC # clapack - depends on !BR2_m68k_cf # clapack - select BR2_PACKAGE_CLAPACK + depends on BR2_PACKAGE_ARMADILLO_CLAPACK_SUPPORTS || \ + BR2_PACKAGE_ARMADILLO_LAPACK_SUPPORTS || \ + BR2_PACKAGE_OPENBLAS_ARCH_SUPPORTS help Armadillo: An Open Source C++ Linear Algebra Library for Fast Prototyping and Computationally Intensive Experiments. http://arma.sourceforge.net/ + +if BR2_PACKAGE_ARMADILLO + +choice + prompt "blas library" + default BR2_PACKAGE_ARMADILLO_CLAPACK if \ + BR2_PACKAGE_ARMADILLO_CLAPACK_SUPPORTS + default BR2_PACKAGE_ARMADILLO_LAPACK if \ + BR2_PACKAGE_ARMADILLO_LAPACK_SUPPORTS && \ + !BR2_PACKAGE_ARMADILLO_CLAPACK_SUPPORTS + default BR2_PACKAGE_ARMADILLO_OPENBLAS if \ + !BR2_PACKAGE_ARMADILLO_LAPACK_SUPPORTS && \ + !BR2_PACKAGE_ARMADILLO_CLAPACK_SUPPORTS && \ + BR2_PACKAGE_OPENBLAS_ARCH_SUPPORTS + help + Selects blas library to use + +config BR2_PACKAGE_ARMADILLO_CLAPACK + bool "clapack" + depends on BR2_PACKAGE_ARMADILLO_CLAPACK_SUPPORTS + select BR2_PACKAGE_CLAPACK + +config BR2_PACKAGE_ARMADILLO_LAPACK + bool "lapack" + depends on BR2_PACKAGE_ARMADILLO_LAPACK_SUPPORTS + select BR2_PACKAGE_LAPACK + +config BR2_PACKAGE_ARMADILLO_OPENBLAS + bool "openblas" + depends on BR2_PACKAGE_OPENBLAS_ARCH_SUPPORTS + select BR2_PACKAGE_OPENBLAS + +endchoice + +endif
package/armadillo/armadillo.mk +10 -1
@@ -7,11 +7,20 @@ ARMADILLO_VERSION = 9.900.2 ARMADILLO_SOURCE = armadillo-$(ARMADILLO_VERSION).tar.xz ARMADILLO_SITE = https://downloads.sourceforge.net/project/arma -ARMADILLO_DEPENDENCIES = clapack ARMADILLO_INSTALL_STAGING = YES ARMADILLO_LICENSE = Apache-2.0 ARMADILLO_LICENSE_FILES = LICENSE.txt +ifeq ($(BR2_PACKAGE_ARMADILLO_OPENBLAS),y) +ARMADILLO_DEPENDENCIES = openblas +else +ifeq ($(BR2_PACKAGE_ARMADILLO_CLAPACK), y) +ARMADILLO_DEPENDENCIES = clapack +else +ARMADILLO_DEPENDENCIES = lapack +endif +endif + ARMADILLO_CONF_OPTS = -DDETECT_HDF5=false $(eval $(cmake-package))
Signature · 1 line
2.20.1
PATCH v2 1/1 package/armadillo: allows to select between clapack, lapack or openblas
Hello,
package/armadillo/Config.in line 3
Quoted 8 lines · On Mon, 24 Aug 2020 15:22:15 +0200 Gwenhael Goavec-Merou…
package/armadillo/Config.in +3
-0@@ -1,3 +1,12 @@ +config BR2_PACKAGE_ARMADILLO_CLAPACK_SUPPORTS + bool + default y if (!BR2_m68k_cf && (!BR2_powerpc || BR2_TOOLCHAIN_USES_GLIBC))
Can we write this like this:
default y depends on !BR2_m68k depends on !BR2_powerpc || BR2_TOOLCHAIN_USES_GLIBC
package/armadillo/Config.in line 8
Quoted 4 lines
package/armadillo/Config.in +4
-0+config BR2_PACKAGE_ARMADILLO_LAPACK_SUPPORTS + bool + default y if BR2_TOOLCHAIN_HAS_FORTRAN && \ + BR2_PACKAGE_OPENBLAS_ARCH_SUPPORTS
I am a bit confused here, why does it require BR2_PACKAGE_OPENBLAS_ARCH_SUPPORTS ? What is the relationship between lapack support and openblas ?
Also, the lapack package has a "depends on !CLAPACK" so if the user has clapack enabled, it should not be possible to enable the lapack "usage" in armadillo.
Also, don't you need to take into account the following dependency from lapack:
# _fpu_control is used on PowerPC, but not available with uClibc depends on !(BR2_powerpc && BR2_TOOLCHAIN_USES_UCLIBC)
Quoted 13 lines
package/armadillo/Config.in +3
-3+ comment "armadillo needs a toolchain w/ C++" depends on !BR2_INSTALL_LIBSTDCPP depends on !BR2_powerpc@@ -10,11 +19,46 @@ comment "armadillo needs a glibc toolchain w/ C++" config BR2_PACKAGE_ARMADILLO bool "armadillo" depends on BR2_INSTALL_LIBSTDCPP - depends on !BR2_powerpc || BR2_TOOLCHAIN_USES_GLIBC # clapack - depends on !BR2_m68k_cf # clapack - select BR2_PACKAGE_CLAPACK + depends on BR2_PACKAGE_ARMADILLO_CLAPACK_SUPPORTS || \ + BR2_PACKAGE_ARMADILLO_LAPACK_SUPPORTS || \
package/armadillo/Config.in comment "armadillo needs a glibc toolchain w/ C++" · line 33
Quoted 10 lines
package/armadillo/Config.in +5
-0+ BR2_PACKAGE_OPENBLAS_ARCH_SUPPORTS help Armadillo: An Open Source C++ Linear Algebra Library for Fast Prototyping and Computationally Intensive Experiments. http://arma.sourceforge.net/ + +if BR2_PACKAGE_ARMADILLO + +choice
Do we really need this choice ? Isn't it possible in the .mk to prefer one solution if available, then another, and finally another ?
This is really an open question: if there are good reason to showing this choice to the user, we can keep it.
package/armadillo/Config.in comment "armadillo needs a glibc toolchain w/ C++" · line 39
Quoted 6 lines
package/armadillo/Config.in +6
-0+ prompt "blas library" + default BR2_PACKAGE_ARMADILLO_CLAPACK if \ + BR2_PACKAGE_ARMADILLO_CLAPACK_SUPPORTS + default BR2_PACKAGE_ARMADILLO_LAPACK if \ + BR2_PACKAGE_ARMADILLO_LAPACK_SUPPORTS && \ + !BR2_PACKAGE_ARMADILLO_CLAPACK_SUPPORTS
I think you can drop the !BR2_PACKAGE_ARMADILLO_CLAPACK_SUPPORTS, Kconfig will pickup the first "default" that has its dependencies met. In fact, you could simply drop all those default statements, and Kconfig would pick the first choice entry that has its dependencies met.
Quoted 7 lines
package/armadillo/armadillo.mk +0
-0@@ -7,11 +7,20 @@ ARMADILLO_VERSION = 9.900.2 ARMADILLO_SOURCE = armadillo-$(ARMADILLO_VERSION).tar.xz
package/armadillo/armadillo.mk line 17
Quoted 10 lines
package/armadillo/armadillo.mk +4
-1ARMADILLO_SITE = https://downloads.sourceforge.net/project/arma -ARMADILLO_DEPENDENCIES = clapack ARMADILLO_INSTALL_STAGING = YES ARMADILLO_LICENSE = Apache-2.0 ARMADILLO_LICENSE_FILES = LICENSE.txt +ifeq ($(BR2_PACKAGE_ARMADILLO_OPENBLAS),y) +ARMADILLO_DEPENDENCIES = openblas +else +ifeq ($(BR2_PACKAGE_ARMADILLO_CLAPACK), y)
put the "else" and following "ifeq" on the same line, so that you don't need an additional "endif".
I.e:
ifeq ...
...
else ifeq ...
...
else
...
endif
package/armadillo/armadillo.mk line 22
Quoted 5 lines
package/armadillo/armadillo.mk +5
-0+ARMADILLO_DEPENDENCIES = clapack +else +ARMADILLO_DEPENDENCIES = lapack +endif +endif
With this logic, there is in fact nothing that guarantees which blas library will be used. If both openblas and clapack are available on the system, even if you select BR2_PACKAGE_ARMADILLO_CLAPACK, openblas might be used by armadillo...
Best regards,
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
PATCH v2 1/1 package/armadillo: allows to select between clapack, lapack or openblas
Thomas, all
Quoted 21 lines · On Mon, 24 Aug 2020 22:36:18 +0200 Thomas Petazzoni…
Hello,
package/armadillo/Config.in line 4
Quoted 9 lines · On Mon, 24 Aug 2020 15:22:15 +0200 Gwenhael Goavec-Merou…
package/armadillo/Config.in +3
-0@@ -1,3 +1,12 @@ +config BR2_PACKAGE_ARMADILLO_CLAPACK_SUPPORTS + bool + default y if (!BR2_m68k_cf && (!BR2_powerpc || BR2_TOOLCHAIN_USES_GLIBC))Can we write this like this:
default y depends on !BR2_m68k depends on !BR2_powerpc || BR2_TOOLCHAIN_USES_GLIBC
Quoted 9 lines
package/armadillo/Config.in line 8
Quoted 4 lines
package/armadillo/Config.in +4
-0+config BR2_PACKAGE_ARMADILLO_LAPACK_SUPPORTS + bool + default y if BR2_TOOLCHAIN_HAS_FORTRAN && \ + BR2_PACKAGE_OPENBLAS_ARCH_SUPPORTSI am a bit confused here, why does it require
BR2_PACKAGE_OPENBLAS_ARCH_SUPPORTS? What is the relationship between lapack support and openblas ?
typo...
Quoted 37 lines
Also, the lapack package has a "depends on !CLAPACK" so if the user has clapack enabled, it should not be possible to enable the lapack "usage" in armadillo.
Also, don't you need to take into account the following dependency from lapack:
#
_fpu_controlis used on PowerPC, but not available with uClibc depends on !(BR2_powerpc &&BR2_TOOLCHAIN_USES_UCLIBC)Quoted 13 lines
package/armadillo/Config.in +3
-3+ comment "armadillo needs a toolchain w/ C++" depends on !BR2_INSTALL_LIBSTDCPP depends on !BR2_powerpc@@ -10,11 +19,46 @@ comment "armadillo needs a glibc toolchain w/ C++" config BR2_PACKAGE_ARMADILLO bool "armadillo" depends on BR2_INSTALL_LIBSTDCPP - depends on !BR2_powerpc || BR2_TOOLCHAIN_USES_GLIBC # clapack - depends on !BR2_m68k_cf # clapack - select BR2_PACKAGE_CLAPACK + depends on BR2_PACKAGE_ARMADILLO_CLAPACK_SUPPORTS || \ + BR2_PACKAGE_ARMADILLO_LAPACK_SUPPORTS || \package/armadillo/Config.in comment "armadillo needs a glibc toolchain w/ C++" · line 33
Quoted 10 lines
package/armadillo/Config.in +5
-0+ BR2_PACKAGE_OPENBLAS_ARCH_SUPPORTS help Armadillo: An Open Source C++ Linear Algebra Library for Fast Prototyping and Computationally Intensive Experiments. http://arma.sourceforge.net/ + +if BR2_PACKAGE_ARMADILLO + +choiceDo we really need this choice ? Isn't it possible in the .mk to prefer one solution if available, then another, and finally another ?
Quoted 3 lines
This is really an open question: if there are good reason to showing this choice to the user, we can keep it.
I'm agree, I'm not happy by using choice but applications maybe require explicitly lapack (and segfault with clapack), or clapack. With an approach based on prefer, it's difficult to respect these constraints. This is why I used choice.
Quoted 13 lines
package/armadillo/Config.in comment "armadillo needs a glibc toolchain w/ C++" · line 39
Quoted 7 lines
package/armadillo/Config.in +6
-0+ prompt "blas library" + default BR2_PACKAGE_ARMADILLO_CLAPACK if \ + BR2_PACKAGE_ARMADILLO_CLAPACK_SUPPORTS + default BR2_PACKAGE_ARMADILLO_LAPACK if \ + BR2_PACKAGE_ARMADILLO_LAPACK_SUPPORTS && \ + !BR2_PACKAGE_ARMADILLO_CLAPACK_SUPPORTSI think you can drop the !BR2_PACKAGE_ARMADILLO_CLAPACK_SUPPORTS,
Kconfigwill pickup the first "default" that has its dependencies met. In fact, you could simply drop all those default statements, andKconfigwould pick the first choice entry that has its dependencies met.
OK
Quoted 32 lines
Quoted 8 lines
package/armadillo/armadillo.mk +0
-0@@ -7,11 +7,20 @@ ARMADILLO_VERSION = 9.900.2 ARMADILLO_SOURCE = armadillo-$(ARMADILLO_VERSION).tar.xzpackage/armadillo/armadillo.mk line 17
Quoted 10 lines
package/armadillo/armadillo.mk +4
-1ARMADILLO_SITE = https://downloads.sourceforge.net/project/arma -ARMADILLO_DEPENDENCIES = clapack ARMADILLO_INSTALL_STAGING = YES ARMADILLO_LICENSE = Apache-2.0 ARMADILLO_LICENSE_FILES = LICENSE.txt +ifeq ($(BR2_PACKAGE_ARMADILLO_OPENBLAS),y) +ARMADILLO_DEPENDENCIES = openblas +else +ifeq ($(BR2_PACKAGE_ARMADILLO_CLAPACK), y)put the "else" and following "ifeq" on the same line, so that you don't need an additional "endif".
I.e:
ifeq ...
...
else ifeq ...
...
else
...
endif
Quoted 11 lines
package/armadillo/armadillo.mk line 22
Quoted 5 lines
package/armadillo/armadillo.mk +5
-0+ARMADILLO_DEPENDENCIES = clapack +else +ARMADILLO_DEPENDENCIES = lapack +endif +endifWith this logic, there is in fact nothing that guarantees which blas library will be used. If both openblas and clapack are available on the system, even if you select
BR2_PACKAGE_ARMADILLO_CLAPACK, openblas might be used by armadillo...
I need to use -DLAPACK_LIBRARIES and -DBLAS_LIBRARIES to avoid this. But I seen another problem with openblas: all provides blas support but only clapack and lapack are lapack providers. I'm not sure if I need to add one choice for lapack and a second one for blas or simply disabling lapack when user select openblas.
Quoted 5 lines
Best regards,
Thomas
Best regards,
Gwenhael