Parallel Development in VS10
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

Parallel Development in VS10

on

  • 633 views

Powered by MVP roadshow presentation, Riga (LV), Vilnius (LT).

Powered by MVP roadshow presentation, Riga (LV), Vilnius (LT).

Statistics

Views

Total Views
633
Views on SlideShare
630
Embed Views
3

Actions

Likes
0
Downloads
21
Comments
0

2 Embeds 3

http://www.linkedin.com 2
https://www.linkedin.com 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • .NET has had support for parallel programming since version 1.0, now referred to as classicthreading, but it was hard to use and made you think too much about managing the parallel aspects ofyour program, which detracts from focusing on what needs to be done.
  • Parallel execution doesn’t come for free. There are overhead costs associated with setting up andmanaging parallel programming features. If you have only a small amount of work to perform, theoverhead can outweigh the performance benefit.
  • Don’t just assume that a parallel solution will give you better performanceand move on.
  • However the thread pool isn’t so great at letting you know when work has been completed orcancelling running threads. The thread pool also doesn’t have any information about the context inwhich the work is created.
  • Dataparallelisim – makeanimage,splitintomanysmallpieciesandperformthesameoperationoneachofthem.Taskparalellisim – takeallsetoftasksandperformthemallatonce.
  • Chunksize – toobig/toosmallChunklayout – memorycache (L2)
  • Ordering– Pipilines, FuturesandDynamicTasks (recursion)
  • Race conditions arise in software when separate processes or threads of execution depend on some shared state
  • A deadlock is a situation in which two or more competing actions are waiting for the other to finish, and thus neither ever does
  • Thread starvation can be caused by creating too many threads
  • Optimizing code for different machine environments
  • If your application is multithreaded is it running in parallel?Operating system allocates time with theCPU to each thread and then rapidly switches between them (known as time slicing)
  • So how does the task scheduler work?1. When tasks are created, they are added to a global task queue.2. The thread pool will create a number of “worker” threads. The exact number that are createddepends on a number of factors such as the number of cores on the machine, current workload, type of work load, and so on. The thread pool utilizes a hill-climbing algorithm thatdynamically adjusts the thread pool to use the optimum number of threads. For example, if thethread pool detects that many threads have an I/O bottleneck, it will create additional threadsto complete the work more quickly. The thread pool contains a background thread that checksevery 0.5 seconds to see whether any work has been completed. If no work has been done (andthere is more work to do), a new thread will be created to perform this work.3. Each worker thread picks up tasks from the global queue and moves it onto its local queue forexecution.4. Each worker thread processes the tasks on its queue.5. If a thread finishes all the work in its local queue, it steals work from other queues to ensure thatwork is processed as quickly as possible. Note that tasks will steal work from the end of the othertask’s queues to minimize the chance that the task has started operating with the work already.
  • The .NET Framework 4 ThreadPool also features a work-stealing algorithm to help make sure that no threads are sitting idle while others still have work in their queues.Stealing work from other thread’s local queue tail.

Parallel Development in VS10 Presentation Transcript

  • 1. Powered by MVP
    Independent Experts. Real World Answers.
    10. februārī, Rīgā
  • 2. Parallel Computing withVisual Studio 2010
    Valdis Iljuconoks
    Microsoft C# MVP, Latvia
  • 3. Whywecareaboutthis?
  • 4. Performance
  • 5. Avoidmultithreading
    Parallelprogrammingishard
    It’sforexperts
  • 6. Parallelism Will Increase Your
    Application's Complexity
  • 7. The keyis
    measurement
  • 8. Comparison Matrix (Amdahl'slaw)
  • 9. Sojust usethreads ?!
  • 10. Crapcode runningin parallel
    is justParallelizedcrap code
  • 11. Where do I start?
  • 12. TasksvsData
    ControlFlow
    ControlandDataFlow
  • 13. DataParallelism
    Chunksize
    Chunklayout
    Datadependencies
  • 14. TaskParallelism
    Taskcount
    Work per task
    Dependencies
  • 15. ControlandDataFlow
    TaskConstraints
    ExternalConstraints
    Orderings
  • 16. Availability - Framework 4
  • 17. Some Functionality in 3.5
    Reactive Extensions (Rx)
    Parallel Extensions CTP
  • 18. ParallelLibraryContent
  • 19. Task Parallel Library (TPL) and Concurrency and Coordination Runtime (CCR)
    Parallel LINQ (PLINQ)
    New debugging and profiling tools
    Coordination data structures
    Parallel Pattern Library(PPL) C++ only
  • 20. ParallelLibraryArchitecture
  • 21. Some of the issues
  • 22. Some of the issues
    Race conditions
  • 23. Some of the issues
    Race conditions
    Deadlocks
  • 24. Some of the issues
    Race conditions
    Deadlocks
    Thread starvation
  • 25. Some of the issues
    Race conditions
    Deadlocks
    Thread starvation
    Difficult to code and debug
  • 26. Some of the issues
    Race conditions
    Deadlocks
    Thread starvation
    Difficult to code and debug
    Environmental
  • 27. Important Concepts
  • 28. Concurrent != Parallel
  • 29. Singlecore machine?
  • 30. Parallelization features
    Canslow down
  • 31. Getting started?
  • 32. Task Factory
    demo
  • 33. Parallel.For()Parallel.ForEach()Parallel.Invoke()
  • 34. Cancelling Task
    demo
  • 35. Avoid
    Console.WriteLine()
  • 36. Debugging Enhancements
    Parallel Task Window
    Parallel Stack Window
    demo
  • 37. Deadlocks
    demo
  • 38. Parallelism Will Increase Your
    Application's Complexity
  • 39. Work Stealing
  • 40. PLINQ
    demo
  • 41. SuccessKeys:
    Frameworksandlibraries
    Tools (VS2010)
    Guidance
  • 42. Maslow’sHammer
  • 43. Questions ?
  • 44. Future Considerations
  • 45. Dormant GPUs
  • 46. Distribute work across
    multiple machines?
  • 47. Async CTP
  • 48. Valdis Iljuconoks
    Software Architect
    Microsoft C# MVP, Latvia
    valdis.iljuconoks@dotnet.lv
    http://dotnet.lv/blogs/vi
  • 49. Powered by MVP
    Independent Experts. Real World Answers.
    10. februārī, Rīgā