Entries:
Comments:
Posts:

Loading User Information from Channel 9

Something went wrong getting user information from Channel 9

Latest Achievement:

Loading User Information from MSDN

Something went wrong getting user information from MSDN

Visual Studio Achievements

Latest Achievement:

Loading Visual Studio Achievements

Something went wrong getting the Visual Studio Achievements

Parallel Programming for C++ Developers: Tasks and Continuations, Part 1 of 2

Download

Right click “Save as…”

The Parallel Computing Concurrency Runtime team write tools for the C++ community that make it easier to write reliable, performant and scalable concurrent and parallel code. In this conversation, Mike Chu , Dana Groff, Artur Laksberg, and Vinod Koduvayoor Subramanian talk about their latest addition to the Parallel Patterns Library which provides wait-free concurrency programming by specifying tasks, the ability to schedule tasks on events and continuations that specify a task or tasks which are run after one or more tasks finish.  What’s better is that much of this is available today through the ConcRT Extra’s “Sample Pack”.

Please download the sample pack, play with the new library, push it and provide feedback to the team. They really want and need your input to insure they deliver the right things for real world usage by C++ developers. Go native!

Watch part 2

Tags:

Follow the Discussion

  • felix9felix9 the cat that walked by itself

    really nice stuff. will definitely use this library.

  • arr the video was too short, whats the timetable for part 2 ?
  • new2STLnew2STL xkcd.com

    very nice! I've made a post in the Goodhew video that I'm happy with ConcRT now I'm even happier Big Smile

    The sample I like more is the nbody simulation, not only they use tasks also they make a nice and simple UI with Direct2D

  • felix9felix9 the cat that walked by itself

    maybe this is somethng that Rx for C++ could be built upon ... hmmm

  • CharlesCharles Welcome Change

    , Mr Crash wrote

    arr the video was too short, whats the timetable for part 2 ?

    Part 2 is less of an extension of this, but obviously related and an extension Smiley . It will ship soon. Too short, eh? Agreed.

    C

  • tilltill

    I think this looks a lot like LWTs from OCaml (http://ocsigen.org/lwt/)... To me it seems that C++ is slowly moving to functional programming style... STL is already really in a functional style and with the arrival of Lambdas a lot more beautifull features from the functional world will appear.

  • new2STLnew2STL xkcd.com

    @till: You guess is not wrong, a lot of new stuff come together with F# (based a lot on OCaml and Haskell) development team and the Visual Studio Team while they are in Beta and early.  If you carve some old blog posts, videos and white-papers from 2008 you will find nice clues and amazing reports Wink

    "C++ is a multi-paradigm programming language, giving you many ways to express your solution" Posted November 4, 2010 by Eric Niebler

  • MarkMark

    What I want to know about is a discussion of efficiency. How efficient are tasks? How free-form are they with efficiency- for example, you said that they are intended for small chunks of code. How small is small? How much of an efficiency penalty am I going to get for getting this definition wrong?

  • new2STLnew2STL xkcd.com

    @Mark:Sure only the devs can answer your question better than me in the forum but what they want to say with 'small' is local constrained, well delimited work around data, PPL/ConcRT are for parallelization like Intel TBB and OpenMP.

    The tasks behavior light, its not like a thread pool that you throw a lot of code logic with many branches like a thread for incoming TCP connections, they are light to keep the lockfree sanit, in the same way you would do on OpenMP

    Here is an Intel internal article comparing ContRT, Intel TBB and OpenMP. ConcRT have near the same performance as Intel TBB.

    Resuming: Task are not Threads, not in the sense of some code that use thread to act like a fork command.

  • @Mark:

    It's a great question but any meaningful answer must be qualified with "compared with what?"

    Tasks definitely have overhead over plain OS threads, and if the amount of work you're doing in a task is small, the overhead becomes more pronounced. Because tasks are built on top of other PPL/ConcRT constructs, they have overhead over these constructs. So one way to look at the efficiency is to try to solve the same problem using different constructs and compare the results.

    To take one specific example, I can calculate a Fibonacci number (using the naïve recursive algorithm) in a parallel_for loop from 0 to 100, then do the same by spawning 100 tasks that do the same, and compare the elapsed time of both solutions. The data I get on my laptop shows that the tasks-based solution is about 5% slower than the parallel_for-based solution. I'm not too worried about this kind of overhead because a) it's small and more importantly b) you would never do this in a real-world application - parallel_for is a better solution for this problem.

    Some of our other performance tests show that the overhead can be quite significant, so more optimization is in order.

    Now to my main point. For problems where PPL tasks offer a more productive programming model, their performance should be "good enough" so that you don't have to fall back to a less productive programming model, such as OS threads. If we have accomplished that, we have succeeded. If you want to use PPL tasks but are forced to use some lower-level constructs to get the performance you need, we have failed.

  • MarkMark

    Thanks for your replies. I'm not concerned about expending performance- CPU cycles exist to be used, and in some cases, to save the programmer time. I am, however, concerned about expending performance because I didn't understand the purpose or implications of using a specific construct.

  • Hi, how big will should be the amount of work on a modern cpu so the costs of synchronization are amortized?

    Intel say that your tasks should be between 10 000 and 100 000 cycles or intstructions ( i do not remember exactly) for their TBB.

    And how we can measure how much cycles a piece of code has (easily)?

    Splitting a code into tasks is a static operation now.

     

     

  • new2STLnew2STL xkcd.com

    Great news! The community finished the 1st version of C++ Parallel Programming Book. Take a look in parallelpatternscpp.codeplex.com.  It's avaible in MSDN, eBook and Printed book.

Remove this comment

Remove this thread

close

Comments Closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.