You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Under certain conditions, STL algorithms execute not element-wise, but multiple element at once on a single CPU core. This is possible due to SIMD (single instruction, multiple data). The use of such approach instead of
11
-
element-wise approach is called vectorization. An implementation that is not vectorized is called scalar.
10
+
Under certain conditions, STL algorithms execute not element-wise, but multiple element at once on a single CPU core. This is possible due to SIMD (single instruction, multiple data). The use of such approach instead of element-wise approach is called vectorization. An implementation that is not vectorized is called scalar.
12
11
13
12
The conditions for vectorization are:
14
13
- The container or range is contiguous. `array`, `vector`, and `basic_string` are contiguous containers, `span` and `basic_string_view` provide contiguous ranges.
@@ -52,7 +51,7 @@ The following algorithms have manual vectorization controlled via `_USE_STD_VECT
52
51
-`reverse`
53
52
-`reverse_copy`
54
53
-`rotate`
55
-
-`is_sorted`
54
+
-`is_sorted`
56
55
-`is_sorted_until`
57
56
-`max_element`
58
57
-`min_element`
@@ -76,7 +75,7 @@ In addition to algorithms, the macro controls the manual vectorization of:
76
75
## Manually vectorized algorithms for floating point types
77
76
78
77
Vectorization of floating point types is connected with extra difficulties:
79
-
- For floating point results, the order of operations may matter. Some reordering may yield a different result, whether more precise, or less precise. Vectotization may need operations reordering, so it may affect that.
78
+
- For floating point results, the order of operations may matter. Some reordering may yield a different result, whether more precise, or less precise. Vectorization may need operations reordering, so it may affect that.
80
79
- Floating point types may contain NaN values, which don't behave transitively while comparing.
81
80
- Floating point operations may raise exceptions.
82
81
@@ -86,7 +85,7 @@ The STL deals with the first two difficulties safely. Only `max_element`, `min_e
86
85
87
86
There's `_USE_STD_VECTOR_FLOATING_ALGORITHMS` to control the use of these vectorized algorithms for floating point types. Set it to 0 to disable the vectorization. The macro has no effect if `_USE_STD_VECTOR_ALGORITHMS` is set to 0.
88
87
89
-
`_USE_STD_VECTOR_FLOATING_ALGORITHMS` defaults to 0 when `/fp:except` option is set. This is to avoid problems with exceptions.
88
+
`_USE_STD_VECTOR_FLOATING_ALGORITHMS` defaults to 0 when [`/fp:except`](../build/reference/fp-specify-floating-point-behavior.md#except) option is set. This is to avoid problems with exceptions.
0 commit comments