[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: how best to package when using hardware vectorization with vector-unit specific code?



On Wed, 10 May 2017, Kay F. Jahnke wrote:
> I had something simpler in mind. I had hoped that a debian package would
> provide some sort of target-side script which is run when the application
> deploys with the user. Then it would be easy to have a bit of code à la

Cannot be done [easily] for newer stuff like avx because ld.so and the
kernel never got updated properly to do it.

> #! /bin/bash
> 
> for instruction_set in mmx sse sse2 sse3 ssse3 sse4 sse4a sse4.1 sse4.2 avx
> avx2 avx512f avx512pf avx512er avx512cd
> do
>   if [[ $( lscpu | grep $instruction_set ) ]]
>   then
>     bestarch=$instruction_set
>   fi
> done
> 
> mv myprogram_$bestarch $target_bin/myprogram

You can do it like that, yes.  I suggest you go with that option.

> ... and optionally delete the binaries for the other ISAs.

If they are large enough to matter, separate them in several binary
packages.  Otherwise, don't bother.  Note that the list of variants
needs to be binary-package-arch specific.  mmx is i386-only, avx is
amd64-only, etc.

> I am using Vc, so whatever Vc supports, my software supports as well. Vc is
> a generic C++ library to abstract away the architecture, so I just compile
> with -mmx -sse or whatever and Vc adapts and produces the code for the
> specific target. I've coded so that my program will also run without using
> the vector units, this is done by simple #ifdefs, and I pass the definition
> in via a -D directive (or I don't, to produce code without vectorization).
> Alternatively Vc can produce a scalar interpretation of the vector code
> which runs on any platform and is equivalent.

Eh, yeah, that would make it far more difficult to use FMV.   But maybe
you should suggest Vc upstream to consider supporting FMV where
available?

-- 
  Henrique Holschuh


Reply to: