Is it safe (from the C++ runtime point of view) to mix PPL and C++11 concurrency constructs ? for example:
#include <amp_graphics.h> // for float_3
using namespace concurrency;
using namespace concurrency::graphics;
// omitted code for vInf initialization
// Reduce asynchronously vInf
std::future<float_3> min_future = std::async(std::launch::async, [&] // from C++11
return parallel_reduce(vInf.begin(), vInf.end(), float_3(FLT_MAX), (const float_3& a, const float_3& b) // from PPL
return float_3(min(a.x, b.x), min(a.y, b.y), min(a.z, b.z));
float_3 min_ = min_future.get();
Does the runtime allocate common concurrency resources (threads, sync objects, etc.) for PPL and C++11 ? If not, how does arbitration occur ? What about debugging such code (parallel tasks window in VS) ?
Thanks for the good question. Yes, it is perfectly safe and in fact intentionally designed to work well when composing these constructs. std::future is powered by PPL Tasks under the hood, and all the sync objects (std::mutex, critical section, conditional
variable etc.) are ConcRT aware in the sense that the underlying runtime reacts to the blocking call by scheduling pending tasks.
All futures show up as Tasks in the parallel tasks view window - which is the desired experience for parallel developers.