Skip to content

Commit bc3d9cf

Browse files
committed
edits
1 parent f890420 commit bc3d9cf

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ helpviewer_keywords: ["_USE_STD_VECTOR_ALGORITHMS", "_USE_STD_VECTOR_FLOATING_AL
77
---
88
# Vectorized STL Algorithms
99

10-
Under specific conditions, algorithms in the C++ Standard Template Library (STL) can process multiple elements simultaneously on a single CPU core, rather than handling each element individually. This optimization leverages single instruction, multiple data (SIMD) instructions provided by the CPU, a technique known as vectorization. When this optimization isn't applied, the implementation is referred to as scalar.
10+
Under specific conditions, algorithms in the C++ Standard Template Library (STL) can process multiple elements simultaneously on a single CPU core, rather than handling each element individually. This optimization uses single instruction, multiple data (SIMD) instructions provided by the CPU, a technique known as vectorization. When this optimization isn't applied, the implementation is referred to as scalar.
1111

1212
The conditions required for vectorization are:
1313
- The container or range must be contiguous. Examples of contiguous containers include `array`, `vector`, and `basic_string`. Contiguous ranges are provided by types like `span` and `basic_string_view`. Built-in arrays also form contiguous ranges. In contrast, containers like `list` and `map` aren't contiguous.
@@ -24,15 +24,16 @@ Algorithms like `transform`, `reduce`, `accumulate` heavily benefit from auto-ve
2424

2525
## Manual vectorization in the STL
2626

27-
For x64 and x86, certain algorithms include manual vectorization. This implementation is separately compiled, and uses runtime CPU dispatch, so it's only used on suitable CPUs.
27+
For x64 and x86, certain algorithms include manual vectorization. This implementation is separately compiled and relies on runtime CPU dispatch, so it applies only to suitable CPUs.
2828

2929
Manually vectorized algorithms use template meta-programming to detect whether the element type is suitable for vectorization. As a result, they're only vectorized for simple types such as standard integer types.
3030

3131
Generally, programs either benefit in performance from this manual vectorization or are unaffected by it. You can disable manual vectorization with `#define _USE_STD_VECTOR_ALGORITHMS=0'. Manually vectorized algorithms are enabled by default on x64 and x86 because it defaults to 1 on those platforms.
3232

33-
To set `_USE_STD_VECTOR_ALGORITHMS` ensure that it's set to the same value for all linked translation units that use algorithms. A reliable way to achieve this to set it using in the project properties instead of in source. For more information about how to do that, see [/D (Preprocessor Definitions)](../build/reference/d-preprocessor-definitions.md).
33+
Ensure that you assign the same value to `_USE_STD_VECTOR_ALGORITHMS` for all linked translation units that use algorithms. A reliable way to do this is by configuring it in the project properties instead of in the source code. For more information about how to configure it, see [/D (Preprocessor Definitions)](../build/reference/d-preprocessor-definitions.md).
3434

35-
The following algorithms are manually vectorized and their behavior is controlled by the `_USE_STD_VECTOR_ALGORITHMS` macro:
35+
36+
The `_USE_STD_VECTOR_ALGORITHMS` macro determines the behavior of the following manually vectorized algorithms:
3637
- `contains`, `contains_subrange`
3738
- `find`, `find_last`, `find_end`, `find_first_of`, `adjacent_find`
3839
- `count`
@@ -60,7 +61,7 @@ In addition to algorithms, the `_USE_STD_VECTOR_ALGORITHMS` macro controls the m
6061

6162
## Manually vectorized algorithms for floating point types
6263

63-
Vectorization of floating point types requires additional considerations:
64+
Vectorization of floating-point types involves specific considerations:
6465
- Vectorization may reorder operations, which can affect the precision of floating point results.
6566
- Floating point types may contain `NaN` values, which don't behave transitively on comparisons.
6667
- Floating point operations may raise exceptions.
@@ -73,7 +74,7 @@ Use `_USE_STD_VECTOR_FLOATING_ALGORITHMS` to control the use of these vectorized
7374

7475
`_USE_STD_VECTOR_FLOATING_ALGORITHMS` defaults to 0 when [`/fp:except`](../build/reference/fp-specify-floating-point-behavior.md#except) is set.
7576

76-
To set `_USE_STD_VECTOR_FLOATING_ALGORITHMS` ensure that it's set to the same value for all linked translation units that use algorithms. A reliable way to achieve this to set it using in the project properties instead of in source. For more information about how to do that, see [/D (Preprocessor Definitions)](../build/reference/d-preprocessor-definitions.md).
77+
Ensure that you assign the same value to `_USE_STD_VECTOR_FLOATING_ALGORITHMS` for all linked translation units that use algorithms. A reliable way to do this is by configuring it in the project properties instead of in the source code. For more information about how to configure it, see [/D (Preprocessor Definitions)](../build/reference/d-preprocessor-definitions.md).
7778

7879
## See also
7980

0 commit comments

Comments
 (0)