Posted By: Jason Olson | Nov 13th, 2008 @ 7:37 AM | 57,144 Views | 16 Comments
Welcome back to another Visual Studio 2010 and .NET Framework 4.0 Week video. In this latest installment, we catch up with Rick Molloy, Program Manager on the Parallel Computing Platform team.

Rick takes us on a tour of the new parallelism features coming with C++ 10 via the Parallel Patterns Library. Covered are features like task groups, structured task groups, and agents-based parallelism, among many others.

Enjoy! 

This is another Visual Studio 2010 and .NET Framework 4.0 Week Video. For other Visual Studio 2010 videos, check out the Visual Studio topic area here on Channel 9.
Media Downloads:
Rating:
5
1
Sorry for the late response on this.  The C++0x library draft is here it has several crucial improvements to help with multi-threading (std::atomic, std::thread, and the locks), but doesn't address fine-grained concurrency in the same way that the PPL or the Concurrency Runtime does.  std::thread gives a developer a portable way to start threads (which is wonderful) and the atomics library and locks give folks a portable way to add thread safety and compare and swap operations, but the PPL provides a task abstraction and algorithms on top of it (similar to the STL algorithms) for describing potential concurrency in an application.  Specifically, I can build up generic 'algorithms' like those in the STL, for_each, accumulate, sort, transform and if as a developer I can guarantee that they won't be modified while being iterated upon (or provide safety), I can use the task_group and task_handles to implement versions of those algorithms that can be run in parallel. 

As far as getting access to ppl.h, check the blog at http://blogs.msdn.com/nativeconcurrency there is some content on the PPL, links to the CTP and links to the forums.

The helper function I showed make_task is not critical, it's a nicety.  task_handle is a template helper class and we need to specify a type for a functor.  I could use a std::function as the type, but again here this is binding it to a particular type, when the type of a lambda is intentionally anonymous, the helper function just makes it a little easier to express, particularly when the lambda is declared inside the constructor.

These are all syntactically correct (though compiled in this form)...

auto lambda1([](){  cout << " hello world from a task! " << endl';});

task_handle<function<void(void)>> task1(lambda1);
auto task2(make_task(lambda1));
task_handle<decltype(lambda1)> task2;

I can then schedule any of these with a structured_task_group or a task_group.

i.e.

structured_task_group tg;
tg.run(task1);
tg.wait();

or:
task_group tg;
tg.run(task2);
tg.wait();

structured_task_group is lighter weight and more efficient, but really for structured, nested or recursive scenarios (like building loops or algorithms), the task_group is more general purpose, the run and wait methods are threadsafe so can be use for unstructured parallelism, and work can be scheduled on it on multiple threads for example, or it can be waited on a separate thread than it was started on.

-Rick
al6
al6
Great, i get it now. I have actually learnt a lot since my first comment so i already knew most of it but now i also get the make_task template function. All it does is to allow me to use auto instead of explicity declaring the type, wouldn't it be great if you then shipped ppl.h with the make_task function? It does no harm to include it as far as i can tell.

Anyway; so i will have to use a task_handle with structured_task_group, wich is very easily done with decltype or if you include make_task Wink But task_group can directly take a lambda.

Ok thanks for the reply, this is very great to actually be talking to Microsoft and clearing things up. VS10 will be a great product, especially since i get it for free through dreamspark? Big Smile

here is the thing : we're in 2009, and I can't display your freaking video

-at home, on a standard mac....

- at work, on window because of your new wizzbang format for... videos ? (wtf?)

How can such a simple thing gets so complex ??

Really a good and interactive post, i think the post is informative and knowledge providing both in regard of current affairs and present economic Situations. by Free reminder

Agents are NOT intended to be used for fine-grained parallelism; for that, the patterns and constructs in the Parallel Patterns Library are better suited.

Academic Writing
Assignments
Case Study Assignment
Computer Programming Assignment

I have seen the "image" example in 2 or 3 videos now. Is there somewhere that this code is available? It would be a great tutor on how all this ties together. I have looked at the blog referenced above, but I have not been able to find the source code.

Microsoft Communities