To add parallelism to the single-threaded application, first inspect and become familiar with the demo application. Afterwards, discover places in the source code that can be executed on a different thread. Then, mark those places in the source code where parallelism might be possible and double check with Intel Advisor. Once you get confirmation on the potential performance gain, you transform the single-threaded app into a multi-threaded one by introducing an asynchronous task handler object.
- [Narrator] Even though the Intel Advisor comes with a stand alone GUI version, we start using the Intel Advisor by jumping straight into the Visual Studio integration option. Since we want to make a single threaded application multi threaded, the focus of this course is on the Advisor threading workflow. The blue boxes are the steps we are going to perform. The white boxes, in the workflow chart, are optional. We still perform some of the white box actions, like running the trip counts analysis, but the main steps are in blue. The workflow chart can be summarized into the following steps.
First we run a survey report, which will tell us where our hotspots are. Hotspots are places in our code where the CPU spends most of it's time and, as a result, the execution time for the application, as a whole, is longer. The survey report gives us our starting point, since it tells us which functions we should look at first. The trip counts analysis shows us the min, max and median number of times a loop body will execute. This is useful for vectorization, where SIMD instructions are used. SIMD stands for single instruction multiple data.
And this is where Intel Intrinsics, like SSE and AVX, come in to play. Annotations is the most crucial step in this course. This is how we perform our multi threaded design on the single threaded application. Annotations are markers that are ignored by the Visual Studio compiler and only used by the Intel Advisor. We place these markers later on, in the source code, in regions where we think parallel execution is possible. The Intel Advisor will then tell us what performance gains are possible, with the suitability report.
The suitability report predicts performance gains and helps us decide if making the application multi threaded is even worth our time. The last step we must run is the dependencies report, in order to see if we have any parallel data sharing problems. For example, if a global variable is being accessed and modified by multiple tasks, then that is a data sharing problem and code can't be made parallel. After going through those steps, we end up with an optimized multi threaded application, that can execute a lot faster.
Whereas before it took 3.17 seconds to complete, by the end of this course, it will only take 0.34 seconds and the number of threads will also increase, like we can see here. Keep in mind that every single time you run the Intel Advisor you can get a different elapsed time. The goal is to get that down, like we can see here.
- Installing Intel Advisor
- Sorting source code
- Integrating Visual Studio and Intel Advisor
- Discovering parallel code
- Adding markers for parallelism
- Predicting parallel behavior
- Predicting data sharing problems
- Adding parallelism with a task handler
- Forecasting performance gains