opencv

Форк
0
/
compare256_power9.c 
64 строки · 2.1 Кб
1
/* compare256_power9.c - Power9 version of compare256
2
 * Copyright (C) 2019 Matheus Castanho <msc@linux.ibm.com>, IBM
3
 * For conditions of distribution and use, see copyright notice in zlib.h
4
 */
5

6
#ifdef POWER9
7
#include <altivec.h>
8
#include "../../zbuild.h"
9
#include "../../zendian.h"
10

11
/* Older versions of GCC misimplemented semantics for these bit counting builtins.
12
 * https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=3f30f2d1dbb3228b8468b26239fe60c2974ce2ac */
13
#if defined(__GNUC__) && !defined(__clang__) && (__GNUC__ < 12)
14
#if BYTE_ORDER == LITTLE_ENDIAN
15
#  define zng_vec_vctzlsbb(vc, len) len = __builtin_vec_vctzlsbb(vc)
16
#else
17
#  define zng_vec_vctzlsbb(vc, len) len = __builtin_vec_vclzlsbb(vc)
18
#endif
19
#else
20
#  define zng_vec_vctzlsbb(vc, len) len = vec_cntlz_lsbb(vc)
21
#endif
22

23
static inline uint32_t compare256_power9_static(const uint8_t *src0, const uint8_t *src1) {
24
    uint32_t len = 0, cmplen;
25

26
    do {
27
        vector unsigned char vsrc0, vsrc1, vc;
28

29
        vsrc0 = *((vector unsigned char *)src0);
30
        vsrc1 = *((vector unsigned char *)src1);
31

32
        /* Compare 16 bytes at a time. Each byte of vc will be either
33
         * all ones or all zeroes, depending on the result of the comparison. */
34
        vc = (vector unsigned char)vec_cmpne(vsrc0, vsrc1);
35

36
        /* Since the index of matching bytes will contain only zeroes
37
         * on vc (since we used cmpne), counting the number of consecutive
38
         * bytes where LSB == 0 is the same as counting the length of the match. */
39
        zng_vec_vctzlsbb(vc, cmplen);
40
        if (cmplen != 16)
41
            return len + cmplen;
42

43
        src0 += 16, src1 += 16, len += 16;
44
    } while (len < 256);
45

46
   return 256;
47
}
48

49
Z_INTERNAL uint32_t compare256_power9(const uint8_t *src0, const uint8_t *src1) {
50
    return compare256_power9_static(src0, src1);
51
}
52

53
#define LONGEST_MATCH       longest_match_power9
54
#define COMPARE256          compare256_power9_static
55

56
#include "match_tpl.h"
57

58
#define LONGEST_MATCH_SLOW
59
#define LONGEST_MATCH       longest_match_slow_power9
60
#define COMPARE256          compare256_power9_static
61

62
#include "match_tpl.h"
63

64
#endif
65

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.