Module 10: Open Multi-Processing
  Lecture 19: What is Parallelization?
 


OpenMP Directives

Parallel Region Construct

A parallel region is a block of code executed by multiple threads simultaneously
#pragma omp parallel [clause[[,] clause] ...]
{
“this is executed in parallel”
} (implied barrier)

Clauses Supported

if (scalar expression)
private (list) firstprivate (list) shared (list)
default (shared|none)
reduction (operator: list)
copyin (list)
num threads (integer-expression)

Example 1

A Multi-threaded “Hello World” Program

Example Code

#include “omp.h”
void main(){
#pragma omp parallel
{
int id = omp get thread num();
printf(“hello(%d)”,ID);
}
}