-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathLUT6.c
58 lines (45 loc) · 1.05 KB
/
LUT6.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include "bench.h"
void
LUT6_scalar(uint8_t lut[64], uint8_t *ptr, size_t n)
{
for (; n--; ++ptr)
*ptr = lut[*ptr & 63], BENCH_CLOBBER();
}
void
LUT6_scalar_autovec(uint8_t lut[restrict 64], uint8_t *restrict ptr, size_t n)
{
for (; n--; ++ptr)
*ptr = lut[*ptr & 63];
}
#define IMPLS(f) \
f(scalar) \
f(scalar_autovec) \
f(rvv_gather_m4) \
f(rvv_m1m2m4_gathers_m4) \
f(rvv_vluxei8_m4) \
f(rvv_vloxei8_m4) \
typedef void Func(uint8_t lut[64], uint8_t *ptr, size_t n);
#define DECLARE(f) extern Func LUT6_##f;
IMPLS(DECLARE)
#define EXTRACT(f) { #f, &LUT6_##f },
Impl impls[] = { IMPLS(EXTRACT) };
uint8_t *ptr;
void init(void) { ptr = (uint8_t*)mem; }
ux checksum(size_t n) {
ux sum = 0;
for (size_t i = 0; i < n; ++i)
sum = uhash(sum) + ptr[i];
return sum;
}
BENCH_BEG(base) {
static uint8_t lut[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"0123456789"
"+/";
bench_memrand(ptr, n * sizeof *ptr);
TIME f(lut, ptr, n);
} BENCH_END
Bench benches[] = {
BENCH( impls, MAX_MEM, "LUT6", bench_base )
}; BENCH_MAIN(benches)