]>
git.proxmox.com Git - ceph.git/blob - ceph/src/pmdk/src/libpmem2/x86_64/memset/memset_t_sse2.c
1 // SPDX-License-Identifier: BSD-3-Clause
2 /* Copyright 2017-2020, Intel Corporation */
8 #include "pmem2_arch.h"
10 #include "memcpy_memset.h"
11 #include "memset_sse2.h"
13 static force_inline
void
14 mm_store_si128(char *dest
, unsigned idx
, __m128i src
)
16 _mm_store_si128((__m128i
*)dest
+ idx
, src
);
19 static force_inline
void
20 memset_mov4x64b(char *dest
, __m128i xmm
, flush64b_fn flush64b
)
22 mm_store_si128(dest
, 0, xmm
);
23 mm_store_si128(dest
, 1, xmm
);
24 mm_store_si128(dest
, 2, xmm
);
25 mm_store_si128(dest
, 3, xmm
);
26 mm_store_si128(dest
, 4, xmm
);
27 mm_store_si128(dest
, 5, xmm
);
28 mm_store_si128(dest
, 6, xmm
);
29 mm_store_si128(dest
, 7, xmm
);
30 mm_store_si128(dest
, 8, xmm
);
31 mm_store_si128(dest
, 9, xmm
);
32 mm_store_si128(dest
, 10, xmm
);
33 mm_store_si128(dest
, 11, xmm
);
34 mm_store_si128(dest
, 12, xmm
);
35 mm_store_si128(dest
, 13, xmm
);
36 mm_store_si128(dest
, 14, xmm
);
37 mm_store_si128(dest
, 15, xmm
);
39 flush64b(dest
+ 0 * 64);
40 flush64b(dest
+ 1 * 64);
41 flush64b(dest
+ 2 * 64);
42 flush64b(dest
+ 3 * 64);
45 static force_inline
void
46 memset_mov2x64b(char *dest
, __m128i xmm
, flush64b_fn flush64b
)
48 mm_store_si128(dest
, 0, xmm
);
49 mm_store_si128(dest
, 1, xmm
);
50 mm_store_si128(dest
, 2, xmm
);
51 mm_store_si128(dest
, 3, xmm
);
52 mm_store_si128(dest
, 4, xmm
);
53 mm_store_si128(dest
, 5, xmm
);
54 mm_store_si128(dest
, 6, xmm
);
55 mm_store_si128(dest
, 7, xmm
);
57 flush64b(dest
+ 0 * 64);
58 flush64b(dest
+ 1 * 64);
61 static force_inline
void
62 memset_mov1x64b(char *dest
, __m128i xmm
, flush64b_fn flush64b
)
64 mm_store_si128(dest
, 0, xmm
);
65 mm_store_si128(dest
, 1, xmm
);
66 mm_store_si128(dest
, 2, xmm
);
67 mm_store_si128(dest
, 3, xmm
);
69 flush64b(dest
+ 0 * 64);
72 static force_inline
void
73 memset_mov_sse2(char *dest
, int c
, size_t len
,
74 flush_fn flush
, flush64b_fn flush64b
)
76 __m128i xmm
= _mm_set1_epi8((char)c
);
78 size_t cnt
= (uint64_t)dest
& 63;
85 memset_small_sse2(dest
, xmm
, cnt
, flush
);
91 while (len
>= 4 * 64) {
92 memset_mov4x64b(dest
, xmm
, flush64b
);
98 memset_mov2x64b(dest
, xmm
, flush64b
);
104 memset_mov1x64b(dest
, xmm
, flush64b
);
111 memset_small_sse2(dest
, xmm
, len
, flush
);
115 memset_mov_sse2_noflush(char *dest
, int c
, size_t len
)
117 LOG(15, "dest %p c %d len %zu", dest
, c
, len
);
119 memset_mov_sse2(dest
, c
, len
, noflush
, noflush64b
);
123 memset_mov_sse2_empty(char *dest
, int c
, size_t len
)
125 LOG(15, "dest %p c %d len %zu", dest
, c
, len
);
127 memset_mov_sse2(dest
, c
, len
, flush_empty_nolog
, flush64b_empty
);
131 memset_mov_sse2_clflush(char *dest
, int c
, size_t len
)
133 LOG(15, "dest %p c %d len %zu", dest
, c
, len
);
135 memset_mov_sse2(dest
, c
, len
, flush_clflush_nolog
, pmem_clflush
);
139 memset_mov_sse2_clflushopt(char *dest
, int c
, size_t len
)
141 LOG(15, "dest %p c %d len %zu", dest
, c
, len
);
143 memset_mov_sse2(dest
, c
, len
, flush_clflushopt_nolog
,
148 memset_mov_sse2_clwb(char *dest
, int c
, size_t len
)
150 LOG(15, "dest %p c %d len %zu", dest
, c
, len
);
152 memset_mov_sse2(dest
, c
, len
, flush_clwb_nolog
, pmem_clwb
);