1 |
Hi Gentoo devs, |
2 |
|
3 |
I redesigned the solution for BLAS/LAPACK runtime switching. |
4 |
New solution is based on eselect+ld.so.conf . See following. |
5 |
|
6 |
> Goal |
7 |
> ---- |
8 |
> |
9 |
> * When a program is linked against libblas.so or liblapack.so |
10 |
> provided by any BLAS/LAPACK provider, the eselect-based solution |
11 |
> will allow user to switch the underlying library without recompiling |
12 |
> anything. |
13 |
|
14 |
Instead of manipulating symlinks, I wrote a dedicated eselect module |
15 |
for BLAS: |
16 |
|
17 |
https://github.com/cdluminate/my-overlay/blob/master/app-eselect/eselect-blas/files/blas.eselect-0.2 |
18 |
|
19 |
This implementation will generate a corresponding ld.so.conf file |
20 |
on switching and refresh ld.so cache. |
21 |
|
22 |
advantages: |
23 |
|
24 |
1. not longer manipulates symlinks under package manager directory, |
25 |
see https://bugs.gentoo.org/531842 and https://bugs.gentoo.org/632624 |
26 |
|
27 |
2. we don't have to think about static lib and header switching like |
28 |
Debian does. |
29 |
|
30 |
> * When a program is linked against a specific implementation, e.g. |
31 |
> libmkl_rt.so, the solution doesn't break anything. |
32 |
|
33 |
This still holds with the new solution. |
34 |
|
35 |
> Solution |
36 |
> -------- |
37 |
> |
38 |
> Similar to Debian's update-alternatives mechanism, Gentoo's eselect |
39 |
> is good at dealing with drop-in replacements as well. My preliminary |
40 |
|
41 |
The redesigned solution totally diverted from Debian's solution. |
42 |
|
43 |
* sci-libs/lapack provides standard API and ABI for BLAS/CBLAS/LAPACK |
44 |
and LAPACKE. It provides a default set of libblas.so, libcblas.so, |
45 |
and liblapack.so . Reverse dependencies linked against the three |
46 |
libraries (reference blas) will take advantage of the runtime |
47 |
switching mechanism through USE="virtual-blas virtual-lapack". |
48 |
Reverse dependencies linked to specific implementations such as |
49 |
libopenblas.so won't be affected at all. |
50 |
|
51 |
* every non-standard BLAS/LAPACK implementations could be registered |
52 |
as alternatives via USE="virtual-blas virtual-lapack". Once the |
53 |
virtual-* flags are toggled, the ebuild file will build some |
54 |
extra shared objects with correct SONAME. |
55 |
|
56 |
For example: |
57 |
|
58 |
/usr/lib64/libblis.so.2 (SONAME=libblis.so.2, general purpose) |
59 |
/usr/lib64/blas/blis/libblas.so.3 (USE="virtual-blas", |
60 |
SONAME=libblas.so.3) |
61 |
/usr/lib64/blas/blis/libcblas.so.3 (USE="virtual-blas", |
62 |
SONAME=libcblas.so.3) |
63 |
|
64 |
* Reverse dependencies of BLAS/LAPACK could optionally provide the |
65 |
"virtual-blas virtual-lapack" USE flags. |
66 |
|
67 |
if use virtual-*: |
68 |
link against reference blas/lapack |
69 |
else: |
70 |
link against whatever the ebuild maintainer like and get rid |
71 |
of the switching mechanism |
72 |
|
73 |
> Proposed Changes |
74 |
> ---------------- |
75 |
> |
76 |
> 1. Deprecate sci-libs/{blas,cblas,lapack,lapacke}-reference from gentoo |
77 |
> main repo. They use exactly the same source tarball. It's not quite |
78 |
> helpful to package these components in a fine-grained manner. A |
79 |
> single |
80 |
> sci-libs/lapack package is enough. |
81 |
|
82 |
sci-libs/{blas,cblas,lapack,lapacke}::gentoo should be deprecated. They |
83 |
are based on exactly the same source tarball, and maintaining 4 ebuild |
84 |
files for a single tarball is not a good choice IHMO. Those old ebuild |
85 |
files seems to leverage the flexibility of upstream build system |
86 |
because it enables one to, for example, skip the reference blas build |
87 |
and use an existing optimized BLAS impelementation and hence introduce |
88 |
flexibility. That flexibility is hard to maintain and is not necessary |
89 |
anymore with the new runtime switching mechanism. |
90 |
|
91 |
That's why I propose to merge the 4 ebuild into a single one: |
92 |
sci-libs/lapack. We don't need to add the "reference" postfix |
93 |
because no upstream will loot the name "lapack". When talking |
94 |
about "lapack" it's always the reference implementation. |
95 |
|
96 |
> 2. Merge the "cblas" eselect unit into "blas" unit. It is potentially |
97 |
> harmful when "blas" and "cblas" point to different implementations. |
98 |
> That means "app-eselect/eselect-cblas" should be deprecated. |
99 |
|
100 |
eselect-cblas should be deprecated. That affects gsl because it is |
101 |
registered as an cblas alternative. gsl doesn't provide the standard |
102 |
BLAS (fortran) API+ABI so it will not be added as a runtime switching |
103 |
candidate. |
104 |
|
105 |
Does this redesinged solution look acceptable now? |
106 |
|
107 |
Best, |
108 |
Mo. |