Synopses & Reviews
Multi-core chips from Intel and AMD offer a dramatic boost in speed and responsiveness, and plenty of opportunities for multiprocessing on ordinary desktop computers. But they also present a challenge: More than ever, multithreading is a requirement for good performance. This guide explains how to maximize the benefits of these processors through a portable C++ library that works on Windows, Linux, Macintosh, and Unix systems. With it, you'll learn how to use Intel Threading Building Blocks (TBB) effectively for parallel programming -- without having to be a threading expert.
Written by James Reinders, Chief Evangelist of Intel Software Products, and based on the experience of Intel's developers and customers, this book explains the key tasks in multithreading and how to accomplish them with TBB in a portable and robust manner. With plenty of examples and full reference material, the book lays out common patterns of uses, reveals the gotchas in TBB, and gives important guidelines for choosing among alternatives in order to get the best performance.
You'll learn how Intel Threading Building Blocks:
- Enables you to specify tasks instead of threads for better portability, easier programming, more understandable source code, and better performance and scalability in general
- Focuses on the goal of parallelizing computationally intensive work to deliver high-level solutions
- Is compatible with other threading packages, and doesn't force you to pick one package for your entire program
- Emphasizes scalable, data-parallel programming, which allows program performance to increase as you add processors
- Relies on generic programming, which enables you to write the best possible algorithms with the fewest constraints
Any C++ programmer who wants to write an application to run on a multi-core system will benefit from this book. TBB is also very approachable for a C programmer or a C++ programmer without much experience with templates. Best of all, you don't need experience with parallel programming or multi-core processors to use this book.
About the Author
James Reinders, Chief Evangelist of Intel Software Products, is a senior engineer who joined Intel Corporation in 1989 and has contributed to a number of projects, including the world's first TeraFLOP supercomputer (ASCI Red), compilers and architecture work for the iWarp, Pentium Pro, Pentium II, Itanium, and Pentium 4 processors. He has years of experience in processor architecture, optimizing compilers, parallel computer architecture, and making products for software developers.
Reinders is also the editorial columnist for the monthly "The Gauntlet" at www.devX.go-parallel.com, as well as the author of the Intel Press book titled "VTune Performance Analyzer Essentials" and contributor to the new book "Multi-Core Programming."
Table of Contents
Foreword; Note from the Lead Developer of Intel Threading Building Blocks; Preface; Assumptions This Book Makes; Contents of This Book; Conventions Used in This Book; Using Code Examples; How to Contact Us; Acknowledgments; Chapter 1: Why Threading Building Blocks?; 1.1 Overview; 1.2 Benefits; Chapter 2: Thinking Parallel; 2.1 Elements of Thinking Parallel; 2.2 Decomposition; 2.3 Scaling and Speedup; 2.4 What Is a Thread?; 2.5 Mutual Exclusion and Locks; 2.6 Correctness; 2.7 Abstraction; 2.8 Patterns; 2.9 Intuition; Chapter 3: Basic Algorithms; 3.1 Initializing and Terminating the Library; 3.2 Loop Parallelization; 3.3 Recursive Range Specifications; 3.4 Recursive Range Specifications; 3.5 Summary of Loops; Chapter 4: Advanced Algorithms; 4.1 Parallel Algorithms for Streams; Chapter 5: Containers; 5.1 concurrent_queue; 5.2 concurrent_vector; 5.3 concurrent_vector; 5.4 concurrent_hash_map; Chapter 6: Scalable Memory Allocation; 6.1 Limitations; 6.2 Problems in Memory Allocation; 6.3 Memory Allocators; 6.4 Replacing malloc, new, and delete; Chapter 7: Mutual Exclusion; 7.1 When to Use Mutual Exclusion; 7.2 Mutexes; 7.3 Mutexes; 7.4 Atomic Operations; Chapter 8: Timing; Chapter 9: Task Scheduler; 9.1 When Task-Based Programming Is Inappropriate; 9.2 Much Better Than Raw Native Threads; 9.3 Initializing the Library Is Your Job; 9.4 Example Program for Fibonacci Numbers; 9.5 Task Scheduling Overview; 9.6 How Task Scheduling Works; 9.7 Recommended Task Recurrence Patterns; 9.8 Making Best Use of the Scheduler; 9.9 Task Scheduler Interfaces; 9.10 Task Scheduler Summary; Chapter 10: Keys to Success; 10.1 Key Steps to Success; 10.2 Relaxed Sequential Execution; 10.3 Safe Concurrency for Methods and Libraries; 10.4 Debug Versus Release; 10.5 For Efficiency's Sake; 10.6 Enabling Debugging Features; 10.7 Mixing with Other Threading Packages; 10.8 Naming Conventions; Chapter 11: Examples; 11.1 The Aha! Factor; 11.2 A Few Other Key Points; 11.3 parallel_for Examples; 11.4 The Game of Life; 11.5 Parallel_reduce Examples; 11.6 CountStrings: Using concurrent_hash_map; 11.7 Quicksort: Visualizing Task Stealing; 11.8 A Better Matrix Multiply (Strassen); 11.9 Advanced Task Programming; 11.10 Packet Processing Pipeline; 11.11 Memory Allocation; 11.12 Game Threading Example; 11.13 Physics Interaction and Update Code; 11.14 Open Dynamics Engine; Chapter 12: History and Related Projects; 12.1 Libraries; 12.2 Languages; 12.3 Pragmas; 12.4 Generic Programming; 12.5 Caches; 12.6 Costs of Time Slicing; 12.7 Quick Introduction to Lambda Functions; 12.8 Further Reading; Colophon;