Is it worth the time to implement OpenMP?

Since clang / llvm does not plan to support OpenMP in the near future, and Intel is going far along the road from the TBB library. Still worth implementing multi-threaded science libraries (I'm working on ccv: http://github.com/liuliu/ccv ) on top of OpenMP? Despite all the criticisms, my experience with OpenMP is quite satisfied (it is very easy to use, and the performance gain is reasonable). But if it's a dying technology, then what is the replacement for a simpler, multi-threaded in C? (not pthread, but TBB is a C ++ thing). Thanks!

+4
source share
3 answers

OpenMP is alive and well, with some effort even to extend it to many things like accellerator. The introduction of OpenMP is sadly small in the Clang priority list, but all existing compiler providers (Intel, gcc, pgi, etc.) are committed not only to existing implementations, but also to current changes in the standard. I would not worry about that; in the end clang / llvm will come.

+3
source

If you look at C ++ 11 support in the clang list , you will notice that concurrency support is completely absent.

So, while the new C ++ standard does offer great features for concurrency and multithreading, we currently cannot use it if we want to remain platform independent.

So, if you have existing OpenMP code, don't sweat; clang is simply not supported, and although it’s a pity, it makes no sense to switch to another technology just because of this. Sure, you can use TBB, but Id says that in the light of C ++ 11, concurrency TBB is just a transition technology.

Personally, Id would be more than happy to see the last of OpenMP, but at the moment it was not.

+1
source

The new C standard, C11, has its own thread support, which follows the broken pthreads model. (C ++ 11 has the same thing, BTW). This cannot replace OpenMP, although in its simplicity it is possible to solve parallel loops and do reductions, etc.

There is one β€œnew” tool worth considering, _Atomic . Classic thread libraries only provide you with mutexes to avoid a race that can be quite heavy when some data overloads. _Atomic finally provides a low-level interface for functions that most processors have, and allows you to do quick updates on counters or similar things between threads without races.

_Atomic and OpenMP should work without problems.

0
source

Source: https://habr.com/ru/post/1402141/


All Articles