Debian Codegraph @

kmc_core/intr_copy.h

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 /*
2 This file is a part of KMC software distributed under GNU GPL 3 licence.
3 The homepage of the KMC project is http://sun.aei.polsl.pl/kmc
4
5 Authors: Sebastian Deorowicz, Agnieszka Debudaj-Grabysz, Marek Kokot
6
7 Version: 3.2.4
8 Date : 2024-02-09
9 */
10
11 #ifndef _INTR_COPY_H
12 #define _INTR_COPY_H
13
14 #ifdef _WIN32
15 #include <intrin.h>
16 #endif
17
18 #if defined(__aarch64__)
19 #include <arm_neon.h>
20 #else
•21 #define SIMDE_ENABLE_NATIVE_ALIASES
22 #include <simde/x86/sse2.h>
23 #endif
24
25
26 #include "critical_error_handler.h"
27
28 #ifndef _WIN32
29 typedef long long __int64;
30 #endif
31
32 // 64b copy function
33 // size - in 8B words (determined during execution)
34 // dest and src must be aligned to 8B
35 inline void IntrCopy64fun(void *_dest, void *_src, uint32_t size)
36 {
37 __int64* dest = (__int64 *)_dest;
38 __int64* src = (__int64 *)_src;
39
40 for (unsigned i = 0; i < size; ++i)
41 #if defined(__aarch64__)
42 dest[i] = src[i];
43 #else
•44 simde_mm_stream_si64(SIMDE_CHECKED_REINTERPRET_CAST(int64_t*, __int64*, dest + i), src[i]);
45 #endif
46 }
47
48
49 // 64bit copy function
50 // SIZE - in 8B words
51 template <unsigned SIZE> struct IntrCopy64
52 {
53 static inline void Copy(void *_dest, void *_src)
54 {
55 __int64* dest = (__int64*)_dest;
56 __int64* src = (__int64*)_src;
57
58 for (unsigned i = 0; i < SIZE; ++i)
59 #if defined(__aarch64__)
60 dest[i] = src[i];
61 #else
•62 simde_mm_stream_si64(SIMDE_CHECKED_REINTERPRET_CAST(int64_t*, __int64*, dest + i), src[i]);
63 #endif
64 }
65 };
66
67
68 template <unsigned SIZE, unsigned MODE> struct IntrCopy128
69 {
70 static inline void Copy(void *_dest, void *_src)
71 {
72 //cerr << "Error\n";
73 CCriticalErrorHandler::Inst().HandleCriticalError("IntrCopy error");
74 }
75 };
76
77 // 128bit copy function
78 // SIZE - in 16B words
79 // dest - aligned to 16B
80 // src - aligned to 16B
81 template <unsigned SIZE> struct IntrCopy128<SIZE, 1>
82 {
83 static inline void Copy(void *_dest, void *_src)
84 {
85 #if defined(__aarch64__)
86 poly128_t* dest = (poly128_t*) _dest;
87 poly128_t* src = (poly128_t*) _src;
88
89 for (unsigned i = 0; i < SIZE; ++i)
90 vstrq_p128(dest + i, vldrq_p128(src + i));
91 #else
92 __m128i *dest = (__m128i *) _dest;
93 __m128i *src = (__m128i *) _src;
94
95 for (unsigned i = 0; i < SIZE; ++i)
96 _mm_stream_si128(dest + i, _mm_load_si128(src + i));
97 #endif
98 }
99 };
100
101
102 // 128bit copy function
103 // SIZE - in 16B words
104 // dest - aligned to 8B
105 // src - aligned to 16B
106 template <unsigned SIZE> struct IntrCopy128<SIZE, 0>
107 {
108 static inline void Copy(void *dest, void *src)
109 {
110 if ((uint64_t)dest % 16) // if only 8B aligned use 64b copy
111 IntrCopy64<SIZE * 2>::Copy(dest, src);
112 else // if 16B aligned use 128b copy
113 IntrCopy128<SIZE, 1>::Copy(dest, src);
114 }
115 };
116
117
118 #endif
119
•120 // ***** EOF