forked from ColinIanKing/stress-ng
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcore-nt-store.h
124 lines (116 loc) · 3.9 KB
/
core-nt-store.h
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/*
* Copyright (C) 2022 Colin Ian King
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef CORE_NT_STORE_H
#define CORE_NT_STORE_H
#if defined(HAVE_XMMINTRIN_H)
#include <xmmintrin.h>
#endif
/* Non-temporal store writes */
/*
* 128 bit non-temporal stores
*/
#if defined(HAVE_INT128_T) && \
defined(HAVE_BUILTIN_SUPPORTS) && \
defined(HAVE_BUILTIN_NONTEMPORAL_STORE)
/* Clang non-temporal stores */
static inline void ALWAYS_INLINE OPTIMIZE3 stress_nt_store128(__uint128_t *addr, register __uint128_t value)
{
__builtin_nontemporal_store(value, addr);
}
#define HAVE_NT_STORE128
#elif defined(HAVE_XMMINTRIN_H) && \
defined(HAVE_INT128_T) && \
defined(HAVE_V2DI) && \
(defined(__x86_64__) || defined(__x86_64)) && \
defined(HAVE_BUILTIN_SUPPORTS) && \
defined(HAVE_BUILTIN_IA32_MOVNTDQ)
/* gcc x86 non-temporal stores */
static inline void ALWAYS_INLINE OPTIMIZE3 stress_nt_store128(__uint128_t *addr, register __uint128_t value)
{
__builtin_ia32_movntdq((__v2di *)addr, (__v2di)value);
}
#define HAVE_NT_STORE128
#endif
/*
* 64 bit non-temporal stores
*/
#if defined(HAVE_BUILTIN_SUPPORTS) && \
defined(HAVE_BUILTIN_NONTEMPORAL_STORE)
/* Clang non-temporal stores */
static inline void ALWAYS_INLINE OPTIMIZE3 stress_nt_store64(uint64_t *addr, register uint64_t value)
{
__builtin_nontemporal_store(value, addr);
}
#define HAVE_NT_STORE64
#elif defined(HAVE_XMMINTRIN_H) && \
(defined(__x86_64__) || defined(__x86_64)) && \
defined(HAVE_BUILTIN_SUPPORTS) && \
defined(HAVE_BUILTIN_IA32_MOVNTI64)
/* gcc x86 non-temporal stores */
static inline void ALWAYS_INLINE OPTIMIZE3 stress_nt_store64(uint64_t *addr, register uint64_t value)
{
__builtin_ia32_movnti64((long long int *)addr, (long long int)value);
}
#define HAVE_NT_STORE64
#endif
/*
* 32 bit non-temporal stores
*/
#if defined(HAVE_BUILTIN_SUPPORTS) && \
defined(HAVE_BUILTIN_NONTEMPORAL_STORE)
/* Clang non-temporal stores */
static inline void ALWAYS_INLINE OPTIMIZE3 stress_nt_store32(uint32_t *addr, register uint32_t value)
{
__builtin_nontemporal_store(value, addr);
}
#define HAVE_NT_STORE32
#elif defined(HAVE_XMMINTRIN_H) && \
(defined(__x86_64__) || defined(__x86_64)) && \
defined(HAVE_BUILTIN_SUPPORTS) && \
defined(HAVE_BUILTIN_IA32_MOVNTI)
/* gcc x86 non-temporal stores */
static inline void ALWAYS_INLINE OPTIMIZE3 stress_nt_store32(uint32_t *addr, register uint32_t value)
{
__builtin_ia32_movnti((int *)addr, value);
}
#define HAVE_NT_STORE32
#endif
/*
* double precision float non-temporal stores
*/
#if defined(HAVE_BUILTIN_SUPPORTS) && \
defined(HAVE_BUILTIN_NONTEMPORAL_STORE)
/* Clang non-temporal stores */
static inline void ALWAYS_INLINE OPTIMIZE3 stress_nt_store_double(double *addr, register double value)
{
__builtin_nontemporal_store(value, addr);
}
#define HAVE_NT_STORE_DOUBLE
#elif defined(HAVE_XMMINTRIN_H) && \
(defined(__x86_64__) || defined(__x86_64)) && \
defined(HAVE_BUILTIN_SUPPORTS) && \
defined(HAVE_BUILTIN_IA32_MOVNTI64)
/* gcc x86 non-temporal stores */
static inline void ALWAYS_INLINE OPTIMIZE3 stress_nt_store_double(double *addr, register double value)
{
__builtin_ia32_movnti64((long long int *)addr, value);
}
#define HAVE_NT_STORE_DOUBLE
#endif
#endif