


























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



























2021 Parallel Computing | UNITEN^1
Objectives
OpenMP Is Not
OpenMP Targets Ease of Use
OpenMP Directive Format
A Simple Example Using parallel
#pragma omp parallel [clause ...] newline if (scalar_expression) private (list) shared (list) default (shared | none) firstprivate (list) reduction (operator: list) copyin (list) num_threads (integer-expression) } structured_block } *newline - Required. Precedes the structured block which is enclosed by this directive. ** Long directive lines can be "continued" on succeeding lines by escaping the newline character with a backslash ("") at the end of a directive line.
OpenMP parallel Region Directive #pragma omp parallel [clause list]
Number of Threads
Interpreting an OpenMP Parallel Directive Meaning
Specifying Worksharing
DO / for - shares iterations of a loop across the team. Represents a type of "data parallelism". SECTIONS - breaks work into separate, discrete sections. Each section is executed by a thread. Can be used to implement a type of "functional parallelism". SINGLE - serializes a section of code
Worksharing for Directive for directive partitions parallel iterations across threads
*- Usage: #pragma omp for [clause list] / for loop */
- Implicit barrier at end of for loop