Notes on learning Openmp

May 30, 2024

Introduction about OpenMP API

Introduction

OpenMP API is used for writing parallel applications for shared memory computers for CPU and GPU architechtures. MPI+OpenMP for CPUs and OpenMP device offload are recommended.

OpenMP Overview

Managing threads and assigning loop distribution to threads. OpenMP: shared-memory parallel programming model All processors/cores access a shared main memory

The OpenMP Memory model:
All threads have access to the same, global shared memory
Data in private memory is only accessible to its particular thread.
Data transfer is through shared memory and is 100% transparent to the application.
image

OpenMP execution model: OpenMP programs just starts with just one thread: The Master
Worker threads are spawned at parallel region, together with master they form team of threads In below figure, the dotted lines indicates OpenMP Runtime taking care of thread management

image

Concept of Fork-Join in computer science: The idea of going parallel and then going sequential again
OpenMP implements incremental parallelization: We can start from sequential program at parallel region and over time make it a parallel program.
Never forget Amdahl’s law!