MulticoreInfo.com header image 2

OpenMP: A Portable Solution for Threading

July 13th, 2010 · No Comments




By Shameem Akhter and Jason Roberts
The OpenMP standard was formulated in 1997 as an API for writing portable, multi-threaded applications. It started as a Fortran-based standard, but later grew to include C and C++. While the current version is OpenMP Version 3.0, this article is based on OpenMP Version 2.5 which supports Fortran, C, and C++. Intel C++ and Fortran compilers support the OpenMP Version 2.5 standard . The OpenMP programming model provides a platform-independent set of compiler pragmas, directives, function calls, and environment variables that explicitly instruct the compiler how and where to use parallelism in the application. Many loops can be threaded by inserting only one pragma right before the loop, as demonstrated by examples in this article. By leaving the nitty-gritty details to the compiler and OpenMP runtime library, you can spend more time determining which loops should be threaded and how to best restructure the algorithms for performance on multi-core processors. The full potential of OpenMP is realized when it is used to thread the most time consuming loops, that is, the hot spots.

Tackling the topic of OpenMP in a single article is an intimidating task. Therefore, this article serves as a bridge for you, allowing you to reach a point where you have a fundamental understanding of threading with OpenMP from which you can build your broader practical knowledge. The power and simplicity of OpenMP can be demonstrated by looking at an example. The following loop converts each 32-bit RGB (red, green, blue) pixel in an array into an 8-bit grayscale pixel. The one pragma, which has been inserted immediately before the loop, is all that is needed for parallel execution under OpenMP.

Full Story

  • Share/Save/Bookmark

Tags: MulticoreInfo

Like what you're reading? Come back every day for multicore news, or subscribe to RSS updates.



Stumble It!     


0 responses so far ↓

  • There are no comments yet...Kick things off by filling out the form below.

You must log in to post a comment.