[Debian-med-packaging] Help to build library in generic form, avx and sse3
Christian Seiler
christian at iwakd.de
Tue Mar 14 15:03:01 UTC 2017
On 03/14/2017 03:46 PM, Andreas Tille wrote:
> I've started packaging Phylogenetic Likelihood Library[1]. Since it
> makes heavy use of amd64 features it comes with specific support of AVX
> and SSE3. My plan is to provide binary packages amd64 only named
> libpll-avx1 and libpll-sse3-1 with the according features plus a generic
> library libpll-generic1 for all architectures. Upstream supports the
> creation of separate avx and sse3 libs out of the box but I failed to
> create the generic version. So I have two questions:
>
> 1. Could anybody please have a look at the automake stuff to
> enable the build of the generic lib in addition to the other
> two. I tried several switches but failed. :-(
>
> 2. What do you think about the plan to support specific hardware
> features in separate binary packages?
GCC from version 6 (which is in Debian Stretch) supports function
multi-versioning (and GCC from 4.8 onwards, which is even in Jessie,
supports a subset of that), which allows you to do the following:
- have a function with generic C/C++ code be compiled multiple
times in different variants, and have the most optimal variant
be selected at runtime (requires GCC 6),
e.g.
__attribute__((target_clones("avx2","sse3","default")))
double foo(double a, double b) {
return a + b;
}
- manually write different versions of the function and mark
them accordingly (requires GCC 4.8)
__attribute__((target("default")))
double foo(double a, double b) {
return a + b;
}
__attribute__((target("sse3")))
double foo(double a, double b) {
SOME_FANCY_SSE3_CODE;
}
__attribute__((target("avx2")))
double foo(double a, double b) {
SOME_FANCY_AVX2_CODE;
}
So from a purely technical perspective I think the best solution
would probably be to work with upstream to allow them to support
FMV properly - and then you only need to compile a single library
version that will work everywhere, but will select the optimal
algorithm depending on the machine it's run - win/win.
Further reading:
https://lwn.net/Articles/691932/
Regards,
Christian
More information about the Debian-med-packaging
mailing list