SlideShare uma empresa Scribd logo
1 de 14
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

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

Introduction to reactive programming
Introduction to reactive programmingIntroduction to reactive programming
Introduction to reactive programming
 
Best Practices for Hyperparameter Tuning with MLflow
Best Practices for Hyperparameter Tuning with MLflowBest Practices for Hyperparameter Tuning with MLflow
Best Practices for Hyperparameter Tuning with MLflow
 
MLeap: Productionize Data Science Workflows Using Spark
MLeap: Productionize Data Science Workflows Using SparkMLeap: Productionize Data Science Workflows Using Spark
MLeap: Productionize Data Science Workflows Using Spark
 
Composable Futures with Akka 2.0
Composable Futures with Akka 2.0Composable Futures with Akka 2.0
Composable Futures with Akka 2.0
 
Ups and downs of enterprise Java app in a research setting
Ups and downs of enterprise Java app in a research settingUps and downs of enterprise Java app in a research setting
Ups and downs of enterprise Java app in a research setting
 
Scaling Apache Spark MLlib to Billions of Parameters: Spark Summit East talk ...
Scaling Apache Spark MLlib to Billions of Parameters: Spark Summit East talk ...Scaling Apache Spark MLlib to Billions of Parameters: Spark Summit East talk ...
Scaling Apache Spark MLlib to Billions of Parameters: Spark Summit East talk ...
 
Stream processing from single node to a cluster
Stream processing from single node to a clusterStream processing from single node to a cluster
Stream processing from single node to a cluster
 
Breaking data
Breaking dataBreaking data
Breaking data
 
Scaling Security Threat Detection with Apache Spark and Databricks
Scaling Security Threat Detection with Apache Spark and DatabricksScaling Security Threat Detection with Apache Spark and Databricks
Scaling Security Threat Detection with Apache Spark and Databricks
 
Introduction to concurrent programming with Akka actors
Introduction to concurrent programming with Akka actorsIntroduction to concurrent programming with Akka actors
Introduction to concurrent programming with Akka actors
 
AI&BigData Lab 2016. Сарапин Виктор: Размер имеет значение: анализ по требова...
AI&BigData Lab 2016. Сарапин Виктор: Размер имеет значение: анализ по требова...AI&BigData Lab 2016. Сарапин Виктор: Размер имеет значение: анализ по требова...
AI&BigData Lab 2016. Сарапин Виктор: Размер имеет значение: анализ по требова...
 
Learning from "Effective Scala"
Learning from "Effective Scala"Learning from "Effective Scala"
Learning from "Effective Scala"
 
Dal deck
Dal deckDal deck
Dal deck
 
Data science on big data. Pragmatic approach
Data science on big data. Pragmatic approachData science on big data. Pragmatic approach
Data science on big data. Pragmatic approach
 
JVM languages "flame wars"
JVM languages "flame wars"JVM languages "flame wars"
JVM languages "flame wars"
 
Columnar Table Performance Enhancements Of Greenplum Database with Block Meta...
Columnar Table Performance Enhancements Of Greenplum Database with Block Meta...Columnar Table Performance Enhancements Of Greenplum Database with Block Meta...
Columnar Table Performance Enhancements Of Greenplum Database with Block Meta...
 
Introduction to Scala Macros
Introduction to Scala MacrosIntroduction to Scala Macros
Introduction to Scala Macros
 
Mini-Training: Let's have a rest
Mini-Training: Let's have a restMini-Training: Let's have a rest
Mini-Training: Let's have a rest
 
Spark Workshop
Spark WorkshopSpark Workshop
Spark Workshop
 
2016 Spark Summit East Keynote: Matei Zaharia
2016 Spark Summit East Keynote: Matei Zaharia2016 Spark Summit East Keynote: Matei Zaharia
2016 Spark Summit East Keynote: Matei Zaharia
 

Semelhante a Parallel Computing in .NET

Java Core | Modern Java Concurrency | Martijn Verburg & Ben Evans
Java Core | Modern Java Concurrency | Martijn Verburg & Ben EvansJava Core | Modern Java Concurrency | Martijn Verburg & Ben Evans
Java Core | Modern Java Concurrency | Martijn Verburg & Ben Evans
JAX London
 
Java Serialization Facts and Fallacies
Java Serialization Facts and FallaciesJava Serialization Facts and Fallacies
Java Serialization Facts and Fallacies
Roman Elizarov
 
Optimizing your java applications for multi core hardware
Optimizing your java applications for multi core hardwareOptimizing your java applications for multi core hardware
Optimizing your java applications for multi core hardware
IndicThreads
 

Semelhante a Parallel Computing in .NET (20)

Multi core programming 1
Multi core programming 1Multi core programming 1
Multi core programming 1
 
Coding For Cores - C# Way
Coding For Cores - C# WayCoding For Cores - C# Way
Coding For Cores - C# Way
 
Functional? Reactive? Why?
Functional? Reactive? Why?Functional? Reactive? Why?
Functional? Reactive? Why?
 
Functional?
 Reactive? 
Why?
Functional?
 Reactive? 
Why?Functional?
 Reactive? 
Why?
Functional?
 Reactive? 
Why?
 
Java 8 features
Java 8 featuresJava 8 features
Java 8 features
 
Data warehouse 26 exploiting parallel technologies
Data warehouse  26 exploiting parallel technologiesData warehouse  26 exploiting parallel technologies
Data warehouse 26 exploiting parallel technologies
 
Arc 300-3 ade miller-en
Arc 300-3 ade miller-enArc 300-3 ade miller-en
Arc 300-3 ade miller-en
 
Mapping Data Flows Perf Tuning April 2021
Mapping Data Flows Perf Tuning April 2021Mapping Data Flows Perf Tuning April 2021
Mapping Data Flows Perf Tuning April 2021
 
Data mining with Weka
Data mining with WekaData mining with Weka
Data mining with Weka
 
Data Parallel and Object Oriented Model
Data Parallel and Object Oriented ModelData Parallel and Object Oriented Model
Data Parallel and Object Oriented Model
 
Building large scale, job processing systems with Scala Akka Actor framework
Building large scale, job processing systems with Scala Akka Actor frameworkBuilding large scale, job processing systems with Scala Akka Actor framework
Building large scale, job processing systems with Scala Akka Actor framework
 
Java Core | Modern Java Concurrency | Martijn Verburg & Ben Evans
Java Core | Modern Java Concurrency | Martijn Verburg & Ben EvansJava Core | Modern Java Concurrency | Martijn Verburg & Ben Evans
Java Core | Modern Java Concurrency | Martijn Verburg & Ben Evans
 
VTU 6th Sem Elective CSE - Module 3 cloud computing
VTU 6th Sem Elective CSE - Module 3 cloud computingVTU 6th Sem Elective CSE - Module 3 cloud computing
VTU 6th Sem Elective CSE - Module 3 cloud computing
 
Nosql databases
Nosql databasesNosql databases
Nosql databases
 
The Why and How of Scala at Twitter
The Why and How of Scala at TwitterThe Why and How of Scala at Twitter
The Why and How of Scala at Twitter
 
Data Pipelines with Python - NWA TechFest 2017
Data Pipelines with Python - NWA TechFest 2017Data Pipelines with Python - NWA TechFest 2017
Data Pipelines with Python - NWA TechFest 2017
 
Java Serialization Facts and Fallacies
Java Serialization Facts and FallaciesJava Serialization Facts and Fallacies
Java Serialization Facts and Fallacies
 
Optimizing your java applications for multi core hardware
Optimizing your java applications for multi core hardwareOptimizing your java applications for multi core hardware
Optimizing your java applications for multi core hardware
 
NoSQL Introduction, Theory, Implementations
NoSQL Introduction, Theory, ImplementationsNoSQL Introduction, Theory, Implementations
NoSQL Introduction, Theory, Implementations
 
Laravel ppt
Laravel pptLaravel ppt
Laravel ppt
 

Mais de meghantaylor

Mais de meghantaylor (6)

Personal Time Management
Personal Time ManagementPersonal Time Management
Personal Time Management
 
Dependency Injection and Autofac
Dependency Injection and AutofacDependency Injection and Autofac
Dependency Injection and Autofac
 
Best Practices for Successful Projects
Best Practices for Successful ProjectsBest Practices for Successful Projects
Best Practices for Successful Projects
 
JavaScript Framework Smackdown
JavaScript Framework SmackdownJavaScript Framework Smackdown
JavaScript Framework Smackdown
 
A Software Architect's View On Diagramming
A Software Architect's View On DiagrammingA Software Architect's View On Diagramming
A Software Architect's View On Diagramming
 
Intro to Responsive Web Design
Intro to Responsive Web DesignIntro to Responsive Web Design
Intro to Responsive Web Design
 

Último

Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
chiefasafspells
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
masabamasaba
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 

Último (20)

Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 

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