Dr. Dobb's Journal - December 2008 - (Page 10) D12vox_p4ds 10/10/08 9:17 AM Page 10 Alia Vox by Charles E. Leiserson The Case for a Concurrency Platform THE ADVENT OF MULTICORE processors is forcing software developers to explore multithreading. A critical decision is whether to “do it yourself” using POSIX threads (Pthreads) or WinAPI threads—which allow developers to directly manipulate operating-system threads—or to build atop a concurrency platform—a layer of software that coordinates, schedules, and manages the multicore resources. Concurrency platforms include any of various thread-pool libraries, such as .NET’s ThreadPool class; message-passing libraries, such as MPI; dataparallel programming languages, such as NESL, RapidMind, and variants of Fortran since Fortran 90; task-parallel libraries, such as Intel’s Threading Building Blocks (TBB) and Microsoft’s Task Parallel Library (TPL); and parallel linguistic extensions, such as OpenMP and Cilk++. I submit that most applications would do better by adopting a concurrency platform than by using DIY multithreading. Over 100 interviews of prospective customers have led us at Cilk Arts to identify three key evaluation criteria on which customers refuse to compromise. We call them the “multicore-software triad”: • Development time: Any solution must offer programmer productivity. Dramatic restructuring of massive codebases to enable parallelism is out of the question. In addition, organizations must be able to train or acquire developers with the skill sets necessary to multithread. • Application performance: The ostensible reason for multicoreenabling an application in the first place. In particular, good response time is a priority for human users. Moreover, as the number of processing cores per chip increases in accordance with Moore’s Law, companies cannot afford to tailor their applications to the specific number of cores provided by each processor generation. Their programs must scale. • Software reliability. In a word, races. Software with races can behave nondeterministically depending on how concurrent tasks are scheduled. These pernicious bugs are extremely hard to find by testing. Let’s start with performance. DIY multithreading may seem convenient if you can functionally decompose your application in a natural way—for example, into a user-interface thread, a compute thread, a render thread, and so on. This approach does not scale, however, because most applications contain only a few functional components suitable for implementation as separate threads. Moreover, if the threads’ computational needs vary, you may find that you’re significantly underutilizing processor cores. Even if you can break your application into many tasks, implementing each task as a thread may be impractical due to the large overheads for creating, switching, and synchronizing threads. One alternative is to write a scheduler to balance load across the processing cores, but that’s tantamount to implementing your own concurrency platform—a big hit on development time. In contrast, concurrency platforms allow you to express the parallelism in your application, and they take the responsibility of automatically managing tasks, load balancing, and synchronizing. DIY multithreaded applications are notoriously unreliable due to race conditions. A race occurs when concurrent threads access a shared-memory location and at least one of the threads stores a value into the location. Depending on how instructions are scheduled, the software may behave differently. DIY multithreading involves writing race-prone protocols for communication and synchronization, and regression testing is generally ineffective at detecting races. The alternative is manual code inspections that can dramatically increase development time. In contrast, concurrency platforms provide structured communication among logically parallel tasks, allowing programmers to avoid direct programming of protocols. Where protocols are necessary, some concurrency platforms offer race-detection tools. Although some such tools exist for DIY multithreading, they tend to offer less code coverage and run far more slowly than tools provided by concurrency platforms, adversely impacting guess what? Developer time. Parallel programming has earned a reputation for being difficult, and a good deal of that credit owes itself to applications written without a concurrency platform. So, if you don’t mind that your multicore software is a mess, if you don’t mind giving corner offices to the few engineers who have at least some clue as to what’s going on, if you don’t mind the occasional segment fault when your software is in the field, then DIY multithreading might be for you. But, if that prospect sounds at least mildly unpleasant, check out one of the concurrency platforms mentioned above. DDJ Charles is CTO, Chairman, and founder of Cilk Arts, and Professor of Computer Science and Engineering at MIT. His Introduction to Algorithms is the leading textbook on computer algorithms and the most-cited reference in all of computer science. Charles’s stints in the industry have included leadership positions at Thinking Machines and Akamai. Concurrency platforms allow you to express the parallelism in your application Although concurrency platforms have advantages over DIY multithreading with respect to application performance and software reliability, to a large extent, it boils down to the third leg of the triad—development time. 10 Dr. Dobb’s Journal l www.ddj.com l December 2008 http://www.ddj.com
Table of Contents Feed for the Digital Edition of Dr. Dobb's Journal - December 2008 Dr. Dobb's Journal - December 2008 Contents Friday Night Fish Fry Alia Vox Developer Diaries Conversations The Man Who Sold the Sky Performance on Rails LINQ-to-SQL and T-SQL A Remote Java RMI Registry Beyond B-Trees File Descriptors and Multithreaded Programs Effective Concurrency The Agile Edge Swaine's Flames Dr. Dobb's Journal - December 2008 Dr. Dobb's Journal - December 2008 - Dr. Dobb's Journal - December 2008 (Page Cover1) Dr. Dobb's Journal - December 2008 - Dr. Dobb's Journal - December 2008 (Page Cover2) Dr. Dobb's Journal - December 2008 - Dr. Dobb's Journal - December 2008 (Page 1) Dr. Dobb's Journal - December 2008 - Dr. Dobb's Journal - December 2008 (Page 2) Dr. Dobb's Journal - December 2008 - Dr. Dobb's Journal - December 2008 (Page 3) Dr. Dobb's Journal - December 2008 - Contents (Page 4) Dr. Dobb's Journal - December 2008 - Contents (Page 5) Dr. Dobb's Journal - December 2008 - Friday Night Fish Fry (Page 6) Dr. Dobb's Journal - December 2008 - Friday Night Fish Fry (Page 7) Dr. Dobb's Journal - December 2008 - Friday Night Fish Fry (Page 8) Dr. Dobb's Journal - December 2008 - Friday Night Fish Fry (Page 9) Dr. Dobb's Journal - December 2008 - Alia Vox (Page 10) Dr. Dobb's Journal - December 2008 - Alia Vox (Page 11) Dr. Dobb's Journal - December 2008 - Developer Diaries (Page 12) Dr. Dobb's Journal - December 2008 - Developer Diaries (Page 13) Dr. Dobb's Journal - December 2008 - Conversations (Page 14) Dr. Dobb's Journal - December 2008 - Conversations (Page 15) Dr. Dobb's Journal - December 2008 - The Man Who Sold the Sky (Page 16) Dr. Dobb's Journal - December 2008 - The Man Who Sold the Sky (Page 17) Dr. Dobb's Journal - December 2008 - The Man Who Sold the Sky (Page 18) Dr. Dobb's Journal - December 2008 - The Man Who Sold the Sky (Page 19) Dr. Dobb's Journal - December 2008 - Performance on Rails (Page 20) Dr. Dobb's Journal - December 2008 - Performance on Rails (Page 21) Dr. Dobb's Journal - December 2008 - Performance on Rails (Page 22) Dr. Dobb's Journal - December 2008 - Performance on Rails (Page 23) Dr. Dobb's Journal - December 2008 - Performance on Rails (Page 24) Dr. Dobb's Journal - December 2008 - Performance on Rails (Page 25) Dr. Dobb's Journal - December 2008 - Performance on Rails (Page 26) Dr. Dobb's Journal - December 2008 - Performance on Rails (Page 27) Dr. Dobb's Journal - December 2008 - Performance on Rails (Page 28) Dr. Dobb's Journal - December 2008 - LINQ-to-SQL and T-SQL (Page 29) Dr. Dobb's Journal - December 2008 - LINQ-to-SQL and T-SQL (Page 30) Dr. Dobb's Journal - December 2008 - LINQ-to-SQL and T-SQL (Page 31) Dr. Dobb's Journal - December 2008 - LINQ-to-SQL and T-SQL (Page 32) Dr. Dobb's Journal - December 2008 - LINQ-to-SQL and T-SQL (Page 33) Dr. Dobb's Journal - December 2008 - LINQ-to-SQL and T-SQL (Page 34) Dr. Dobb's Journal - December 2008 - A Remote Java RMI Registry (Page 35) Dr. Dobb's Journal - December 2008 - A Remote Java RMI Registry (Page 36) Dr. Dobb's Journal - December 2008 - A Remote Java RMI Registry (Page 37) Dr. Dobb's Journal - December 2008 - A Remote Java RMI Registry (Page 38) Dr. Dobb's Journal - December 2008 - A Remote Java RMI Registry (Page 39) Dr. Dobb's Journal - December 2008 - Beyond B-Trees (Page 40) Dr. Dobb's Journal - December 2008 - Beyond B-Trees (Page 41) Dr. Dobb's Journal - December 2008 - File Descriptors and Multithreaded Programs (Page 42) Dr. Dobb's Journal - December 2008 - File Descriptors and Multithreaded Programs (Page 43) Dr. Dobb's Journal - December 2008 - File Descriptors and Multithreaded Programs (Page 44) Dr. Dobb's Journal - December 2008 - File Descriptors and Multithreaded Programs (Page 45) Dr. Dobb's Journal - December 2008 - Effective Concurrency (Page 46) Dr. Dobb's Journal - December 2008 - Effective Concurrency (Page 47) Dr. Dobb's Journal - December 2008 - Effective Concurrency (Page 48) Dr. Dobb's Journal - December 2008 - The Agile Edge (Page 49) Dr. Dobb's Journal - December 2008 - The Agile Edge (Page 50) Dr. Dobb's Journal - December 2008 - The Agile Edge (Page 51) Dr. Dobb's Journal - December 2008 - Swaine's Flames (Page 52) Dr. Dobb's Journal - December 2008 - Swaine's Flames (Page Cover3) Dr. Dobb's Journal - December 2008 - Swaine's Flames (Page Cover4)
For optimal viewing of this digital publication, please enable JavaScript and then refresh the page. If you would like to try to load the digital publication without using Flash Player detection, please click here.