0% found this document useful (0 votes)
45 views24 pages

Openmp: John H. Osorio Ríos

OpenMP is an application programming interface that provides a portable model for developers of shared memory parallel applications. It supports C/C++ and Fortran. OpenMP uses compiler directives, runtime library routines, and environment variables to explicitly direct multi-threaded, shared memory parallelism. It uses a thread-based programming model with a fork-join execution model. OpenMP programs can be compiled with compiler flags and executed by setting environment variables to control the number of threads. Common OpenMP directives include parallel, work-sharing, and synchronization constructs to divide work across threads.

Uploaded by

Juan Suarez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views24 pages

Openmp: John H. Osorio Ríos

OpenMP is an application programming interface that provides a portable model for developers of shared memory parallel applications. It supports C/C++ and Fortran. OpenMP uses compiler directives, runtime library routines, and environment variables to explicitly direct multi-threaded, shared memory parallelism. It uses a thread-based programming model with a fork-join execution model. OpenMP programs can be compiled with compiler flags and executed by setting environment variables to control the number of threads. Common OpenMP directives include parallel, work-sharing, and synchronization constructs to divide work across threads.

Uploaded by

Juan Suarez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

OpenMP

John H. Osorio Ríos


Abstract (1/1)

● OpenMP is an Application Program


Interface.
● Provides a portable, scalable model for
developers of shared memory parallel
applications.
● Supports C/C++ and Fortran.
What is OpenMP? (1/2)

● May be used to explicitly direct


multi-threaded, shared memory parallelism.
● API Components:
○ Compiler Directives
○ Runtime Library Routines
○ Environment Variables
What is OpenMP? (2/2)

● An abbreviation for:
○ Short Version: Open Multi-Processing
○ Long Version: Open Specifications for
Multi-Processing via collaborative work
between interested parties from the
hardware and software industry,
government and academia.
Goals of OpenMP (1/1)

● Standardization
● Lean and Mean
● Ease of Use
● Portability
History (1/1)
OpenMP Programming Model (1/4)
OpenMP Programming Model (2/4)

● Thread Based Parallelism:


○ Exclusively through the use of threads
○ A thread is the smallest unit of
processing
○ Number of Threads = Number of
Processors
OpenMP Programming Model (3/4)

● Explicit Parallelism:
○ Isn’t automatic programming model.
○ Offers to the programmer full control
○ Can be as simple as inserting compiler
directives …
○ Or as complex as using multiple levels
of parallelism, locks, even nested locks
OpenMP Programming Model (4/4)

● Fork - Join Model:


OpenMP API Overview (1/4)

● Compiler Directives:
○ Appear as comments in the source code
○ Need to use a compiler flag
○ Have the following syntax
OpenMP API Overview (2/4)

● Runtime Library Routines:


○ Setting and querying the number of threads
○ Querying a thread’s unique identifier
○ Setting and querying the dynamic threads feature
OpenMP API Overview (3/4)

● Environment Variables:
○ Setting the number of threads
○ Binding threads to processors
○ Enabling/disabling dynamic threads
OpenMP API Overview (4/4)

● OpenMP Code Structure:


Compiling OpenMP Programs (1/1)

● gcc test.c -o test -fopenmp


OpenMP Directives (1/3)

● Parallel Region Construct:


OpenMP Exercise (1/1)

● Download the source code from here


● Compile the code
● Run the code
● Change OMP_NUM_THREADS
environment variable and run again
OpenMP Directives (2/3)

● Work-Sharing Constructs:
OpenMP Directives (3/3)

● Work-Sharing Constructs:
OpenMP Exercise (1/1)

● Download the source code from here


● Compile the code
● Run the code
TODO (1/1)
● Implement the matrix multiplication using openmp
● Make some test and try to figure out the best number
of threads to use.
● Remember to measure the execution time of the
program.
Bibliography (1/1)
● http://www.openmp.org/mp-documents/OpenMP4.0.0.
pdf
● http://www.openmp.org/mp-documents/OpenMP3.1.p
df
● https://computing.llnl.gov/tutorials/openMP/
THANKS
[email protected]

You might also like