Skip to content

akares/openmp_playground

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This repository contains my reference examples of OpenMP API specification for parallel programming. It is based on the amazing Introduction to OpenMP by Tim Mattson (Intel).

Contents

hello.c — demonstrates how parallelisation is useless without synchronisation.

pi.c — calculates Pi in a good old one-threaded serial way. Used just as a starting point for performance improvements.

pi_par.c — basic usage of parallel pragma, single construct and atomic sync primitive. Forks a few worker threads and aggregates the final result in a thread safe way.

pi_par_loop.c — basic usage of parallel for and reduction to parallelize the loop and aggregate the result. Compared to parallel approach above it keeps the code structure close to its serial version.

sharing.cdefault, firstprivate, lastprivate, linear, none, private and shared data-sharing attribute clauses examples from OpenMP documentation.

utilise_cores.c — example of how to properly force exactly one thread per core.

...TBA

Usage

Compile and run all the examples:
make test

Complile and run one specific example:
make pi_par.exe && ./pi_par.exe

The .exe extension is used just becaue it's easier to ignore it in .gitignore.

Supported platforms are macOS and Linux (can be modified to run in Windows but nobody cares). See Makefile for details.

About

Reference examples of OpenMP API specification for parallel programming.

Resources

Stars

Watchers

Forks