Skip to content

niksterg/openmp-course

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

83 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenMP Examples

Prof. N. Stergioulas

Aristotle University of Thessaloniki

Example programs

The following example programs introduce the main concepts of OpenMP step by step.

  1. hello-world-parallel.c (the most basic hello world executed in parallel)

  2. hello-world-parallel-id.c (similar to 1. but the id of each thread and the total number of threads are also printed)

  3. hello-world-parallel-id-func.c (same result as 2. but a function is called to print inside the parallel region)

  4. hello-world-parallel-id-scope.c (same result as 2. but data scope is used in the parallel region)

  5. table-add1-manual.c (add a number to each element of a table, using manual parallelization)

  6. table-add1.c (same result as 5. but with automatic work scheduling)

  7. table-add1-combined.c (same result as 6. but with combined parallel region and for construct)

  8. table-add1-wrong.c (similar to 6. and 7. but giving wrong answer - find the error in the code!)

  9. table-implicit-notpar.c (parallel execution gives wrong answer - find out why!)

  10. table-sum.c (computing the sum of all elements in a table)

  11. table-sum-wrong.c (similar to 10. but gives wrong answer - find the error in the code!)

Exercises

2020 Homework on 2D wave equation

2019 Homework on Poisson solvers (see this figure)

poisson-SOR.c Example: ./poisson-SOR -N 400 -M 400 -a 1e-6 -o 1.9

2023/24 Homework:

Set #1:

  • Run the examples 1 - 10.
  • Find and correct the mistakes in examples 8, 9 and 11.

Set #2:

  • Write a code in C/C++ that calculates π using a Monte-Carlo method. Use up to 10^10 points.
  • Parallelize the code using OpenMP. Run the code using 1, 2, 4, etc. threads (up to twice the physical number of cores, try at least up to 8).
  • Create a Jupyter python notebook within which you automatically run the C/C++ code using different number of cores (use a list) and plot the execution time as a function of the number of cores. Alternatively, run the C/C++ code using a script, save the results in a file and load them into a Jupyter notebook to make the plot.
  • In the same notebook, create a second plot of parallel speedup vs number of cores.
  • Use Amdahl's law to fit the resulting curve and find the proportion p of the code that benefits from parallelization and the maximum possible speedup in the limit of 10000 cores. (You can do the fit with e.g. spipy's curvefit.)
  • Run the code for 10^2, 10^3, 10^4, ... , 10^11 points and, in a second notebook, calculate the convergence rate of your Monte-Carlo implementation. You can do this if you fit a line in a log-log- plot of the error in calculating π vs. the number of points. Try to find what the theoretical expectation is and compare your result to it.

Use logarithmic scale wherever the numerical values change by orders of magnitude!

(Bonus track: repeat with Python+Numba and/or Julia)

2024/25

Example code: 2D Laplace equation with OpenMP

Example codes: Calculate pi using MCMC, with OpenMP, but also in python and Julia

Example code: Multi-dimensional regression using ANN

2024/25 Homework (due Feb. 28):

Set #1:

  • Run the examples 1 - 10.
  • Find and correct the mistakes in examples 8, 9 and 11.

Set #2:

OpenMP: Decide on your own problem to parallelize with OpenMP and construct a similar report as for Set #2 of 2023/24, following the guidelines in that problem set.

Set #3:

Select a multidimensional regression problem (real data or synthetic data that you create) and write an ANN to predict y(X). Perform many trainings varying the hyperparameters and write a report with your findings. You can use data from Kaggle or from other sources or from your own experiments or create your own synthetic data. Submit a) your codes, b) link to the data c) a detailed report of your findings.

2024/25 Homework (due Jan. 31):

Area of Mandelbrot set

Tutorials

  1. Tutorial by N. Trifonidis (part 1)
  2. Tutorial by N. Trifonidis (part 2)
  3. A brief introduction by A. Kiessling
  4. Tutorial by S.C. Huang
  5. Tutorial by Texas A&M
  6. Tutorial by T. Mattson and L. Meadows
  7. Tutorial by Y. W. Li (includes Vtune examples)
  8. Online tutorial by B. Barney
  9. Online tutorial by Y. Yliluoma
  10. Online list of potential mistakes
  11. Video tutorial by C. Terboven (part 1)
  12. Video tutorial by C. Terboven (part 2)
  13. Video channel by PPCES
  14. Additional resources
  15. OpenMP 3.1 Quick Reference Card

License

Content provided under a Creative Commons Attribution license, CC BY-NC-SA 4.0; code under MIT License. (c)2018 Nikolaos Stergioulas

About

OpenMP Course at AUTh examples

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors