SlideShare une entreprise Scribd logo
1  sur  44
Télécharger pour lire hors ligne
ParallelFx
Bringing Mono applications in the multicore era




                 Jérémie Laval




     @     jeremie.laval@gmail.com
           http://blog.neteril.org
           http://twitter.com/jeremie_laval
     IRC   Garuma on #mono @ GIMPNet.org
Outline


Why bother?
  The free lunch
  An awesome idea
  Remaining performant

ParallelFx
   The big picture
   Tasks and co
   PLinq
   State of things

A note for the future
Why bother? ParallelFx A note for the future Questions




Why are we bothering with parallelization




 3 / 23
Why bother? ParallelFx A note for the future Questions




Why are we bothering with parallelization



                   Everyone loves his single thread




 3 / 23
Why bother? ParallelFx A note for the future Questions




Why are we bothering with parallelization



                   Everyone loves his single thread



“The ideal number of thread you should use is 1”

                                                                   – Alan Mc Govern
                                                                        Mono hacker



 3 / 23
Why bother? ParallelFx A note for the future Questions




Why are we bothering with parallelization



                   Everyone loves his single thread




                                                                   – Alan Mc Govern
                                                                        Mono hacker



 3 / 23
Why bother? ParallelFx A note for the future Questions




Why are we bothering with parallelization




 4 / 23
Why bother? ParallelFx A note for the future Questions




Why are we bothering with parallelization


                     Because the free lunch is over!




 4 / 23
Why bother? ParallelFx A note for the future Questions




Free lunch?

                                70’s - 2005: Moore’s law in action

                                                 Intel Processor Clock Speed (MHz)
                 10000
                                                                                                     Pentium 4 (Prescott)


                                                                                                                  Core 2
                                                                                                                 Extreme
                  1000
                                                                                    Pentium III

                                                                                 Celeron                 Multicore crisis
                                                                    Pentium                                 is here !
                  100

                                                            80486

                                                    80386

                   10
                                         80286
                                8080



                    1
                         1968     1973       1979            1984         1990    1995            2001            2006




                  0.1




                                                                                                                Source: Smoothspan blog

 5 / 23
Why bother? ParallelFx A note for the future Questions




The awesome idea




6 / 23
Why bother? ParallelFx A note for the future Questions




The awesome idea


          Can’t scale vertically? Scale horizontally!




6 / 23
Why bother? ParallelFx A note for the future Questions




Trend of things


                                   Number of cores


             1                 2                 4                 12ish          80

                                       Core 2                                 Intel
Pentium             Core Duo                           Core i7-980X
                                       Quad                                prototype




 7 / 23
Why bother? ParallelFx A note for the future Questions




Problem




8 / 23
Why bother? ParallelFx A note for the future Questions




Problem




                     No more magical free-lunch




8 / 23
Why bother? ParallelFx A note for the future Questions




Solution
                                  Let’s break up work...




                             ....and share it among cores
 9 / 23
Why bother? ParallelFx A note for the future Questions




Errr...




 10 / 23
Why bother? ParallelFx A note for the future Questions




Parallelization is difficult




11 / 23
Why bother? ParallelFx A note for the future Questions




Parallelization is difficult


  Hard: is that stuff really thread safe?




11 / 23
Why bother? ParallelFx A note for the future Questions




Parallelization is difficult


  Hard: is that stuff really thread safe?

  Tedious: whose turn is it to debug deadlocks?




11 / 23
Why bother? ParallelFx A note for the future Questions




Parallelization is difficult


  Hard: is that stuff really thread safe?

  Tedious: whose turn is it to debug deadlocks?

  Inefficient: how many thread to use?




11 / 23
Why bother? ParallelFx A note for the future Questions




Parallelization is difficult


  Hard: is that stuff really thread safe?

  Tedious: whose turn is it to debug deadlocks?

  Inefficient: how many thread to use?
          Too few: it’s not scaling




11 / 23
Why bother? ParallelFx A note for the future Questions




Parallelization is difficult


  Hard: is that stuff really thread safe?

  Tedious: whose turn is it to debug deadlocks?

  Inefficient: how many thread to use?
          Too few: it’s not scaling
          Too much: context-switching hurts performance




11 / 23
Why bother? ParallelFx A note for the future Questions




Parallelization is difficult


  Hard: is that stuff really thread safe?

  Tedious: whose turn is it to debug deadlocks?

  Inefficient: how many thread to use?
          Too few: it’s not scaling
          Too much: context-switching hurts performance
          What if the number of core changes?




11 / 23
Why bother? ParallelFx A note for the future Questions




KISS time (Keep it simple, stupid)


We need something different :




 12 / 23
Why bother? ParallelFx A note for the future Questions




KISS time (Keep it simple, stupid)


We need something different :

   Automagically regulate thread usage at runtime




 12 / 23
Why bother? ParallelFx A note for the future Questions




KISS time (Keep it simple, stupid)


We need something different :

   Automagically regulate thread usage at runtime

   As straightforward as possible




 12 / 23
Why bother? ParallelFx A note for the future Questions




KISS time (Keep it simple, stupid)


We need something different :

   Automagically regulate thread usage at runtime

   As straightforward as possible
           Simulate familiar constructs




 12 / 23
Why bother? ParallelFx A note for the future Questions




KISS time (Keep it simple, stupid)


We need something different :

   Automagically regulate thread usage at runtime

   As straightforward as possible
           Simulate familiar constructs
           Reuse existing code with only slight modification




 12 / 23
Why bother? ParallelFx A note for the future Questions




Enter ParallelFx

                                  ParallelFx at a glance




13 / 23
Why bother? ParallelFx A note for the future Questions




At the heart

                                   Work-stealing scheduler


                                                  Mono Application

                             Shared
                                                  ParallelFX library
                              work
                              pool                  (Scheduler)


                                        Retrieve



                        Local work        Steal                        Local work
                           pool                                           pool


                         Thread          Manage                         Thread
                         Worker                                         Worker

                            OS                                             OS
                          thread                                         thread


14 / 23
Why bother? ParallelFx A note for the future Questions




Tasks



   CancellationTokenSource source = new CancellationTokenSource ();

   Task task = Task.Factory.StartNew (() => DoSomeStuff (), source.Token);

   Task continuation = task.ContinueWith ((t) => Console.WriteLine ("task finished");

   source.Cancel ();

   t.Wait ();




15 / 23
Why bother? ParallelFx A note for the future Questions




Future (Task<T>)



 static int SumParallel (Tree<int> tree, int curDepth)
 {
   const int SequentialThreshold = 3;

     if (tree == null) return 0;

     if (curDepth > SequentialThreshold)
        return SumSequentialInternal (tree);

     int right = SumParallel (tree.Right, curDepth + 1);

     Task<int> left =
                Task.Factory.StartNew (() => SumParallel (tree.Left, curDepth + 1));

     return tree.Data + left.Value + right;
 }




16 / 23
Why bother? ParallelFx A note for the future Questions




Parallel.For



   Fractal fractal = new Fractal (width, height);

   ColorChooser colorChooser = new ColorChooser ();

   Parallel.For (0, width, (i) => {
     for (int j = 0; j < height; j++) {
       ProcessPixel (i, j, fractal, colorChooser);
     }
   });




17 / 23
Why bother? ParallelFx A note for the future Questions




Demo: Parallel For




    Demo: image processing with parallel
                  loops




18 / 23
Why bother? ParallelFx A note for the future Questions




PLinq


   ParallelEnumerable.Range (1, 1000)./* ... */
   ParallelEnumerable.Repeat (‘‘Rupert’’, 1000)./* ... */
   enumerable.AsParallel ()./* ... */

   var query = from x in Directory.GetFiles ("/etc/")
               .AsParallel ()
               where x.EndsWith (".conf")
               select x;

   query.ForAll ((e) => {
     Console.WriteLine ("{0} from {1}", e,
                        Thread.CurrentThread.ManagedThreadId);
   });




19 / 23
Why bother? ParallelFx A note for the future Questions




Demo: PLinq




             Demo: raytracing the PLinq way




20 / 23
Why bother? ParallelFx A note for the future Questions




State of things


  Mono 2.6 (December 2009): .NET 4 beta 1
          Task, Future, Parallel loops
          Concurrent collections
          Coordination data structures

  Mono 2.8 (or git master): .NET 4 compliant
          Enabled by default
          Tons of improvement
          With PLinq!




21 / 23
Why bother? ParallelFx A note for the future Questions




A note for the future




22 / 23
Why bother? ParallelFx A note for the future Questions




A note for the future


                GLinq: GPGPU-powered Linq




22 / 23
Why bother? ParallelFx A note for the future Questions




A note for the future


                GLinq: GPGPU-powered Linq
  Re-use PLinq pipeline




22 / 23
Why bother? ParallelFx A note for the future Questions




A note for the future


                GLinq: GPGPU-powered Linq
  Re-use PLinq pipeline
  Same design guidelines than PLinq: simplicity, transparency




22 / 23
Why bother? ParallelFx A note for the future Questions




A note for the future


                GLinq: GPGPU-powered Linq
  Re-use PLinq pipeline
  Same design guidelines than PLinq: simplicity, transparency
  Rewrite C# code in OpenCL (Expression trees FTW!)




22 / 23
Why bother? ParallelFx A note for the future Questions




A note for the future


                GLinq: GPGPU-powered Linq
  Re-use PLinq pipeline
  Same design guidelines than PLinq: simplicity, transparency
  Rewrite C# code in OpenCL (Expression trees FTW!)
  Transparent mapping of OpenCL idioms to .NET




22 / 23
Why bother? ParallelFx A note for the future Questions




Closing the curtains




23 / 23

Contenu connexe

Dernier

FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 

Dernier (20)

FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 

En vedette

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 

En vedette (20)

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 

ParallelFx, bringing Mono applications in the multicore era

  • 1. ParallelFx Bringing Mono applications in the multicore era Jérémie Laval @ jeremie.laval@gmail.com http://blog.neteril.org http://twitter.com/jeremie_laval IRC Garuma on #mono @ GIMPNet.org
  • 2. Outline Why bother? The free lunch An awesome idea Remaining performant ParallelFx The big picture Tasks and co PLinq State of things A note for the future
  • 3. Why bother? ParallelFx A note for the future Questions Why are we bothering with parallelization 3 / 23
  • 4. Why bother? ParallelFx A note for the future Questions Why are we bothering with parallelization Everyone loves his single thread 3 / 23
  • 5. Why bother? ParallelFx A note for the future Questions Why are we bothering with parallelization Everyone loves his single thread “The ideal number of thread you should use is 1” – Alan Mc Govern Mono hacker 3 / 23
  • 6. Why bother? ParallelFx A note for the future Questions Why are we bothering with parallelization Everyone loves his single thread – Alan Mc Govern Mono hacker 3 / 23
  • 7. Why bother? ParallelFx A note for the future Questions Why are we bothering with parallelization 4 / 23
  • 8. Why bother? ParallelFx A note for the future Questions Why are we bothering with parallelization Because the free lunch is over! 4 / 23
  • 9. Why bother? ParallelFx A note for the future Questions Free lunch? 70’s - 2005: Moore’s law in action Intel Processor Clock Speed (MHz) 10000 Pentium 4 (Prescott) Core 2 Extreme 1000 Pentium III Celeron Multicore crisis Pentium is here ! 100 80486 80386 10 80286 8080 1 1968 1973 1979 1984 1990 1995 2001 2006 0.1 Source: Smoothspan blog 5 / 23
  • 10. Why bother? ParallelFx A note for the future Questions The awesome idea 6 / 23
  • 11. Why bother? ParallelFx A note for the future Questions The awesome idea Can’t scale vertically? Scale horizontally! 6 / 23
  • 12. Why bother? ParallelFx A note for the future Questions Trend of things Number of cores 1 2 4 12ish 80 Core 2 Intel Pentium Core Duo Core i7-980X Quad prototype 7 / 23
  • 13. Why bother? ParallelFx A note for the future Questions Problem 8 / 23
  • 14. Why bother? ParallelFx A note for the future Questions Problem No more magical free-lunch 8 / 23
  • 15. Why bother? ParallelFx A note for the future Questions Solution Let’s break up work... ....and share it among cores 9 / 23
  • 16. Why bother? ParallelFx A note for the future Questions Errr... 10 / 23
  • 17. Why bother? ParallelFx A note for the future Questions Parallelization is difficult 11 / 23
  • 18. Why bother? ParallelFx A note for the future Questions Parallelization is difficult Hard: is that stuff really thread safe? 11 / 23
  • 19. Why bother? ParallelFx A note for the future Questions Parallelization is difficult Hard: is that stuff really thread safe? Tedious: whose turn is it to debug deadlocks? 11 / 23
  • 20. Why bother? ParallelFx A note for the future Questions Parallelization is difficult Hard: is that stuff really thread safe? Tedious: whose turn is it to debug deadlocks? Inefficient: how many thread to use? 11 / 23
  • 21. Why bother? ParallelFx A note for the future Questions Parallelization is difficult Hard: is that stuff really thread safe? Tedious: whose turn is it to debug deadlocks? Inefficient: how many thread to use? Too few: it’s not scaling 11 / 23
  • 22. Why bother? ParallelFx A note for the future Questions Parallelization is difficult Hard: is that stuff really thread safe? Tedious: whose turn is it to debug deadlocks? Inefficient: how many thread to use? Too few: it’s not scaling Too much: context-switching hurts performance 11 / 23
  • 23. Why bother? ParallelFx A note for the future Questions Parallelization is difficult Hard: is that stuff really thread safe? Tedious: whose turn is it to debug deadlocks? Inefficient: how many thread to use? Too few: it’s not scaling Too much: context-switching hurts performance What if the number of core changes? 11 / 23
  • 24. Why bother? ParallelFx A note for the future Questions KISS time (Keep it simple, stupid) We need something different : 12 / 23
  • 25. Why bother? ParallelFx A note for the future Questions KISS time (Keep it simple, stupid) We need something different : Automagically regulate thread usage at runtime 12 / 23
  • 26. Why bother? ParallelFx A note for the future Questions KISS time (Keep it simple, stupid) We need something different : Automagically regulate thread usage at runtime As straightforward as possible 12 / 23
  • 27. Why bother? ParallelFx A note for the future Questions KISS time (Keep it simple, stupid) We need something different : Automagically regulate thread usage at runtime As straightforward as possible Simulate familiar constructs 12 / 23
  • 28. Why bother? ParallelFx A note for the future Questions KISS time (Keep it simple, stupid) We need something different : Automagically regulate thread usage at runtime As straightforward as possible Simulate familiar constructs Reuse existing code with only slight modification 12 / 23
  • 29. Why bother? ParallelFx A note for the future Questions Enter ParallelFx ParallelFx at a glance 13 / 23
  • 30. Why bother? ParallelFx A note for the future Questions At the heart Work-stealing scheduler Mono Application Shared ParallelFX library work pool (Scheduler) Retrieve Local work Steal Local work pool pool Thread Manage Thread Worker Worker OS OS thread thread 14 / 23
  • 31. Why bother? ParallelFx A note for the future Questions Tasks CancellationTokenSource source = new CancellationTokenSource (); Task task = Task.Factory.StartNew (() => DoSomeStuff (), source.Token); Task continuation = task.ContinueWith ((t) => Console.WriteLine ("task finished"); source.Cancel (); t.Wait (); 15 / 23
  • 32. Why bother? ParallelFx A note for the future Questions Future (Task<T>) static int SumParallel (Tree<int> tree, int curDepth) { const int SequentialThreshold = 3; if (tree == null) return 0; if (curDepth > SequentialThreshold) return SumSequentialInternal (tree); int right = SumParallel (tree.Right, curDepth + 1); Task<int> left = Task.Factory.StartNew (() => SumParallel (tree.Left, curDepth + 1)); return tree.Data + left.Value + right; } 16 / 23
  • 33. Why bother? ParallelFx A note for the future Questions Parallel.For Fractal fractal = new Fractal (width, height); ColorChooser colorChooser = new ColorChooser (); Parallel.For (0, width, (i) => { for (int j = 0; j < height; j++) { ProcessPixel (i, j, fractal, colorChooser); } }); 17 / 23
  • 34. Why bother? ParallelFx A note for the future Questions Demo: Parallel For Demo: image processing with parallel loops 18 / 23
  • 35. Why bother? ParallelFx A note for the future Questions PLinq ParallelEnumerable.Range (1, 1000)./* ... */ ParallelEnumerable.Repeat (‘‘Rupert’’, 1000)./* ... */ enumerable.AsParallel ()./* ... */ var query = from x in Directory.GetFiles ("/etc/") .AsParallel () where x.EndsWith (".conf") select x; query.ForAll ((e) => { Console.WriteLine ("{0} from {1}", e, Thread.CurrentThread.ManagedThreadId); }); 19 / 23
  • 36. Why bother? ParallelFx A note for the future Questions Demo: PLinq Demo: raytracing the PLinq way 20 / 23
  • 37. Why bother? ParallelFx A note for the future Questions State of things Mono 2.6 (December 2009): .NET 4 beta 1 Task, Future, Parallel loops Concurrent collections Coordination data structures Mono 2.8 (or git master): .NET 4 compliant Enabled by default Tons of improvement With PLinq! 21 / 23
  • 38. Why bother? ParallelFx A note for the future Questions A note for the future 22 / 23
  • 39. Why bother? ParallelFx A note for the future Questions A note for the future GLinq: GPGPU-powered Linq 22 / 23
  • 40. Why bother? ParallelFx A note for the future Questions A note for the future GLinq: GPGPU-powered Linq Re-use PLinq pipeline 22 / 23
  • 41. Why bother? ParallelFx A note for the future Questions A note for the future GLinq: GPGPU-powered Linq Re-use PLinq pipeline Same design guidelines than PLinq: simplicity, transparency 22 / 23
  • 42. Why bother? ParallelFx A note for the future Questions A note for the future GLinq: GPGPU-powered Linq Re-use PLinq pipeline Same design guidelines than PLinq: simplicity, transparency Rewrite C# code in OpenCL (Expression trees FTW!) 22 / 23
  • 43. Why bother? ParallelFx A note for the future Questions A note for the future GLinq: GPGPU-powered Linq Re-use PLinq pipeline Same design guidelines than PLinq: simplicity, transparency Rewrite C# code in OpenCL (Expression trees FTW!) Transparent mapping of OpenCL idioms to .NET 22 / 23
  • 44. Why bother? ParallelFx A note for the future Questions Closing the curtains 23 / 23