SlideShare a Scribd company logo
Parallel Computing in .NET
James Rapp
TOPICS
• Task Parallel Library
• Parallel Debugging
• Parallel Profiling
TYPES OF PARALLELISM
Data Parallelism
Occurs when you carry out the same operation on multiple subsets of the
data simultaneously and independently.
Examples:
• Matrix multiplication
• Jacobi Relaxation
• Ray Tracing
TYPES OF PARALLELISM
Task Parallelism
One or more independent tasks running concurrently
Examples:
• Sorting
• Dataflow Networks
• Asynchrony
WHY IS PARALLELISM RELEVANT?
• Moore’s law: Transistor count doubles every two years
• We’ve reached the physical limits of clock speed
• Solution: Scale horizontally, not vertically
• The free lunch is over: We now must right parallel code if we want to
benefit from better hardware
TASK PARALLEL LIBRARY
Implementing Thread-Based Parallelism
• Tedious and error-prone
• Difficult to read
• Threads are heavyweight
• Wrong abstraction level
TPL
• Simplifies parallel programming
• Raises the level of abstraction
• Encapsulates common patterns
• Enables fine-grained control
Tasks (System.Threading.Tasks)
Task – A lightweight schedulable unit of work.
• Represents an asynchronous operation
• Higher level of abstraction than a ThreadPool work item
Purpose of Tasks
• Simplifies low-level details such as cancellation or exception handling.
• More control – rich APIs for continuations, custom scheduling, etc.
.NET PARALLELISM OVERVIEW
Operating System
Threads
Concurrency Runtime
ThreadPool
Task Scheduler
Resource Manager
Developer Tools
Parallel Debugger
Concurrency
Visualizer
Programming Models
PLINQ
Task Parallel Library
A NOTE ON CHILD TASKS
Behavior Detached Attached
Parent waits for child to
complete
No Yes
Parent propagates exceptions
thrown by child
No Yes
Status of parent depends on
status of child
No Yes
CONCURRENT COLLECTIONS
(System.Collections.Concurrent)
Class Description
ConcurrentDictionary Collection of key/value pairs that can be accessed by safely by
multiple threads
ConcurrentQueue Thread-safe FIFO collection
ConcurrentStack Thread-safe LIFO collection
Partitioner Provides common partitioning strategies for arrays, lists, and
enumerables
ConcurrentBag Thread-safe, unordered collection of objects
BlockingCollection Provides blocking and bounding capabilities for thread-safe
collections that implement IProducerConsumerCollection<T>
Etc.
• Thread-safe collection classes – Optimized for performance
– Should be used instead of System.Collections and System.Collections.Generic
TPA DATAFLOW
(System.Threading.Tasks.Dataflow)
• Meant for course-grained dataflow or pipeline tasks
• Useful for processing data as it becomes available (e.g. red eye reduction
on a web cam)
.NET ASYNC
• Symplifies asynchronous programming
• Improves UI responsiveness and performance
async Task<int> AccessTheWebAsync()
{
HttpClient client = new HttpClient();
Task<string> getStringTask = client.GetStringAsync(“www.geneca.com");
//Work that doesn’t rely on getStringTask
DoIndependentWork();
string urlContents = await getStringTask;
return urlContents.Length;
}
NOT COVERED (Suggestions for
Further Research)
• Other Parallel Programming Models in .NET
– PLINQ
• Native Concurrency
– Parallel Patterns Library
• Data Parallelism on the GPU
– C++ AMP
Parallel Computing in .NET

More Related Content

What's hot (20)

PDF
Introduction to reactive programming
Leapfrog Technology Inc.
 
PDF
Best Practices for Hyperparameter Tuning with MLflow
Databricks
 
PDF
MLeap: Productionize Data Science Workflows Using Spark
Jen Aman
 
PPTX
Composable Futures with Akka 2.0
Mike Slinn
 
PPTX
Ups and downs of enterprise Java app in a research setting
Csaba Toth
 
PDF
Scaling Apache Spark MLlib to Billions of Parameters: Spark Summit East talk ...
Spark Summit
 
PPTX
Stream processing from single node to a cluster
Gal Marder
 
PDF
Breaking data
Terry Bunio
 
PDF
Scaling Security Threat Detection with Apache Spark and Databricks
Databricks
 
PDF
Introduction to concurrent programming with Akka actors
Shashank L
 
PDF
AI&BigData Lab 2016. Сарапин Виктор: Размер имеет значение: анализ по требова...
GeeksLab Odessa
 
KEY
Learning from "Effective Scala"
Kazuhiro Sera
 
PPT
Dal deck
Caroline_Rose
 
PPTX
Data science on big data. Pragmatic approach
Pavel Mezentsev
 
PPTX
JVM languages "flame wars"
Gal Marder
 
PPTX
Columnar Table Performance Enhancements Of Greenplum Database with Block Meta...
Ontico
 
ODP
Introduction to Scala Macros
Knoldus Inc.
 
PPTX
Mini-Training: Let's have a rest
Betclic Everest Group Tech Team
 
PPTX
Spark Workshop
Navid Kalaei
 
PDF
2016 Spark Summit East Keynote: Matei Zaharia
Databricks
 
Introduction to reactive programming
Leapfrog Technology Inc.
 
Best Practices for Hyperparameter Tuning with MLflow
Databricks
 
MLeap: Productionize Data Science Workflows Using Spark
Jen Aman
 
Composable Futures with Akka 2.0
Mike Slinn
 
Ups and downs of enterprise Java app in a research setting
Csaba Toth
 
Scaling Apache Spark MLlib to Billions of Parameters: Spark Summit East talk ...
Spark Summit
 
Stream processing from single node to a cluster
Gal Marder
 
Breaking data
Terry Bunio
 
Scaling Security Threat Detection with Apache Spark and Databricks
Databricks
 
Introduction to concurrent programming with Akka actors
Shashank L
 
AI&BigData Lab 2016. Сарапин Виктор: Размер имеет значение: анализ по требова...
GeeksLab Odessa
 
Learning from "Effective Scala"
Kazuhiro Sera
 
Dal deck
Caroline_Rose
 
Data science on big data. Pragmatic approach
Pavel Mezentsev
 
JVM languages "flame wars"
Gal Marder
 
Columnar Table Performance Enhancements Of Greenplum Database with Block Meta...
Ontico
 
Introduction to Scala Macros
Knoldus Inc.
 
Mini-Training: Let's have a rest
Betclic Everest Group Tech Team
 
Spark Workshop
Navid Kalaei
 
2016 Spark Summit East Keynote: Matei Zaharia
Databricks
 

Similar to Parallel Computing in .NET (20)

PPTX
Coding For Cores - C# Way
Bishnu Rawal
 
PPTX
Multi core programming 1
Robin Aggarwal
 
PPT
MTaulty_DevWeek_Parallel
ukdpe
 
PPTX
Parallel extensions in .Net 4.0
Dima Maleev
 
ZIP
.Net 4.0 Threading and Parallel Programming
Alex Moore
 
PPT
Parallel Extentions to the .NET Framework
ukdpe
 
PPTX
Using Parallel Computing Platform - NHDNUG
North Houston .NET Users Group
 
PPTX
Parallel Processing
RTigger
 
PPT
Overview Of Parallel Development - Ericnel
ukdpe
 
PPT
Task and Data Parallelism
Sasha Goldshtein
 
PPTX
Dot net parallelism and multicore computing
Aravindhan Gnanam
 
PPTX
C# Parallel programming
Umeshwaran V
 
PDF
.Net Multithreading and Parallelization
Dmitri Nesteruk
 
PPTX
Parallel and Asynchronous Programming - ITProDevConnections 2012 (Greek)
Panagiotis Kanavos
 
PDF
Concurrency and parallel in .net
Mohammad Hossein Karami
 
PPTX
Parallel and Asynchronous Programming - ITProDevConnections 2012 (English)
Panagiotis Kanavos
 
PPTX
.NET Multithreading/Multitasking
Sasha Kravchuk
 
PPTX
Toub parallelism tour_oct2009
nkaluva
 
PPT
Parallel Programming and F#
llangit
 
PPTX
C# 5 deep drive into asynchronous programming
Praveen Prajapati
 
Coding For Cores - C# Way
Bishnu Rawal
 
Multi core programming 1
Robin Aggarwal
 
MTaulty_DevWeek_Parallel
ukdpe
 
Parallel extensions in .Net 4.0
Dima Maleev
 
.Net 4.0 Threading and Parallel Programming
Alex Moore
 
Parallel Extentions to the .NET Framework
ukdpe
 
Using Parallel Computing Platform - NHDNUG
North Houston .NET Users Group
 
Parallel Processing
RTigger
 
Overview Of Parallel Development - Ericnel
ukdpe
 
Task and Data Parallelism
Sasha Goldshtein
 
Dot net parallelism and multicore computing
Aravindhan Gnanam
 
C# Parallel programming
Umeshwaran V
 
.Net Multithreading and Parallelization
Dmitri Nesteruk
 
Parallel and Asynchronous Programming - ITProDevConnections 2012 (Greek)
Panagiotis Kanavos
 
Concurrency and parallel in .net
Mohammad Hossein Karami
 
Parallel and Asynchronous Programming - ITProDevConnections 2012 (English)
Panagiotis Kanavos
 
.NET Multithreading/Multitasking
Sasha Kravchuk
 
Toub parallelism tour_oct2009
nkaluva
 
Parallel Programming and F#
llangit
 
C# 5 deep drive into asynchronous programming
Praveen Prajapati
 
Ad

More from meghantaylor (6)

PPTX
Personal Time Management
meghantaylor
 
PPTX
Dependency Injection and Autofac
meghantaylor
 
PPTX
Best Practices for Successful Projects
meghantaylor
 
PPTX
JavaScript Framework Smackdown
meghantaylor
 
PPTX
A Software Architect's View On Diagramming
meghantaylor
 
PPTX
Intro to Responsive Web Design
meghantaylor
 
Personal Time Management
meghantaylor
 
Dependency Injection and Autofac
meghantaylor
 
Best Practices for Successful Projects
meghantaylor
 
JavaScript Framework Smackdown
meghantaylor
 
A Software Architect's View On Diagramming
meghantaylor
 
Intro to Responsive Web Design
meghantaylor
 
Ad

Recently uploaded (20)

PDF
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
PDF
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
PDF
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
PPTX
Equipment Management Software BIS Safety UK.pptx
BIS Safety Software
 
PDF
Executive Business Intelligence Dashboards
vandeslie24
 
DOCX
Import Data Form Excel to Tally Services
Tally xperts
 
PPTX
MiniTool Power Data Recovery Full Crack Latest 2025
muhammadgurbazkhan
 
PDF
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
PPTX
An Introduction to ZAP by Checkmarx - Official Version
Simon Bennetts
 
PDF
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
PDF
GetOnCRM Speeds Up Agentforce 3 Deployment for Enterprise AI Wins.pdf
GetOnCRM Solutions
 
PDF
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
PPTX
The Role of a PHP Development Company in Modern Web Development
SEO Company for School in Delhi NCR
 
PDF
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
Nabin Dhakal
 
PDF
Understanding the Need for Systemic Change in Open Source Through Intersectio...
Imma Valls Bernaus
 
PPTX
Human Resources Information System (HRIS)
Amity University, Patna
 
PPTX
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
PDF
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
PDF
Salesforce CRM Services.VALiNTRY360
VALiNTRY360
 
PPTX
How Apagen Empowered an EPC Company with Engineering ERP Software
SatishKumar2651
 
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
Equipment Management Software BIS Safety UK.pptx
BIS Safety Software
 
Executive Business Intelligence Dashboards
vandeslie24
 
Import Data Form Excel to Tally Services
Tally xperts
 
MiniTool Power Data Recovery Full Crack Latest 2025
muhammadgurbazkhan
 
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
An Introduction to ZAP by Checkmarx - Official Version
Simon Bennetts
 
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
GetOnCRM Speeds Up Agentforce 3 Deployment for Enterprise AI Wins.pdf
GetOnCRM Solutions
 
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
The Role of a PHP Development Company in Modern Web Development
SEO Company for School in Delhi NCR
 
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
Nabin Dhakal
 
Understanding the Need for Systemic Change in Open Source Through Intersectio...
Imma Valls Bernaus
 
Human Resources Information System (HRIS)
Amity University, Patna
 
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
Salesforce CRM Services.VALiNTRY360
VALiNTRY360
 
How Apagen Empowered an EPC Company with Engineering ERP Software
SatishKumar2651
 

Parallel Computing in .NET

  • 1. Parallel Computing in .NET James Rapp
  • 2. TOPICS • Task Parallel Library • Parallel Debugging • Parallel Profiling
  • 3. TYPES OF PARALLELISM Data Parallelism Occurs when you carry out the same operation on multiple subsets of the data simultaneously and independently. Examples: • Matrix multiplication • Jacobi Relaxation • Ray Tracing
  • 4. TYPES OF PARALLELISM Task Parallelism One or more independent tasks running concurrently Examples: • Sorting • Dataflow Networks • Asynchrony
  • 5. WHY IS PARALLELISM RELEVANT? • Moore’s law: Transistor count doubles every two years • We’ve reached the physical limits of clock speed • Solution: Scale horizontally, not vertically • The free lunch is over: We now must right parallel code if we want to benefit from better hardware
  • 6. TASK PARALLEL LIBRARY Implementing Thread-Based Parallelism • Tedious and error-prone • Difficult to read • Threads are heavyweight • Wrong abstraction level TPL • Simplifies parallel programming • Raises the level of abstraction • Encapsulates common patterns • Enables fine-grained control
  • 7. Tasks (System.Threading.Tasks) Task – A lightweight schedulable unit of work. • Represents an asynchronous operation • Higher level of abstraction than a ThreadPool work item Purpose of Tasks • Simplifies low-level details such as cancellation or exception handling. • More control – rich APIs for continuations, custom scheduling, etc.
  • 8. .NET PARALLELISM OVERVIEW Operating System Threads Concurrency Runtime ThreadPool Task Scheduler Resource Manager Developer Tools Parallel Debugger Concurrency Visualizer Programming Models PLINQ Task Parallel Library
  • 9. A NOTE ON CHILD TASKS Behavior Detached Attached Parent waits for child to complete No Yes Parent propagates exceptions thrown by child No Yes Status of parent depends on status of child No Yes
  • 10. CONCURRENT COLLECTIONS (System.Collections.Concurrent) Class Description ConcurrentDictionary Collection of key/value pairs that can be accessed by safely by multiple threads ConcurrentQueue Thread-safe FIFO collection ConcurrentStack Thread-safe LIFO collection Partitioner Provides common partitioning strategies for arrays, lists, and enumerables ConcurrentBag Thread-safe, unordered collection of objects BlockingCollection Provides blocking and bounding capabilities for thread-safe collections that implement IProducerConsumerCollection<T> Etc. • Thread-safe collection classes – Optimized for performance – Should be used instead of System.Collections and System.Collections.Generic
  • 11. TPA DATAFLOW (System.Threading.Tasks.Dataflow) • Meant for course-grained dataflow or pipeline tasks • Useful for processing data as it becomes available (e.g. red eye reduction on a web cam)
  • 12. .NET ASYNC • Symplifies asynchronous programming • Improves UI responsiveness and performance async Task<int> AccessTheWebAsync() { HttpClient client = new HttpClient(); Task<string> getStringTask = client.GetStringAsync(“www.geneca.com"); //Work that doesn’t rely on getStringTask DoIndependentWork(); string urlContents = await getStringTask; return urlContents.Length; }
  • 13. NOT COVERED (Suggestions for Further Research) • Other Parallel Programming Models in .NET – PLINQ • Native Concurrency – Parallel Patterns Library • Data Parallelism on the GPU – C++ AMP