0

OpenMP's tasks and parallel for loops seem like a good choice for concurrent processing within a specific process, but I'm not sure if it covers all use-cases.

What if I just want to spawn off an asynchronous task that doesn't need to return anything and I don't want to wait for it, I just want it to run in the background then end when done... does OpenMP have this ability? And if not can I safely use std:thread whilst also using OpenMP pragmas for other things?

And what if the spawned thread itself uses OpenMP task group, whilst the parent thread is also using another OpenMP task group for something else? Is this going to cause issues?

Alasdair
  • 13,348
  • 18
  • 82
  • 138
  • 2
    Don't do this, it will lead to thread over-subscription and will behave differently on different platforms. It seems you've outgrown OpenMP and need to do your own threading, e.g. using TBB. Also see [Can I safely use OpenMP with C++11?](https://stackoverflow.com/questions/13837696/can-i-safely-use-openmp-with-c11) – rustyx Apr 23 '21 at 08:13
  • Theoretically one can do pretty much everything via OpenMP, but one may have to get deep into it. And if one wants to get deep into this kind of thing in C++ one should probably use something that is written for C++. I haven't used TBB myself, but as far as I know it's probably the best candidate here. – paleonix Apr 23 '21 at 13:00

0 Answers0