Ask HN: What C++ parallelization framework do you use?
5 comments
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.
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.
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?
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.
Modern C++ has some great, simple constructs like std::thread and std::mutex.
What kind of parallelization do you need?
What kind of parallelization do you need?
seems like OP wants something without explicit threads/locks if they mentioned Kokkos/OpenMP type constructs...just a hunch.
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.
If anyone has a multi-threaded conundrum, I'd be glad to discuss it.
All opinions welcome, thank you!