
Ask HN: What C++ parallelization framework do you use? - vanilla_nerd
There seems to be a huge selection of parallelization frameworks for C++ to choose from. Help me choose! I want to write threaded code in C++ without a lot of extra code (basically I want something simple to code but with the power of threads). I looked at TBB, OpenMP Tasks, Kokkos, C++11 threads, RaftLib, FastFlow, and several others. Seems like like Kokkos, RaftLib and FastFlow get away with the least boilerplate code but they all seem rather early stage. Kokkos looks like it&#x27;ll do GPGPU which is cool but not necessarily a requirement. Googling turns up lots and lots of frameworks. Is there anything more mature out there? I like using Go and feel like there should be something similar to channels&#x2F;pipelines C++. TBB looks like it could be used for this (and is mature) but it seems like its a lot more work&#x2F;clunkier than the other frameworks. I could do it myself with boost, but again...lots of boilerplate code. There doesn&#x27;t seem to be a perfect option.<p>All opinions welcome, thank you!
======
davismwfl
There isn't one correct framework for threading in C++. Your use case will
help drive which one will work the best. A lot of times OpenMP is all anyone
every needs and it does the job really well and isn't that hard to figure out.
But other times you need something different so maybe boost threads or another
package. I'd typically stick with a more mature library over something fresh,
mainly because things that have some miles and time on them are easier to
predict what will happen. Yea you'll live with some tradeoffs usually but at
least you have a better idea what you are getting. Not a dig on new libraries,
I just like to stick to mature libraries for production products and keep new
libraries to research and experiments.

------
blackflame7000
C++11 Threads are your building blocks. They are a core part of the language
and are portable. I personally however prefer to use Qt and their style of
threading via QThread and QueuedConnections between QObjects. It makes it much
easier to designate cross-thread member functions from private member
functions that run exclusively in one thread.

------
f0llowL8r
As much as I like new frameworks, I'm going to have go agree. For products
more mature things are likely better long term. My experience boost tends to
change too many things too rapidly. that leaves TBB and OpenMP. Looking at the
other frameworks you mentioned, it seems RaftLib is the closest to Go for
C++...although I'd wait awhile before putting it in a production product
unless you want to beta test something with customers on the line. For general
open source, hacking, and others stuff where your companies dollars aren't
directly on the line..why not try out new frameworks?

------
quinnftw
I've found that most of my multithreading needs can be serviced by a simple
thread pool that I rolled using the constructs that c++ provides (std::queue,
std::thread, and std::future mainly). Obviously it's not heavily optimized,
but for CPU bound tasks it gets the job done and doesn't require any heavy
lifting installing libraries and what not.

------
bwackwat
Modern C++ has some great, simple constructs like std::thread and std::mutex.

What kind of parallelization do you need?

~~~
xf00ba7
seems like OP wants something without explicit threads/locks if they mentioned
Kokkos/OpenMP type constructs...just a hunch.

~~~
bwackwat
Right. I think it is quite practical to wrap std::thread into "tasks" using
std::mutex and/or std::atomic<T>.

If anyone has a multi-threaded conundrum, I'd be glad to discuss it.

