Session: Parallel Programming for Managed Developers with Visual Studio 2010

parallel extension in .Net platform

Demo: 16 cores machine

The trend of Computer hardware is more and more cores.
Threading/concurrency-> parallelism
on multi-core machine
->don’t block the UI-> thread affinity
async operations
->improve performance

1. set the scene
2.fine-grained parallelism
3.debugger support
4.structured parallelism
5.declarative data parallelism

vs 2010 consoles applications
tree class, each node in tree is an integer
1. tree class
2.static method for construct a sample tree

1.program file with main()
2.walktree() ->call process item for each node in tree.
3.processitem()->do some work for each node’s data

before optimize : 15022

//optimize the processitem function*)->done
//optimize walktree
1st attempt , not so good. one thread for each node is bad!

improvement 1st attempt: create thread base on # of core you have.
use keyword task instead of thread

new time: 3118

Tasks–> improve locality, load balancing, contention

Demo2: task: rich API

Demo3: what happen when processitem needs other node’s data to be processed first?.
use keyword future!

write code once, and it will scale with better hardware.
partition works into multiple chunks->need fine-grained parallelism

Demo 3: New debugger
new window:
Parallel tasks
Parallel Stacks


Declarative Data Parallelism
Plain Linq, find prime in 1mil number
time =4352

parallel LINQ
time =1182

Bonus: coordination data structure.


This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s