Lecture 7 Flashcards
OpenMP?
An API for shared-memory parallel programming.
MP = multiprocessing
Designed for systems in which each thread or process can potentially have access to all available memory.
System is viewed as a collection of cores or CPU’s, all of which have access to main memory.
Pragmas?
Special preprocessor instructions.
Typically added to a system to allow behaviours that aren’t part of C.
What’s a team in OpenMP parlance?
A team is the collection of threads executing the parallel block- the original thread and the new threads.
What do master and slave mean in OpenMP parlance?
Master - original thread.
Slaves - additional threads.
pragma omp parallel?
Creates a parallel region of code. Instructs the compiler to parallelise the enclosed block of code, allowing multiple threads to execute the code concurrently.
pragma omp critical?
Used to define a critical section in the code. It ensures that only one thread at a time can execute the code within the critical section.
pragma omp single?
Designates a section of code that should be executed by only one thread in a parallel region.
Reduction operators?
Mathematical operations that are applied to a set of values in parallel. Always a binary operation.
A reduction is a computation that repeatedly applies the same reduction operator to a sequence of operands in order to get a single result.
pragma omp parallel for?
Allows a loop to be executed in parallel by multiple threads or processes. It divides iterations of a loop into smaller chunks and assigns them to different threads or processes for concurrent execution.
The expressions start, end, and incr must not change during execution of the loop.
During execution of the loop, the variable index can only be modified by the “increment expression” in the for statement.
There also cannot be any loop carried dependencies (the result of one iteration depends on the result of a previous iteration).