]> wimlib.net Git - wimlib/blob - include/wimlib/matchfinder_avx2.h
WIMBoot / system compression: try WOFADK in addition to WOF
[wimlib] / include / wimlib / matchfinder_avx2.h
1 /*
2  * matchfinder_avx2.h
3  *
4  * Matchfinding routines optimized for Intel AVX2 (Advanced Vector Extensions).
5  *
6  * Author:      Eric Biggers
7  * Year:        2014, 2015
8  *
9  * The author dedicates this file to the public domain.
10  * You can do whatever you want with this file.
11  */
12
13 #include <immintrin.h>
14
15 static inline bool
16 matchfinder_init_avx2(pos_t *data, size_t size)
17 {
18         __m256i v, *p;
19         size_t n;
20
21         if (size % sizeof(__m256i) * 4)
22                 return false;
23
24         if (sizeof(pos_t) == 2)
25                 v = _mm256_set1_epi16((u16)MATCHFINDER_NULL);
26         else if (sizeof(pos_t) == 4)
27                 v = _mm256_set1_epi32((u32)MATCHFINDER_NULL);
28         else
29                 return false;
30
31         p = (__m256i *)data;
32         n = size / (sizeof(__m256i) * 4);
33         do {
34                 p[0] = v;
35                 p[1] = v;
36                 p[2] = v;
37                 p[3] = v;
38                 p += 4;
39         } while (--n);
40         return true;
41 }