 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
|
 |
 |
 |
|
 |
|
|
 |
|
 |
 |
 |
| |
|
|
 |
 |
 |
|
|
| |
|
Parallel worlds |
 |
Simon Bisson talks to Intel’s Heinz Bast about the new tools that come with Parallel Studio to help Visual Studio C/C++ developers take advantage of multi-core systems. |
|
|
It wasn’t long ago that code efficiency didn’t really matter. If it didn’t perform well now you just had to wait: eventually the silicon would get fast enough to make even the most sloppiest code look good. However those days are now gone. Running processors faster than around 3.8GHz generates too much heat which means that, even though the number of transistors keeps increasing, individual cores aren’t getting any faster. Intel’s solution is to introduce more cores – up to eight this year and many more in the future through architectures like ‘Larrabee’.
Four cores on one chip is a whole symmetric multiprocessor architecture, ready for you to take your programs into a new parallel world. Traditional programming models work with only one processor and one core, and while parallel threads can run across multiple cores, it’s not easy to convert existing code to take advantage of parallel execution – especially when it’s native C and C++ code. This is where Intel’s new Parallel Studio comes in.
We talked to Heinz Bast from Intel’s Software Solution Group about Parallel Studio and the company’s approach to parallel application development. Bast told us: “The challenge of parallelising software has been around a long time, but it has been restricted to the high performance computing world. Tools exist, but only for the experienced programmer, and they tend to come from an 
Application Engineer Heinz Bast relaxes
before giving his talk at the 2009 Intel
Software Conference in Salzburg.academic background. Meanwhile multi-core architectures are moving to the desktop and the laptop, and parallel programming is now a problem facing the mainstream developer. Intel is targeting mass developers with new tools.”
Intel Parallel Studio
Currently in beta, Intel’s Parallel Studio will consist of four components:
• Parallel Advisor helps the developer gain insight into where parallelism will most benefit existing source code.
• Parallel Composer is a development tool and debugging bundle comprising Intel C++ Compiler for Windows, Intel Parallel Debugger Extension for Visual Studio, and the Intel Threading Building Blocks (TBB) and Integrated Performance Primitives (IPP) libraries.
• Parallel Amplifier is a tuning and profiling tool which provides hotspot analysis, indicating where CPU time is spent; concurrency analysis, indicating why a program is not using all the cores, and when is it over-subscribing to system resources; and lock and synchronization analysis, indicating where time is spent waiting to enter critical sections of code or doing I/O, both of which cause locks that considerably reduce parallelism.
• Parallel Inspector consists of a thread checker which detects race condition and deadlocks, and a memory checker which handles common memory issues (including leaks) and illegal accesses to memory that has already been de-allocated.
The initial release of Studio won’t contain Parallel Advisor as this is a complex piece of software, using many new techniques. However customers will be able to download a ‘Lite’ version from the Intel Web site free of charge.
Parallel programming in Visual Studio 2010
A major reworking of Visual Studio, Visual Studio 2010 will contain parallel programming support for both native and managed code applications. There’s improved support for multi-threaded applications in the Visual Studio IDE, and in Microsoft’s languages. Visual C++ developers get access to a Parallel Pattern Library offering native C++ libraries that work well alongside existing STL libraries, together with a new Concurrency Runtime that will manage the resources available from multi-core hardware, along with managing task scheduling.
If you’re working with managed code, then you’ll be using the Parallel Extensions to the .NET Framework. These add support for imperative data and task parallelism, declarative data parallelism, plus work coordination and managing shared state to the familiar .NET environment, and to applications built using Microsoft’s managed code languages such as Visual Basic and C#. There is also a set of new extensions to the .NET runtime. There’s even a parallel version of LINQ, called PLINQ, for working with data sources effectively, partitioning data between multiple threads.
Visual Studio debugging tools also get additional parallel programming features with parallel debugging windows, a consistency checker and a new set of profiling views. You can explore the task stack, sorting by whether tasks have started or have completed. The profiling tools show CPU utilization and thread timelines, as well as mapping threads to cores.
Parallel programming needs to be as easy as traditional application development. That’s why tools like Visual Studio 2010 and the Intel Parallel Studio are so important. Bast explains: “The tools need to be easy, covering important steps in a typical design cycle such as implementation and debugging.” It’s important to reach developer communities, and Bast has visited many ISVs: “They’re a little bit shocked, as they can’t use the hardware improvements for free anymore. In the past you could exploit new features without doing anything to your code, but now developers need to do things explicit to exploit additional cores. It’s a huge change.”
Tools like Advisor will be important. It’s hard for those who have only developed single-threaded applications to identify just how they can change their code to make best use of multiple cores. That’s Advisor’s sweet spot as it will help developers identify the sections of a program that can safely run in parallel, as well as showing the program features that get in the way of parallel execution, such as globally declared data that is shared by multiple threads. The Amplifier also has profiling tools which can be used to identify bottlenecks that can be removed by using multiple parallel threads.
Amplifier also helps you identify underlying problems in application design, tracking down algorithms that may make it difficult to take advantage of multiple parallel threads. If you know where a program uses the most CPU, or where it runs slow, it’s a lot easier to identify whether a problem is down to how you are working with memory and data, or if it’s due to a limitation of the platform. Clean up these problems and then run Amplifier over the code again to find areas where you can make further improvements.
It can be difficult to debug parallel applications as race and lock conditions can cause bugs that are non-deterministic: they exist but are not repeatable. Inspector includes a thread checker that analyses code using test cases, giving you a list of potential data races and deadlocks. Bast says, “It’s the key issue facing developers. Errors can come up in one run but not in another, and they’re very difficult to detect - unless you use a tool like Parallel Inspector.” When asked what the main cause of errors was, Bast noted that, “The main error class is race conditions, where multiple threads are writing to the same piece of memory. It needs protection.”
Once you’ve identified portions of code where you can take advantage of parallel execution, you can then use the tools bundled in the Composer to build your application, starting with Intel’s own C/C++ compiler. The easiest way is to choose the ‘–parallel’ switch to generate multi-threaded code automatically. If you want more explicit control then Parallel Composer offers various solutions. For example, the Intel compiler offers full support for OpenMP 3.0 extensions, and there is also Intel’s own TBB library which Bast describes as “Intel building blocks for C++ that add threading to Windows, bringing parallel execution to object oriented code.” Intel also provides its own library of common routines that you can use in your applications. The components and routines in the IPP library have been written to use multiple threads; so if you need a parallel execution H. 264 decoder, pick the library version, as Intel’s engineers have already done the heavy lifting for you.
Debugging parallel applications isn’t easy, as Bast points out: “It’s difficult to debug multi-threaded applications. It’s especially hard to observe thread behaviour and to single step through them.” The problem is at its worst when you’re working with several threads that are executing at the same time and accessing the dame data objects, so Intel Parallel Studio adds new debugging tools to familiar IDEs. The Intel Parallel Debugger Extension plugs in to Visual Studio so that you don’t have to learn a new development environment.
The parallel debugger can be used to track down and handle multi-threading specific bugs, including shared data access and re-entrant function detection. If you’re using OpenMP there’s also support for task hierarchies, wait lists and locks.

Graphic display makes it clear where the bottlenecks are in your code.
Visual Studio 2010 will include much more support for parallel execution, and as Bast points out Intel and Microsoft are “working very closely”, particularly on support for managed code (C# and Visual Basic), and on the Microsoft Concurrency Runtime Environment.
One myth about parallel programming is that only certain types of application are suitable for parallel execution. Even the smallest amount of parallel code can speed up applications, and it’s really only event-driven applications like text editors that can’t be given at least some parallel features. You may need to change your chosen algorithms to ones that offer easier parallelisation to get the best effect, and tools like the OpenMP API and Intel’s TBB make it a lot easier to make the shift to the parallel world – especially for applications that work with data held in arrays that are processed by simple for-loops. As Bast points out, people have ignored the need to shift to parallel code, but “there are eight-core systems this year, and many cores coming in ‘Larabee’. This is the future and it has to be faced.”

The Intel Parallel Debugger Extensions allow you to see potential problems
where
multiple threads are accessing the same data.
Intel’s support for parallel programming goes beyond the technology as it’s working to educate the next generation of developers. The Intel University Program includes on-site and online training, with workshops and events. There’s also a wide selection of free course materials including software tools, labs, and support. Staff teaching parallel programming can access Intel-sponsored research through the Intel Academic Community Web site.
Intel is looking at, and investing in, new parallel programming models such as Throughput Computing, transactional memory and Concurrent Collections for C++. Bast looks forward to discovering “what models and changes in programming languages will find acceptance in the developer community, as it’s the developer who will decide what works.” |
|
SIMON BISSON

Simon is a freelance IT writer and consultant. He can be found in South West London dreaming up new things to do with XML and Web Services.
.
simonb@hardcopymag.com
|
|
|
Find out more...
|
|
|
|
|
|
|
 |
|
|
 |
|
 |
Copyright © 1983-2010 Grey Matter Ltd. All rights reserved. |
 |
 |
 |
 |
|