How do developers use parallel Libraries? Semih Okur & Danny Dig University of Illinois at Urbana- Champaign.

Slides:



Advertisements
Similar presentations
James Kolpack, InRAD LLC popcyclical.com. CodeStock is proudly partnered with: Send instant feedback on this session via Twitter: Send a direct message.
Advertisements

FUTURE OF.NET PARALLEL PROGRAMMING Joseph Albahari SESSION CODE: DEV308 (c) 2011 Microsoft. All rights reserved.
A Dynamic World, what can Grids do for Multi-Core computing? Daniel Goodman, Anne Trefethen and Douglas Creager
Rules for Designing Multithreaded Applications CET306 Harry R. Erwin University of Sunderland.
/ PSWLAB Concurrent Bug Patterns and How to Test Them by Eitan Farchi, Yarden Nir, Shmuel Ur published in the proceedings of IPDPS’03 (PADTAD2003)
The Path to Multi-core Tools Paul Petersen. Multi-coreToolsThePathTo 2 Outline Motivation Where are we now What is easy to do next What is missing.
PARALLEL PROGRAMMING WITH OPENMP Ing. Andrea Marongiu
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 2 nd Edition Chapter 4: Threads.
1 Tuesday, November 07, 2006 “If anything can go wrong, it will.” -Murphy’s Law.
DISTRIBUTED AND HIGH-PERFORMANCE COMPUTING CHAPTER 7: SHARED MEMORY PARALLEL PROGRAMMING.
Virtual techdays INDIA │ 9-11 February 2011 Parallelism in.NET 4.0 Parag Paithankar │ Technology Advisor - Web, Microsoft India.
Software Group © 2006 IBM Corporation Compiler Technology Task, thread and processor — OpenMP 3.0 and beyond Guansong Zhang, IBM Toronto Lab.
Behavioral Design Outline –Design Specification –Behavioral Design –Behavioral Specification –Hardware Description Languages –Behavioral Simulation –Behavioral.
CS220 Software Development Lecture: Multi-threading A. O’Riordan, 2009.
Microprocessors Introduction to ia64 Architecture Jan 31st, 2002 General Principles.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
PARALLEL PROGRAMMING ABSTRACTIONS 6/16/2010 Parallel Programming Abstractions 1.
Parallel Programming in.NET Kevin Luty.  History of Parallelism  Benefits of Parallel Programming and Designs  What to Consider  Defining Types of.
SEC(R) 2008 Intel® Concurrent Collections for C++ - a model for parallel programming Nikolay Kurtov Software and Services.
Parallel Programming in Java with Shared Memory Directives.
Lecture 4: Parallel Programming Models. Parallel Programming Models Parallel Programming Models: Data parallelism / Task parallelism Explicit parallelism.
Prospector : A Toolchain To Help Parallel Programming Minjang Kim, Hyesoon Kim, HPArch Lab, and Chi-Keung Luk Intel This work will be also supported by.
Multi-core Programming Thread Profiler. 2 Tuning Threaded Code: Intel® Thread Profiler for Explicit Threads Topics Look at Intel® Thread Profiler features.
國立台灣大學 資訊工程學系 Chapter 4: Threads. 資工系網媒所 NEWS 實驗室 Objectives To introduce the notion of a thread — a fundamental unit of CPU utilization that forms the.
Collage of Information Technology University of Palestine Advanced programming MultiThreading 1.
Silberschatz, Galvin and Gagne ©2011Operating System Concepts Essentials – 8 th Edition Chapter 4: Threads.
Process Management. Processes Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication.
Parallel Programming Models Jihad El-Sana These slides are based on the book: Introduction to Parallel Computing, Blaise Barney, Lawrence Livermore National.
1 OpenMP Writing programs that use OpenMP. Using OpenMP to parallelize many serial for loops with only small changes to the source code. Task parallelism.
CS 390- Unix Programming Environment CS 390 Unix Programming Environment Topics to be covered: Distributed Computing Fundamentals.
Uncovering the Multicore Processor Bottlenecks Server Design Summit Shay Gal-On Director of Technology, EEMBC.
OpenMP – Introduction* *UHEM yaz çalıştayı notlarından derlenmiştir. (uhem.itu.edu.tr)
Use of Coverity & Valgrind in Geant4 Gabriele Cosmo.
About Me Microsoft MVP Intel Blogger TechEd Israel, TechEd Europe Expert C++ Book
MATRIX MULTIPLY WITH DRYAD B649 Course Project Introduction.
CS 346 – Chapter 4 Threads –How they differ from processes –Definition, purpose Threads of the same process share: code, data, open files –Types –Support.
Lecture 21 Parallel Programming Richard Gesick. Parallel Computing Parallel computing is a form of computation in which many operations are carried out.
The Singleton Pattern SE-2811 Dr. Mark L. Hornick 1.
Data Parallelism Task Parallel Library (TPL) The use of lambdas Map-Reduce Pattern FEN 20141UCN Teknologi/act2learn.
Parallelism without Concurrency Charles E. Leiserson MIT.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 4: Threads.
3/12/2013Computer Engg, IIT(BHU)1 OpenMP-1. OpenMP is a portable, multiprocessing API for shared memory computers OpenMP is not a “language” Instead,
CPE779: Shared Memory and OpenMP Based on slides by Laxmikant V. Kale and David Padua of the University of Illinois.
Tuning Threaded Code with Intel® Parallel Amplifier.
Concurrent Programming in Java Based on Notes by J. Johns (based on Java in a Nutshell, Learning Java) Also Java Tutorial, Concurrent Programming in Java.
Concurrent Revisions: A deterministic concurrency model. Daan Leijen & Sebastian Burckhardt Microsoft Research (OOPSLA 2010, ESOP 2011)
Chapter 4 – Thread Concepts
Chapter 4: Threads Modified by Dr. Neerja Mhaskar for CS 3SH3.
Chapter 4: Multithreaded Programming
Chapter 4: Threads.
Slide design: Dr. Mark L. Hornick
Threads.
Chapter 4 – Thread Concepts
Async or Parallel? No they aren’t the same thing!
Pattern Parallel Programming
Computer Engg, IIT(BHU)
Functional Programming with Java
Chapter 4: Threads.
Pattern Parallel Programming
Chapter 4: Threads.
Shared Memory Programming
Programming with Shared Memory
Chapter 4: Threads.
Chapter 4: Threads & Concurrency
Chapter 4: Threads.
Chapter 4: Threads.
Chapter 4: Threads.
Chapter 4: Threads.
Chapter 4 Threads!!!.
Lecture 20 Parallel Programming CSE /8/2019.
Presentation transcript:

How do developers use parallel Libraries? Semih Okur & Danny Dig University of Illinois at Urbana- Champaign

Why 2 Parallel HARDWARE is Everywhere NOW 2004

Why 3 Parallel programming is hard [From “The Practice of Parallel Programming” book cover] Requires balancing two conflicting forces (1) Thread-safe (2) Scalable Makes the code more complex

Why 4 parallel libraries are widespread PPL & ConcRT java.util.concurren t

Why 5 which parallel libraries are you most familiar with? A) OpenMP for C/C++ B) Intel TBB for C/C++ C) java.util.concurrent package for Java D) Microsoft Parallel Libraries for C# E) None of them

Why 6 We know nothing about how developers use these libraries No empirical study on a large-scale so far 4 different communities strongly need such a study

Why 7 Developers Without such a study

Why 8 Miss educational resources Cannot decide whether to invest time to learn API Developers Without such a study

Why 9

10 Researchers Miss educational resources Cannot decide whether to invest time to learn API Developers Without such a study

Why 11 Make wrong assumptions Researchers Miss educational resources Cannot decide whether to invest time to learn API Developers Without such a study

Why 12 Library Designers Stephen Toub Make wrong assumptions Researchers Cannot decide whether to invest time to learn API Developers Without such a study Miss educational resources

Why 13 In danger of designing error- prone, hard to use APIs Library Designers Make wrong assumptions Researchers Cannot decide whether to invest time to learn API Developers Without such a study Miss educational resources

Why 14 Tool Vendors In danger of designing error- prone, hard to use APIs Library Designers Make wrong assumptions Researchers Cannot decide whether to invest time to learn API Developers Without such a study Miss educational resources

Why 15 Don’t know what to automate Tool Vendors In danger of designing error- prone, hard to use APIs Library Designers Make wrong assumptions Researchers Cannot decide whether to invest time to learn API Developers Without such a study Miss educational resources

Why 16 Are developers embracing multi-threading? How quickly do developers start using the newly released parallel libraries? Which parallel constructs do developers use most often? How do developers protect accesses to shared variables? Which parallel patterns do developers embrace? Which advanced features do developers use? Do developers make their parallel code unnecessarily complex? Are there constructs that developers commonly mis-use?

Why 17 Are developers embracing multi-threading? How quickly do developers start using the newly released parallel libraries? Which parallel constructs do developers use most often? How do developers protect accesses to shared variables? Which parallel patterns do developers embrace? Which advanced features do developers use? Do developers make their parallel code unnecessarily complex? Are there constructs that developers commonly mis-use?

18 Why C# What is our data? How do we gather information from the data? How Why

How 19 Rising trend: C# parallel

Why 20 which one does not belong to C# parallel libraries? A) Concurrent Collections B) Task Parallel Library (TPL) C) Threading D) Parallel Patterns Library (PPL) E) Plinq

How 21 C# Parallel api 2010.NET 4.0 is released Collections.Concurren tPLINQTPL 2002.NET 1.0 is released Threading Old New

How 22 corpus of data Downloaded all C# projects as of January 31, Filters: 1.Discarded toy applications (less than 1000 non-comment SLOC) Compilable and targeting.NET 4.0 After all, got 7778 applications

How 23 corpus of data Size According to SLOC => Small (1K- 10K) Medium (10K- 100K) Large (>100K) Total Multi-threaded Applications Focused on the apps adopted new parallel libraries: TPL & PLINQ 655 applications = 17.6M SLOC by1609 programmers # Apps in Colored Area: 655

How 24 AUTOMATED STATIC analysis based on Microsoft Roslyn Project syntactic (lexical) analysis: traversing AST nodes used Syntax API of Roslyn semantic analysis: get type and object binding information used Symbol and Binding APIs of Roslyn Collected the usage details for each construct in 4 libraries patterns based on heuristics

25 Present the results for 3 of our 8 research questions Why What How

What 26 Rq1: Are developers embracing multi-threading? Should we learn how to use parallel libraries, or should we avoid them because they are a passing fad? We built multicores but do developers exploit parallelism?

What 27 Rq1: Are developers embracing multi-threading? SmallMediumLargeTotal Applications compilable and targeting.NET Multi-threaded Applications %87%

What 28 39%74% 13% RQ1: HOW MANY APPS USE PARALLELISM VS CONCURRENCY? Concurrency FromAsync, TaskCompletion- Source, UI event dispatching thread Parent thread does not wait for worker threads Parallelism Parallel.For, PLINQ constructs Parent thread forks worker threads and waits for them to finish

What 29 Many applications have embraced multi-threading, however many of them use it for concurrency rather than parallelism. RQ1: ARE DEVELOPERS EMBRACING MULTI-THREADING? Developers will not be able to avoid multi- threaded programming for much longer Intel should be happy. Developers are taking advantage of multicores

What 30 RQ7: Do developers make their parallel code unnecessarily complex? Parallel code is much more complex than sequential code. Why is my parallel code so complex? Can we simplify the parallel code?

What 31 RQ7: Do developers make their parallel code unnecessarily complex? for (int i = 1; i DoInsert(...)); tasks.Add(taskHandle);}Task.WaitAll(tasks); Parallel.For(1,threadCount,(i)=>DoInsert(..)) 29% of all cases creating tasks in loop could have used Parallel.For or Parallel.ForEach “ravendb” [github.com/ravendb/ravendb]

What 32 RQ7: Do developers make their parallel code unnecessarily complex? Refactorings to improve the readability of parallel code are desperately needed Despite the fact that parallel programs are already complex, developers make them even more complex than they need to be.

What 33 RQ8: Are there constructs that developers commonly misuse? Why does not my code get any speedup with parallel constructs? What are these constructs that developers misuse?

What 34 Q8: Are there constructs that developers commonly misuse?

What 35 RQ8: Are there constructs that developers commonly misuse? Why does not my code get any speedup with parallel constructs? Which constructs do developers misuse?

What 36 RQ8: Are there constructs that developers commonly misuse? assembly.GetTypes().AsParallel(). Where(t => t.IsSubclassOf(...)). ForAll(t => controllersCache.Add(...)); AsParallel() from PLINQ Correct

What 37 RQ8: Are there constructs that developers commonly misuse? foreach (var module in Modules.AsParallel()) module.Refresh(); The foreach proceeds sequentially. 12% of all AsParallel usages are incorrect Incorrect “profit” [profit.codeplex.com]

What 38 RQ8: Are there constructs that developers commonly misuse? Misuse of parallel constructs can lead to code with parallel syntax but sequential execution.

So What 39 so what?

So What 40 Library designers Learn how to make the APIs easier and less error-prone to use Confirmed that our suggestions are useful and will influence the future development of the libraries

So What 41 Tool vendors & researchers Focus on their efforts on widely (mis)used constructs and patterns

So What 42 ET FOR DEVELOPERS 3700 unique organic visitors from 88 different countries generates page views in 4 months we created

So What 43

So What 44

So What 47 conclusion First large-scale empirical study on the usage of parallel libraries We answered 8 research questions related to adoption, frequently (mis)used constructs, and patterns. Implications for Developers: Library Designers: awareness of API problems Researchers & Tool Vendors: know what to automate

Why 48 BACKUP Slides

What 49 PARALLELISM VS CONCURRENCY throughputresponsiveness [From: Tom Ball’s slides]

What 50 q1: How many apps use Parallelism vs Concurrency?

What 51 Q1: ARE DEVELOPERS EMBRACING MULTI-THREADING? Developer Tools7 Data Mining7 Multimedia6 Graphics6 Games5 Cloud Computing5 Finance3 Database3 Networking3 Social Media2 Killer applications for parallelism

What 52 q2: How quickly do developers start using the new TPL & PLINQ libraries? How long does it take for developers to start using new parallel libraries?

What 53 q2: How quickly do developers start using the new TPL & PLINQ libraries? Purpose is to find out the tipping point for new parallel constructs Tipping point: magic moment when a trend spreads like wildfire

What 54 q2: How quickly do developers start using the new TPL & PLINQ libraries? Selected the subset of applications that exist in the repository as of April 2010: 54 out of 655 Analyzed monthly snapshots: 31.9MLOC, comprising 694 different versions Collected the usage details of TPL & PLINQ constructs from these versions

What 55 TIPPING POINT Small Medium Large after 2-3 months after 4-5 months after 8-9 months # APPLICATIONS

What 56 Applications of different size adopt the new parallel libraries differently Small applications are early adopters. They have higher density of parallel constructs Developers are better off looking for parallelism examples in small applications. Q2: HOW QUICKLY DO DEVELOPERS START USING THE NEW TPL & PLINQ LIBRARIES?

What 57 q3: Which parallel constructs do developers use most often? Which constructs do developers prefer to use and which ones do not they prefer? How can I become proficient quickly? Where can I find sample code?

What 58 q3: Which parallel constructs do developers use most often? Usage details for 4 Libraries, 138 classes, 1651 methods Detected each method call, class constructor call and got the type of the caller and callee by using Symbol and Binding APIs Type information: 100% precise

What 59 q3: Which parallel constructs do developers use most often?

What 60 67% (1114) of all method signatures are never used 10% of the API methods account for 90% of the total usage. Q3: WHICH PARALLEL CONSTRUCTS DO DEVELOPERS USE MOST OFTEN? Percent of Parallel Constructs Percent of Total Usage

What 61 Good news for developers who are just learning parallel libraries: they can focus on learning a relatively small subset of the library APIs and still be able to master a large number of parallelism scenarios. Library designers can think about never used methods. How to reduce API size? Parallel library usage follows a power-law distribution: 10% of the API methods account for 90% of the total usage. Q3: WHICH PARALLEL CONSTRUCTS DO DEVELOPERS USE MOST OFTEN?

What 62 q4: How do developers protect accesses to shared variables? Which synchronization types should we model in our algorithms and tools?

What 63 q4: How do developers protect accesses to shared variables? Around 25 different synchronization constructs in 5 different categories: Locking, non-blocking, signaling, implicit, blocking

What 64 61%

What 65 q4: How do developers protect accesses to shared variables? Data-race detectors should also model these other synchronization constructs, not only locks! While locks are still very popular, developers use a wide variety of other synchronization constructs.

What 66 Q5: Which parallel patterns do developers embrace? Where can we find real world examples of parallel patterns? Which parallel patterns should we support in our tools?

What 67 Q5: Which parallel patterns do developers embrace? Data Parallelis m Task Parallelis m Regular Parallel Loops Aggregation (parallel dependent loops) Regular fork join tasks futures, task dependency pipeline dynamic task parallelism

What 68 Q5: Which parallel patterns do developers embrace? Data Parallelis m (68%) Task Parallelis m (32%) Regular Parallel Loops Aggregation (parallel dependent loops) Regular fork join tasks futures, task dependency pipeline dynamic task parallelism

What 69 Our study also educates developers by showing real-world examples of parallel patterns Regular data parallelism is the most used parallel pattern in practice Q5: WHICH PARALLEL PATTERNS DO DEVELOPERS EMBRACE?

What 70 Q6: Which advanced features do developers use? Are developers using our fancy features?

What 71 Q6: Which advanced features do developers use? [From us/library/dd aspx] us/library/dd aspx]

What 72 Q6: Which advanced features do developers use? All Parallel class methods (Invoke, For, ForEach) can take ParallelOptions as an argument. With ParallelOptions; (1) insert a cancellation token (2) limit the maximum concurrency (3) specify a custom task scheduler. ParallelOptions opts= new ParallelOptions { CancellationToken= (new CancellationTokenSource()).token; MaxDegreeOfParallelism = Environment.ProcessorCount; TaskScheduler= new QueuedTaskScheduler()}; Parallel.For(0, 100, options, i=> {... });

What 73 Of 852 method calls of Parallel class, only 3% use ParallelOptions. When ParallelOptions is used: Custom TaskScheduler is used only once 60% of the times developers overwrite MaxDegreeOfParallelism to be equal with the number of processors ParallelOptions opts= new ParallelOptions { MaxDegreeOfParallelism = Environment.ProcessorCount; Q6: WHICH ADVANCED FEATURES DO DEVELOPERS USE?

What 74 To Library Designers: developers are not happy about the default degree of parallelism. The advanced features and optional arguments are rarely used in practice Q6: WHICH ADVANCED FEATURES DO DEVELOPERS USE?

What 75 Q7: Do developers make their parallel code unnecessarily complex? var runDaemons = new Task(RunDaemonJobs,..);...var runScheduledJobs = new Task(RunScheduledJobs,..); var tasks = new[] {runDaemons,..., runScheduledJobs};Array.ForEach(tasks, x => x.Start()); Task.WaitAll(tasks); Parallel.Invoke(RunDaemonJobs,...,RunScheduledJobs); 63 out of 268 regular fork/join task parallelism, the programmers could have used Parallel.Invoke

What 76 Q8: Are there constructs that developers commonly misuse? Parallel.Invoke(() => i.ImportGPX(..)); ImportGPX will execute in parallel with the main thread, when in fact it doesn’t. 11% of all usages of Parallel.Invoke take only one action parameter in different applications. blocking main thread another thread importGPX(..)