Stephen Blair-Chappell is a technical consulting engineer at Intel.
One of the fun things I do as an Intel technologist is to speak at various conferences and seminars. The hottest topic of the year at these events has been "how do I make my program parallel?". To answer this question, I decided to use Intel Parallel Studio which is designed to help programmers to develop and debug parallel applications. Parallel Studio is ideal for Windows C\C++ programmers who write and develop programs using Microsoft Visual Studio.
Parallel Studio consists of four tools that plug into Visual Studio:
- Intel Parallel Advisor
- Intel Parallel Composer
- Intel Parallel Inspector
- Intel Parallel Amplifier.
In my presentations I show how to change a serial application into parallel. The techniques I used are not new -- I've been promoting the same four-stage development cycle for the last 18 months. What was new was the use of the Parallel Studio as a complete solution. In this development cycle (see Figure 1) I first analyse an existing application looking for the best place to apply parallelism. I then add parallel code to the spot just identified. Following that I verify that the code I have added is correct and has no parallel-type bugs. Finally I tune the parallel application.
Analysis
The program I use as a starting point is one that calculates the value of Pi using an approximate integration technique. In this first stage I am interested in identifying hotspots in the code, since these are likely to be the best place to add parallelism. Using Parallel Amplifier, it can be seen that at the heart of the code is a function that does all the donkey work.
Code and Debug
For my example I decided to use OpenMP as the means of adding parallelism. OpenMP is easy to use and is great for incrementally introducing parallelism to applications. My first attempt looked like this:
double CalcPi()
{
double pi, sum=0.0;
#pragma omp parallel for
for (int i=0; i<num_steps; i++)
{
sum = CalcSum(i,sum);
}
pi = sum*step;
return pi;
}
If you're an expert, you've already spotted the errors in my code. These errors will become obvious in the next stage of the development cycle.
Intel Parallel Composer users have several options on how to implement their parallelism. As well as supporting OpenMP, Parallel Studio includes a simplified parallel language extension; Threading Building Blocks; and Win32 native threads. Alongside the compiler comes a parallel debugger that extends the Visual Studio debugger to make parallel debugging simpler.
Verify
I'm told that one of the biggest hurdles stopping programmers from introducing parallelism in their code is the fear that they will introduce diffi cult to find errors. Parallel Inspector helps programmers detect parallel type errors such as data races and deadlocks, as well as memory leaks (see Figure 2).
In my application, Inspector identified two data races which I then corrected by modifying the code. One of the great things about Parallel Studio is how easy the tool can be configured. For example, when using Parallel Inspector the analysis type is selected by simply turning a dial (Figure 3).
Tune
The Intel Parallel Amplifier is used to spot load in balances and threading overhead. In my Pi program, Parallel Amplifier confirmed that my application had a high degree of parallelism with no threading overhead (Figure 4).
Conclusion
The things that stick out for me are ease-of-use and that all the required components of Parallel Studio integrate into the Microsoft Visual Studio from a single installer. That means you don't have to hunt around for different packages and licences.


