Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause 2 : : * Copyright(c) 2017 Intel Corporation 3 : : */ 4 : : 5 : : #ifndef _RTE_MEMBER_X86_H_ 6 : : #define _RTE_MEMBER_X86_H_ 7 : : 8 : : #include <x86intrin.h> 9 : : 10 : : #ifdef __cplusplus 11 : : extern "C" { 12 : : #endif 13 : : 14 : : #if defined(__AVX2__) 15 : : 16 : : static inline int 17 : : update_entry_search_avx(uint32_t bucket_id, member_sig_t tmp_sig, 18 : : struct member_ht_bucket *buckets, 19 : : member_set_t set_id) 20 : : { 21 [ + + ]: 107595 : uint32_t hitmask = _mm256_movemask_epi8((__m256i)_mm256_cmpeq_epi16( 22 [ + + + + ]: 107595 : _mm256_load_si256((__m256i const *)buckets[bucket_id].sigs), 23 : : _mm256_set1_epi16(tmp_sig))); 24 [ + + + + ]: 107595 : if (hitmask) { 25 : 71741 : uint32_t hit_idx = rte_ctz32(hitmask) >> 1; 26 : 71741 : buckets[bucket_id].sets[hit_idx] = set_id; 27 : : return 1; 28 : : } 29 : : return 0; 30 : : } 31 : : 32 : : static inline int 33 : : search_bucket_single_avx(uint32_t bucket_id, member_sig_t tmp_sig, 34 : : struct member_ht_bucket *buckets, 35 : : member_set_t *set_id) 36 : : { 37 : 40 : uint32_t hitmask = _mm256_movemask_epi8((__m256i)_mm256_cmpeq_epi16( 38 : 54 : _mm256_load_si256((__m256i const *)buckets[bucket_id].sigs), 39 : : _mm256_set1_epi16(tmp_sig))); 40 [ + + - + : 54 : while (hitmask) { + + - + ] 41 : 40 : uint32_t hit_idx = rte_ctz32(hitmask) >> 1; 42 [ + + - - : 40 : if (buckets[bucket_id].sets[hit_idx] != RTE_MEMBER_NO_MATCH) { + + - - ] 43 : 26 : *set_id = buckets[bucket_id].sets[hit_idx]; 44 : : return 1; 45 : : } 46 : 14 : hitmask &= ~(3U << ((hit_idx) << 1)); 47 : : } 48 : : return 0; 49 : : } 50 : : 51 : : static inline void 52 : 40 : search_bucket_multi_avx(uint32_t bucket_id, member_sig_t tmp_sig, 53 : : struct member_ht_bucket *buckets, 54 : : uint32_t *counter, 55 : : uint32_t match_per_key, 56 : : member_set_t *set_id) 57 : : { 58 : 40 : uint32_t hitmask = _mm256_movemask_epi8((__m256i)_mm256_cmpeq_epi16( 59 : 40 : _mm256_load_si256((__m256i const *)buckets[bucket_id].sigs), 60 : : _mm256_set1_epi16(tmp_sig))); 61 [ + + ]: 130 : while (hitmask) { 62 : 90 : uint32_t hit_idx = rte_ctz32(hitmask) >> 1; 63 [ + - ]: 90 : if (buckets[bucket_id].sets[hit_idx] != RTE_MEMBER_NO_MATCH) { 64 : 90 : set_id[*counter] = buckets[bucket_id].sets[hit_idx]; 65 : 90 : (*counter)++; 66 [ + - ]: 90 : if (*counter >= match_per_key) 67 : : return; 68 : : } 69 : 90 : hitmask &= ~(3U << ((hit_idx) << 1)); 70 : : } 71 : : } 72 : : #endif 73 : : 74 : : #ifdef __cplusplus 75 : : } 76 : : #endif 77 : : 78 : : #endif /* _RTE_MEMBER_X86_H_ */