Introduction to OpenMP Flashcards
(21 cards)
What is OpenMP?
A specification for shared memory parallel programming with C, C++, or Fortran
How is OpenMP used?
OpenMP provides extensions to specify where parallelism should be added and how to add it.
What are the three types of OpenMP extension?
- Compiler Directives
- Environment Variables
- Runtime library routines
What execution model does OpenMP use?
Fork-Join Execution model
How are OpenMP directives designated?
pragma
What compiler flag is used for OpenMP?
-fopenmp
What is OMP_NUM_THREADS used for?
It controls the number of threads forked in a parallel region
What routines are included in the OpenMP runtime library?
- Routines to control and query the execution environment
- Timing Routines
- Device memory routines for managing memory and pointers on accelerators
- Locking routines to synchronise access to data
How are OpenMP functions made available?
Including the omp.h header file
What does the C pre-processor do?
It processes source code before it is passed to the compiler
How is conditional compilation defined?
Using the #ifdef preprocessor directive to only compile a section if a macro is defined.
How is work load distributed between threads?
By parallelising for loops inside a parallel region this enables different threads to carry out different iterations of the loop.
What is a data race?
When multiple threads try to update the same variable at the same time, causing the updates to the variable to be corrupted.
What is reduction?
Combining results from multiple threads into a single value using a reduction operator.
What is a data dependency?
if one statement reads from or writes to a memory location AND another statement reads from or writes to a memory location AND one or both of these accesses are writes.
What is a loop carried dependency?
When there is a dependence between statements executed by different iterations of a loop.
What are three types of loop-carried dependencys?
- Flow Dependency
- Anti-dependency
- Output Dependency
What is a flow dependency?
Known as a read-after-write dependency, or a true dependency, it is not possible to resolve this dependency in parallel.
What is an anti-dependency?
Also known as a write after read dependency, an iteration of a loop requires the next element when it has not been updated. This is resolved using a different array to ensure iterations are independent.
What is an output dependency?
When two statements write to the same memory location there is an output dependency. Corrected by using a lastprivate variable.
What are the issues with data dependencies?
If a loop is parallelised, then data dependencies will result in incorrect behaviour.