What’s the difference between “static” and “dynamic” schedule in OpenMP?

Others have since answered most of the question but I would like to point to some specific cases where a particular scheduling type is more suited than the others. Schedule controls how loop iterations are divided among threads. Choosing the right schedule can have great impact on the speed of the application. static schedule means … Read more

Pthreads vs. OpenMP

Pthreads and OpenMP represent two totally different multiprocessing paradigms. Pthreads is a very low-level API for working with threads. Thus, you have extremely fine-grained control over thread management (create/join/etc), mutexes, and so on. It’s fairly bare-bones. On the other hand, OpenMP is much higher level, is more portable and doesn’t limit you to using C. … Read more

OpenMP and Python

Cython Cython has OpenMP support: With Cython, OpenMP can be added by using the prange (parallel range) operator and adding the -fopenmp compiler directive to setup.py. When working in a prange stanza, execution is performed in parallel because we disable the global interpreter lock (GIL) by using the with nogil: to specify the block where … Read more

memory bandwidth for many channels x86 systems

The hardware prefetcher is tuned differently on server vs workstation CPUs. Servers are expected to handle many threads, so the prefetcher will request smaller chunks from RAM. Here is a paper that goes into detail about the issue you’re experiencing, but from the other side of the coin: Hardware Prefetcher Aggressiveness Controllers: Do We Need … Read more

Using OpenMP with C++11 range-based for loops?

The OpenMP 4.0 specification was finalised and published several days ago here. It still mandates that parallel loops should be in the canonical form (ยง2.6, p.51): for (init-expr; test-expr; incr-expr) structured-block The standard allows for containers that provide random-access iterators to be used in all of the expressions, e.g.: #pragma omp parallel for for (it … Read more

How are firstprivate and lastprivate different than private clauses in OpenMP?

private variables are not initialised, i.e. they start with random values like any other local automatic variable (and they are often implemented using automatic variables on the stack of each thread). Take this simple program as an example: #include <stdio.h> #include <omp.h> int main (void) { int i = 10; #pragma omp parallel private(i) { … Read more