|
1 | 1 | --- |
2 | 2 | description: "Learn more about: Vectorizer and parallelizer messages" |
3 | 3 | title: "Vectorizer and parallelizer messages" |
4 | | -ms.date: "04/17/2019" |
| 4 | +ms.date: 02/16/2021 |
5 | 5 | f1_keywords: ["C5011", "C5002", "C5021", "C5001", "C5012"] |
6 | | -ms.assetid: d8f4844a-f414-42ab-b9a5-925a5da9d365 |
7 | 6 | --- |
8 | 7 | # Vectorizer and parallelizer messages |
9 | 8 |
|
10 | | -You can use the Microsoft C++ compiler options [/Qpar-report](../../build/reference/qpar-report-auto-parallelizer-reporting-level.md) and [/Qvec-report](../../build/reference/qvec-report-auto-vectorizer-reporting-level.md) to set the [Auto-parallelization and auto-vectorization](../../parallel/auto-parallelization-and-auto-vectorization.md) to output reason codes and informational messages about its activity. This article explains the reason codes and the messages. |
| 9 | +You can use the Microsoft C++ compiler options [`/Qpar-report`](../../build/reference/qpar-report-auto-parallelizer-reporting-level.md) and [`/Qvec-report`](../../build/reference/qvec-report-auto-vectorizer-reporting-level.md) to set the [Auto-parallelization and auto-vectorization](../../parallel/auto-parallelization-and-auto-vectorization.md) to output reason codes and informational messages about its activity. This article explains the reason codes and the messages. |
11 | 10 |
|
12 | 11 | ## <a name="BKMK_InformationalMessages"></a> Informational messages |
13 | 12 |
|
14 | 13 | Depending on the reporting level that you specify, one of the following informational messages appears for each loop. |
15 | 14 |
|
16 | 15 | For information about reason codes, refer to the next part of this article. |
17 | 16 |
|
18 | | -|Informational Message|Description| |
19 | | -|---------------------------|-----------------| |
20 | | -|5001|`Loop vectorized.`| |
21 | | -|5002|`Loop not vectorized due to reason '*description*'.`| |
22 | | -|5011|`Loop parallelized.`| |
23 | | -|5012|`Loop not parallelized due to reason '*description*'.`| |
24 | | -|5021|`Unable to associate loop with pragma.`| |
| 17 | +| Informational message | Description | |
| 18 | +|--|--| |
| 19 | +| 5001 | Loop vectorized. | |
| 20 | +| 5002 | Loop not vectorized due to reason '*description*'. | |
| 21 | +| 5011 | Loop parallelized. | |
| 22 | +| 5012 | Loop not parallelized due to reason '*description*'. | |
| 23 | +| 5021 | Unable to associate loop with pragma. | |
25 | 24 |
|
26 | 25 | The following sections list possible reason codes for the parallelizer and vectorizer. |
27 | 26 |
|
28 | 27 | ## <a name="BKMK_ReasonCode50x"></a> 5xx reason codes |
29 | 28 |
|
30 | 29 | The 5*xx* reason codes apply to both the parallelizer and the vectorizer. |
31 | 30 |
|
32 | | -|Reason Code|Explanation| |
33 | | -|-----------------|-----------------| |
34 | | -|500|A generic message that covers several cases—for example, the loop includes multiple exits, or the loop header doesn't end by incrementing the induction variable.| |
35 | | -|501|`Induction variable is not local; or upper bound is not loop-invariant.`| |
36 | | -|502|`Induction variable is stepped in some manner other than a simple +1.`| |
37 | | -|503|`Loop includes exception-handling or switch statements.`| |
38 | | -|504|`Loop body may throw an exception that requires destruction of a C++ object.`| |
| 31 | +| Reason code | Explanation | |
| 32 | +|--|--| |
| 33 | +| 500 | A generic message that covers several cases—for example, the loop includes multiple exits, or the loop header doesn't end by incrementing the induction variable. | |
| 34 | +| 501 | Induction variable isn't local; or upper bound isn't loop-invariant. | |
| 35 | +| 502 | Induction variable is stepped in some manner other than a simple +1. | |
| 36 | +| 503 | Loop includes exception-handling or switch statements. | |
| 37 | +| 504 | Loop body may throw an exception that requires destruction of a C++ object. | |
39 | 38 |
|
40 | 39 | ```cpp |
41 | 40 | void code_500(int *A) |
@@ -192,19 +191,19 @@ void code_504(int *A) { |
192 | 191 |
|
193 | 192 | The 10*xx* reason codes apply to the parallelizer. |
194 | 193 |
|
195 | | -|Reason Code|Explanation| |
196 | | -|-----------------|-----------------| |
197 | | -|1000|`The compiler detected a data dependency in the loop body.`| |
198 | | -|1001|`The compiler detected a store to a scalar variable in the loop body, and that scalar has a use beyond the loop.`| |
199 | | -|1002|`The compiler tried to parallelize a loop that has an inner loop that was already parallelized.`| |
200 | | -|1003|`The loop body contains an intrinsic call that may read or write to memory.`| |
201 | | -|1004|`There is a scalar reduction in the loop body. Scalar reduction can occur if the loop has been vectorized.`| |
202 | | -|1005|`The no_parallel pragma was specified.`| |
203 | | -|1006|`This function contains openmp. Resolve this by removing any openmp in this function.`| |
204 | | -|1007|`The loop induction variable or the loop bounds are not signed 32-bit numbers (int or long). Resolve this by changing the type of the induction variable.`| |
205 | | -|1008|`The compiler detected that this loop does not perform enough work to warrant auto-parallelization.`| |
206 | | -|1009|`The compiler detected an attempt to parallelize a "do-while" loop. The auto-parallelizer only targets "for" loops.`| |
207 | | -|1010|`The compiler detected that the loop is using "not-equals" (!=) for its condition.`| |
| 194 | +| Reason code | Explanation | |
| 195 | +|--|--| |
| 196 | +| 1000 | The compiler detected a data dependency in the loop body. | |
| 197 | +| 1001 | The compiler detected a store to a scalar variable in the loop body, and that scalar has a use beyond the loop. | |
| 198 | +| 1002 | The compiler tried to parallelize a loop that has an inner loop that was already parallelized. | |
| 199 | +| 1003 | The loop body contains an intrinsic call that may read or write to memory. | |
| 200 | +| 1004 | There's a scalar reduction in the loop body. Scalar reduction can occur if the loop has been vectorized. | |
| 201 | +| 1005 | The `no_parallel` pragma was specified. | |
| 202 | +| 1006 | This function contains OpenMP. Resolve it by removing any OpenMP in this function. | |
| 203 | +| 1007 | The loop induction variable or the loop bounds aren't signed 32-bit numbers (`int` or `long`). Resolve it by changing the type of the induction variable. | |
| 204 | +| 1008 | The compiler detected that this loop doesn't perform enough work to justify auto-parallelization. | |
| 205 | +| 1009 | The compiler detected an attempt to parallelize a "`do`-`while`" loop. The auto-parallelizer only targets "`for`" loops. | |
| 206 | +| 1010 | The compiler detected that the loop is using "not-equals" (`!=`) for its condition. | |
208 | 207 |
|
209 | 208 | ```cpp |
210 | 209 | int A[1000]; |
@@ -401,15 +400,15 @@ void code_1010() |
401 | 400 |
|
402 | 401 | The 11*xx* reason codes apply to the vectorizer. |
403 | 402 |
|
404 | | -|Reason Code|Explanation| |
405 | | -|-----------------|-----------------| |
406 | | -|1100|`Loop contains control flow—for example, "if" or "?".`| |
407 | | -|1101|`Loop contains datatype conversion—perhaps implicit—that cannot be vectorized.`| |
408 | | -|1102|`Loop contains non-arithmetic or other non-vectorizable operations.`| |
409 | | -|1103|`Loop body includes shift operations whose size might vary within the loop.`| |
410 | | -|1104|`Loop body includes scalar variables.`| |
411 | | -|1105|`Loop includes a unrecognized reduction operation.`| |
412 | | -|1106|`Outer loop not vectorized.`| |
| 403 | +| Reason code | Explanation | |
| 404 | +|--|--| |
| 405 | +| 1100 | Loop contains control flow—for example, "`if`" or "`?:`". | |
| 406 | +| 1101 | Loop contains datatype conversion—perhaps implicit—that can't be vectorized. | |
| 407 | +| 1102 | Loop contains non-arithmetic or other non-vectorizable operations. | |
| 408 | +| 1103 | Loop body includes shift operations whose size might vary within the loop. | |
| 409 | +| 1104 | Loop body includes scalar variables. | |
| 410 | +| 1105 | Loop includes an unrecognized reduction operation. | |
| 411 | +| 1106 | Outer loop not vectorized. | |
413 | 412 |
|
414 | 413 | ```cpp |
415 | 414 | void code_1100(int *A, int x) |
@@ -549,12 +548,13 @@ void code_1106(int *A) |
549 | 548 |
|
550 | 549 | The 12*xx* reason codes apply to the vectorizer. |
551 | 550 |
|
552 | | -|Reason Code|Explanation| |
553 | | -|-----------------|-----------------| |
554 | | -|1200|`Loop contains loop-carried data dependences that prevent vectorization. Different iterations of the loop interfere with each other such that vectorizing the loop would produce wrong answers, and the auto-vectorizer cannot prove to itself that there are no such data dependences.`| |
555 | | -|1201|`Array base changes during the loop.`| |
556 | | -|1202|`Field in a struct is not 32 or 64 bits wide.`| |
557 | | -|1203|`Loop body includes non-contiguous accesses into an array.`| |
| 551 | +| Reason code | Explanation | |
| 552 | +|--|--| |
| 553 | +| 1200 | Loop contains loop-carried data dependencies that prevent vectorization. Different iterations of the loop interfere with each other such that vectorizing the loop would produce wrong answers, and the auto-vectorizer can't prove to itself that there are no such data dependences. | |
| 554 | +| 1201 | Array base changes during the loop. | |
| 555 | +| 1202 | Field in a struct isn't 32 or 64 bits wide. | |
| 556 | +| 1203 | Loop body includes non-contiguous accesses into an array. | |
| 557 | +| 1204 | Compiler internal data structure limit hit: too many data dependence edges. | |
558 | 558 |
|
559 | 559 | ```cpp |
560 | 560 | void fn(); |
@@ -618,20 +618,36 @@ void code_1203(int *A) |
618 | 618 | A[i] += A[i*2+2] + 2; // non-contiguous memory access not vectorized |
619 | 619 | } |
620 | 620 | } |
| 621 | +
|
| 622 | +void code_1204(int *A) |
| 623 | +{ |
| 624 | + // Code 1204 is emitted when internal compiler data structures |
| 625 | + // hit a limit on the number of data dependence edges recorded. |
| 626 | + // Resolve this by moving the innermost loop to another function. |
| 627 | +
|
| 628 | + for (int i=0; i<1000; i++) |
| 629 | + for (int j=0; j<1000; j++) |
| 630 | + for (int k=0; k<1000; k++) |
| 631 | + for (int l=0; l<1000; l++) |
| 632 | + { |
| 633 | + for (int m=0; m<1000; m++) |
| 634 | + A[m] = A[m+i] + A[m+j] + A[m+k] + A[m+l]; |
| 635 | + } |
| 636 | +} |
621 | 637 | ``` |
622 | 638 |
|
623 | 639 | ## <a name="BKMK_ReasonCode130x"></a> 13xx reason codes |
624 | 640 |
|
625 | 641 | The 13*xx* reason codes apply to the vectorizer. |
626 | 642 |
|
627 | | -|Reason Code|Explanation| |
628 | | -|-----------------|-----------------| |
629 | | -|1300|`Loop body contains no—or very little—computation.`| |
630 | | -|1301|`Loop stride is not +1.`| |
631 | | -|1302|`Loop is a "do-while".`| |
632 | | -|1303|`Too few loop iterations for vectorization to provide value.`| |
633 | | -|1304|`Loop includes assignments that are of different sizes.`| |
634 | | -|1305|`Not enough type information.`| |
| 643 | +| Reason code | Explanation | |
| 644 | +|--|--| |
| 645 | +| 1300 | Loop body contains no—or very little—computation. | |
| 646 | +| 1301 | Loop stride isn't +1. | |
| 647 | +| 1302 | Loop is a "`do`-`while`". | |
| 648 | +| 1303 | Too few loop iterations for vectorization to provide value. | |
| 649 | +| 1304 | Loop includes assignments that are of different sizes. | |
| 650 | +| 1305 | Not enough type information. | |
635 | 651 |
|
636 | 652 | ```cpp |
637 | 653 | void code_1300(int *A, int *B) |
@@ -756,14 +772,14 @@ void code_1305( S_1305 *s, S_1305 x) |
756 | 772 |
|
757 | 773 | The 14*xx* reason codes occur when some option that is incompatible with vectorization is specified. |
758 | 774 |
|
759 | | -|Reason Code|Explanation| |
760 | | -|-----------------|-----------------| |
761 | | -|1400|`#pragma loop(no_vector) is specified.`| |
762 | | -|1401|`/kernel switch is specified when targeting x86 or ARM.`| |
763 | | -|1402|`/arch:SSE2 or higher switch is not specified when targeting x86.`| |
764 | | -|1403|`/arch:ATOM switch is specified and the loop includes operations on doubles.`| |
765 | | -|1404|`/O1 or /Os switch is specified.`| |
766 | | -|1405|`Vectorization is disabled to aid in dynamic-initializer-to-static-initializer optimization.`| |
| 775 | +| Reason code | Explanation | |
| 776 | +|--|--| |
| 777 | +| 1400 | `#pragma loop(no_vector)` is specified. | |
| 778 | +| 1401 | `/kernel` switch is specified when targeting x86 or ARM. | |
| 779 | +| 1402 | `/arch:SSE2` or higher switch isn't specified when targeting x86. | |
| 780 | +| 1403 | `/arch:ATOM` switch is specified and the loop includes operations on doubles. | |
| 781 | +| 1404 | `/O1` or `/Os` switch is specified. | |
| 782 | +| 1405 | Vectorization is disabled to aid in dynamic-initializer-to-static-initializer optimization. | |
767 | 783 |
|
768 | 784 | ```cpp |
769 | 785 | void code_1400(int *A) |
@@ -828,14 +844,14 @@ void code_1404(int *A) |
828 | 844 |
|
829 | 845 | The 15*xx* reason codes apply to aliasing. Aliasing occurs when a location in memory can be accessed by two different names. |
830 | 846 |
|
831 | | -|Reason Code|Explanation| |
832 | | -|-----------------|-----------------| |
833 | | -|1500|`Possible aliasing on multi-dimensional arrays.`| |
834 | | -|1501|`Possible aliasing on arrays-of-structs.`| |
835 | | -|1502|`Possible aliasing and array index is other than n + K.`| |
836 | | -|1503|`Possible aliasing and array index has multiple offsets.`| |
837 | | -|1504|`Possible aliasing; would require too many runtime checks.`| |
838 | | -|1505|`Possible aliasing, but runtime checks are too complex.`| |
| 847 | +| Reason code | Explanation | |
| 848 | +|--|--| |
| 849 | +| 1500 | Possible aliasing on multi-dimensional arrays. | |
| 850 | +| 1501 | Possible aliasing on arrays-of-structs. | |
| 851 | +| 1502 | Possible aliasing and array index is other than n + K. | |
| 852 | +| 1503 | Possible aliasing and array index has multiple offsets. | |
| 853 | +| 1504 | Possible aliasing; would require too many runtime checks. | |
| 854 | +| 1505 | Possible aliasing, but runtime checks are too complex. | |
839 | 855 |
|
840 | 856 | ```cpp |
841 | 857 | void code_1500(int A[100][100], int B[100][100]) |
@@ -954,10 +970,10 @@ void code_1505(int *A, int *B) |
954 | 970 |
|
955 | 971 | ## See also |
956 | 972 |
|
957 | | -[C/C++ Compiler and build tools errors and warnings](../compiler-errors-1/c-cpp-build-errors.md) |
958 | | -[Auto-parallelization and auto-vectorization](../../parallel/auto-parallelization-and-auto-vectorization.md) \ |
959 | | -[Auto-Vectorizer in Visual Studio 2012 – Overview](/archive/blogs/nativeconcurrency/auto-vectorizer-in-visual-studio-2012-overview) \ |
960 | | -[#pragma loop()](../../preprocessor/loop.md) \ |
961 | | -[/Q Options (Low-Level Operations)](../../build/reference/q-options-low-level-operations.md) \ |
962 | | -[/Qpar-report (Auto-Parallelizer Reporting Level)](../../build/reference/qpar-report-auto-parallelizer-reporting-level.md) \ |
963 | | -[/Qvec-report (Auto-Vectorizer Reporting Level)](../../build/reference/qvec-report-auto-vectorizer-reporting-level.md) |
| 973 | +[C/C++ Compiler and build tools errors and warnings](../compiler-errors-1/c-cpp-build-errors.md)\ |
| 974 | +[Auto-parallelization and auto-vectorization](../../parallel/auto-parallelization-and-auto-vectorization.md)\ |
| 975 | +[Auto-Vectorizer in Visual Studio 2012 – Overview](/archive/blogs/nativeconcurrency/auto-vectorizer-in-visual-studio-2012-overview)\ |
| 976 | +[`#pragma loop()`](../../preprocessor/loop.md)\ |
| 977 | +[`/Q` Options (Low-Level Operations)](../../build/reference/q-options-low-level-operations.md)\ |
| 978 | +[`/Qpar-report` (Auto-Parallelizer Reporting Level)](../../build/reference/qpar-report-auto-parallelizer-reporting-level.md)\ |
| 979 | +[`/Qvec-report` (Auto-Vectorizer Reporting Level)](../../build/reference/qvec-report-auto-vectorizer-reporting-level.md) |
0 commit comments