PDC: Visual Studio 2010 CTP Adds Parallel Computing Tools
- By Kurt Mackie
- October 29, 2008
Microsoft released a Community Technology Preview (CTP) of Visual Studio 2010 and .NET 4.0 at its Professional Developers Conference (PDC) on Monday, and developers may be pleased with the new parallel computing capabilities now available in the CTP.
To better deal with the problems of concurrency, where threads of code run at the same time and sometimes share resources, Microsoft has added some new .NET Framework libraries to work with Visual Studio 2010.
The point of the new libraries is to provide developers with profiling and debugging tools for parallel computing while using the familiar Visual Studio interface.
The new .NET libraries include "the Task Parallel Library and Parallel LINQ, as well as the Parallel Pattern Library and Concurrency Runtime for developing native applications with C++," according to an Oct. 27 blog by Soma Somasegar, Microsoft's senior vice president of the Developer Division. The new Concurrency Runtime supports Windows operating systems down to XP.
In addition to that bit of news, this week's PDC features several sessions on parallel computing. On Monday, developers got a practical example of how to use Visual Studio Team System (VSTS) 2010 to debug a parallel app. The demo was presented by Hazim Shafi, Microsoft's principal architect on the parallel computing platform team. Shafi presented on the topic," Microsoft Visual Studio: Bringing out the Best in Multicore Systems."
Multicore is a bit limited these days, as it refers to about eight hardware processors working simultaneously.
Shafi noted that developers are being dragged into parallel computing by the limitations of hardware. Manufacturers can't make CPU chipsets faster that that won't overheat and melt. Hence, to exploit speed in code, developers have to think about taking advantage of that extra processing capacity enabled by multicore systems.
"The most important point to remember now and today is that single-thread performance is going to be relatively flat for the foreseeable future," Shafi said. "So we no longer have the free lunch of a doubling in performance every year and a half that we used to have for free, basically. What that means to us as software professionals is that the burden has shifted to us. We have to do more work now in order to exploit the latest performance that exists in these processors."
For developers, the worst thing to deal with is a sequential app that you have to parallelize, he said. In that case, you don't want to rewrite all of your code.
In a multicore world, the new problem for developers is that you have to worry about things like synchronization, he added.
To illustrate that problem, Shafi demonstrated a ray-trace graphics application. The demo, when run, showed two mirrored spheres. One sphere was bouncing and carrying the reflection of the other. The demo showed an out-of-sync bouncing sphere, and Shafi showed how the VSTS 2010 development environment can be used to debug such an application.
The profiler in VSTS 2010 can display a summary page that shows the resource use of the app. In the demo, the summary page showed how much time was spent in loop-computing the luminescence of every pixel in the lighted space of the ray-trace animation.
To measure performance issues, VSTS 2010 has a CPU utilization analysis view that shows the varying time spent using the core. There is also a core execution analysis view that shows you how your threads were scheduled on your hardware system.
You can switch to a thread locking view in VSTS 2010 to determine when a thread is running or not running.
VSTS 2010 also has profiler graphs that will show I/O delays in a color-coded display. You can click on the graph where a delay occurs and it will point to the code-line number in VSTS 2010 associated with that delay. Shafi said he used to do this kind of debugging by hand, and while there's still work to do, VSTS 2010 points to the problem and "it's relatively painless," he said.
"What we're trying to do here is release you from the painful aspects of parallelism," Shafi told the developer crowd.
Some coding changes made by Shafi involved substituting "for" loop statements with "parallel_for" statements -- a seemingly easy change to make.
Shafi didn't present VSTS 2010 as a cure-all for parallel computing woes, but he did offer some advice on how best to avoid problems. He recommended planning for parallelism in the future in applications, but "don't parallelize unless it's absolutely necessary," he said. Identify the areas of applications amenable to parallelism. The basic debugging approach is to reduce the I/O, improve caching and use efficient algorithms, he added.
At the end of the demo, after some code fixing, Shafi showed a bouncing ray-traced sphere that kept in perfect pace with its reflection. It all looked so easy!
Kurt Mackie is senior news producer for 1105 Media's Converge360 group.