Adding more cores doesn’t guarantee your programs will go faster: You need to tell the programs how to use the cores. We’ll show you how to use OpenMP to speed up your code in just 30 minutes.
Now that your shiny new desktop and/or laptop computers have multiple cores in them, I’ll bet you’re thinking about how to make use of your new-found hardware. Just adding cores doesn’t make programs go faster, you also need to tell the program how to use the cores.
Programming Models
You can tell your program how to use those extra cores in many ways. The merits of each method require a more detailed discussion. In this article we are going to get you started on using OpenMP.
There are many ways to write and design programs. Programming models are abstractions that provide a framework for implementing the model. In a massive oversimplification, there are two major programming models for multiple processors; shared memory and distributed memory.
Shared memory models (sometimes called “shared everything” models) assume you have one or more CPUs/cores that can directly access and change all the variables in your program. Well not exactly this, but we are simplifying the situation.
Distributed memory memory models (sometimes called “shared nothing” models) assume that every CPU has access to its own memory space, and can alter its own local variables.
This seems like a minor semantic difference until you realize that you have to actively move data between CPUs in the distributed memory case, and you can assume a passive motion between CPUs for the shared memory case.
The rest of this article will focus upon shared memory programming using OpenMP, and provide some basic examples of how to get started…
Please log in to view this content.
Not Yet a Member?
Register with LinuxMagazine.com and get free access to the entire archive, including: