mirror of
https://github.com/openvswitch/ovs
synced 2025-08-31 14:25:26 +00:00
dpcls: fix build on compilers without AVX512-VPOPCNT
This commit adds extra checks around the AVX-512 vpopcnt instruction
enabling, ensuring that in the function where the ISA is enabled the
compiler has also indicated its support for the ISA. This is achieved
by checking the __AVX512VPOPCNTDQ__ define, which the compiler sets if
it is capable of handling the vpopcnt instruction.
If the compiler is not capable of handling vpopcnt, we fall back to
the emulated vpopcnt implementation.
Reported-by: Ian Stokes <ian.stokes@intel.com>
Fixes: 1e31489134
("dpcls-avx512: Enable avx512 vector popcount instruction.")
Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
Signed-off-by: Ian Stokes <ian.stokes@intel.com>
This commit is contained in:
committed by
Ian Stokes
parent
ccb6cc20ff
commit
c15c3df3ac
@@ -53,15 +53,6 @@
|
||||
|
||||
VLOG_DEFINE_THIS_MODULE(dpif_lookup_avx512_gather);
|
||||
|
||||
|
||||
/* Wrapper function required to enable ISA. */
|
||||
static inline __m512i
|
||||
__attribute__((__target__("avx512vpopcntdq")))
|
||||
_mm512_popcnt_epi64_wrapper(__m512i v_in)
|
||||
{
|
||||
return _mm512_popcnt_epi64(v_in);
|
||||
}
|
||||
|
||||
static inline __m512i
|
||||
_mm512_popcnt_epi64_manual(__m512i v_in)
|
||||
{
|
||||
@@ -85,6 +76,23 @@ _mm512_popcnt_epi64_manual(__m512i v_in)
|
||||
return _mm512_sad_epu8(v_u8_pop, _mm512_setzero_si512());
|
||||
}
|
||||
|
||||
/* Wrapper function required to enable ISA. First enable the ISA via the
|
||||
* attribute target for this function, then check if the compiler actually
|
||||
* #defines the ISA itself. If the ISA is not #define-ed by the compiler it
|
||||
* indicates the compiler is too old or is not capable of compiling the
|
||||
* requested ISA level, so fallback to the integer manual implementation.
|
||||
*/
|
||||
static inline __m512i
|
||||
__attribute__((__target__("avx512vpopcntdq")))
|
||||
_mm512_popcnt_epi64_wrapper(__m512i v_in)
|
||||
{
|
||||
#ifdef __AVX512VPOPCNTDQ__
|
||||
return _mm512_popcnt_epi64(v_in);
|
||||
#else
|
||||
return _mm512_popcnt_epi64_manual(v_in);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline uint64_t
|
||||
netdev_rule_matches_key(const struct dpcls_rule *rule,
|
||||
const uint32_t mf_bits_total,
|
||||
|
Reference in New Issue
Block a user