x
Loading
 Loading
Hello, Guest | Login | Register

OpenMP in 30 Minutes

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:

  • Hands-on Content
  • White Papers
  • Community Features
  • And more.
Already a Member?
Log in!
Username

Password

Remember me

Forgotten your password?
Forgotten your username?
Read More
  1. Power Up Linux GUI Apps
  2. Tweeting from the Command Line with Twyt
  3. When Memory Serves You: Using ramfs and tmpfs
  4. Disk-O-Tech: Linux Disk Management
  5. Bang for the Buck
Follow Linux Magazine
Rackspace