views:

76

answers:

1
+2  Q: 

What is OpenMP?

What's a high-level description of OpenMP?

The Wikipedia article states that "OpenMP (Open Multi-Processing) is an application programming interface (API) that supports multi-platform shared memory multiprocessing programming in C, C++ and Fortran on many architectures, including Unix and Microsoft Windows platforms. It consists of a set of compiler directives, library routines, and environment variables that influence run-time behavior." What?

How does it compare to other approaches to concurrency, like threads, thread-pools, and work-stealing?

+3  A: 

It's a set of extensions to provide C/C++ with the ability to run certain parts of the code in parallel, without explicitly managing (creating, destroying, assigning) threads.

It basically abstract you from the complexity of managing threads your self by allowing you to declaratively run certain portions of your code in parallel. A code sample always help:

# pragma omp parallel \
  shared ( n, x, y ) \
  private ( i ) \
  reduction ( + : xdoty )

# pragma omp for

  for ( i = 0; i < n; i++ )
  {
    xdoty = xdoty + x[i] * y[i];
  }
Pablo Santa Cruz
Isn't there a 'parallel' missing at the last pragma?
tur1ng
Don't think so. But not sure.
Pablo Santa Cruz