You are previewing Parallel Programming with Microsoft® Visual C++®.
O'Reilly logo
Parallel Programming with Microsoft® Visual C++®

Book Description

Save time and reduce risk on your software development projects by incorporating patterns &practices, Microsoft®'s applied engineering guidance that includes both production quality source code and documentation.

Table of Contents

  1. Parallel Programming with Microsoft Visual C++®: Design Patterns for Decomposition and Coordination on Multicore Architectures
  2. Foreword
  3. Preface
    1. Who This Book Is For
    2. Why This Book Is Pertinent Now
    3. What You Need to Use the Code
    4. How to Use This Book
      1. Introduction
      2. Parallelism with Control Dependencies Only
      3. Parallelism with Control and Data Dependencies
      4. Dynamic Task Parallelism and Pipelines
      5. Supporting Material
    5. What Is Not Covered
    6. Goals
  4. Acknowledgments
  5. 1. Introduction
    1. The Importance of Potential Parallelism
    2. Decomposition, Coordination, and Scalable Sharing
      1. Understanding Tasks
      2. Coordinating Tasks
      3. Scalable Sharing of Data
      4. Design Approaches
    3. Selecting the Right Pattern
    4. A Word about Terminology
    5. The Limits of Parallelism
    6. A Few Tips
    7. Exercises
    8. For More Information
  6. 2. Parallel Loops
    1. The Basics
      1. Parallel for Loops
      2. Parallel_for_Each
      3. What to Expect
    2. An Example
      1. Sequential Credit Review Example
      2. Credit Review Example Using parallel_for_each
      3. Performance Comparison
    3. Variations
      1. Breaking out of Loops Early
      2. Exception Handling
      3. Special Handling of Small Loop Bodies
      4. Controlling the Degree of Parallelism
    4. Anti-Patterns
      1. Hidden Loop Body Dependencies
      2. Small Loop Bodies with Few Iterations
      3. Duplicates in the Input Enumeration
      4. Scheduling Interactions with Cooperative Blocking
    5. Related Patterns
    6. Exercises
    7. Further Reading
  7. 3. Parallel Tasks
    1. The Basics
    2. An Example
    3. Variations
      1. Coordinating Tasks with Cooperative Blocking
      2. Canceling a Task Group
      3. Handling Exceptions
      4. Speculative Execution
    4. Anti-Patterns
      1. Variables Captured by Closures
      2. Unintended Propagation of Cancellation Requests
      3. The Cost of Synchronization
    5. Design Notes
      1. Task Group Calling Conventions
      2. Tasks and Threads
      3. How Tasks Are Scheduled
      4. Structured Task Groups and Task Handles
      5. Lightweight Tasks
    6. Exercises
    7. Further Reading
  8. 4. Parallel Aggregation
    1. The Basics
    2. An Example
    3. Variations
      1. Considerations for Small Loop Bodies
      2. Other Uses for Combinable Objects
    4. Design Notes
    5. Related Patterns
    6. Exercises
    7. Further Reading
  9. 5. Futures
    1. The Basics
      1. Futures
    2. Example: The Adatum Financial Dashboard
      1. The Business Objects
      2. The Analysis Engine
    3. Variations
      1. Canceling Futures
      2. Removing Bottlenecks
      3. Modifying the Graph at Run Time
    4. Design Notes
      1. Decomposition into Futures
      2. Functional Style
    5. Related Patterns
      1. Pipeline Pattern
      2. Master/Worker Pattern
      3. Dynamic Task Parallelism Pattern
      4. Discrete Event Pattern
    6. Exercises
  10. 6. Dynamic Task Parallelism
    1. The Basics
    2. An Example
    3. Variations
      1. Parallel While-Not-Empty
      2. Adding Tasks to a Pending Wait Context
    4. Exercises
    5. Further Reading
  11. 7. Pipelines
    1. Types of Messaging Blocks
    2. The Basics
    3. An Example
      1. Sequential Image Processing
      2. The Image Pipeline
      3. Performance Characteristics
    4. Variations
      1. Asynchronous Pipelines
      2. Canceling a Pipeline
      3. Handling Pipeline Exceptions
      4. Load Balancing Using Multiple Producers
      5. Pipelines and Streams
    5. Anti-Patterns
      1. Copying Large Amounts of Data between Pipeline Stages
      2. Pipeline Stages that Are Too Small
      3. Forgetting to Use Message Passing for Isolation
      4. Infinite Waits
      5. Unbounded Queue Growth
      6. More Information
    6. Design Notes
    7. Related Patterns
    8. Exercises
    9. Further Reading
  12. A. The Task Scheduler and Resource Manager
    1. Resource Manager
      1. Why It’s Needed
      2. How Resource Management Works
      3. Dynamic Resource Management
      4. Oversubscribing Cores
      5. Querying the Environment
    2. Kinds of Tasks
      1. Lightweight Tasks
      2. Tasks Created Using PPL
    3. Task Schedulers
      1. Managing Task Schedulers
        1. Creating and Attaching a Task Scheduler
        2. Detaching a Task Scheduler
        3. Destroying a Task Scheduler
        4. Scenarios for Using Multiple Task Schedulers
        5. Implementing a Custom Scheduling Component
      2. The Scheduling Algorithm
        1. Schedule Groups
        2. Adding Tasks
        3. Running Tasks
        4. Enhanced Locality Mode
        5. Forward Progress Mode
        6. Task Execution Order
        7. Tasks That Are Run Inline
      3. Using Contexts to Communicate with the Scheduler
        1. Debugging Information
        2. Querying for Cancellation
        3. Interface to Cooperative Blocking
        4. Waiting
        5. The Caching Suballocator
        6. Long-Running I/O Tasks
      4. Setting Scheduler Policy
    4. Anti-Patterns
      1. Multiple Resource Managers
      2. Resource Management Overhead
      3. Unintentional Oversubscription from Inlined Tasks
      4. Deadlock from Thread Starvation
      5. Ignored Process Affinity Mask
    5. References
  13. B. Debugging and Profiling Parallel Applications
    1. The Parallel Tasks and Parallel Stacks Windows
    2. Breakpoints and Memory Allocation
    3. The Concurrency Visualizer
      1. Scenario Markers
    4. Visual Patterns
      1. Oversubscription
      2. Lock Contention and Serialization
      3. Load Imbalance
    5. Further Reading
  14. C. Technology Overview
    1. Further Reading
  15. Glossary
  16. Index
  17. About the Authors
  18. Copyright