Programming for multiprocessor and multicore systems remains a challenging endeavor. But if engineering code is to run faster as computers get faster, it is a technical challenge that both software developers and engineers have to understand and master.
In previous columns, I’ve discussed several approaches that vendors have offered to enable developers to more easily create code that can partition itself onto multiple processors or cores. But in most cases the approach requires an understanding of how to analyze a program structure and write code so that segments can be executed independently. Toolkits such as Intel’s Parallel Studio, NVIDIA’s Nexus (specifically for NVIDIA graphics processing units), and Mitrionics C can help, but still require a high level of skill by the programmer. And these toolkits don’t exactly take over all of the work for software engineers; they still need to intimately understand the application and what it takes to execute some of the code in parallel.
As design engineers, you may not see an immediate need to learn how to write code that can execute in parallel, but being able to do so will greatly speed up your applications. Scientists, mathematicians, and engineers have a lot of computations that can potentially run in parallel, and increasingly need to take advantage of multicore desktop and cluster computing power.
A few days ago I talked to Silvina Grad-Freilich, parallel computing manager at The MathWorks (http://www.mathworks.com) for MATLAB, the mathematics and engineering programming environment, about a series of announcements made by the parallel computing group around the time of Supercomputing 2009 in late November.
A bit more than a year ago, the MATLAB folks told me that you could use the MATLAB language to execute certain code segments in parallel. Specifically, MATLAB offered the ability to take an existing program that ran on the desktop, and wrap certain portions of that program in a construct known as a PAR FOR. This code will automatically be partitioned by the compiler and run on any number of processors or cores available. This seemed to me a good start in the quest to execute engineering code in parallel.
Of course, you had to identify the code that would run in parallel (a matrix or a FOR loop, for example), and insert the PAR FOR. These days, the MATLAB parallel toolkit will automatically identify those parts of a MATLAB program that can execute simultaneously, and run it on however many processors or cores are available (in practice, there was a limit of eight processors or cores at the time we had our last discussion, although this is likely to expand in the future).
The caveat is, of course, that it only works for MATLAB code. If your code calls other languages, or you have your MATLAB code embedded in the code of another language, the toolkit won’t automatically parallelize that other language.
MATLAB is a specialized programming environment for a particular type of engineering user, and it is unreasonable to think that the approach taken by The MathWorks parallel toolkit will work with more general-purposes languages. But this vendor is showing others what might be the best way to put the computing power that actually sits on their desks into the hands of engineers.
How can a more general-purpose toolkit provider imagine all of the circumstances where an arbitrary program could execute code in parallel, and identify those circumstances within a vast array of code? I’m not sure that the MATLAB model can be generalized, but other vendors should follow this lead. Engineers need to be able to fully use all processors and cores, but can’t become programming experts in the process. And now, MATLAB doesn’t require them to do so.
Contributing Editor Peter Varhol covers the HPC and IT beat for DE. His expertise is software development, math systems, and systems management. You can reach him at DE-Editors@deskeng.com.