Parallel Programming - Using OpenMP
OpenMP is a parallel programming model for shared memory parallel computers.
- OpenMP programs begin as a single thread - the Master thread, which executes sequentially until the first parallel region construct is encountered.
- Fork: the master thread then creates a team of concurrent threads, which will execute some user provided codes.
when the team threads complete, they are synchronized to wait each
other(barrier) and then terminate, leaving only the master thread ahead
Work Sharing Constructs
core functionality of OpenMP is to parallelly process data or execution
tasks, I.E, sharing work load. It provides several constructs to
- For, OpenMP will automatically divide these (independent) loop iterations and assign them to one of the team thread to execute.
- Section, programmer can define static code sections, each one will be (parallelly) assigned to one of the team thread to execute.
- Task, data and code can be (dynamically) packed as a task and the delivered to team thread to execute them.
OpenMP is designed for Fortran and C/C++. Its functionalities often exist in the following form:
- New Construct as Language Directive
- APIs as runtime library
- Environment Variables
Currently, visual studio 2008 supports OpenMP 2.5, OpenMP@MSDN
use OpenMP in VS2008 c++ developing, you only need to include omp.h
header and enable compiler flag /openmp (project property -> c/c++
-> language -> OpenMP Support)
More detailed tutorial can be found at .
I had written some OpenMP sample applications, it's compiled with vs2008 (except the task example).
 Parallel Programming with OpenMP and MPI
 Blog on OpenMP programming
 Intel on OpenMP traps
 Parallel Programming Model Comparison
 Microsoft on OpenMP version in Visual Studio
 More OpenMP sample applications