3 ms·
I was surprised there was no mention of OpenMP in the discussion of shared-memory parallel programming in C. OpenMP is a lot easier to work with (and is more c
by jn6118 1y ago
I was surprised there was no mention of OpenMP in the discussion of shared-memory parallel programming in C.
OpenMP is a lot easier to work with (and is more concise) than pthreads. It is introduced using pragma directives (so you can maintain serial and parallel versions in the same code). It includes support for many common parallel patterns (e.g. distribution of array based and task-based calculations) and makes the synchronisation easier (or automatic). It also gives you powerful control over work sharing to reduce load imbalance, etc.
It's available in most common C and C++ compilers and many other accelerated programming solutions wrap the API (e.g. you can use OpenMP within a Cython module, called from a Python script).