aboutsummaryrefslogtreecommitdiff
path: root/share/man/man7/simd.7
blob: 6ddf769b6d38dc308477e0760b593be7e146c6a6 (plain) (blame)
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
.\" Copyright (c) 2023 The FreeBSD Foundation
.
.\" This documentation was written by Robert Clausecker <fuz@FreeBSD.org>
.\" under sponsorship from the FreeBSD Foundation.
.
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ''AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE
.
.Dd November 14, 2023
.Dt SIMD 7
.Os
.Sh NAME
.Nm simd
.Nd SIMD enhancements
.
.Sh DESCRIPTION
On some architectures, the
.Fx
.Em libc
provides enhanced implementations of commonly used functions, replacing
the architecture-independent implementations used otherwise.
Depending on architecture and function, an enhanced
implementation of a function may either always be used or the
.Em libc
detects at runtime which SIMD instruction set extensions are
supported and picks the most suitable implementation automatically.
On
.Cm amd64 ,
the environment variable
.Ev ARCHLEVEL
can be used to override this mechanism.
.Pp
Enhanced functions are present for the following architectures:
.Bl -column FUNCTION_________ aarch64_ arm_ amd64_ i386_ ppc64_ -offset indent
.It Em FUNCTION          Ta Em AARCH64 Ta Em ARM Ta Em AMD64  Ta Em I386 Ta Em PPC64
.It    bcmp              Ta            Ta        Ta    S1     Ta    S
.It    bcopy             Ta            Ta    S   Ta    S      Ta    S    Ta    SV
.It    bzero             Ta            Ta    S   Ta    S      Ta    S
.It    div               Ta            Ta        Ta    S      Ta    S
.It    index             Ta    S       Ta        Ta    S1
.It    ldiv              Ta            Ta        Ta    S      Ta    S
.It    lldiv             Ta            Ta        Ta    S
.It    memchr            Ta            Ta        Ta    S1
.It    memcmp            Ta            Ta    S   Ta    S1     Ta    S
.It    memcpy            Ta    S       Ta    S   Ta    S      Ta    S    Ta    SV
.It    memmove           Ta    S       Ta    S   Ta    S      Ta    S    Ta    SV
.It    memset            Ta            Ta    S   Ta    S      Ta    S
.It    rindex            Ta    S       Ta        Ta    S1     Ta    S
.It    stpcpy            Ta            Ta        Ta    S1
.It    stpncpy           Ta            Ta        Ta    S1
.It    strcat            Ta            Ta        Ta    S1     Ta    S
.It    strchr            Ta    S       Ta        Ta    S1     Ta    S
.It    strchrnul         Ta            Ta        Ta    S1
.It    strcmp            Ta            Ta    S   Ta    S1     Ta    S
.It    strcpy            Ta            Ta        Ta    S1     Ta    S    Ta    S2
.It    strcspn           Ta            Ta        Ta    S2
.It    strlen            Ta            Ta    S   Ta    S1
.It    strncmp           Ta            Ta    S   Ta    S1     Ta    S
.It    strncpy           Ta            Ta        Ta    S1     Ta         Ta    S2
.It    strnlen           Ta            Ta        Ta    S1
.It    strrchr           Ta    S       Ta        Ta    S1     Ta    S
.It    strpbrk           Ta            Ta        Ta    S2
.It    strsep            Ta            Ta        Ta    S2
.It    strspn            Ta            Ta        Ta    S2
.It    swab              Ta            Ta        Ta           Ta    S
.It    timingsafe_bcmp   Ta            Ta        Ta    S1
.It    timingsafe_memcmp Ta            Ta        Ta    S
.It    wcschr            Ta            Ta        Ta           Ta    S
.It    wcscmp            Ta            Ta        Ta           Ta    S
.It    wcslen            Ta            Ta        Ta           Ta    S
.It    wmemchr           Ta            Ta        Ta           Ta    S
.El
.Pp
.Sy S Ns :\ scalar (non-SIMD),
.Sy 1 Ns :\ amd64 baseline,
.Sy 2 Ns :\ x86-64-v2
or PowerPC\ 2.05,
.Sy 3 Ns :\ x86-64-v3,
.Sy 4 Ns :\ x86-64-v4,
.Sy V Ns :\ PowerPC\ VSX.
.
.Sh ENVIRONMENT
.Bl -tag
.It Ev ARCHLEVEL
On
.Em amd64 ,
controls the level of SIMD enhancements used.
If this variable is set to an architecture level from the list below
and that architecture level is supported by the processor, SIMD
enhancements up to
.Ev ARCHLEVEL
are used.
If
.Ev ARCHLEVEL
is unset, not recognised, or not supported by the processor, the highest
level of SIMD enhancements supported by the processor is used.
.Pp
A suffix beginning with
.Sq ":"
or
.Sq "+"
in
.Ev ARCHLEVEL
is ignored and may be used for future extensions.
The architecture level can be prefixed with a
.Sq "!"
character to force use of the requested architecture level, even if the
processor does not advertise that it is supported.
This usually causes applications to crash and should only be used for
testing purposes or if architecture level detection yields incorrect
results.
.Pp
The architecture levels follow the AMD64 SysV ABI supplement:
.Bl -tag -width x86-64-v2
.It Cm scalar
scalar enhancements only (no SIMD)
.It Cm baseline
cmov, cx8, x87 FPU, fxsr, MMX, osfxsr, SSE, SSE2
.It Cm x86-64-v2
cx16, lahf/sahf, popcnt, SSE3, SSSE3, SSE4.1, SSE4.2
.It Cm x86-64-v3
AVX, AVX2, BMI1, BMI2, F16C, FMA, lzcnt, movbe, osxsave
.It Cm x86-64-v4
AVX-512F/BW/CD/DQ/VL
.El
.El
.
.Sh DIAGNOSTICS
.Bl -diag
.It "Illegal Instruction"
Printed by
.Xr sh 1
if a command is terminated through delivery of a
.Dv SIGILL
signal, see
.Xr signal 3 .
.Pp
Use of an unsupported architecture level was forced by setting
.Ev ARCHLEVEL
to a string beginning with a
.Sq "!"
character, causing a process to crash due to use of an unsupported
instruction.
Unset
.Ev ARCHLEVEL ,
remove the
.Sq "!"
prefix or select a supported architecture level.
.Pp
Message may also appear for unrelated reasons.
.El
.
.Sh SEE ALSO
.Xr string 3 ,
.Xr arch 7
.Rs
.%A H. J. Lu
.%A Michael Matz
.%A Milind Girkar
.%A Jan Hubi\[u010D]ka \" \(vc
.%A Andreas Jaeger
.%A Mark Mitchell
.%B System V Application Binary Interface
.%D May 23, 2023
.%T AMD64 Architecture Processor Supplement
.%O Version 1.0
.Re
.
.Sh HISTORY
Architecture-specific enhanced
.Em libc
functions were added starting
with
.Fx 2.0
for
.Cm i386 ,
.Fx 6.0
for
.Cm arm ,
.Fx 6.1
for
.Cm amd64 ,
.Fx 11.0
for
.Cm aarch64 ,
and
.Fx 12.0
for
.Cm powerpc64 .
SIMD-enhanced functions were first added with
.Fx 13.0
for
.Cm powerpc64
and with
.Fx 14.1
for
.Cm amd64 .
.Pp
A
.Nm
manual page appeared in
.Fx 14.1 .
.
.Sh AUTHOR
.An Robert Clausecker Aq Mt fuz@FreeBSD.org
.
.Sh CAVEATS
Other parts of
.Fx
such as cryptographic routines in the kernel or in
OpenSSL may also use SIMD enhancements.
These enhancements are not subject to the
.Ev ARCHLEVEL
variable and may have their own configuration
mechanism.
.
.Sh BUGS
Use of SIMD enhancements cannot be configured on powerpc64.