On 2021/07/26 13:19, openbsd wrote:
> Hi,
> 
> I'm porting marisa-tire[0] now, it is a C++ implementation of MARISA 
> (Matching Algorithm with Recursively Implemented StorAge) trie data 
> structure. It offers a configure flag --enable-native-code for detecting 
> and enabling processor-dependent optimizations which I'm not sure if I 
> should use in my port. Will this cause compatibility issue for binary 
> package users? I wonder what's the policy on this kind of optimizations?

Ports must not use cpu features detected at build time in the default
build.

In some special cases it might make sense to have a "native" flavour
that is not linked to the build by default (i.e. so packages are not
normally built) as long as that doesn't change the ABI.

On amd64 you can use SSE2 which is present on all 64-bit capable CPUs,
anything else should either have a runtime cpuid check and fall back to
another implementation, or in some special cases where something else
is required for the software to work at all (e.g. in textproc/hyperscan)
then it will need something else which we'd probably want to look at
case-by-case.

(Some software tries to use indirect functions aka IFUNC to manage
code using optional cpu features at runtime; these aren't supported on
OpenBSD or, as far as I can tell, pretty much anything other than
linux+glibc).

> On my i7-3520M it detects and enables the following optimizations:
> 
> marisa 0.2.6 configuration:
> -------------------------------
>   HOST:      x86_64-unknown-openbsd6.9
>   CXX:       c++
>   CXXFLAGS:  -g -O2 -DMARISA_USE_POPCNT -mpopcnt -DMARISA_USE_SSE4 -msse4

also this suggests the port isn't passing in CXXFLAGS from ports to the
build environment (port shouldn't hardcode -O2).

>   LDFLAGS:   
>   PREFIX:    /usr/local
> 
>   NATIVE:    yes
>   SSE2:      yes
>   SSE3:      yes
>   SSSE3:     yes
>   SSE4.1:    yes
>   SSE4.2:    yes
>   SSE4a:     no
>   POPCNT:    yes
>   BMI:       no
>   BMI2:      no
> 
> ... and it brings about 13% of performance gain when running 
> marisa-benchmark and with enwiki-latest-all-titles-in-ns0 as input.
> 
> [0]: https://github.com/s-yata/marisa-trie
> 

Reply via email to