Skip to content

Commit 6d98a0e

Browse files
STL review feedback
Co-authored-by: StephanTLavavej <[email protected]>
1 parent 8f4b39f commit 6d98a0e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

docs/standard-library/vectorized-stl-algorithms.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,23 @@ helpviewer_keywords: ["_USE_STD_VECTOR_ALGORITHMS", "_USE_STD_VECTOR_FLOATING_AL
1010
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.
1111

1212
The conditions for vectorization are:
13-
- The container or range is contiguous. `array`, `vector`, and `basic_string` are contiguous containers, `span` and `basic_string_view` provide contiguous ranges.
13+
- The container or range is contiguous. `array`, `vector`, and `basic_string` are contiguous containers, `span` and `basic_string_view` provide contiguous ranges. Built-in array elements also form contiguous range. In contrast, `list` and `map` are not contiguous containers.
1414
- There are such SIMD instructions available for the target platform that implement the particular algorithm on particular element types efficiently. Often this is true for plain types (like built-in integers) and simple operations.
1515
- Either of the following:
1616
- The compiler is capable of emitting vectorized machine code for an implementation written as scalar code (auto-vectorization)
1717
- The implementation itself is written as vectorized code (manual vectorization)
1818

1919
## Auto-vectorization in STL
2020

21-
See [Auto-Vectorizer](../parallel/auto-parallelization-and-auto-vectorization.md#auto-vectorizer). It applies to the STL implementation code the same way as to user code.
21+
See [Auto-Vectorizer](../parallel/auto-parallelization-and-auto-vectorization.md#auto-vectorizer) and the discussion of [`/arch`](../build/reference/arch-minimum-cpu-architecture.md) switch there. It applies to the STL implementation code the same way as to user code.
2222

2323
Algorithms like `transform`, `reduce`, `accumulate` heavily benefit from auto-vectorization.
2424

2525
## Manual vectorization in STL
2626

27-
For x64 and x86 targets, certain algorithms have manual vectorization implemented. This implementation is pre-compiled, and uses runtime CPU dispatch, so it is engaged on suitable CPUs only.
27+
For x64 and x86 targets, certain algorithms have manual vectorization implemented. This implementation is separately compiled, and uses runtime CPU dispatch, so it is engaged on suitable CPUs only.
2828

29-
The manually vectorized algorithms use template meta-programming to detect the suitable element types, so they only vectorized for simple types, like standard integer types.
29+
The manually vectorized algorithms use template meta-programming to detect the suitable element types, so they are only vectorized for simple types, like standard integer types.
3030

3131
Generally, programs either benefit in performance from this manual vectorization or are unaffected by it. In case of any problem, you can disable manual vectorization by defining `_USE_STD_VECTOR_ALGORITHMS` macro set to 0. It defaults to 1 on x64 and x86, which means that manually vectorized algorithms are enabled by default.
3232

0 commit comments

Comments
 (0)