What type of multithreading is best studied?

I want to learn multithreading in C ++, but I'm not sure which type would be most useful. The ones I saw are dedicated to:

  • Windows native calls
  • Openmp
  • Increase

(I'm sure probably more.)

What are each of the key features and what are they best used for?

Note. I have already done multithreading in C # by creating threads manually, and the complexity of threading will just make it more fun. :)

+6
source share
4 answers

What about TBB ? It is portable and has easy-to-use parallel template templates, parallel containers, a task scheduler, and scalable memory assistants. TBB allows you to directly control the flows, but this is not necessary in most cases.

Personally, I would stay away from specific threads on the platform, if there was no urgent need to do something, well, a specific platform.

Boost streams are portable and easy to use, but have neither parallel patterns nor parallel containers. You will need to manage the threads manually, which can become ugly pretty quickly.

PThreads is not available on Windows and its C. You really want multithreading in C ++, not C. RAII goes well with mutexes and fixed locks.

Another option is PPL in Visual C ++ 2010. It is similar to TBB, but, as you can assume, it is available only for Windows.

OpenMP is easy to use but not very flexible. Since you already learned C ++, you should use something more serious, like TBB or PPL. For some strange reason, Visual C ++ 2010 does not support OpenMP 3. Too bad.

+3
source

I would start with pthreads if you have more C background or Boost Thread if you are used to more idiomatic C ++. Any of them is quite portable and widely used.

+5
source

If you want to be portable, explore Posix topics. You know, all thread libraries provide more or less the same set of functions, so it is up to you, but Posix will provide you with the foundation.

openMP is not exactly โ€œmultithreaded,โ€ as you mean it.

+3
source

Maturereads (Windows) and pthreads (Linux) are POSIX threads and are probably your best bet to get started. It is important to know the difference between processes and threads, and then learn about the different memory access models that are associated with them. Then try using concurrency approaches like OpenMP and MPI streams.

There are several basic concepts that will be repeated. Learn them well.

+1
source

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


All Articles