Samples updated for ConcRT, PPL and Agents

We’ve posted an update to our sample pack at for the release candidate of Visual Studio 2010. There’s a lot of good stuff from the team here including demos, concurrent data structures and additional parallel algorithms and helper functions.

New Demos:
There are 3 new demos in the sample pack:

The parallel plug-in for excel we blogged about earlier is now available in the sample pack it’s a great example of how to use the PPL for financial applications and how to build an excel plug-in in C++.

An n-bodies implementation has been built on top of Direct2D and is an example of how to build an application from the ground up using both the Agents library and the PPL for fine-grained concurrency and asynchronous communication.

Carmichaels is a very short example I put together for PDC to show the performance gains of nesting parallel loops and relies on the algorithms in ppl_extras.h

Here’s what’s new (and old) in the concrt extras:

ppl_extras.h has been updated to include parallel_sort, parallel_merge and parallel_count_if which as usual mimic their stl counterparts. It also contains what was added in the previous update: parallel_accumulate (reduce), parallel_partial_sum (scan), parallel_transform (map), parallel_all_of, parallel_any_of, parallel_none_of and also parallel_for_fixed, parallel_accumulate_fixed, parallel_partial_sum_fixed.

agents_extras.h additional useful message blocks like priority_buffer, bounded_buffer, alternator, join_transform and  a recalculate_buffer.

concrt_extras.h contains useful wrapper classes and functions from the runtime itself like concrt_suballocator a std::allocator built on Concurrency::Alloc, task_scheduler, schedule_group and schedule_task which are simple wrapper classes around Scheduler and ScheduleGroup that offer functor support like PPL for scheduling tasks.

connect.h contains a new helper API called ‘connect’ for connecting and disconnecting message blocks and agents that contain message blocks, a blog post will follow but this presents a cleaner interface for managing a mix of pointers and references to message blocks.

concurrent_unordered_map,h and concurrent_hash_map.h: as their name implies these are lock-free implementations of an unordered_map and hash_map.

semaphore.h and barrier.h: contains efficient and concrt aware implementations of a semaphore and barrier.

These are located in the Concurrency::samples namespace and the team will be blogging about many of these over the coming weeks, but please feel free to ask any questions here or in the forums.


Comments (6)
  1. Cory Nelson says:

    Awesome, can’t wait to play around with these new things.  I’ve been using the concrt stuff since the RC came out and have been very impressed.

  2. Ayman Shoukry says:

    Hello Cory,

    Thanks for your feedback. We would love to understand more about the scenarios you are using ConcRT for. We started planning for the next release and hence any feedback would be very much appreciated. Please feel free to send me more details directly at "aymans at microsoft dot com"


    Ayman Shoukry

  3. Nikola says:

    I can see that your Concurrency namespace still has capital C. Will this change?

  4. Robin says:

    Hi there,

    parallel_for_fixed and parallel_for_each_fixed don’t seem to compile in the released version of VS2010 – the _Parallel_chunk_impl template function now expects 8 parameters but the code in ppl_extras.h only passes 4. Is there an update on the way or a relatively easy fix for this?



  5. artur.laksberg says:


    It appears that there is an error in one of the header files we released.

    We’re looking at it right now and will issue an update if necessary. Stay tuned!

    Artur Laksberg

    ConcRT Team

  6. artur.laksberg says:


    Thank you again for reporting this bug! We fixed the problem and released the new sample pack (v 0.32) here:

    If you want to quickly patch the problem in-place, open ppl_extras.h file and replace line 161:

                       ::Concurrency::_Parallel_chunk_impl<worker_class>(first, range, step, func);

    with the following lines:

                       // Get the number of chunks to divide the work

                       index_type num_chunks = _Get_num_chunks<index_type>();

                       index_type iterations;

                       if (step != 1)


                           iterations = ((range – 1) / step) + 1;




                           iterations = last – first;


                       // Allocate memory on the stack for task_handles to ensure everything is properly structured.

                       task_handle<worker_class> * chunk_helpers = (task_handle<worker_class> *) _alloca(sizeof(task_handle<worker_class>) * num_chunks);

                       structured_task_group task_group;

                       ::Concurrency::_Parallel_chunk_impl(first, iterations, step, func, task_group, chunk_helpers, num_chunks, true);

Comments are closed.

Skip to main content