Visual C++ provides a rich set of technologies for writing multi-threaded and parallel programs. From the high-level Parallel Patterns Library (PPL) that ships as part of the Concurrency Runtime, to the standards-based OpenMP pragmas, to C++11Documentation Index
Fetch the complete documentation index at: https://mintlify.com/MicrosoftDocs/cpp-docs/llms.txt
Use this file to discover all available pages before exploring further.
std::thread, to fully automatic compiler-driven parallelization — there is a solution for every level of control and portability requirement. Choosing the right approach depends on how much explicit control you need, whether your parallelism is data-parallel or task-parallel, and whether portability to other compilers matters.
Parallelism Technology Comparison
Concurrency Runtime (PPL)
Best for: Task parallelism, parallel loops over collections, concurrent data structures. Part of the MSVC toolchain; no external dependencies.
OpenMP
Best for: Loop-level data parallelism in numerical code. Standards-based (OpenMP 2.0), portable to GCC and Clang. Enabled with
/openmp.std::thread / std::async
Best for: Portable, explicit thread management when you need fine-grained control without MSVC-specific APIs. Part of the C++11 Standard Library.
Auto-Parallelization (/Qpar)
Best for: Automatically parallelizing simple loops without code changes. Conservative — only safe loops are parallelized.
Concurrency Runtime and Parallel Patterns Library (PPL)
The Concurrency Runtime (ConcRT) is a concurrency framework built into MSVC that provides cooperative task scheduling, parallel algorithms, and concurrent containers. The Parallel Patterns Library (PPL) is its user-facing API layer.The PPL is available automatically when you include
<ppl.h>. No additional project settings are required beyond the default MSVC toolchain.Task-Based Parallelism
OpenMP
OpenMP provides compiler-directive-based parallelism using#pragma omp pragmas. It is the standard choice for scientific computing and numerical loops where portability across compilers is important.
std::thread and std::async (C++ Standard Library)
For maximum portability or when you need explicit thread lifecycle management, use C++11 standard library threading:
- std::thread
- std::async
Auto-Parallelization (/Qpar)
The MSVC auto-parallelizer analyzes loops at compile time and automatically generates multi-threaded code for loops it determines are safe to parallelize. No source changes are required.
/Qpar-report:1 to see which loops were parallelized, or /Qpar-report:2 to see why loops were not parallelized.
Auto-Vectorization (/O2)
Auto-vectorization is enabled automatically at /O2 and higher. The compiler generates SIMD instructions (SSE, AVX) for eligible loops. Use /arch:AVX2 to unlock 256-bit SIMD operations.
When to Choose Each Approach
| Scenario | Recommended Approach |
|---|---|
| Parallel algorithms over collections | PPL (parallel_for, parallel_for_each) |
| Asynchronous background tasks, continuations | PPL tasks / std::async |
| Scientific loop parallelism, cross-compiler portability | OpenMP (/openmp) |
| Explicit thread management, custom synchronization | std::thread |
| Zero-code-change performance on eligible loops | Auto-parallelization (/Qpar) |
| SIMD acceleration on numeric arrays | Auto-vectorization (/O2 /arch:AVX2) |
| GPU general-purpose computing (VS 2019 and earlier) | C++ AMP (deprecated in VS 2022+) |