Parallel Programming: Soon the Only Game in Town
Parallel Programming: Soon the Only Game in Town
How it’s done
“Parallel programming means mapping the code into ‘threads,’ ” says Weltzin. “A thread is just a piece of code that tells the operating system that it can run in parallel with other pieces of code. Each thread can then run on a different processor core.”
Parallel development begins with discovering parallelism in the problem that the program is intended to solve. For example, “Update all pixels in an image” exhibits data parallelism. The same task, “update,” is performed on each pixel datum. On the other hand, “Evaluate multiple properties within a chemical reaction system” exhibits task parallelism. Both the task (“evaluate”) and the data vary. Consultation with domain experts can reveal parallelism that is far less apparent.
Parallelism discovered in the problem is then used to develop an algorithm and data structures that can be expressed in a programming language. Parallel programming has such broad relevance that it can be profitably implemented at different levels: at a low level, closer to the computer, it offers great control and the last ounce of performance; at a higher level, closer to the physical problem, it offers convenience and domain focus.
In a typical architecture, the output of the previous step in a program is a sequential instruction that could execute in a parallel fashion but won’t yet. At this point, the programmer adds explicit parallel constructs in a notation that will allow the program to execute in parallel if multiple cores are available. The ways to do this include compiler directives, message passing, calls to thread libraries and custom‑programmed control of individual threads. Debugging parallel programs is critical—and difficult, especially when parallel threads share and modify the same memory. Tuning will almost certainly be necessary because small changes in a parallel program can significantly alter overall performance.
Weltzin advises, “If I were to make one recommendation to programmers who want to get into parallel programming, I’d say, ‘Look at the tools that are out there.’ ” But parallel programming will probably never be easy. “Parallel programming is simply a different way of thinking,” Weltzin concludes.
Marty Weil , martyweil@charter.net, is an Automation World Contributing Writer.
National Instruments Corp.
www.ni.com
Thinking Parallel
www.thinkingparallel.com
Intel Corp.
www.intel.com
Subscribe to Automation World's RSS Feeds for Columns & Departments









Comments(0)
Add new comment