-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfast_func.cpp
More file actions
55 lines (42 loc) · 1.02 KB
/
fast_func.cpp
File metadata and controls
55 lines (42 loc) · 1.02 KB
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
#include "fast_func.hpp"
#if !defined(__USE_OFFLOAD__)
#if defined(__AVX__) || !defined(_MSC_VER)
/**
* Copies the content of one 32 byte aligned
* byte buffer of length n into another using AVX
*
* @param dest
* A pointer to the destination buffer
*
* @param src
* A pointer to the source buffer
*
* @param len
* The number of bytes to copy
*/
OFFLOAD_DECL
void A_memcpy_n(void *dest, const unsigned char *src, int len) {
I32B *A_memcpy_32_bufferS = (I32B*) (src);
I32B *A_memcpy_32_bufferD = (I32B*) (dest);
while (len >= 32) {
STORE_I32B(A_memcpy_32_bufferD, A_memcpy_32_bufferS);
A_memcpy_32_bufferS++;
A_memcpy_32_bufferD++;
_mm_prefetch((char*) (A_memcpy_32_bufferS), _MM_HINT_T2);
len -= 32;
}
char *ptrS = (char*) A_memcpy_32_bufferS;
char *ptrD = (char*) A_memcpy_32_bufferD;
if (len >= 16) {
STORE_I16B((I16B*) ptrD, (I16B*) ptrS);
ptrS += 16;
ptrD += 16;
_mm_prefetch((char*) (ptrS), _MM_HINT_T2);
len -= 16;
}
for (int i = 0; i < len; i++) {
ptrD[i] = ptrS[i];
}
};
#endif
#endif