|
dispenso 1.6.0
A library for task parallelism
|
Use dispenso when:
then() and when_all()Use something else when:
#pragma omp parallel for reduction(+:sum) syntax — dispenso's reduction requires per-thread state accumulation with manual combining (see Getting Started). A first-class reduction API is planned.In kernel context switch scenarios (networking, disk I/O, TLB misses), dispenso::Future can be used with dispenso::NewThreadInvoker for per-task threading similar to std::async.
Exceptions thrown inside parallel_for or TaskSet lambdas are caught and stored. When the calling thread calls wait() (or the TaskSet destructor runs), the first captured exception is rethrown. Other in-flight tasks continue to run — there is no immediate cancellation on exception.
For cooperative early termination without exceptions, use ConcurrentTaskSet with cancellation.
Builds with -fno-exceptions are fully supported. In that mode, dispenso uses abort() instead of throwing.
| Strategy | Best for | How it works |
|---|---|---|
kStatic (default) | Uniform per-element work | Divides range into equal chunks up front. Lowest overhead. |
kAdaptive | Non-uniform work (e.g., Mandelbrot) | Stripe-based with work stealing. Prefers same-L3 cache victims. |
kAuto | General use | Currently selects kStatic. May change in future versions. |
Use ParForOptions::minItemsPerChunk to set a lower bound on chunk size, preventing over-parallelization for cheap per-element work.
Dispenso tends to be faster for:
TBB tends to be faster for:
See the Interactive Benchmark Dashboard for detailed cross-platform comparisons, or the TBB Migration Guide for API mappings.
| Platform | Threading | CPU affinity | Topology detection | Wake mechanism |
|---|---|---|---|---|
| Linux x86_64/ARM64 | Full | Full | Full (sysfs) | futex |
| macOS ARM64/x86_64 | Full | No (OS limitation) | Full | os_sync_wait / ulock |
| Windows x86_64/ARM64 | Full | Full | Full | WaitOnAddress |
| FreeBSD | Full | Full (cpuset) | Full (sysctl) | _umtx_op |
| Android ARM64 | Full | Partial | Partial | futex |
C++14 minimum. C++17 enables std::shared_mutex benchmarks and some convenience features. C++20 adds concept constraints for better template error messages — no behavioral changes.
Yes:
#pragma omp with dispenso equivalents, handling reductions and nested parallelism