📜 ⬆️ ⬇️

Intel® Composer XE 2015 Beta: reporting is fine!


Finally, a beta program for Intel Software Development Tools has been launched. New versions of all the tools that Intel offers for developers are on the way. Let's see what interesting next compiler release will bring us.

So, in 2015, the beta version of Composer included C ++ and Fortran compilers v.15.0 beta, Math Kernel Library 11.2 beta libraries, Integrated Performance Primitives 8.1 and Threading Building Blocks 4.2 Update 3. As usual, all platforms are supported - Windows, Linux and OS X. Please note that the compiler version 14.1 is not and will not be (the previous version is 14.0).

The beta version again has the ability to perform calculations using integrated graphics - Intel Graphics Technology. I say again, because this functionality has already been tested in the previous beta version, but did not appear in the official release. Let's hope that this time she will see the light. The opportunity is interesting and certainly deserves special attention and a separate conversation. Support for Intel Xeon Phi has been added to IPP - here without surprises. In addition, new compilers “icl” and “icl ++” have appeared on OS X for better compatibility with clang / LLVM. Interestingly, for the C ++ compiler, the option -ansi-alias is now enabled by default, which was not there before, and the C ++ 11 standard is now fully supported.

Perhaps most of all the changes were made to the compiler's optimization reports, such as opt-report, vec-report, openmp-report and par-report. We will talk about them in more detail.
')
Let me remind you that they all gave out various information about what optimizations the compiler performed with the source code. Over the years, we have heard requests to improve these reports - to make them more readable, convenient and understandable. The most worried about the vectorization report, which is crucial for optimizing cycles. Let's see what has changed in practice using the example of a simple code with two functions and cycles:

void foo0(int n, int *a) { for (int i = 0; i < n; ++i) { if (n & 1) { a[i] = a[i+1]; } } } void foo1(int n, int *a) { // will not be vectorized due to data dependency. for (int i = 1; i < n; ++i) { if (n & 1) { a[i] = a[i-1]; } } } 

Having compiled the code with the previous version of the compiler, I, frankly, got a little confused in its output.

 >icl -Qopt-report -c test.cpp 

First, we received a whole set of information, very similar to some kind of internal, debugging and absolutely useless:

 <;-1:-1;IPO ROUTINE ATTRIBUTES PROPAGATION;;0> ROUTINE ATTRIBUTE PROPAGATION TOTALS: RDECL: NSE(0->0), AR(0->0) ENTRY: SE(0->0), DSE(0->0), AR(0->0) <;-1:-1;IPO MODREF;;0> CI-MOD: TOTAL(2):OTHER(2) CI-REF: TOTAL(2):OTHER(2) <;-1:-1;IPO;;0> 

You must admit that there is practically nothing to understand without the code of the compiler itself, but this is an IPO optimization, a fact. Therefore, below we see the values ​​of some parameters for inline and the corresponding report:

 INLINING OPTION VALUES: -Qinline-factor: 100 -Qinline-min-size: 30 -Qinline-max-size: 230 -Qinline-max-total-size: 2000 -Qinline-max-per-routine: 10000 -Qinline-max-per-compile: 500000 < test.cpp;2:8;IPO INLINING;?foo0@@YAXHPEAH@Z;0> INLINING REPORT: (?foo0@@YAXHPEAH@Z) [1/2=50.0%] 

The following is a vectorization report for the foo function:

 HPO VECTORIZER REPORT (?foo0@@YAXHPEAH@Z) LOG OPENED ON Wed May 14 14:38:33 2014 < test.cpp;-1:-1;hpo_vectorization;?foo0@@YAXHPEAH@Z;0> HPO Vectorizer Report (?foo0@@YAXHPEAH@Z) test.cpp(3:5-3:5):VEC:?foo0@@YAXHPEAH@Z: vectorization support: unroll factor set to 2 LOOP WAS VECTORIZED loop was not vectorized: nonstandard loop is not a vectorization candidate HLO REPORT LOG OPENED ON Wed May 14 14:38:33 2014 

And HLO report:

 <test.cpp;-1:-1;hlo;?foo0@@YAXHPEAH@Z;0> High Level Optimizer Report (?foo0@@YAXHPEAH@Z) Predicate unswitching Report: (Condition and loop line numbers) <test.cpp;3:4;hlo_opt_pred;?foo0@@YAXHPEAH@Z;0> Condition at line 4 hoisted from loop at line 3 

I will not continue the analysis of this conclusion, because it is obvious that all this is extremely inconvenient. It takes constantly from a heap of unnecessary information to look out for what interests us. Nevertheless, it was still possible to use such a tool - I got the information I needed about the vectorization of cycles, and something else about the transformations of the cycles themselves by the compiler, for example, in the function foo, they took the condition out of the cycle. But, obviously, such a report looks more like primitiveness.

So, with a flick of the wrist, I opened the console with a new version of the compiler and tried to do the same:

 >icl -Qopt-report -c test.cpp 

The result surprised me a little. I did not see anything in the console, because now the compiler defaults to send a report to the file with the .optrpt extension for each object user, and says this:

 icl: remark #10398: optimization reports are generated in *.optrpt files in the output directory 

Suddenly, and this must be prepared. In our case, the test.optrpt file appeared. This behavior can be changed and returned to the previous display in STDERR with the -opt-report-file: stderr key.
Well, let's see what is in this file. Immediately, attention is drawn to the fact that all unnecessary information in the form <; - 1: -1; IPRE MODREF ;; 0> and so on has been removed. The report is well structured and much more understandable. It begins, as before, with a report on IPO optimization, but now it is clearly prescribed:

 Report from: Interprocedural optimizations [ipo] IPO OPTIMIZATION REPORT: INLINING OPTION VALUES: -Qinline-factor: 100 -Qinline-min-size: 30 -Qinline-max-size: 230 -Qinline-max-total-size: 2000 -Qinline-max-per-routine: 10000 -Qinline-max-per-compile: 500000 

In general, the report added a lot of words about where the report starts, which facilitates understanding. Let's say this:
 Begin optimization report for: foo0 Report from: Interprocedural optimizations [ipo] INLINE REPORT: (foo0) [1] Report from: Loop nest, Vector & Auto-parallelization optimizations [loop, vec, par] … =========================================================================== Begin optimization report for: foo1 Report from: Interprocedural optimizations [ipo] INLINE REPORT: (foo1) [2] Report from: Loop nest, Vector & Auto-parallelization optimizations [loop, vec, par] … 

But most of all I was pleased with the information from the vectorizer of the following form:
 LOOP BEGIN at C:\Users\ivorobts\Desktop\opt-report\test.cpp(13,5) Predicate Optimized v1 remark #25426: Invariant Condition at line 14 hoisted out of this loop remark #15046: loop was not vectorized: existence of vector dependence remark #25443: unrolled with remainder by 2 remark #25014: Number of Array Refs Scalar Replaced In Loop: 2 LOOP END 

For each loop, there are now “beacons” of the form LOOP BEGIN ... LOOP END, so they are easy to distinguish. By the way, replacing the opt-report option with vec-report7, previously it was possible to obtain information only on vectorization, and with the greatest possible detail.
From this version of the compiler, the vec-report is still supported, but soon it will completely go away "for centuries", transferring all the powers of opt-report-phase: vec. Yes, and the maximum level set for the report is no longer 7, but 5. Let me remind you that in version 14.0, installation of level 7 (maximum) required the use of a special script to parse the output and bring it into a normal, readable form. Now it is organized without any scripts, and the maximum level is now 5, as in school.

So, we try:

 icl -Qopt-report:vec5 -c test.cpp 

Oops ... anyway, in the report we see the availability of information about IPO. An error that seems to be fixed soon. But the good old vec-report worked as it should, and there is nothing in the report file, except for the vectorizer report:

 >icl -Qvec-report5 -c test.cpp 

But you should not get involved in the use of separate options for each optimization - they will soon be completely “thrown out”.
With level 5 we got a lot of information about the cycle in the foo function:

 LOOP BEGIN at C:\Users\ivorobts\Desktop\opt-report\test.cpp(3,5) remark #15134: vectorization support: reference a has aligned access remark #15135: vectorization support: reference a has unaligned access remark #15127: vectorization support: unaligned access used inside loop body remark #15002: LOOP WAS VECTORIZED remark #36058: entire loop may be executed in remainder remark #36065: unmasked aligned unit stride stores: 1 remark #36066: unmasked unaligned unit stride loads: 1 remark #36091: --- begin vector loop cost summary --- remark #36092: scalar loop cost: 8 remark #36093: vector loop cost: 1.250 remark #36094: estimated potential speedup: 5.820 remark #36095: lightweight vector operations: 3 remark #36104: --- end vector loop cost summary --- LOOP END 

By the way, there is a good news - soon Visual Studio has to learn how to display these reports in a beautiful and convenient form, and it will not be necessary to pry and open files. They promise to add this feature, already described in the documentation for the beta version (Qopt-report-format: vs key), in the next update. Well, let's wait. In the meantime, everyone can try new features of the tools from Intel, including the compiler, by participating in the beta program , which will last until July 11. Your feedback on new features is very valuable to us, so thank you in advance and good luck!

Source: https://habr.com/ru/post/222769/


All Articles