PREFACE 1 WANT TO GO FASTER? RAISE YOUR HANDS IF YOU WANT TO GO FASTER! Some Questions You May Have Four Steps of a Threading Methodology Background of Parallel Algorithms Shared-Memory Programming Versus Distributed-Memory Programming This Book’s Approach to Concurrent Programming 2 CONCURRENT OR NOT CONCURRENT? Design Models for Concurrent Algorithms What’s Not Parallel 3 PROVING CORRECTNESS AND MEASURING PERFORMANCE Verification of Parallel Algorithms Example: The Critical Section Problem Performance Metrics (How Am I Doing?) Review of the Evolution for Supporting Parallelism in Hardware 4 EIGHT SIMPLE RULES FOR DESIGNING MULTITHREADED APPLICATIONS Rule 1: Identify Truly Independent Computations Rule 2: Implement Concurrency at the Highest Level Possible Rule 3: Plan Early for Scalability to Take Advantage of Increasing Numbers of Cores Rule 4: Make Use of Thread-Safe Libraries Wherever Possible Rule 5: Use the Right Threading Model Rule 6: Never Assume a Particular Order of Execution Rule 7: Use Thread-Local Storage Whenever Possible or Associate Locks to Specific Data Rule 8: Dare to Change the Algorithm for a Better Chance of Concurrency Summary 5 THREADING LIBRARIES Implicit Threading Explicit Threading What Else Is Out There? Domain-Specific Libraries 6 PARALLEL SUM AND PREFIX SCAN Parallel Sum Prefix Scan Selection A Final Thought 7 MAPREDUCE Map As a Concurrent Operation Reduce As a Concurrent Operation Applying MapReduce MapReduce As Generic Concurrency 8 SORTING Bubblesort Odd-Even Transposition Sort Shellsort Quicksort Radix Sort 9 SEARCHING Unsorted Sequence Binary Search 10 GRAPH ALGORITHMS Depth-First Search All-Pairs Shortest Path Minimum Spanning Tree 11 THREADING TOOLS Debuggers Performance Tools Anything Else Out There? Go Forth and Conquer GLOSSARY PHOTO CREDITS INDEX