Before we can run VTune Lock and Wait Analysis on our demo app we need to create a new project and configure the project properties. Doing this prep work is required for every project that you create in VTune. We add the path to our target application .exe, we add binary symbol search paths where the system environment variable _NT_SYMBOL_PATH that we added earlier is put.
- [Instructor] We have two options, when it comes to how we want to use Intel's Vtune Amplifier. The first is the standalone option, where we simply launch Vtune by itself, from the desktop icon, or from our Windows Start Menu. The second option, is the Visual Studio Integration option. The Visual Studio Integration option is the more popular choice, since it allows us to easily switch back-and-forth, from source code to results, all within the same environment. We will be spending the course inside Visual Studio, using this integration feature.
But, I still want to cover the standalone option. This standalone option is very useful, when you are profiling an application, or you do not have access to the source code. This is common, since developers are very reluctant to share their source code for obvious copyright and security reasons. You will still be able to see the application's behavior through Windows APIs it calls, and how the threads wait, but you won't be able to see the exact code lines being called, except in assembly-level instructions.
With that said, let's create a desktop shortcut by dragging the Intel Vtune amplifier from our Windows start menu, over to the desktop. Once it is on the desktop, right-click on it and run it as administrator. Click yes on any prompts that come up. We must run it as Admin in order to give the VTune amplifier system-level privileges, which it needs in order to access the set driver and perform other background tasks. Before we can run VTune Locks and Waits Analysis on our demo app, we need to create a new project and configure the project properties.
Doing this prep work is required for every project that you create in Vtune. So, to create a project, we go to this plus button at the very top, and click on it. For the project name, we'll put tachyon_standalone. We're going to leave the save location as is. By default it is saved to your users' documents folder. In amplifier/projects. Click on Create project and the project properties window pops up.
We're going to specify our application target by clicking on the browse button, next to the application field. Select the executable once you have located it. Now there's these other buttons, Binary/Symbol Search, and Source Search. I want to bring your attention to the Source Search, because this is what you would use if you did have access to the source files. You would specify the source code location by clicking on the Browse button here. But the Binary/Symbol Search, if you didn't set up your NT symbol path system environment variable, you would have to specify path to the pdb files here.
Since we have already done that, let's click on the Choose Analysis. Once the Analysis Type window comes up, click on the Locks and Waits Analysis. We're going to leave the check boxes unchecked and default options as is. Let's click Start and Vtune will launch our application and start the data collection. Afterwards we are taken to the summary page. Now this is just a preview of the results.
We will dive in and spend more time interpreting the results when we are inside Visual Studio. For now, I just want to bring your attention to the Bottom-Up tab. This shows the tasks that took the longest to execute. If I double-click on the first function in the call stack, this is where the Source Search comes in. If I expand this critical section, we can see this pthread_mutex_lock call. If I click on this, and select View Source, we're taken to the exact code line.
We can see the assembly-level equivalent by clicking on the Assembly button at the top. This is the assembly-level instructions equivalent of this line. If you don't know Assembly, that's okay, because if we right-click on one of these instructions and select Instruction Reference, a PDF will pop up and we are taken exactly to what that instruction means. So here we can see that this is a call procedure, meaning the assembly-level instruction is saying that we calling a function, which makes sense, since we're making a call to enter the critical section.
By the end of this course you will know how to use the Locks and Waits analysis on your own application and improve the efficiency of parallel task execution on Windows.
- Installing VTune Amplifier
- Choosing options for the Locks and Waits analysis
- Working with the VTune Amplifier GUI
- Viewing the analysis summary
- Removing the lock
- Conducting lock-removed analysis
- Comparing results