diff --git a/.gitignore b/.gitignore index 4ec4d2c..0df4343 100644 --- a/.gitignore +++ b/.gitignore @@ -39,6 +39,8 @@ build_*/ # Generated benchmark and documentation artifacts # The final v1.1 real-world CSV/Markdown results are intentionally versioned. validation/output/*.csv +!validation/output/v1.4.0_parallel_algorithms.csv +!validation/output/v1.4.0_parallel_algorithms_raw.csv validation/output/plots/ docs/generated/ diff --git a/CHANGELOG.md b/CHANGELOG.md index f939d5f..02e3ff9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,51 @@ All notable public changes to SmartParallel are documented here. Detailed internal milestone history is retained in [`docs/archive/v1.1-development/CHANGELOG_DEVELOPMENT_HISTORY.md`](docs/archive/v1.1-development/CHANGELOG_DEVELOPMENT_HISTORY.md). +## [1.4.0] — Parallel algorithm expansion + +### Added + +- `parallel_for_each`, unary/binary `parallel_transform`, `parallel_copy`, `parallel_fill`, and indexed `parallel_generate`. +- `parallel_reduce` and unary/binary `parallel_transform_reduce` with ordered chunk combination. +- `parallel_count`, `parallel_count_if`, `parallel_any_of`, `parallel_all_of`, and `parallel_none_of`. +- `parallel_find` and `parallel_find_if` with earliest-index result semantics. +- Dedicated cross-backend correctness, nested execution, exception, sanitizer, installed-package, and benchmark validation. +- A versioned v1.4 benchmark matrix with sequential, automatic, ThreadPool, StaticThread, and oneTBB modes. + +### Fixed + +- Added a scheduler-approved direct sequential range path for v1.4 algorithms. When automatic scheduling selects sequential execution, the algorithm now uses one-pass standard-library or iterator traversal instead of executing logical chunks through per-chunk dispatch, partial-result storage, or search/predicate atomics. +- Deferred per-chunk callable copies and reduction partial storage until a chunk is actually executed, keeping the cached sequential path close to the direct sequential baseline without changing parallel plans or backend behavior. +- Added deterministic validation that cached automatic sequential plans preserve correctness for reduce, count, and search. +- Added an Auto-only, root-only algorithm hot-dispatch cache for `parallel_reduce`, `parallel_count`, `parallel_find`, `parallel_find_if`, `parallel_any_of`, `parallel_all_of`, `parallel_none_of`, and `parallel_copy`. It learns from separate real complete scheduled and sequential invocations, then bypasses chunk construction and scheduler entry when direct sequential execution wins. +- Added bounded, sharded dispatch retention, workload/byte buckets, policy and profile-cache epoch invalidation, single-flight probes, hysteresis, and periodic revalidation. +- Corrected `parallel_copy` learning by measuring actual sequential copy time instead of inferring it from a bandwidth-limited parallel execution; scheduled chunks now use `std::copy` so contiguous iterators retain standard-library optimizations. +- Reduced search and predicate coordination overhead with relaxed atomics while retaining scheduler-completion synchronization. +- Cached Windows hardware topology discovery for the process lifetime, matching the existing Linux and macOS behavior. + +### Architecture + +- All algorithms reuse the existing adaptive scheduler, backend abstraction, runtime learning, nested coordinator, concurrency budgets, ThreadPool helping, StaticThread engine, and oneTBB arenas. +- Algorithms submit bounded contiguous logical chunks through one internal scheduler adapter; no second execution model was introduced. +- Existing `parallel_for`, scheduler policy, backend logic, and v1.1 benchmark algorithms remain unchanged. + +### Semantics + +- v1.4 algorithms require random-access iterators. +- Reduction operations must be associative; chunk and input ordering are preserved but parenthesization may differ from a sequential fold. +- Predicate and search algorithms use best-effort short-circuiting, and search returns the earliest match. +- User callables may execute concurrently and must synchronize shared mutable state. + +### Validation + +- GCC Release passed the complete 17-test deterministic suite. +- Clang Release and Clang ASan+UBSan passed the v1.4 algorithm validation. +- The installed CMake package consumer compiled and executed v1.4 transform and reduction APIs. +- Local GCC and Clang benchmark matrices passed checksum validation for every API. +- The accepted Windows/MSVC Release snapshot passed all 80 summary rows and 560 raw samples with checksum correctness and backend authentication. +- The eight parallel-selected automatic cases achieved a 3.30× geometric-mean speedup; all eight corrected cheap-dispatch families were within 3.5% of direct sequential latency or faster. +- Added a versioned v1.4 benchmark report, reproduction guide, PNG/SVG figures, generated metrics, and source hashes. + ## [1.3.0] — Cross-platform CI and portability ### Added @@ -77,6 +122,7 @@ All notable public changes to SmartParallel are documented here. Detailed intern - Added ThreadPool, StaticThread, oneTBB, and sequential execution paths. - Added bounded runtime experience, diagnostics, validation programs, and the original OpenCV/scientific benchmark suite. +[1.4.0]: docs/v1.4/release-notes.md [1.3.0]: docs/v1.3/release-notes.md [1.1.0]: docs/v1.1/release-notes.md [1.0.0]: docs/v1.0/README.md diff --git a/CMakeLists.txt b/CMakeLists.txt index 623db0d..0ed182e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,7 @@ endif() project( SmartParallel - VERSION 1.3.0 + VERSION 1.4.0 DESCRIPTION "Adaptive parallel scheduling for modern C++" LANGUAGES CXX ) @@ -74,6 +74,10 @@ option(SMARTPARALLEL_BUILD_PARALLEL_FOR_HARDENING "Build parallel_for hardening tests" OFF) option(SMARTPARALLEL_BUILD_PARALLEL_FOR_OVERHEAD "Build parallel_for overhead benchmark" OFF) +option(SMARTPARALLEL_BUILD_V140_ALGORITHM_VALIDATION + "Build v1.4 parallel algorithm correctness validation" OFF) +option(SMARTPARALLEL_BUILD_V140_ALGORITHM_BENCHMARKS + "Build v1.4 parallel algorithm benchmark suite" OFF) option(SMARTPARALLEL_BUILD_SCIENTIFIC_TEST1 "Build scientific Test 1: numerical integration" OFF) option(SMARTPARALLEL_BUILD_SCIENTIFIC_TEST2 diff --git a/CMakePresets.json b/CMakePresets.json index bb238f8..d1c50f7 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -63,6 +63,19 @@ "SMARTPARALLEL_BUILD_ALL": "ON" } }, + { + "name": "v14-algorithms", + "displayName": "v1.4 algorithm Release validation and benchmarks", + "inherits": "release", + "binaryDir": "${sourceDir}/build/v14-algorithms", + "cacheVariables": { + "SMARTPARALLEL_BUILD_VALIDATION": "ON", + "SMARTPARALLEL_BUILD_V140_ALGORITHM_BENCHMARKS": "ON", + "SMARTPARALLEL_BUILD_BENCHMARKS": "OFF", + "SMARTPARALLEL_ENABLE_TBB": "ON", + "SMARTPARALLEL_INSTALL": "ON" + } + }, { "name": "ci-debug-no-tbb", "displayName": "CI Debug validation without oneTBB", @@ -131,6 +144,10 @@ "name": "ci-debug-no-tbb", "configurePreset": "ci-debug-no-tbb" }, + { + "name": "v14-algorithms", + "configurePreset": "v14-algorithms" + }, { "name": "ci-release-tbb", "configurePreset": "ci-release-tbb" @@ -175,6 +192,13 @@ "output": { "outputOnFailure": true } + }, + { + "name": "v14-algorithms", + "configurePreset": "v14-algorithms", + "output": { + "outputOnFailure": true + } } ] } diff --git a/README.md b/README.md index f6efd2e..a62986d 100644 --- a/README.md +++ b/README.md @@ -6,11 +6,12 @@ SmartParallel is a C++17 library that chooses and coordinates CPU parallel-loop The fastest way to execute a loop depends on callback cost, iteration count, irregularity, backend overhead, and whether the loop is already inside parallel work. Hard-coding one strategy everywhere can make small loops slower and nested loops unsafe or wasteful. -SmartParallel provides one public loop API, two generations of runtime policy, and a cross-platform portability release. The final v1.3 pull-request validation passed all six GitHub Actions jobs across Windows, Linux, and macOS: +SmartParallel provides an adaptive loop runtime, coordinated nested execution, cross-platform validation, and a v1.4 parallel-algorithm layer. The stabilized runtime continues to run across Windows, Linux, and macOS: - **SmartParallel v1.0 — Automatic Loop Optimization:** selects a sequential or parallel execution strategy and improves repeated decisions using runtime observations. - **SmartParallel v1.1 — Nested Parallelism Coordination:** coordinates nested loops through a shared root session, bounded worker leases, automatic frontier selection, and stable-plan reuse. - **SmartParallel v1.3 — Cross-Platform CI and Portability:** validates the same scheduler and API on Windows/MSVC, Linux/GCC and Clang, and macOS/Apple Clang, including installed-package consumers and oneTBB on/off builds. +- **SmartParallel v1.4 — Parallel Algorithm Expansion:** adds adaptive elementwise, reduction, counting, predicate, and search algorithms, including pre-scheduler hot dispatch for cheap operations. ## Minimal example @@ -36,6 +37,18 @@ int main() Nested calls use the same API. SmartParallel coordinates them under the active root budget instead of creating independent teams at every depth. +The v1.4 algorithms are available from: + +```cpp +#include + +#include + +auto total = smart::parallel_transform_reduce( + values.begin(), values.end(), 0.0, std::plus<>{}, + [](double value) { return value * value; }); +``` + ## Capabilities - Runtime selection between sequential, ThreadPool, StaticThread, and oneTBB execution. @@ -45,8 +58,22 @@ Nested calls use the same API. SmartParallel coordinates them under the active r - Cooperative ThreadPool helping and constrained oneTBB arenas. - Exception propagation, cooperative cancellation, exactly-once validation, and structured trace export. - Native Windows, Linux, and macOS CPU-topology/cache discovery with conservative fallbacks. +- Fourteen adaptive v1.4 algorithms covering transforms, reductions, counting, predicates, and search, with a direct one-pass path when automatic scheduling selects sequential execution. - CMake package installation as `SmartParallel::smart_parallel`. +## v1.4 algorithm results + +The accepted Windows/MSVC Release snapshot covers sixteen algorithm cases across sequential, automatic, ThreadPool, StaticThread, and oneTBB modes: + +- all **80 summary rows** and **560 raw samples** passed correctness and backend authentication; +- automatic selected ThreadPool for eight compute-heavy cases and direct sequential execution for eight cheap or bandwidth-sensitive cases; +- the parallel-selected group achieved a **3.30× geometric-mean speedup**, ranging from **2.67× to 3.53×**; +- every corrected cheap-dispatch family stayed within **3.5%** of direct sequential latency or faster. + +![SmartParallel v1.4 automatic speedup](docs/v1.4/assets/benchmarks/automatic-speedup-by-algorithm.png) + +The results are machine-specific. See the [complete v1.4 benchmark report](docs/v1.4/benchmarks.md), [methodology](docs/v1.4/benchmark-methodology.md), and [reproduction guide](docs/v1.4/benchmark-reproduction.md). + ## Real-world v1.1 results The final recorded suite covers OpenCV image pipelines, LZ4 batch compression, custom BVH construction, and a custom particle simulation. On the recorded four-worker Windows/MSVC machine: @@ -60,7 +87,7 @@ The results are machine-specific measurements, not universal guarantees. See the ## Build -Requirements: CMake 3.20+, a C++17 compiler, and oneTBB only when the oneTBB backend is enabled. SmartParallel v1.3 is continuously validated with MSVC, GCC, Clang, and Apple Clang. The repository includes a vcpkg manifest for oneTBB and optional real-world benchmark dependencies. +Requirements: CMake 3.20+, a C++17 compiler, and oneTBB only when the oneTBB backend is enabled. SmartParallel v1.4 is continuously validated with MSVC, GCC, Clang, and Apple Clang. The repository includes a vcpkg manifest for oneTBB and optional real-world benchmark dependencies. ```text cmake --preset release @@ -78,18 +105,20 @@ find_package(SmartParallel CONFIG REQUIRED) target_link_libraries(my_application PRIVATE SmartParallel::smart_parallel) ``` -Windows users can run the complete real-world validation suite with: +Windows users can build, test, and benchmark every v1.4 algorithm with: ```bat -set "VCPKG_ROOT=D:\Tools\vcpkg" && scripts\benchmarks\run_real_world_complete.bat 31 +set "VCPKG_ROOT=D:\Tools\vcpkg" && scripts\validation\run_v14_algorithm_release_validation.bat 7 ``` -See the [v1.3 cross-platform installation guide](docs/v1.3/installation.md), [GitHub Actions setup](docs/v1.3/ci-and-github-setup.md), [native hardware discovery](docs/v1.3/native-hardware-discovery.md), [release checklist](docs/v1.3/release-checklist.md), and [benchmark reproduction](docs/v1.1/benchmark-reproduction.md) for the complete workflows. +The historical v1.1 real-world suite remains available through `scripts\benchmarks\run_real_world_complete.bat`. See the [v1.4 API](docs/v1.4/api.md), [architecture](docs/v1.4/architecture.md), [benchmark results](docs/v1.4/benchmarks.md), [v1.4 reproduction guide](docs/v1.4/benchmark-reproduction.md), [v1.3 cross-platform installation guide](docs/v1.3/installation.md), [GitHub Actions setup](docs/v1.3/ci-and-github-setup.md), [native hardware discovery](docs/v1.3/native-hardware-discovery.md), and [release checklist](docs/v1.3/release-checklist.md). ## Documentation -- [v1.3 documentation](docs/v1.3/README.md) — current portability and CI release -- [v1.1 runtime documentation](docs/v1.1/README.md) — scheduler and nested-parallelism behavior retained by v1.3 +- [v1.4 documentation](docs/v1.4/README.md) — current parallel-algorithm release +- [v1.4 benchmark results](docs/v1.4/benchmarks.md) — accepted automatic/forced backend matrix and graphs +- [v1.3 documentation](docs/v1.3/README.md) — portability and CI release +- [v1.1 runtime documentation](docs/v1.1/README.md) — scheduler and nested-parallelism behavior retained by v1.4 - [Getting started](docs/v1.1/getting-started.md) - [API reference](docs/v1.1/api.md) - [Architecture](docs/v1.1/architecture.md) @@ -102,7 +131,7 @@ See the [v1.3 cross-platform installation guide](docs/v1.3/installation.md), [Gi ## Project status -**Current release: v1.3.0.** v1.3 keeps the stabilized v1.1 scheduler and public semantics while adding automated cross-platform build, test, install, oneTBB on/off, and external-consumer validation. Real-world performance benchmarks remain manual and the checked-in v1.1 results remain the current performance evidence. +**Current release: v1.4.0.** v1.4 keeps the stabilized scheduler and nested runtime while adding adaptive elementwise, reduction, counting, predicate, and search APIs. The repository now includes accepted v1.4 algorithm measurements and the retained v1.1 real-world integration results; performance benchmarks remain manual and machine-specific. Important boundaries remain: admission is per root rather than process-wide, global configuration must not be mutated concurrently, traces add overhead, experience is in-memory by default, and automatic scheduling is not guaranteed to beat the best manually selected strategy on every workload. diff --git a/benchmarks/CMakeLists.txt b/benchmarks/CMakeLists.txt index 0ba7e9a..418dcd0 100644 --- a/benchmarks/CMakeLists.txt +++ b/benchmarks/CMakeLists.txt @@ -1,3 +1,5 @@ # Versioned benchmark suites. add_subdirectory(v1.0.0) add_subdirectory(v1.1.0) + +add_subdirectory(v1.4.0) diff --git a/benchmarks/README.md b/benchmarks/README.md index 43f0739..33df3b8 100644 --- a/benchmarks/README.md +++ b/benchmarks/README.md @@ -1,5 +1,15 @@ # SmartParallel benchmark suites +## v1.4.0 parallel algorithm suite + +[`benchmarks/v1.4.0/`](v1.4.0/README.md) benchmarks every v1.4 public algorithm against a sequential reference and the available SmartParallel backends. Each repetition is checksum validated. + +```bat +set "VCPKG_ROOT=D:\Tools\vcpkg" && scripts\validation\run_v14_algorithm_release_validation.bat 7 +``` + +Results are written to `validation/output/v1.4.0_parallel_algorithms.csv` and the matching `_raw.csv` file. The suite is manual and is not a CI merge gate. + ## Current performance suite: v1.1.0 (retained for v1.3) The current recorded performance suite is [`benchmarks/v1.1.0/`](v1.1.0/README.md). Its real-world integrations cover OpenCV image pipelines, LZ4 compression, custom BVH construction, and a custom particle simulation. diff --git a/benchmarks/v1.4.0/CMakeLists.txt b/benchmarks/v1.4.0/CMakeLists.txt new file mode 100644 index 0000000..425f4a2 --- /dev/null +++ b/benchmarks/v1.4.0/CMakeLists.txt @@ -0,0 +1,11 @@ +if(SMARTPARALLEL_BUILD_V140_ALGORITHM_BENCHMARKS) + add_executable( + smartparallel_v140_algorithm_benchmarks + src/parallel_algorithm_benchmarks.cpp + ) + target_link_libraries( + smartparallel_v140_algorithm_benchmarks + PRIVATE SmartParallel::smart_parallel + ) + smartparallel_copy_tbb_runtime(smartparallel_v140_algorithm_benchmarks) +endif() diff --git a/benchmarks/v1.4.0/README.md b/benchmarks/v1.4.0/README.md new file mode 100644 index 0000000..13b7c39 --- /dev/null +++ b/benchmarks/v1.4.0/README.md @@ -0,0 +1,17 @@ +# SmartParallel v1.4.0 algorithm benchmarks + +`smartparallel_v140_algorithm_benchmarks` benchmarks all fourteen v1.4 API families through sixteen unary/binary cases against sequential references and available SmartParallel backends. Every repetition is checksum validated. + +Build directly with: + +```text +-DSMARTPARALLEL_BUILD_V140_ALGORITHM_BENCHMARKS=ON +``` + +The recommended complete Windows workflow is: + +```bat +set "VCPKG_ROOT=D:\Tools\vcpkg" && scripts\validation\run_v14_algorithm_release_validation.bat 7 +``` + +See [`docs/v1.4/benchmark-methodology.md`](../../docs/v1.4/benchmark-methodology.md) for the schema and measurement rules. diff --git a/benchmarks/v1.4.0/src/parallel_algorithm_benchmarks.cpp b/benchmarks/v1.4.0/src/parallel_algorithm_benchmarks.cpp new file mode 100644 index 0000000..ac2a34e --- /dev/null +++ b/benchmarks/v1.4.0/src/parallel_algorithm_benchmarks.cpp @@ -0,0 +1,688 @@ +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace +{ +using Clock = std::chrono::steady_clock; +constexpr const char* schema_version = "1.4.0"; +constexpr std::size_t element_count = 262144; + +struct ConfigGuard +{ + smart::Config saved = smart::global_config(); + ~ConfigGuard() { smart::global_config() = saved; } +}; + +struct BenchmarkCase +{ + std::string name; + std::size_t iterations = 0; + std::function prepare; + std::function sequential; + std::function parallel; + std::function checksum; +}; + +struct Mode +{ + std::string name; + bool sequential = false; + smart::ExecutionEngineType engine = smart::ExecutionEngineType::Auto; +}; + +struct Sample +{ + double elapsed_ms = 0.0; + std::uint64_t checksum = 0; + std::string backend = "sequential"; + bool parallel = false; + bool backend_authenticated = false; +}; + +struct Summary +{ + std::string algorithm; + std::string mode; + std::size_t repetitions = 0; + std::size_t iterations = 0; + double median_ms = 0.0; + double minimum_ms = 0.0; + double maximum_ms = 0.0; + double sequential_median_ms = 0.0; + double speedup = 0.0; + std::uint64_t checksum = 0; + std::uint64_t expected_checksum = 0; + bool correct = false; + bool backend_authenticated = false; + std::string observed_backend = "sequential"; + bool parallel_observed = false; + std::vector samples; +}; + +std::uint64_t mix(std::uint64_t value, std::size_t rounds = 8) +{ + for (std::size_t round = 0; round < rounds; ++round) + { + value += 0x9E3779B97F4A7C15ull + round; + value = (value ^ (value >> 30)) * 0xBF58476D1CE4E5B9ull; + value = (value ^ (value >> 27)) * 0x94D049BB133111EBull; + value ^= value >> 31; + } + return value; +} + +std::uint64_t checksum_vector(const std::vector& values) +{ + std::uint64_t checksum = 0xCBF29CE484222325ull; + for (std::size_t index = 0; index < values.size(); ++index) + checksum ^= mix(values[index] + index, 2); + return checksum; +} + +double median(std::vector values) +{ + if (values.empty()) + return 0.0; + std::sort(values.begin(), values.end()); + const std::size_t middle = values.size() / 2; + return values.size() % 2 == 0 + ? (values[middle - 1] + values[middle]) * 0.5 + : values[middle]; +} + +void configure_mode(const smart::Config& baseline, const Mode& mode) +{ + smart::global_config() = baseline; + auto& config = smart::global_config(); + config.enable_experience = false; + config.enable_experience_ranking = false; + config.enable_online_exploration = false; + config.enable_parallel_for_backend_calibration = false; + config.nested_root_concurrency_budget = 4; + config.enable_nested_execution_session = true; + config.enable_parallel_for_profile_cache = true; + config.enable_parallel_for_auto_profiling = true; + config.execution_engine = mode.engine; + if (!mode.sequential && mode.engine != smart::ExecutionEngineType::Auto) + { + config.enable_parallel_for_cached_sequential_fast_path = false; + config.enable_parallel_for_tiny_work_bypass = false; + config.parallel_for_minimum_predicted_speedup = 0.0; + config.parallel_for_estimated_overhead_ms = 0.0; + config.small_workload_iteration_threshold = 0; + config.cheap_workload_sequential_threshold = 0; + config.nested_min_iterations_per_worker = 1; + config.nested_min_parallel_work_ms = 0.0; + config.nested_plan_hysteresis = 1.0; + } + ++config.parallel_for_policy_generation; + smart::global_function_profile_cache().clear(); +} + +std::pair observed_plan() +{ + const smart::ExecutionPlan plan = smart::global_last_decision_report().plan; + if (!plan.parallel) + return {"sequential", false}; + return {smart::runtime_name(smart::resolve_execution_engine_type(plan.engine)), true}; +} + +bool authenticate_backend(const Mode& mode, const std::string& backend, bool parallel) +{ + if (mode.sequential) + return !parallel && backend == "sequential"; + if (mode.engine == smart::ExecutionEngineType::Auto) + { + if (!parallel) + return backend == "sequential"; + return backend == "thread_pool" || backend == "static_thread" || backend == "one_tbb"; + } + return parallel && backend == mode.name; +} + +Sample run_sample(const BenchmarkCase& benchmark_case, const Mode& mode) +{ + benchmark_case.prepare(); + const auto start = Clock::now(); + if (mode.sequential) + benchmark_case.sequential(); + else + benchmark_case.parallel(); + const double elapsed_ms = + std::chrono::duration(Clock::now() - start).count(); + + auto [backend, parallel] = mode.sequential + ? std::pair{"sequential", false} + : observed_plan(); + const bool backend_authenticated = authenticate_backend(mode, backend, parallel); + const std::uint64_t checksum = benchmark_case.checksum(); + return {elapsed_ms, checksum, std::move(backend), parallel, backend_authenticated}; +} + +Summary benchmark_mode(const BenchmarkCase& benchmark_case, + const Mode& mode, + std::size_t repetitions, + std::uint64_t expected_checksum, + double sequential_median_ms) +{ + std::cout << benchmark_case.name << " / " << mode.name << " ... " << std::flush; + (void)run_sample(benchmark_case, mode); + + Summary summary; + summary.algorithm = benchmark_case.name; + summary.mode = mode.name; + summary.repetitions = repetitions; + summary.iterations = benchmark_case.iterations; + summary.expected_checksum = expected_checksum; + summary.sequential_median_ms = sequential_median_ms; + summary.samples.reserve(repetitions); + + std::vector elapsed; + elapsed.reserve(repetitions); + summary.minimum_ms = std::numeric_limits::max(); + for (std::size_t repetition = 0; repetition < repetitions; ++repetition) + { + Sample sample = run_sample(benchmark_case, mode); + elapsed.push_back(sample.elapsed_ms); + summary.minimum_ms = std::min(summary.minimum_ms, sample.elapsed_ms); + summary.maximum_ms = std::max(summary.maximum_ms, sample.elapsed_ms); + summary.checksum = sample.checksum; + if (summary.samples.empty()) + summary.observed_backend = sample.backend; + else if (summary.observed_backend != sample.backend) + summary.observed_backend = "mixed"; + summary.parallel_observed = summary.parallel_observed || sample.parallel; + summary.samples.push_back(std::move(sample)); + } + + summary.median_ms = median(elapsed); + if (mode.sequential) + summary.sequential_median_ms = summary.median_ms; + summary.speedup = summary.median_ms > 0.0 + ? summary.sequential_median_ms / summary.median_ms + : 0.0; + summary.correct = std::all_of( + summary.samples.begin(), summary.samples.end(), [&](const Sample& sample) { + return sample.checksum == expected_checksum; + }); + summary.backend_authenticated = std::all_of( + summary.samples.begin(), summary.samples.end(), [](const Sample& sample) { + return sample.backend_authenticated; + }); + + const bool passed = summary.correct && summary.backend_authenticated; + std::cout << (passed ? "PASS" : "FAIL") + << " median=" << std::fixed << std::setprecision(3) + << summary.median_ms << " ms backend=" << summary.observed_backend << '\n'; + return summary; +} + +std::vector make_cases() +{ + std::vector cases; + + { + auto values = std::make_shared>(element_count); + cases.push_back({ + "parallel_for_each", element_count, + [values] { std::iota(values->begin(), values->end(), std::uint64_t{1}); }, + [values] { + for (auto& value : *values) + value = mix(value); + }, + [values] { + smart::parallel_for_each(values->begin(), values->end(), [](std::uint64_t& value) { + value = mix(value); + }); + }, + [values] { return checksum_vector(*values); }}); + } + { + auto input = std::make_shared>(element_count); + auto output = std::make_shared>(element_count); + cases.push_back({ + "parallel_transform", element_count, + [input, output] { + std::iota(input->begin(), input->end(), std::uint64_t{3}); + std::fill(output->begin(), output->end(), 0); + }, + [input, output] { + std::transform(input->begin(), input->end(), output->begin(), + [](std::uint64_t value) { return mix(value); }); + }, + [input, output] { + smart::parallel_transform(input->begin(), input->end(), output->begin(), + [](std::uint64_t value) { return mix(value); }); + }, + [output] { return checksum_vector(*output); }}); + } + { + auto left = std::make_shared>(element_count); + auto right = std::make_shared>(element_count); + auto output = std::make_shared>(element_count); + cases.push_back({ + "parallel_transform_binary", element_count, + [left, right, output] { + std::iota(left->begin(), left->end(), std::uint64_t{3}); + std::iota(right->begin(), right->end(), std::uint64_t{17}); + std::fill(output->begin(), output->end(), 0); + }, + [left, right, output] { + std::transform(left->begin(), left->end(), right->begin(), output->begin(), + [](std::uint64_t a, std::uint64_t b) { + return mix(a ^ (b << 1)); + }); + }, + [left, right, output] { + smart::parallel_transform( + left->begin(), left->end(), right->begin(), output->begin(), + [](std::uint64_t a, std::uint64_t b) { return mix(a ^ (b << 1)); }); + }, + [output] { return checksum_vector(*output); }}); + } + { + auto input = std::make_shared>(element_count * 4); + auto output = std::make_shared>(input->size()); + cases.push_back({ + "parallel_copy", input->size(), + [input, output] { + std::iota(input->begin(), input->end(), std::uint64_t{7}); + std::fill(output->begin(), output->end(), 0); + }, + [input, output] { std::copy(input->begin(), input->end(), output->begin()); }, + [input, output] { + smart::parallel_copy(input->begin(), input->end(), output->begin()); + }, + [output] { return checksum_vector(*output); }}); + } + { + auto values = std::make_shared>(element_count * 4); + cases.push_back({ + "parallel_fill", values->size(), + [values] { std::fill(values->begin(), values->end(), 0); }, + [values] { std::fill(values->begin(), values->end(), 0x12345678u); }, + [values] { + smart::parallel_fill(values->begin(), values->end(), std::uint64_t{0x12345678u}); + }, + [values] { return checksum_vector(*values); }}); + } + { + auto values = std::make_shared>(element_count); + cases.push_back({ + "parallel_generate", values->size(), + [values] { std::fill(values->begin(), values->end(), 0); }, + [values] { + for (std::size_t index = 0; index < values->size(); ++index) + (*values)[index] = mix(index + 11); + }, + [values] { + smart::parallel_generate(values->begin(), values->end(), [](std::size_t index) { + return mix(index + 11); + }); + }, + [values] { return checksum_vector(*values); }}); + } + { + auto values = std::make_shared>(element_count); + auto result = std::make_shared(0); + cases.push_back({ + "parallel_reduce", values->size(), + [values, result] { + for (std::size_t index = 0; index < values->size(); ++index) + (*values)[index] = mix(index, 2) & 0xFFFFu; + *result = 0; + }, + [values, result] { + *result = std::accumulate(values->begin(), values->end(), std::uint64_t{17}); + }, + [values, result] { + *result = smart::parallel_reduce( + values->begin(), values->end(), std::uint64_t{17}); + }, + [result] { return *result; }}); + } + { + auto values = std::make_shared>(element_count); + auto result = std::make_shared(0); + cases.push_back({ + "parallel_transform_reduce", values->size(), + [values, result] { + std::iota(values->begin(), values->end(), std::uint64_t{1}); + *result = 0; + }, + [values, result] { + *result = std::accumulate( + values->begin(), values->end(), std::uint64_t{19}, + [](std::uint64_t sum, std::uint64_t value) { + return sum + (mix(value) & 0xFFFFu); + }); + }, + [values, result] { + *result = smart::parallel_transform_reduce( + values->begin(), values->end(), std::uint64_t{19}, std::plus<>{}, + [](std::uint64_t value) { return mix(value) & 0xFFFFu; }); + }, + [result] { return *result; }}); + } + { + auto left = std::make_shared>(element_count); + auto right = std::make_shared>(element_count); + auto result = std::make_shared(0); + cases.push_back({ + "parallel_transform_reduce_binary", element_count, + [left, right, result] { + std::iota(left->begin(), left->end(), std::uint64_t{1}); + std::iota(right->begin(), right->end(), std::uint64_t{9}); + *result = 0; + }, + [left, right, result] { + std::uint64_t total = 23; + for (std::size_t index = 0; index < left->size(); ++index) + total += mix((*left)[index] ^ ((*right)[index] << 1), 4) & 0xFFFFu; + *result = total; + }, + [left, right, result] { + *result = smart::parallel_transform_reduce( + left->begin(), left->end(), right->begin(), std::uint64_t{23}, + std::plus<>{}, [](std::uint64_t a, std::uint64_t b) { + return mix(a ^ (b << 1), 4) & 0xFFFFu; + }); + }, + [result] { return *result; }}); + } + { + auto values = std::make_shared>(element_count); + auto result = std::make_shared(0); + cases.push_back({ + "parallel_count", values->size(), + [values, result] { + for (std::size_t index = 0; index < values->size(); ++index) + (*values)[index] = index % 31; + *result = 0; + }, + [values, result] { + *result = static_cast( + std::count(values->begin(), values->end(), 7)); + }, + [values, result] { + *result = smart::parallel_count( + values->begin(), values->end(), std::uint64_t{7}); + }, + [result] { return *result; }}); + } + { + auto values = std::make_shared>(element_count); + auto result = std::make_shared(0); + cases.push_back({ + "parallel_count_if", values->size(), + [values, result] { + std::iota(values->begin(), values->end(), std::uint64_t{0}); + *result = 0; + }, + [values, result] { + *result = static_cast(std::count_if( + values->begin(), values->end(), + [](std::uint64_t value) { return (mix(value, 3) & 7u) == 0; })); + }, + [values, result] { + *result = smart::parallel_count_if( + values->begin(), values->end(), + [](std::uint64_t value) { return (mix(value, 3) & 7u) == 0; }); + }, + [result] { return *result; }}); + } + { + auto values = std::make_shared>(element_count); + auto result = std::make_shared(0); + cases.push_back({ + "parallel_any_of", values->size(), + [values, result] { + std::iota(values->begin(), values->end(), std::uint64_t{0}); + *result = 0; + }, + [values, result] { + *result = std::any_of(values->begin(), values->end(), [](std::uint64_t value) { + return value == element_count - 1; + }) ? 1u : 0u; + }, + [values, result] { + *result = smart::parallel_any_of( + values->begin(), values->end(), [](std::uint64_t value) { + return value == element_count - 1; + }) ? 1u : 0u; + }, + [result] { return *result; }}); + } + { + auto values = std::make_shared>(element_count); + auto result = std::make_shared(0); + cases.push_back({ + "parallel_all_of", values->size(), + [values, result] { + std::iota(values->begin(), values->end(), std::uint64_t{1}); + *result = 0; + }, + [values, result] { + *result = std::all_of(values->begin(), values->end(), [](std::uint64_t value) { + return value != 0; + }) ? 1u : 0u; + }, + [values, result] { + *result = smart::parallel_all_of( + values->begin(), values->end(), [](std::uint64_t value) { + return value != 0; + }) ? 1u : 0u; + }, + [result] { return *result; }}); + } + { + auto values = std::make_shared>(element_count); + auto result = std::make_shared(0); + cases.push_back({ + "parallel_none_of", values->size(), + [values, result] { + std::iota(values->begin(), values->end(), std::uint64_t{1}); + *result = 0; + }, + [values, result] { + *result = std::none_of(values->begin(), values->end(), [](std::uint64_t value) { + return value == 0; + }) ? 1u : 0u; + }, + [values, result] { + *result = smart::parallel_none_of( + values->begin(), values->end(), [](std::uint64_t value) { + return value == 0; + }) ? 1u : 0u; + }, + [result] { return *result; }}); + } + { + auto values = std::make_shared>(element_count); + auto result = std::make_shared(0); + cases.push_back({ + "parallel_find", values->size(), + [values, result] { + std::iota(values->begin(), values->end(), std::uint64_t{0}); + *result = 0; + }, + [values, result] { + *result = static_cast( + std::find(values->begin(), values->end(), element_count - 1) + - values->begin()); + }, + [values, result] { + *result = static_cast( + smart::parallel_find(values->begin(), values->end(), element_count - 1) + - values->begin()); + }, + [result] { return *result; }}); + } + { + auto values = std::make_shared>(element_count); + auto result = std::make_shared(0); + cases.push_back({ + "parallel_find_if", values->size(), + [values, result] { + std::iota(values->begin(), values->end(), std::uint64_t{0}); + *result = 0; + }, + [values, result] { + *result = static_cast(std::find_if( + values->begin(), values->end(), [](std::uint64_t value) { + return value == element_count - 1; + }) - values->begin()); + }, + [values, result] { + *result = static_cast(smart::parallel_find_if( + values->begin(), values->end(), [](std::uint64_t value) { + return value == element_count - 1; + }) - values->begin()); + }, + [result] { return *result; }}); + } + return cases; +} + +std::filesystem::path raw_output_path(const std::filesystem::path& summary) +{ + const std::string stem = summary.stem().string(); + return summary.parent_path() / (stem + "_raw.csv"); +} + +void write_results(const std::filesystem::path& output, const std::vector& results) +{ + if (!output.parent_path().empty()) + std::filesystem::create_directories(output.parent_path()); + std::ofstream summary_file(output); + if (!summary_file) + throw std::runtime_error("failed to open benchmark summary output"); + summary_file << "schema_version,algorithm,mode,repetitions,iterations,median_ms,min_ms,max_ms," + "sequential_median_ms,speedup,checksum,expected_checksum,correct," + "backend_authenticated,observed_backend,parallel_observed\n"; + summary_file << std::fixed << std::setprecision(6); + for (const auto& result : results) + { + summary_file << schema_version << ',' << result.algorithm << ',' << result.mode << ',' + << result.repetitions << ',' << result.iterations << ',' << result.median_ms << ',' + << result.minimum_ms << ',' << result.maximum_ms << ',' + << result.sequential_median_ms << ',' << result.speedup << ',' + << result.checksum << ',' << result.expected_checksum << ',' + << (result.correct ? 1 : 0) << ',' + << (result.backend_authenticated ? 1 : 0) << ',' + << result.observed_backend << ',' + << (result.parallel_observed ? 1 : 0) << '\n'; + } + + std::ofstream raw_file(raw_output_path(output)); + if (!raw_file) + throw std::runtime_error("failed to open benchmark raw output"); + raw_file << "schema_version,algorithm,mode,repetition,elapsed_ms,checksum,correct," + "backend_authenticated,observed_backend,parallel_observed\n"; + raw_file << std::fixed << std::setprecision(6); + for (const auto& result : results) + { + for (std::size_t repetition = 0; repetition < result.samples.size(); ++repetition) + { + const auto& sample = result.samples[repetition]; + raw_file << schema_version << ',' << result.algorithm << ',' << result.mode << ',' + << (repetition + 1) << ',' << sample.elapsed_ms << ',' << sample.checksum << ',' + << (sample.checksum == result.expected_checksum ? 1 : 0) << ',' + << (sample.backend_authenticated ? 1 : 0) << ',' + << sample.backend << ',' << (sample.parallel ? 1 : 0) << '\n'; + } + } +} +} // namespace + +int main(int argc, char** argv) +{ + ConfigGuard guard; + try + { + const std::filesystem::path output = argc > 1 + ? std::filesystem::path(argv[1]) + : std::filesystem::path("validation/output/v1.4.0_parallel_algorithms.csv"); + const std::size_t repetitions = argc > 2 + ? static_cast(std::stoull(argv[2])) + : 7; + if (repetitions == 0) + throw std::invalid_argument("repetitions must be positive"); + + const smart::Config baseline = smart::global_config(); + std::vector modes{ + {"sequential", true, smart::ExecutionEngineType::Auto}, + {"automatic", false, smart::ExecutionEngineType::Auto}, + {"thread_pool", false, smart::ExecutionEngineType::ThreadPool}, + {"static_thread", false, smart::ExecutionEngineType::StaticThread}}; + if (smart::execution_backend_available(smart::ExecutionEngineType::OneTbb)) + modes.push_back({"one_tbb", false, smart::ExecutionEngineType::OneTbb}); + + std::vector results; + bool all_valid = true; + for (const BenchmarkCase& benchmark_case : make_cases()) + { + configure_mode(baseline, modes.front()); + benchmark_case.prepare(); + benchmark_case.sequential(); + const std::uint64_t expected = benchmark_case.checksum(); + + configure_mode(baseline, modes.front()); + Summary sequential = benchmark_mode( + benchmark_case, modes.front(), repetitions, expected, 0.0); + const double sequential_median_ms = sequential.median_ms; + all_valid = all_valid && sequential.correct && sequential.backend_authenticated; + results.push_back(std::move(sequential)); + + for (std::size_t mode_index = 1; mode_index < modes.size(); ++mode_index) + { + configure_mode(baseline, modes[mode_index]); + Summary result = benchmark_mode( + benchmark_case, + modes[mode_index], + repetitions, + expected, + sequential_median_ms); + all_valid = all_valid && result.correct && result.backend_authenticated; + results.push_back(std::move(result)); + } + } + + write_results(output, results); + std::cout << "Summary: " << output << '\n'; + std::cout << "Raw samples: " << raw_output_path(output) << '\n'; + if (!all_valid) + { + std::cerr << "SmartParallel v1.4 algorithm benchmark validation: FAIL\n"; + return 1; + } + std::cout << "SmartParallel v1.4 algorithm benchmark validation: PASS\n"; + return 0; + } + catch (const std::exception& error) + { + std::cerr << "SmartParallel v1.4 algorithm benchmark failed: " << error.what() << '\n'; + return 1; + } +} diff --git a/cmake/SmartParallelOptions.cmake b/cmake/SmartParallelOptions.cmake index b8c4ed4..fc3007d 100644 --- a/cmake/SmartParallelOptions.cmake +++ b/cmake/SmartParallelOptions.cmake @@ -11,6 +11,7 @@ if(SMARTPARALLEL_BUILD_VALIDATION) set(SMARTPARALLEL_BUILD_AUTO_PROFILE_TEST ON) set(SMARTPARALLEL_BUILD_PARALLEL_FOR_VALIDATION ON) set(SMARTPARALLEL_BUILD_PARALLEL_FOR_HARDENING ON) + set(SMARTPARALLEL_BUILD_V140_ALGORITHM_VALIDATION ON) endif() if(SMARTPARALLEL_BUILD_REAL_WORLD_BENCHMARKS) @@ -31,6 +32,7 @@ if(SMARTPARALLEL_BUILD_BENCHMARKS) set(SMARTPARALLEL_BUILD_SCIENTIFIC_TEST3 ON) set(SMARTPARALLEL_BUILD_DECISION_QUALITY_AUDIT ON) set(SMARTPARALLEL_BUILD_V110_NESTED_BENCHMARKS ON) + set(SMARTPARALLEL_BUILD_V140_ALGORITHM_BENCHMARKS ON) endif() set(SMARTPARALLEL_BUILD_ANY_VALIDATION OFF) @@ -38,6 +40,7 @@ if(SMARTPARALLEL_BUILD_V1_PHASE1 OR SMARTPARALLEL_BUILD_AUTO_PROFILE_TEST OR SMARTPARALLEL_BUILD_PARALLEL_FOR_VALIDATION OR SMARTPARALLEL_BUILD_PARALLEL_FOR_HARDENING + OR SMARTPARALLEL_BUILD_V140_ALGORITHM_VALIDATION OR SMARTPARALLEL_BUILD_PARALLEL_FOR_OVERHEAD) set(SMARTPARALLEL_BUILD_ANY_VALIDATION ON) endif() @@ -52,6 +55,7 @@ if(SMARTPARALLEL_BUILD_OPENCV_TEST1 OR SMARTPARALLEL_BUILD_SCIENTIFIC_TEST3 OR SMARTPARALLEL_BUILD_DECISION_QUALITY_AUDIT OR SMARTPARALLEL_BUILD_V110_NESTED_BENCHMARKS + OR SMARTPARALLEL_BUILD_V140_ALGORITHM_BENCHMARKS OR SMARTPARALLEL_BUILD_OPENCV_BENCHMARK OR SMARTPARALLEL_BUILD_LZ4_BENCHMARK OR SMARTPARALLEL_BUILD_BVH_BENCHMARK diff --git a/docs/README.md b/docs/README.md index 11c8df1..52a982e 100644 --- a/docs/README.md +++ b/docs/README.md @@ -2,20 +2,27 @@ ## Current release -The current release is **SmartParallel v1.3.0**, focused on cross-platform portability and continuous integration. +The current release is **SmartParallel v1.4.0**, focused on adaptive parallel algorithms implemented on the existing scheduler and nested runtime. + +- [v1.4 overview](v1.4/README.md) +- [v1.4 API and correctness contracts](v1.4/api.md) +- [v1.4 architecture and hot dispatch](v1.4/architecture.md) +- [v1.4 benchmark results](v1.4/benchmarks.md) +- [v1.4 benchmark methodology](v1.4/benchmark-methodology.md) +- [v1.4 benchmark reproduction](v1.4/benchmark-reproduction.md) +- [v1.4 validation](v1.4/validation.md) +- [v1.4 known limitations](v1.4/known-limitations.md) +- [v1.4 release notes](v1.4/release-notes.md) + +SmartParallel v1.3 remains the portability and CI foundation: - [v1.3 overview](v1.3/README.md) - [GitHub Actions and vcpkg setup](v1.3/ci-and-github-setup.md) -- [Portability audit](v1.3/portability-audit.md) -- [Native hardware discovery](v1.3/native-hardware-discovery.md) - [Cross-platform installation](v1.3/installation.md) -- [v1.3 release notes](v1.3/release-notes.md) -- [Local and GitHub Actions validation](v1.3/local-validation.md) -- [v1.3 release checklist](v1.3/release-checklist.md) ## Runtime and scheduler documentation -SmartParallel v1.3 retains the stabilized v1.1 runtime behavior. The detailed scheduler documentation remains under [`docs/v1.1/`](v1.1/README.md). +SmartParallel v1.4 retains the stabilized v1.1 runtime behavior. The detailed scheduler documentation remains under [`docs/v1.1/`](v1.1/README.md). - [Getting started](v1.1/getting-started.md) - [API](v1.1/api.md) diff --git a/docs/v1.4/README.md b/docs/v1.4/README.md new file mode 100644 index 0000000..ff78510 --- /dev/null +++ b/docs/v1.4/README.md @@ -0,0 +1,62 @@ +# SmartParallel v1.4 — Parallel Algorithm Expansion + +> **Current release:** SmartParallel v1.4.0 + +SmartParallel v1.4 extends the adaptive indexed runtime with parallel algorithms for elementwise work, reductions, counting, predicates, and search. It keeps the stabilized scheduler and nested-execution model while adding a root automatic hot-dispatch path for operations whose complete sequential body is cheaper than scheduler construction. + +## Release result + +The accepted benchmark snapshot validates all sixteen measured API cases across sequential, automatic, ThreadPool, StaticThread, and oneTBB modes: + +- **80/80 summary rows** and **560/560 raw samples** passed correctness and backend authentication; +- the eight parallel-selected cases achieved a **3.30× geometric-mean speedup** over sequential; +- their automatic speedups ranged from **2.67× to 3.53×**; +- the eight corrected cheap-dispatch families were all within **3.5%** of direct sequential latency or faster. + +![SmartParallel v1.4 automatic speedup](assets/benchmarks/automatic-speedup-by-algorithm.png) + +See the [complete benchmark report](benchmarks.md) for all values, forced-backend comparisons, qualifications, and source data. + +## Public APIs + +```text +parallel_for_each +parallel_transform +parallel_copy +parallel_fill +parallel_generate +parallel_reduce +parallel_transform_reduce +parallel_count +parallel_count_if +parallel_any_of +parallel_all_of +parallel_none_of +parallel_find +parallel_find_if +``` + +All v1.4 algorithms are declared by: + +```cpp +#include +``` + +## Runtime integration + +Parallel plans reuse automatic backend selection, runtime profiling, nested execution sessions, root concurrency budgets, ThreadPool helping, StaticThread execution, oneTBB arenas, exception propagation, and diagnostics. + +For `reduce`, `count`, `find`, predicate families, and `copy`, a bounded root automatic learning phase compares real end-to-end scheduled and sequential invocations. Stable sequential decisions are then checked before chunk creation so later calls can execute the direct one-pass implementation without constructing the scheduler. Forced backends and nested calls retain the original runtime path. + +## Documentation + +- [API and correctness contracts](api.md) +- [Architecture and hot dispatch](architecture.md) +- [Benchmark results](benchmarks.md) +- [Benchmark methodology](benchmark-methodology.md) +- [Benchmark reproduction](benchmark-reproduction.md) +- [Validation](validation.md) +- [Known limitations](known-limitations.md) +- [Release notes](release-notes.md) + +Detailed scheduler and nested-runtime behavior remains documented under [`docs/v1.1/`](../v1.1/README.md). Cross-platform build and CI instructions remain under [`docs/v1.3/`](../v1.3/README.md). diff --git a/docs/v1.4/api.md b/docs/v1.4/api.md new file mode 100644 index 0000000..546490f --- /dev/null +++ b/docs/v1.4/api.md @@ -0,0 +1,74 @@ +# v1.4 parallel algorithm API + +Include: + +```cpp +#include +``` + +All v1.4 algorithms require random-access iterators. Parallel routes schedule contiguous logical chunks through the existing `parallel_for` runtime, so nested calls inherit the active execution session and concurrency budget. For the cheap root automatic families, a learned direct-sequential decision can be applied before chunk construction; scheduler-approved sequential plans also use the same one-pass algorithm body. Public result and exception contracts do not change. + +## Elementwise algorithms + +```cpp +smart::parallel_for_each(first, last, function); + +output_end = smart::parallel_transform(first, last, output, unary_operation); +output_end = smart::parallel_transform(first1, last1, first2, output, binary_operation); + +output_end = smart::parallel_copy(first, last, output); +smart::parallel_fill(first, last, value); + +smart::parallel_generate(first, last, [](std::size_t index) { + return make_value(index); +}); +``` + +`parallel_generate` intentionally uses an indexed generator. A shared stateful no-argument generator would either race or produce a sequence that depends on scheduling order. + +The fill value is copied before parallel execution, so aliasing an element in the destination cannot change the value observed by other chunks. Exact in-place unary transform is supported. Other overlapping input/output ranges are not supported. Elementwise execution order is unspecified, and a thrown exception may leave a partially modified output range. + +## Reductions + +```cpp +auto sum = smart::parallel_reduce(first, last, initial, operation); +auto sum = smart::parallel_reduce(first, last, initial); + +auto result = smart::parallel_transform_reduce( + first, last, initial, reduction, transform); + +auto dot = smart::parallel_transform_reduce( + first1, last1, first2, initial, reduction, binary_transform); +``` + +The reduction operation must be associative. It does not have to be commutative: each chunk is reduced in input order and chunk partials are combined in chunk order. Parenthesization differs from a strictly sequential fold, so floating-point results may differ in their last bits. + +Reduction operations and transforms must be copy constructible. Exceptions destroy temporary partials and propagate to the caller. + +## Counting and predicates + +```cpp +auto count = smart::parallel_count(first, last, value); +auto count = smart::parallel_count_if(first, last, predicate); + +bool any = smart::parallel_any_of(first, last, predicate); +bool all = smart::parallel_all_of(first, last, predicate); +bool none = smart::parallel_none_of(first, last, predicate); +``` + +Counting results are exact. Predicate algorithms use best-effort short-circuiting: work that has already started may finish after the logical result is known. Predicate order and invocation count are unspecified. + +## Search + +```cpp +auto iterator = smart::parallel_find(first, last, value); +auto iterator = smart::parallel_find_if(first, last, predicate); +``` + +Search returns the earliest matching iterator or `last`. Chunks may be searched out of order, but an atomic lowest-index result preserves the public earliest-match contract. Some predicate work may continue after a candidate is found. + +## Common callable contract + +Algorithm callables must be copy constructible. SmartParallel keeps a separate callable copy for each logical chunk. Calls from different chunks may execute concurrently, so state referenced by a callable must not be mutated without synchronization. Exceptions are propagated through the existing SmartParallel cancellation and cleanup path. + +For reusable functor types used at unrelated semantic callsites, `smart::with_parallel_callsite(key, functor)` remains available to separate runtime-learning identities. diff --git a/docs/v1.4/architecture.md b/docs/v1.4/architecture.md new file mode 100644 index 0000000..1cc646c --- /dev/null +++ b/docs/v1.4/architecture.md @@ -0,0 +1,95 @@ +# v1.4 algorithm architecture + +SmartParallel v1.4 adds a parallel-algorithm layer without introducing a second scheduler. Parallel plans still execute bounded contiguous chunks through the existing `parallel_for` runtime, nested execution session, participant budget, ThreadPool helper model, StaticThread engine, and oneTBB arena integration. + +## Public call path + +For algorithms that remain profitable in parallel, the path is: + +```text +public algorithm + -> range validation and size + -> logical chunk construction + -> algorithm callback adapter + -> existing parallel_for scheduler + -> selected backend + -> result assembly +``` + +Each algorithm supplies a direct whole-range sequential implementation as well as a chunk implementation. The scheduler and forced backend modes continue to use the established execution contracts. + +## Algorithm-level hot dispatch + +Microsecond-scale algorithms cannot afford to enter the complete scheduler merely to discover that direct sequential execution is faster. The v1.4 correction therefore adds a narrow dispatch layer before chunk construction for these root automatic families: + +```text +parallel_reduce +parallel_count +parallel_find / parallel_find_if +parallel_any_of / parallel_all_of / parallel_none_of +parallel_copy +``` + +The hot path is: + +```text +public algorithm + -> inexpensive dispatch-key lookup + -> stable sequential decision: execute the whole-range direct body + -> otherwise: continue into the existing scheduler path +``` + +The already-fast transform, generate, for-each, fill, count-if, and transform-reduce families do not use this new early cache. + +## Learning without duplicated user work + +A single public invocation never executes both sequential and scheduled work. Learning uses separate real calls: + +1. one call executes the complete scheduled route and records end-to-end time; +2. another call executes the complete direct sequential route and records end-to-end time; +3. the cache selects a stable route only after both observations exist; +4. close results favor sequential execution through hysteresis; +5. periodic revalidation samples the alternative route on a later invocation. + +This preserves exactly-once callable semantics, output correctness, exception behavior, and side-effect expectations. + +## Dispatch identity + +Entries distinguish material execution conditions, including: + +- algorithm family; +- callsite/callable and value-type identity where relevant; +- actual element-count bucket; +- byte-count and element-size buckets for copy; +- root execution and effective concurrency budget; +- configuration and profiling generations. + +The cache is bounded and sharded. A small local hot layer avoids a contended global lookup on stable decisions, while process-wide entries retain learning samples and revalidation state. + +## Invalidation and revalidation + +A decision is not permanent. Workload buckets prevent small and large ranges from sharing one plan, and policy/profile epochs invalidate decisions when configuration or execution conditions materially change. Stable routes are periodically revalidated so a workload can move from sequential to scheduled execution or back again. + +## Forced and nested execution + +Forced ThreadPool, StaticThread, and oneTBB modes bypass the algorithm hot cache. They continue directly into the established scheduler/backend path so benchmark authentication and user intent remain unchanged. + +Nested algorithm calls also bypass the root hot cache. They retain the active nested execution session, participant leases, frontier decisions, and descendant suppression rules from the v1.1 runtime. + +## Algorithm-specific behavior + +### Reduction and count + +Direct routes use the corresponding one-pass standard-library operation and avoid partial-result allocation. Parallel routes retain ordered chunk reduction and deterministic partial combination. + +### Search and predicates + +Direct routes avoid chunk state and atomics. Parallel routes retain earliest-index search and best-effort predicate short-circuiting. Coordination atomics use relaxed ordering because scheduler completion provides the final synchronization boundary. + +### Copy + +Copy dispatch uses real sequential and scheduled timings plus byte-aware workload buckets. It does not infer sequential cost by multiplying a parallel measurement by worker count, which is unreliable for memory-bandwidth-limited operations. Scheduled chunks invoke `std::copy` so contiguous iterator optimizations remain available. + +## Hardware discovery + +Windows hardware topology discovery is cached once per process, matching the existing Linux and macOS approach. This removes repeated operating-system topology queries from cheap root calls and scheduler setup. diff --git a/docs/v1.4/assets/benchmarks/README.md b/docs/v1.4/assets/benchmarks/README.md new file mode 100644 index 0000000..c910114 --- /dev/null +++ b/docs/v1.4/assets/benchmarks/README.md @@ -0,0 +1,21 @@ +# v1.4 benchmark assets + +These figures and generated summaries are derived from the checked-in release snapshot: + +- `validation/output/v1.4.0_parallel_algorithms.csv` +- `validation/output/v1.4.0_parallel_algorithms_raw.csv` + +Regenerate every asset from the repository root with: + +```text +python tools/plot_v14_algorithm_results.py +``` + +The script validates the CSV schema, algorithm/mode coverage, checksum status, and backend-authentication fields before writing: + +- PNG figures for GitHub Markdown and release pages; +- matching SVG figures for scalable reuse; +- `benchmark-metrics.json` with source SHA-256 hashes and aggregate metrics; +- `generated-results.md` with the complete automatic-result table. + +The checked-in run contains seven repetitions per algorithm/mode pair. Results are machine-specific and are not universal performance guarantees. diff --git a/docs/v1.4/assets/benchmarks/automatic-speedup-by-algorithm.png b/docs/v1.4/assets/benchmarks/automatic-speedup-by-algorithm.png new file mode 100644 index 0000000..6ef42a5 Binary files /dev/null and b/docs/v1.4/assets/benchmarks/automatic-speedup-by-algorithm.png differ diff --git a/docs/v1.4/assets/benchmarks/automatic-speedup-by-algorithm.svg b/docs/v1.4/assets/benchmarks/automatic-speedup-by-algorithm.svg new file mode 100644 index 0000000..9bd6b3c --- /dev/null +++ b/docs/v1.4/assets/benchmarks/automatic-speedup-by-algorithm.svg @@ -0,0 +1,2047 @@ + + + + + + + + image/svg+xml + + + SmartParallel v1.4 benchmark generator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/v1.4/assets/benchmarks/benchmark-metrics.json b/docs/v1.4/assets/benchmarks/benchmark-metrics.json new file mode 100644 index 0000000..05b5a2b --- /dev/null +++ b/docs/v1.4/assets/benchmarks/benchmark-metrics.json @@ -0,0 +1,156 @@ +{ + "schema_version": "1.4.0-docs-1", + "source": { + "summary": "validation/output/v1.4.0_parallel_algorithms.csv", + "summary_sha256": "285865fa5e7843bb6c6a9fddaaad81e9fa8e204257af82bf10e20a60b3b90917", + "raw": "validation/output/v1.4.0_parallel_algorithms_raw.csv", + "raw_sha256": "3df182e101a835a7cd33635dfc610ce3cf8e26a2234b8f9c3d8661149be8918e" + }, + "validation": { + "summary_rows": 80, + "raw_rows": 560, + "repetitions": 7, + "all_correct": true, + "all_backends_authenticated": true + }, + "automatic": { + "thread_pool_selected": 8, + "sequential_selected": 8, + "parallel_selected_geometric_mean_speedup": 3.2987259460832643, + "parallel_selected_median_speedup": 3.432597, + "parallel_selected_min_speedup": 2.66896, + "parallel_selected_max_speedup": 3.534167, + "cheap_dispatch_max_slowdown_percent": 3.4547570034905606, + "cheap_dispatch_max_absolute_overhead_ms": 0.03859999999999997 + }, + "algorithms": { + "parallel_for_each": { + "iterations": 262144, + "automatic_median_ms": 1.0813, + "sequential_median_ms": 3.7626, + "automatic_speedup": 3.4797, + "observed_backend": "thread_pool", + "parallel_observed": true + }, + "parallel_transform": { + "iterations": 262144, + "automatic_median_ms": 1.0661, + "sequential_median_ms": 3.7515, + "automatic_speedup": 3.518901, + "observed_backend": "thread_pool", + "parallel_observed": true + }, + "parallel_transform_binary": { + "iterations": 262144, + "automatic_median_ms": 1.1071, + "sequential_median_ms": 3.8617, + "automatic_speedup": 3.488122, + "observed_backend": "thread_pool", + "parallel_observed": true + }, + "parallel_copy": { + "iterations": 1048576, + "automatic_median_ms": 1.1559, + "sequential_median_ms": 1.1173, + "automatic_speedup": 0.966606, + "observed_backend": "sequential", + "parallel_observed": false + }, + "parallel_fill": { + "iterations": 1048576, + "automatic_median_ms": 0.4069, + "sequential_median_ms": 1.086, + "automatic_speedup": 2.66896, + "observed_backend": "thread_pool", + "parallel_observed": true + }, + "parallel_generate": { + "iterations": 262144, + "automatic_median_ms": 1.098, + "sequential_median_ms": 3.6957, + "automatic_speedup": 3.365847, + "observed_backend": "thread_pool", + "parallel_observed": true + }, + "parallel_reduce": { + "iterations": 262144, + "automatic_median_ms": 0.0292, + "sequential_median_ms": 0.0325, + "automatic_speedup": 1.113014, + "observed_backend": "sequential", + "parallel_observed": false + }, + "parallel_transform_reduce": { + "iterations": 262144, + "automatic_median_ms": 1.0712, + "sequential_median_ms": 3.7858, + "automatic_speedup": 3.534167, + "observed_backend": "thread_pool", + "parallel_observed": true + }, + "parallel_transform_reduce_binary": { + "iterations": 262144, + "automatic_median_ms": 0.5253, + "sequential_median_ms": 1.7784, + "automatic_speedup": 3.385494, + "observed_backend": "thread_pool", + "parallel_observed": true + }, + "parallel_count": { + "iterations": 262144, + "automatic_median_ms": 0.0349, + "sequential_median_ms": 0.0341, + "automatic_speedup": 0.977077, + "observed_backend": "sequential", + "parallel_observed": false + }, + "parallel_count_if": { + "iterations": 262144, + "automatic_median_ms": 0.3752, + "sequential_median_ms": 1.1459, + "automatic_speedup": 3.054104, + "observed_backend": "thread_pool", + "parallel_observed": true + }, + "parallel_any_of": { + "iterations": 262144, + "automatic_median_ms": 0.0684, + "sequential_median_ms": 0.0685, + "automatic_speedup": 1.001462, + "observed_backend": "sequential", + "parallel_observed": false + }, + "parallel_all_of": { + "iterations": 262144, + "automatic_median_ms": 0.0681, + "sequential_median_ms": 0.0681, + "automatic_speedup": 1.0, + "observed_backend": "sequential", + "parallel_observed": false + }, + "parallel_none_of": { + "iterations": 262144, + "automatic_median_ms": 0.0685, + "sequential_median_ms": 0.0683, + "automatic_speedup": 0.99708, + "observed_backend": "sequential", + "parallel_observed": false + }, + "parallel_find": { + "iterations": 262144, + "automatic_median_ms": 0.0295, + "sequential_median_ms": 0.0291, + "automatic_speedup": 0.986441, + "observed_backend": "sequential", + "parallel_observed": false + }, + "parallel_find_if": { + "iterations": 262144, + "automatic_median_ms": 0.0685, + "sequential_median_ms": 0.068, + "automatic_speedup": 0.992701, + "observed_backend": "sequential", + "parallel_observed": false + } + } +} diff --git a/docs/v1.4/assets/benchmarks/cheap-dispatch-relative-latency.png b/docs/v1.4/assets/benchmarks/cheap-dispatch-relative-latency.png new file mode 100644 index 0000000..20fdea1 Binary files /dev/null and b/docs/v1.4/assets/benchmarks/cheap-dispatch-relative-latency.png differ diff --git a/docs/v1.4/assets/benchmarks/cheap-dispatch-relative-latency.svg b/docs/v1.4/assets/benchmarks/cheap-dispatch-relative-latency.svg new file mode 100644 index 0000000..dca5ddc --- /dev/null +++ b/docs/v1.4/assets/benchmarks/cheap-dispatch-relative-latency.svg @@ -0,0 +1,1543 @@ + + + + + + + + image/svg+xml + + + SmartParallel v1.4 benchmark generator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/v1.4/assets/benchmarks/generated-results.md b/docs/v1.4/assets/benchmarks/generated-results.md new file mode 100644 index 0000000..3af58fe --- /dev/null +++ b/docs/v1.4/assets/benchmarks/generated-results.md @@ -0,0 +1,34 @@ +# Generated v1.4 benchmark summary + +> Generated by `python tools/plot_v14_algorithm_results.py` from the checked-in +> `validation/output/v1.4.0_parallel_algorithms.csv` and raw sample file. + +## Release summary + +- **80** summary rows and **560** raw samples validated. +- Automatic selected ThreadPool for **8** cases and direct sequential for **8** cases. +- The parallel-selected group achieved a **3.30×** geometric-mean speedup. +- All cheap-dispatch families were within **3.45%** of the direct sequential median or faster. + +## Automatic results + +| Algorithm | Sequential median | Automatic median | Speedup | Automatic route | +|---|---:|---:|---:|---| +| `parallel_for_each` | 3.7626 ms | 1.0813 ms | 3.48× | `thread_pool` | +| `parallel_transform` | 3.7515 ms | 1.0661 ms | 3.52× | `thread_pool` | +| `parallel_transform_binary` | 3.8617 ms | 1.1071 ms | 3.49× | `thread_pool` | +| `parallel_copy` | 1.1173 ms | 1.1559 ms | 0.97× | `sequential` | +| `parallel_fill` | 1.0860 ms | 0.4069 ms | 2.67× | `thread_pool` | +| `parallel_generate` | 3.6957 ms | 1.0980 ms | 3.37× | `thread_pool` | +| `parallel_reduce` | 0.0325 ms | 0.0292 ms | 1.11× | `sequential` | +| `parallel_transform_reduce` | 3.7858 ms | 1.0712 ms | 3.53× | `thread_pool` | +| `parallel_transform_reduce_binary` | 1.7784 ms | 0.5253 ms | 3.39× | `thread_pool` | +| `parallel_count` | 0.0341 ms | 0.0349 ms | 0.98× | `sequential` | +| `parallel_count_if` | 1.1459 ms | 0.3752 ms | 3.05× | `thread_pool` | +| `parallel_any_of` | 0.0685 ms | 0.0684 ms | 1.00× | `sequential` | +| `parallel_all_of` | 0.0681 ms | 0.0681 ms | 1.00× | `sequential` | +| `parallel_none_of` | 0.0683 ms | 0.0685 ms | 1.00× | `sequential` | +| `parallel_find` | 0.0291 ms | 0.0295 ms | 0.99× | `sequential` | +| `parallel_find_if` | 0.0680 ms | 0.0685 ms | 0.99× | `sequential` | + +All rows in the source CSVs passed checksum correctness and backend-authentication checks. diff --git a/docs/v1.4/assets/benchmarks/parallel-family-backend-comparison.png b/docs/v1.4/assets/benchmarks/parallel-family-backend-comparison.png new file mode 100644 index 0000000..fb7c60a Binary files /dev/null and b/docs/v1.4/assets/benchmarks/parallel-family-backend-comparison.png differ diff --git a/docs/v1.4/assets/benchmarks/parallel-family-backend-comparison.svg b/docs/v1.4/assets/benchmarks/parallel-family-backend-comparison.svg new file mode 100644 index 0000000..7e1dd59 --- /dev/null +++ b/docs/v1.4/assets/benchmarks/parallel-family-backend-comparison.svg @@ -0,0 +1,1893 @@ + + + + + + + + image/svg+xml + + + SmartParallel v1.4 benchmark generator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/v1.4/benchmark-methodology.md b/docs/v1.4/benchmark-methodology.md new file mode 100644 index 0000000..15add07 --- /dev/null +++ b/docs/v1.4/benchmark-methodology.md @@ -0,0 +1,54 @@ +# v1.4 algorithm benchmark methodology + +The v1.4 benchmark executable covers all fourteen public API families and separately measures unary/binary transform and unary/binary transform-reduce, producing sixteen cases. Each case is measured in five modes: + +- direct sequential reference; +- SmartParallel automatic selection; +- forced ThreadPool; +- forced StaticThread; +- forced oneTBB when oneTBB is available. + +## Workloads + +The benchmark uses deterministic random-access ranges. Compute-heavy transform, generate, for-each, count-if, and transform-reduce cases contain enough per-element work to make parallel execution profitable. Reduce, count, search, predicate, and copy cases intentionally exercise operations for which scheduler overhead or memory bandwidth can dominate. + +Iteration counts are recorded in the CSV. The accepted snapshot uses 262,144 elements for most cases and 1,048,576 elements for copy and fill. + +## Timing and correctness + +Timing includes the complete public algorithm route and stops before checksum calculation. Every measured repetition then validates a deterministic checksum or result against the sequential reference. Forced backend rows authenticate the runtime that actually executed. Any incorrect or unauthenticated row causes the executable and release script to fail. + +The benchmark writes: + +```text +validation/output/v1.4.0_parallel_algorithms.csv +validation/output/v1.4.0_parallel_algorithms_raw.csv +``` + +The summary records median/minimum/maximum operation time, sequential median, speedup, checksum correctness, backend authentication, observed backend, and whether parallel execution was observed. The raw file retains every repetition. + +## Automatic learning phase + +Automatic rows include normal runtime learning. For the cheap-dispatch families, the unmeasured warm-up normally supplies a complete scheduled observation and the first measured call supplies a complete direct-sequential observation. Later calls use the learned route before chunk creation. + +Each public invocation executes exactly one route. The benchmark never runs both alternatives inside one call, so user work, side effects, output writes, and exceptions are not duplicated for measurement. + +Forced backend rows and nested calls bypass the algorithm-level hot cache and continue through the existing scheduler/backend implementations. + +## Release interpretation + +The v1.4 performance gate for the corrected cheap families is: + +```text +automatic median <= direct sequential median * 1.05 +``` + +This gate verifies that automatic dispatch no longer pays material scheduler overhead after learning. It does not require automatic mode to match the fastest forced backend on every machine. + +For the protected parallel families, the release expectation is that automatic execution remains decisively faster than sequential and preserves the established scheduling path. + +## Repetitions + +The checked-in acceptance snapshot contains seven repetitions per algorithm/mode pair. Seven is suitable for development and regression confirmation. A new publication-quality machine result should use a larger odd count such as 31 on an otherwise idle physical machine. + +See [benchmark reproduction](benchmark-reproduction.md) for the exact commands and [benchmark results](benchmarks.md) for the accepted data. diff --git a/docs/v1.4/benchmark-reproduction.md b/docs/v1.4/benchmark-reproduction.md new file mode 100644 index 0000000..2e865ef --- /dev/null +++ b/docs/v1.4/benchmark-reproduction.md @@ -0,0 +1,68 @@ +# Reproducing the v1.4 algorithm benchmark + +The v1.4 benchmark is a manual Release validation workflow for Windows/MSVC with oneTBB enabled. It configures the project, builds the library and benchmark target, runs the complete deterministic CTest suite, executes the five-mode algorithm matrix, and validates that all expected APIs and oneTBB rows are present. + +## Requirements + +- Windows 10 or later; +- Visual Studio 2022 with the Desktop development with C++ workload; +- CMake 3.20 or newer in `PATH`; +- a vcpkg checkout containing oneTBB; +- Python 3 with `pandas`, `numpy`, and `matplotlib` only when regenerating documentation figures. + +## Release-quality benchmark + +From a normal Command Prompt at the repository root: + +```bat +set "VCPKG_ROOT=D:\Tools\vcpkg" && scripts\validation\run_v14_algorithm_release_validation.bat 31 +``` + +The first argument is the repetition count. Use an odd value so the median is an observed sample. Seven repetitions are suitable for development; 31 or more are recommended for a publication run on an otherwise idle physical machine. + +To rerun tests and benchmarks without reconfiguring or rebuilding an existing successful build directory: + +```bat +scripts\validation\run_v14_algorithm_release_validation.bat 31 reuse +``` + +## Generated CSVs + +```text +validation/output/v1.4.0_parallel_algorithms.csv +validation/output/v1.4.0_parallel_algorithms_raw.csv +``` + +The summary CSV contains one row per algorithm/mode pair. The raw CSV contains every timed repetition. Both include correctness and backend-authentication fields. + +## Regenerating the report assets + +After producing or replacing the CSVs: + +```bat +python tools\plot_v14_algorithm_results.py +``` + +The script validates the source data before updating `docs/v1.4/assets/benchmarks/` with PNG/SVG figures, generated Markdown, aggregate metrics, and SHA-256 hashes of the input CSVs. + +Optional explicit paths are supported: + +```bat +python tools\plot_v14_algorithm_results.py ^ + --summary validation\output\v1.4.0_parallel_algorithms.csv ^ + --raw validation\output\v1.4.0_parallel_algorithms_raw.csv ^ + --output docs\v1.4\assets\benchmarks +``` + +## Measurement discipline + +For a release run: + +- use a physical machine rather than a shared CI runner or virtual machine; +- close background compilation, indexing, browser, and synchronization workloads; +- keep the power plan and CPU thermal state stable; +- avoid comparing results produced with different repetition counts or build types without saying so; +- preserve both CSV files, not only screenshots or summary values; +- record compiler, CPU, memory, operating-system, and oneTBB/vcpkg revisions in the release or pull-request notes. + +The checked-in v1.4 snapshot uses seven repetitions and is retained as acceptance evidence for the hot-dispatch correction. It should not be presented as a universal hardware ranking. diff --git a/docs/v1.4/benchmarks.md b/docs/v1.4/benchmarks.md new file mode 100644 index 0000000..f555241 --- /dev/null +++ b/docs/v1.4/benchmarks.md @@ -0,0 +1,93 @@ +# SmartParallel v1.4 parallel-algorithm benchmark results + +> Final accepted v1.4 benchmark snapshot. Values are calculated from +> [`validation/output/v1.4.0_parallel_algorithms.csv`](../../validation/output/v1.4.0_parallel_algorithms.csv) +> and the matching raw sample file. + +SmartParallel v1.4 adds fourteen public algorithm families, with separate unary and binary measurements for transform and transform-reduce. The final matrix contains sixteen benchmark cases across sequential, automatic, ThreadPool, StaticThread, and oneTBB modes. + +## Release summary + +The checked-in Windows/MSVC Release run produced: + +- **80/80 summary rows** passing checksum correctness and backend authentication; +- **560/560 raw samples** passing the same validation; +- automatic ThreadPool execution for the eight compute-heavy cases; +- direct sequential hot dispatch for the eight cheap or bandwidth-sensitive cases; +- a **3.30× geometric-mean speedup** across the eight parallel-selected cases; +- automatic speedups ranging from **2.67× to 3.53×** for those parallel-selected cases; +- every corrected cheap-dispatch family within **3.5%** of direct sequential latency or faster. + +![Automatic speedup by algorithm](assets/benchmarks/automatic-speedup-by-algorithm.png) + +*Automatic median speedup over the direct sequential baseline. Bar color identifies the observed automatic route.* + +## Automatic results + +| Algorithm | Iterations | Sequential median | Automatic median | Speedup | Automatic route | +|---|---:|---:|---:|---:|---| +| `parallel_for_each` | 262,144 | 3.7626 ms | 1.0813 ms | 3.48× | `thread_pool` | +| `parallel_transform` | 262,144 | 3.7515 ms | 1.0661 ms | 3.52× | `thread_pool` | +| `parallel_transform_binary` | 262,144 | 3.8617 ms | 1.1071 ms | 3.49× | `thread_pool` | +| `parallel_copy` | 1,048,576 | 1.1173 ms | 1.1559 ms | 0.97× | `sequential` | +| `parallel_fill` | 1,048,576 | 1.0860 ms | 0.4069 ms | 2.67× | `thread_pool` | +| `parallel_generate` | 262,144 | 3.6957 ms | 1.0980 ms | 3.37× | `thread_pool` | +| `parallel_reduce` | 262,144 | 0.0325 ms | 0.0292 ms | 1.11× | `sequential` | +| `parallel_transform_reduce` | 262,144 | 3.7858 ms | 1.0712 ms | 3.53× | `thread_pool` | +| `parallel_transform_reduce_binary` | 262,144 | 1.7784 ms | 0.5253 ms | 3.39× | `thread_pool` | +| `parallel_count` | 262,144 | 0.0341 ms | 0.0349 ms | 0.98× | `sequential` | +| `parallel_count_if` | 262,144 | 1.1459 ms | 0.3752 ms | 3.05× | `thread_pool` | +| `parallel_any_of` | 262,144 | 0.0685 ms | 0.0684 ms | 1.00× | `sequential` | +| `parallel_all_of` | 262,144 | 0.0681 ms | 0.0681 ms | 1.00× | `sequential` | +| `parallel_none_of` | 262,144 | 0.0683 ms | 0.0685 ms | 1.00× | `sequential` | +| `parallel_find` | 262,144 | 0.0291 ms | 0.0295 ms | 0.99× | `sequential` | +| `parallel_find_if` | 262,144 | 0.0680 ms | 0.0685 ms | 0.99× | `sequential` | + +## Cheap-dispatch correction + +The release correction targeted `parallel_reduce`, `parallel_count`, `parallel_find`, `parallel_find_if`, `parallel_any_of`, `parallel_all_of`, `parallel_none_of`, and `parallel_copy`. These operations had either microsecond-scale bodies or memory-bandwidth behavior that made scheduler construction more expensive than direct execution. + +![Cheap-dispatch relative latency](assets/benchmarks/cheap-dispatch-relative-latency.png) + +*Automatic median latency relative to direct sequential execution after the algorithm-level hot cache learned its route. The dashed line marks the +5% release gate.* + +The largest measured automatic slowdown in this group was `parallel_copy` at **3.45%**. `parallel_reduce` measured faster than its separately timed sequential row in this sample; that difference should be treated as normal microbenchmark variance, not as evidence that the direct route changes the algorithm. + +The result demonstrates the intended behavior: after learning, automatic calls bypass chunk construction and scheduler entry, so cheap algorithms remain close to the standard-library baseline instead of paying tens of microseconds of framework overhead. + +## Parallel-selected algorithms + +The algorithms that were already profitable in parallel retained their original scheduling path. Across this group, automatic execution achieved a **3.30× geometric-mean speedup**. + +![Backend comparison for parallel-selected algorithms](assets/benchmarks/parallel-family-backend-comparison.png) + +*Speedup over sequential for automatic and forced backend modes. Automatic remains close to the strongest backend without changing forced-mode behavior.* + +| Algorithm | Automatic | ThreadPool | StaticThread | oneTBB | +|---|---:|---:|---:|---:| +| `parallel_for_each` | 3.48× | 3.15× | 2.71× | 3.40× | +| `parallel_transform` | 3.52× | 3.53× | 2.54× | 3.25× | +| `parallel_transform_binary` | 3.49× | 3.44× | 2.64× | 3.18× | +| `parallel_fill` | 2.67× | 2.47× | 1.02× | 2.02× | +| `parallel_generate` | 3.37× | 3.47× | 2.71× | 3.60× | +| `parallel_transform_reduce` | 3.53× | 3.57× | 2.68× | 3.24× | +| `parallel_transform_reduce_binary` | 3.39× | 3.49× | 2.07× | 3.72× | +| `parallel_count_if` | 3.05× | 2.93× | 1.69× | 3.14× | + +## Manual backend observations + +Forced modes are diagnostic comparisons, not targets for the automatic policy. oneTBB was the fastest measured route for some cases, including `parallel_any_of`, `parallel_find_if`, and `parallel_copy`. Automatic still selected direct sequential execution for these calls because the learned difference was small or noisy relative to scheduler risk and the policy intentionally favors the lower-overhead route unless parallel execution wins decisively. + +This is an expected boundary of adaptive execution: automatic mode aims for a strong, stable plan, not guaranteed equality with the fastest forced backend on every machine and data distribution. + +## Correctness and authenticity + +Every timed repetition verifies a deterministic checksum or result against the sequential reference. Forced ThreadPool, StaticThread, and oneTBB rows also authenticate the backend that actually executed. A failed correctness or authentication field causes the benchmark executable and release script to return failure. + +The raw CSV is retained so medians, ranges, route transitions, and outliers can be audited independently. + +## Reproduction and source data + +See [benchmark reproduction](benchmark-reproduction.md) for the complete command sequence. Machine-readable generated metrics and source hashes are retained in [`assets/benchmarks/benchmark-metrics.json`](assets/benchmarks/benchmark-metrics.json), and the generated automatic table is in [`assets/benchmarks/generated-results.md`](assets/benchmarks/generated-results.md). + +These results are specific to the recorded workload, compiler, operating system, dependency versions, and machine state. They do not establish universal scaling or guarantee that automatic mode is always the fastest possible strategy. diff --git a/docs/v1.4/known-limitations.md b/docs/v1.4/known-limitations.md new file mode 100644 index 0000000..51cf78c --- /dev/null +++ b/docs/v1.4/known-limitations.md @@ -0,0 +1,39 @@ +# v1.4 known limitations + +SmartParallel v1.4 is designed to choose a strong stable route, not to guarantee the fastest possible backend for every invocation. + +## Performance evidence is machine-specific + +The checked-in benchmark uses one Windows/MSVC Release environment and seven repetitions per row. CPU model, memory configuration, power state, operating-system activity, compiler revision, and oneTBB revision can all change the result. Reproduce the suite on target hardware before making workload-specific claims. + +## Automatic mode can differ from the fastest forced backend + +The hot-dispatch policy uses hysteresis and favors direct sequential execution when results are close or noisy. A forced oneTBB run can therefore be faster in an individual benchmark case even when automatic mode selects sequential. This is visible in the accepted `parallel_any_of`, `parallel_find_if`, and `parallel_copy` rows. + +## Learning is in-process + +Algorithm dispatch evidence is retained in memory. A new process starts a new learning phase. Periodic revalidation intentionally adds occasional probe calls, and the first calls at a new workload bucket may not represent steady-state performance. + +## Nested calls keep the existing scheduler path + +The root automatic hot cache does not override nested execution. Nested algorithms continue through the established session, budget, and frontier machinery. This avoids cross-context decisions but means a cheap nested call can retain more scheduler overhead than a learned root call. + +## Random-access iterators are required + +All v1.4 algorithms require random-access iterators because the implementation partitions contiguous indexable ranges. Forward-only and bidirectional iterators are not accepted. + +## Short-circuit work is best effort + +Predicate and search operations can have work already in flight after the logical result is known. Invocation order and total predicate call count are not specified. Search still returns the earliest matching iterator. + +## Reductions require associativity + +Chunk and input ordering are preserved, but parallel parenthesization can differ from a strict left fold. Floating-point results can differ in their least significant bits. Non-associative operations are not supported as parallel reductions. + +## Configuration remains process-global + +Runtime configuration must be established before concurrent execution and must not be mutated concurrently with active calls. Cache generations handle material configuration changes, but they do not make process-global configuration mutation thread-safe. + +## oneTBB remains optional + +The oneTBB backend and its forced benchmark rows are available only when SmartParallel is built with oneTBB enabled. ThreadPool, StaticThread, sequential, and automatic execution remain available without it. diff --git a/docs/v1.4/release-notes.md b/docs/v1.4/release-notes.md new file mode 100644 index 0000000..671e455 --- /dev/null +++ b/docs/v1.4/release-notes.md @@ -0,0 +1,50 @@ +# SmartParallel v1.4.0 release notes + +SmartParallel v1.4 adds adaptive standard-algorithm-style APIs on the stabilized v1.1 scheduler and the v1.3 portability/CI foundation. + +## Added + +- Fourteen adaptive parallel algorithm families for elementwise work, reductions, counting, predicates, and search. +- Unary and binary `parallel_transform` overloads. +- Unary and binary `parallel_transform_reduce` overloads. +- Indexed deterministic `parallel_generate`. +- Ordered chunk reduction and earliest-index parallel search. +- Dedicated correctness, nested-execution, exception, installed-package, sanitizer, and benchmark coverage. +- A five-mode benchmark matrix producing summary and raw CSV files. +- Reproducible v1.4 benchmark reporting with PNG/SVG figures, generated Markdown, machine-readable metrics, and source hashes. + +## Performance correction + +- Added an Auto-only, root-only algorithm hot-dispatch cache for `parallel_reduce`, `parallel_count`, `parallel_find`, `parallel_find_if`, `parallel_any_of`, `parallel_all_of`, `parallel_none_of`, and `parallel_copy`. +- Moved the stable sequential decision before chunk construction and scheduler entry. +- Learned from separate real complete scheduled and sequential invocations without duplicating user work. +- Added bounded sharded retention, workload/byte buckets, policy and profile-cache epoch invalidation, single-flight probes, hysteresis, and periodic revalidation. +- Corrected `parallel_copy` learning by measuring actual sequential copy time instead of inferring it from bandwidth-limited parallel execution. +- Updated scheduled copy chunks to call `std::copy` so contiguous iterators retain standard-library optimizations. +- Reduced search and predicate coordination overhead with relaxed atomics while retaining scheduler-completion synchronization. +- Cached Windows hardware topology discovery for the process lifetime. + +## Preserved behavior + +- Forced ThreadPool, StaticThread, and oneTBB modes bypass the algorithm hot cache. +- Nested calls retain the established nested execution session and participant budget. +- `parallel_for`, scheduler policy, backend engines, and v1.1 benchmark algorithms are unchanged. +- The already-fast transform, generate, for-each, fill, count-if, and transform-reduce families keep their original automatic scheduling path. + +## Accepted benchmark result + +The checked-in Windows/MSVC Release snapshot contains seven repetitions per algorithm/mode pair: + +- **80/80 summary rows** and **560/560 raw samples** passed correctness and backend authentication; +- automatic selected ThreadPool for eight compute-heavy cases and direct sequential execution for eight cheap/bandwidth-sensitive cases; +- the parallel-selected group achieved a **3.30× geometric-mean speedup**, ranging from **2.67× to 3.53×**; +- every corrected cheap-dispatch family remained within **3.5%** of direct sequential latency or faster. + +See [benchmark results](benchmarks.md) for the complete table and qualifications. + +## Compatibility + +- C++17 and CMake 3.20 remain the minimum requirements. +- The installed target remains `SmartParallel::smart_parallel`. +- v1.4 algorithms require random-access iterators. +- Reduction operations must be associative. diff --git a/docs/v1.4/validation.md b/docs/v1.4/validation.md new file mode 100644 index 0000000..93f176c --- /dev/null +++ b/docs/v1.4/validation.md @@ -0,0 +1,48 @@ +# v1.4 validation + +The deterministic target is: + +```text +smartparallel_v140_parallel_algorithms_validation +``` + +It validates all APIs under automatic selection, forced ThreadPool, and forced StaticThread, plus forced oneTBB when compiled in. + +## Correctness coverage + +- empty and single-element ranges; +- exactly-once elementwise execution; +- unary, binary, and in-place transforms; +- copy, fill, and indexed generate; +- ordered associative reductions; +- unary and binary transform-reduce; +- exact count and count-if results; +- predicate identities and short-circuit results; +- earliest-match search; +- exception propagation and cleanup; +- nested algorithm calls under the existing execution session; +- installed-package consumption through `SmartParallel::smart_parallel`. + +## Hot-dispatch coverage + +Validation also exercises scheduler-approved direct sequential execution and the algorithm-level hot cache for reduce, count, search, predicates, and copy. Release checks verify that: + +- one public invocation executes one route only; +- forced ThreadPool, StaticThread, and oneTBB modes remain forced; +- nested calls retain the existing nested runtime; +- cached direct paths preserve results and exception behavior; +- workload/configuration changes do not silently reuse an invalid plan. + +## Completed local validation + +During the v1.4 correction: + +- GCC Release passed the complete 17-test deterministic suite; +- Clang Release passed the v1.4 algorithm validation; +- Clang AddressSanitizer and UndefinedBehaviorSanitizer passed the v1.4 validation; +- the installed CMake package consumer built and executed the public algorithm API; +- the accepted Windows/MSVC benchmark produced **80/80 correct/authenticated summary rows** and **560/560 correct/authenticated raw samples**. + +The repository GitHub Actions matrix remains the authoritative cross-platform build/test gate after a branch is pushed. It covers Windows/MSVC, Linux/GCC, Linux/Clang, macOS/Apple Clang, oneTBB-enabled/disabled configurations, installation, and the external package consumer. + +Performance benchmarks remain manual and are not executed on shared CI runners. See [benchmark results](benchmarks.md) and [benchmark reproduction](benchmark-reproduction.md). diff --git a/include/smart/core/config.hpp b/include/smart/core/config.hpp index 546b082..d553820 100644 --- a/include/smart/core/config.hpp +++ b/include/smart/core/config.hpp @@ -17,6 +17,7 @@ inline constexpr std::size_t exploration_states = 4096; inline constexpr std::size_t nested_trace_records = 65536; inline constexpr std::size_t nested_plan_snapshots = 4096; inline constexpr std::size_t backend_calibration_states = 4096; +inline constexpr std::size_t algorithm_dispatch_entries = 2048; inline constexpr std::size_t bounded_limit(std::size_t configured, std::size_t production_default) noexcept @@ -202,6 +203,18 @@ struct Config // Zero disables age-based revalidation. std::size_t parallel_for_profile_revalidate_after_ms = 300'000; + // v1.4 cheap-algorithm dispatch. Eligible root Auto calls learn from real + // complete sequential and scheduled invocations, then bypass chunk and + // scheduler construction when direct sequential execution wins. + bool enable_parallel_algorithm_hot_dispatch = true; + std::size_t parallel_algorithm_hot_dispatch_max_entries = + runtime_limits::algorithm_dispatch_entries; + double parallel_algorithm_hot_dispatch_minimum_parallel_speedup = 1.12; + double parallel_algorithm_hot_dispatch_probe_max_ms = 5.0; + double parallel_algorithm_hot_dispatch_blend = 0.25; + std::size_t parallel_algorithm_hot_dispatch_revalidate_interval = 64; + std::size_t parallel_algorithm_hot_dispatch_search_revalidate_interval = 32; + // Analytical workload thresholds. These preserve the previous defaults // but are configurable instead of being embedded in decision rules. std::size_t small_workload_iteration_threshold = 1'000; diff --git a/include/smart/execution/algorithm_dispatch.hpp b/include/smart/execution/algorithm_dispatch.hpp new file mode 100644 index 0000000..11a48ac --- /dev/null +++ b/include/smart/execution/algorithm_dispatch.hpp @@ -0,0 +1,529 @@ +#pragma once + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace smart +{ +namespace detail +{ +enum class ParallelAlgorithmKind : std::size_t +{ + ForEach = 0xA14001u, + Transform = 0xA14002u, + Copy = 0xA14003u, + Fill = 0xA14004u, + Generate = 0xA14005u, + Reduce = 0xA14006u, + TransformReduce = 0xA14007u, + Count = 0xA14008u, + CountIf = 0xA14009u, + AnyOf = 0xA1400Au, + AllOf = 0xA1400Bu, + NoneOf = 0xA1400Cu, + Find = 0xA1400Du, + FindIf = 0xA1400Eu +}; + +enum class AlgorithmDispatchRoute : std::uint8_t +{ + Scheduled, + Sequential +}; + +inline bool algorithm_hot_dispatch_family(ParallelAlgorithmKind kind) noexcept +{ + switch (kind) + { + case ParallelAlgorithmKind::Copy: + case ParallelAlgorithmKind::Reduce: + case ParallelAlgorithmKind::Count: + case ParallelAlgorithmKind::AnyOf: + case ParallelAlgorithmKind::AllOf: + case ParallelAlgorithmKind::NoneOf: + case ParallelAlgorithmKind::Find: + case ParallelAlgorithmKind::FindIf: + return true; + default: + return false; + } +} + +inline bool algorithm_search_or_predicate_family(ParallelAlgorithmKind kind) noexcept +{ + switch (kind) + { + case ParallelAlgorithmKind::AnyOf: + case ParallelAlgorithmKind::AllOf: + case ParallelAlgorithmKind::NoneOf: + case ParallelAlgorithmKind::Find: + case ParallelAlgorithmKind::FindIf: + return true; + default: + return false; + } +} + +inline std::size_t algorithm_dispatch_policy_signature(const Config& config) noexcept +{ + std::size_t hash = parallel_policy_signature(config); + hash = combine_hash(hash, config.enable_parallel_algorithm_hot_dispatch ? 1u : 0u); + hash = combine_hash(hash, config.parallel_algorithm_hot_dispatch_max_entries); + hash = combine_hash( + hash, std::hash{}(config.parallel_algorithm_hot_dispatch_minimum_parallel_speedup)); + hash = combine_hash( + hash, std::hash{}(config.parallel_algorithm_hot_dispatch_probe_max_ms)); + hash = combine_hash(hash, std::hash{}(config.parallel_algorithm_hot_dispatch_blend)); + hash = combine_hash(hash, config.parallel_algorithm_hot_dispatch_revalidate_interval); + hash = combine_hash(hash, config.parallel_algorithm_hot_dispatch_search_revalidate_interval); + return hash; +} + +struct AlgorithmDispatchKey +{ + ParallelAlgorithmKind kind = ParallelAlgorithmKind::Reduce; + std::size_t callsite = 0; + std::size_t element_size = 0; + std::size_t iteration_bucket = 0; + std::size_t byte_bucket = 0; + std::size_t root_budget = 0; + std::size_t policy_signature = 0; + std::uint64_t profile_cache_epoch = 0; + + bool operator==(const AlgorithmDispatchKey& other) const noexcept + { + return kind == other.kind && callsite == other.callsite + && element_size == other.element_size + && iteration_bucket == other.iteration_bucket + && byte_bucket == other.byte_bucket && root_budget == other.root_budget + && policy_signature == other.policy_signature + && profile_cache_epoch == other.profile_cache_epoch; + } +}; + +struct AlgorithmDispatchKeyHasher +{ + std::size_t operator()(const AlgorithmDispatchKey& key) const noexcept + { + std::size_t hash = static_cast(key.kind); + hash = combine_hash(hash, key.callsite); + hash = combine_hash(hash, key.element_size); + hash = combine_hash(hash, key.iteration_bucket); + hash = combine_hash(hash, key.byte_bucket); + hash = combine_hash(hash, key.root_budget); + hash = combine_hash(hash, key.policy_signature); + hash = combine_hash(hash, static_cast(key.profile_cache_epoch)); + return hash; + } +}; + +struct AlgorithmDispatchSelection +{ + bool enabled = false; + AlgorithmDispatchRoute route = AlgorithmDispatchRoute::Scheduled; + bool probe = false; + bool fresh_scheduler = false; + std::uint64_t probe_nonce = 0; + AlgorithmDispatchKey key{}; +}; + +class AlgorithmDispatchCache +{ + public: + AlgorithmDispatchSelection select(ParallelAlgorithmKind kind, + std::size_t callsite, + std::size_t total, + std::size_t element_size) + { + const Config& config = global_config(); + const ExecutionContext context = current_execution_context(); + if (!config.enable_parallel_algorithm_hot_dispatch + || config.execution_engine != ExecutionEngineType::Auto || context.depth != 0 + || total == 0 || !algorithm_hot_dispatch_family(kind)) + { + return {}; + } + + AlgorithmDispatchSelection selection; + selection.enabled = true; + selection.key = make_key(kind, callsite, total, element_size, config); + + Shard& shard = shards_[shard_index(selection.key)]; + std::lock_guard lock(shard.mutex); + auto found = shard.entries.find(selection.key); + if (found == shard.entries.end()) + { + make_room_for_insert_locked(shard, configured_max_entries(config)); + found = shard.entries.emplace(selection.key, Entry{}).first; + } + Entry& entry = found->second; + entry.last_access_epoch = ++shard.access_epoch; + + if (entry.probe_in_progress) + { + selection.route = entry.stable + ? entry.stable_route + : AlgorithmDispatchRoute::Scheduled; + return selection; + } + + if (!entry.stable) + { + if (entry.scheduled_samples == 0) + { + begin_probe(entry, selection, AlgorithmDispatchRoute::Scheduled, false); + return selection; + } + + if (entry.sequential_samples == 0) + { + if (entry.scheduled_ms <= config.parallel_algorithm_hot_dispatch_probe_max_ms) + { + begin_probe(entry, selection, AlgorithmDispatchRoute::Sequential, false); + return selection; + } + + entry.stable = true; + entry.stable_route = AlgorithmDispatchRoute::Scheduled; + entry.uses_since_revalidation = 0; + selection.route = AlgorithmDispatchRoute::Scheduled; + return selection; + } + + choose_stable_route(entry, config); + } + + const std::size_t interval = revalidation_interval(kind, config); + if (interval > 0 && ++entry.uses_since_revalidation >= interval) + { + entry.uses_since_revalidation = 0; + if (entry.stable_route == AlgorithmDispatchRoute::Sequential) + { + begin_probe(entry, selection, AlgorithmDispatchRoute::Scheduled, true); + return selection; + } + if (entry.scheduled_ms <= config.parallel_algorithm_hot_dispatch_probe_max_ms) + { + begin_probe(entry, selection, AlgorithmDispatchRoute::Sequential, false); + return selection; + } + } + + selection.route = entry.stable_route; + return selection; + } + + void complete(const AlgorithmDispatchSelection& selection, double elapsed_ms) noexcept + { + if (!selection.enabled || elapsed_ms < 0.0) + return; + + Shard& shard = shards_[shard_index(selection.key)]; + std::lock_guard lock(shard.mutex); + const auto found = shard.entries.find(selection.key); + if (found == shard.entries.end()) + return; + + Entry& entry = found->second; + entry.last_access_epoch = ++shard.access_epoch; + const double blend = bounded_blend(global_config().parallel_algorithm_hot_dispatch_blend); + if (selection.route == AlgorithmDispatchRoute::Sequential) + { + update_measurement(entry.sequential_ms, entry.sequential_samples, elapsed_ms, blend); + } + else + { + update_measurement(entry.scheduled_ms, entry.scheduled_samples, elapsed_ms, blend); + } + + if (selection.probe && entry.probe_in_progress + && entry.active_probe_nonce == selection.probe_nonce) + { + entry.probe_in_progress = false; + entry.active_probe_nonce = 0; + if (entry.scheduled_samples > 0 && entry.sequential_samples > 0) + choose_stable_route(entry, global_config()); + else if (entry.scheduled_samples > 0 + && entry.scheduled_ms + > global_config().parallel_algorithm_hot_dispatch_probe_max_ms) + { + entry.stable = true; + entry.stable_route = AlgorithmDispatchRoute::Scheduled; + entry.uses_since_revalidation = 0; + } + } + } + + void cancel(const AlgorithmDispatchSelection& selection) noexcept + { + if (!selection.enabled || !selection.probe) + return; + Shard& shard = shards_[shard_index(selection.key)]; + std::lock_guard lock(shard.mutex); + const auto found = shard.entries.find(selection.key); + if (found == shard.entries.end()) + return; + Entry& entry = found->second; + if (entry.probe_in_progress && entry.active_probe_nonce == selection.probe_nonce) + { + entry.probe_in_progress = false; + entry.active_probe_nonce = 0; + } + } + + void clear() + { + for (Shard& shard : shards_) + { + std::lock_guard lock(shard.mutex); + shard.entries.clear(); + shard.access_epoch = 0; + } + } + + private: + struct Entry + { + bool stable = false; + AlgorithmDispatchRoute stable_route = AlgorithmDispatchRoute::Scheduled; + double sequential_ms = 0.0; + double scheduled_ms = 0.0; + std::size_t sequential_samples = 0; + std::size_t scheduled_samples = 0; + std::size_t uses_since_revalidation = 0; + bool probe_in_progress = false; + std::uint64_t active_probe_nonce = 0; + std::uint64_t last_access_epoch = 0; + }; + + struct Shard + { + std::mutex mutex; + std::unordered_map entries; + std::uint64_t access_epoch = 0; + }; + + static constexpr std::size_t shard_count = 16; + + static AlgorithmDispatchKey make_key(ParallelAlgorithmKind kind, + std::size_t callsite, + std::size_t total, + std::size_t element_size, + const Config& config) noexcept + { + const std::size_t maximum = std::numeric_limits::max(); + const std::size_t bytes = element_size != 0 && total > maximum / element_size + ? maximum + : total * element_size; + return {kind, + callsite, + element_size, + iteration_bucket(total), + iteration_bucket(bytes), + config.nested_root_concurrency_budget, + algorithm_dispatch_policy_signature(config), + global_function_profile_cache().cache_epoch()}; + } + + static std::size_t configured_max_entries(const Config& config) noexcept + { + return runtime_limits::bounded_limit( + config.parallel_algorithm_hot_dispatch_max_entries, + runtime_limits::algorithm_dispatch_entries); + } + + static std::size_t revalidation_interval(ParallelAlgorithmKind kind, + const Config& config) noexcept + { + return algorithm_search_or_predicate_family(kind) + ? config.parallel_algorithm_hot_dispatch_search_revalidate_interval + : config.parallel_algorithm_hot_dispatch_revalidate_interval; + } + + static double bounded_blend(double blend) noexcept + { + return std::max(0.0, std::min(1.0, blend)); + } + + static void update_measurement(double& average, + std::size_t& samples, + double elapsed_ms, + double blend) noexcept + { + if (samples == 0) + average = elapsed_ms; + else + average = average * (1.0 - blend) + elapsed_ms * blend; + if (samples != std::numeric_limits::max()) + ++samples; + } + + static void choose_stable_route(Entry& entry, const Config& config) noexcept + { + if (entry.sequential_samples == 0 || entry.scheduled_samples == 0) + return; + const double required_speedup = std::max( + 1.0, config.parallel_algorithm_hot_dispatch_minimum_parallel_speedup); + entry.stable = true; + entry.stable_route = entry.scheduled_ms > 0.0 + && entry.sequential_ms / entry.scheduled_ms >= required_speedup + ? AlgorithmDispatchRoute::Scheduled + : AlgorithmDispatchRoute::Sequential; + entry.uses_since_revalidation = 0; + } + + void begin_probe(Entry& entry, + AlgorithmDispatchSelection& selection, + AlgorithmDispatchRoute route, + bool fresh_scheduler) noexcept + { + const std::uint64_t nonce = next_probe_nonce_.fetch_add(1, std::memory_order_relaxed); + entry.probe_in_progress = true; + entry.active_probe_nonce = nonce; + selection.route = route; + selection.probe = true; + selection.fresh_scheduler = fresh_scheduler; + selection.probe_nonce = nonce; + } + + static std::size_t shard_index(const AlgorithmDispatchKey& key) noexcept + { + return AlgorithmDispatchKeyHasher{}(key) % shard_count; + } + + static void make_room_for_insert_locked(Shard& shard, std::size_t maximum_entries) + { + const std::size_t per_shard = std::max( + 1, (maximum_entries + shard_count - 1) / shard_count); + while (shard.entries.size() >= per_shard) + { + auto victim = shard.entries.end(); + for (auto it = shard.entries.begin(); it != shard.entries.end(); ++it) + { + if (it->second.probe_in_progress) + continue; + if (victim == shard.entries.end() + || it->second.last_access_epoch < victim->second.last_access_epoch) + victim = it; + } + if (victim == shard.entries.end()) + break; + shard.entries.erase(victim); + } + } + + std::array shards_{}; + std::atomic next_probe_nonce_{1}; +}; + +inline AlgorithmDispatchCache& global_algorithm_dispatch_cache() +{ + static AlgorithmDispatchCache cache; + return cache; +} + +inline void publish_algorithm_direct_sequential(double elapsed_ms) noexcept +{ + // Keep the thread-local diagnostics authoritative without reconstructing + // the large DecisionReport object on every microsecond-scale cache hit. + DecisionReport& report = global_last_decision_report(); + report.has_function_profile = false; + report.plan = ExecutionPlan{}; + report.plan.engine = ExecutionEngineType::Auto; + report.actual_execution_ms = elapsed_ms; + + ParallelForProfileDiagnostics& diagnostics = + global_last_parallel_for_profile_diagnostics(); + diagnostics.profile_available = true; + diagnostics.cache_hit = true; + diagnostics.sequential_fast_path = true; + diagnostics.sampled_iterations = 0; + diagnostics.estimated_sequential_ms = elapsed_ms; + diagnostics.estimated_parallel_ms = 0.0; + diagnostics.predicted_speedup = 0.0; + diagnostics.cache_lookup_ms = 0.0; + diagnostics.workload_analysis_ms = 0.0; + diagnostics.profiling_ms = 0.0; + diagnostics.decision_ms = 0.0; + diagnostics.execution_ms = elapsed_ms; + diagnostics.total_ms = elapsed_ms; +} + +inline std::size_t algorithm_dispatch_scheduler_callsite( + std::size_t base_callsite, + const AlgorithmDispatchSelection& selection) noexcept +{ + if (!selection.fresh_scheduler) + return base_callsite; + std::size_t hash = combine_hash(base_callsite, 0xA140484F54505242ull); + hash = combine_hash(hash, static_cast(selection.probe_nonce)); + return hash; +} + +template +auto run_hot_dispatched_algorithm(ParallelAlgorithmKind kind, + std::size_t callsite, + std::size_t total, + std::size_t element_size, + SequentialFunction&& sequential_function, + ScheduledFunction&& scheduled_function) + -> std::invoke_result_t +{ + using Result = std::invoke_result_t; + static_assert(std::is_same_v>, + "SmartParallel hot dispatch routes must return the same type"); + + AlgorithmDispatchSelection selection = global_algorithm_dispatch_cache().select( + kind, callsite, total, element_size); + if (!selection.enabled) + return scheduled_function(callsite); + + const auto start = std::chrono::steady_clock::now(); + try + { + if constexpr (std::is_void_v) + { + if (selection.route == AlgorithmDispatchRoute::Sequential) + sequential_function(); + else + scheduled_function(algorithm_dispatch_scheduler_callsite(callsite, selection)); + const double elapsed_ms = std::chrono::duration( + std::chrono::steady_clock::now() - start).count(); + global_algorithm_dispatch_cache().complete(selection, elapsed_ms); + if (selection.route == AlgorithmDispatchRoute::Sequential) + publish_algorithm_direct_sequential(elapsed_ms); + } + else + { + Result result = selection.route == AlgorithmDispatchRoute::Sequential + ? sequential_function() + : scheduled_function(algorithm_dispatch_scheduler_callsite(callsite, selection)); + const double elapsed_ms = std::chrono::duration( + std::chrono::steady_clock::now() - start).count(); + global_algorithm_dispatch_cache().complete(selection, elapsed_ms); + if (selection.route == AlgorithmDispatchRoute::Sequential) + publish_algorithm_direct_sequential(elapsed_ms); + return result; + } + } + catch (...) + { + global_algorithm_dispatch_cache().cancel(selection); + throw; + } +} +} // namespace detail +} // namespace smart diff --git a/include/smart/execution/algorithms.hpp b/include/smart/execution/algorithms.hpp new file mode 100644 index 0000000..5c1978c --- /dev/null +++ b/include/smart/execution/algorithms.hpp @@ -0,0 +1,1108 @@ +#pragma once + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace smart +{ +namespace detail +{ +class AlgorithmChunkFunctionRef +{ + public: + template , AlgorithmChunkFunctionRef>>> + explicit AlgorithmChunkFunctionRef(Function& function) noexcept + : object_(std::addressof(function)), + invoke_([](void* object, std::size_t chunk) + { + (*static_cast(object))(chunk); + }) + { + } + + void operator()(std::size_t chunk) const { invoke_(object_, chunk); } + + private: + void* object_ = nullptr; + void (*invoke_)(void*, std::size_t) = nullptr; +}; + +class AlgorithmSequentialRangeFunctionRef +{ + public: + template , AlgorithmSequentialRangeFunctionRef>>> + explicit AlgorithmSequentialRangeFunctionRef(Function& function) noexcept + : object_(std::addressof(function)), + invoke_([](void* object, std::size_t begin, std::size_t end) + { + (*static_cast(object))(begin, end); + }) + { + } + + void operator()(std::size_t begin, std::size_t end) const + { + invoke_(object_, begin, end); + } + + private: + void* object_ = nullptr; + void (*invoke_)(void*, std::size_t, std::size_t) = nullptr; +}; + +// Implemented in src/algorithms.cpp. Keeping the scheduler invocation behind a +// fixed callback type avoids repeatedly instantiating the large parallel_for +// template for every public algorithm/callable combination. Parallel plans +// invoke the chunk callback. Scheduler-approved sequential plans invoke the +// direct range callback, eliminating chunk dispatch and synchronization costs. +void execute_algorithm_chunks( + std::size_t chunk_count, + std::size_t callsite_key, + AlgorithmChunkFunctionRef function, + AlgorithmSequentialRangeFunctionRef sequential_function); + +template +using IteratorCategory = typename std::iterator_traits::iterator_category; + +template +constexpr bool is_random_access_iterator_v = + std::is_base_of_v>; + +template +std::size_t algorithm_range_size(Iterator first, Iterator last, const char* algorithm_name) +{ + static_assert(is_random_access_iterator_v, + "SmartParallel v1.4 algorithms require random-access iterators"); + const auto distance = last - first; + if (distance < 0) + throw std::invalid_argument(std::string("SmartParallel ") + algorithm_name + + " end must not precede begin"); + using UnsignedDifference = + std::make_unsigned_t>; + const auto unsigned_distance = static_cast(distance); + if (unsigned_distance > std::numeric_limits::max()) + throw std::overflow_error(std::string("SmartParallel ") + algorithm_name + + " range size overflow"); + return static_cast(unsigned_distance); +} + +template +Iterator algorithm_advance(Iterator iterator, std::size_t offset) +{ + using Difference = typename std::iterator_traits::difference_type; + if (offset > static_cast(std::numeric_limits::max())) + throw std::overflow_error("SmartParallel iterator offset overflow"); + return iterator + static_cast(offset); +} + +inline std::size_t algorithm_identity(ParallelAlgorithmKind kind) noexcept +{ + return combine_hash(0x5331504152414C47ull, static_cast(kind)); +} + +template +std::size_t algorithm_identity(ParallelAlgorithmKind kind, const Callable& callable) noexcept +{ + return combine_hash(algorithm_identity(kind), callable_identity_hash(callable)); +} + +template +std::size_t algorithm_identity(ParallelAlgorithmKind kind, + const CallableA& first, + const CallableB& second) noexcept +{ + return combine_hash( + combine_hash(algorithm_identity(kind), callable_identity_hash(first)), + callable_identity_hash(second)); +} + +template +std::size_t typed_algorithm_identity(ParallelAlgorithmKind kind) noexcept +{ + return combine_hash(algorithm_identity(kind), typeid(Value).hash_code()); +} + +inline std::size_t algorithm_chunk_count(std::size_t total) +{ + if (total == 0) + return 0; + const HardwareCharacteristics hardware = hardware_characteristics(); + std::size_t workers = std::max(1, hardware.logical_threads); + const Config& config = global_config(); + const ExecutionContext context = current_execution_context(); + if (context.depth > 0) + { + const std::size_t inherited_budget = context.parallel + ? context.concurrency_budget + : context.inherited_concurrency_budget; + workers = std::min(workers, std::max(1, inherited_budget)); + } + else if (config.nested_root_concurrency_budget != 0) + { + workers = std::min(workers, config.nested_root_concurrency_budget); + } + const std::size_t target_chunks_per_worker = std::max( + 4, config.nested_target_chunks_per_worker); + const std::size_t maximum = std::numeric_limits::max(); + const std::size_t desired = workers > maximum / target_chunks_per_worker + ? maximum + : workers * target_chunks_per_worker; + return std::max(1, std::min(total, desired)); +} + +struct AlgorithmChunkRange +{ + std::size_t begin = 0; + std::size_t end = 0; +}; + +template +class AlgorithmChunkCopies +{ + public: + AlgorithmChunkCopies(const Function& function, std::size_t chunk_count) + : function_(function), chunk_count_(chunk_count) + { + } + + Function& operator[](std::size_t chunk) + { + std::call_once(initialization_, [&] + { + functions_.reserve(chunk_count_); + for (std::size_t index = 0; index < chunk_count_; ++index) + functions_.emplace_back(function_); + }); + return functions_[chunk]; + } + + private: + Function function_; + std::size_t chunk_count_ = 0; + std::once_flag initialization_; + std::vector functions_; +}; + +inline AlgorithmChunkRange algorithm_chunk_range(std::size_t total, + std::size_t chunks, + std::size_t ordinal) noexcept +{ + const std::size_t base = total / chunks; + const std::size_t remainder = total % chunks; + const std::size_t begin = ordinal * base + std::min(ordinal, remainder); + const std::size_t length = base + (ordinal < remainder ? 1u : 0u); + return {begin, begin + length}; +} + +template +void run_chunked_algorithm(std::size_t total, + std::size_t callsite_key, + Function&& function, + SequentialFunction&& sequential_function) +{ + using ChunkFunction = std::decay_t; + static_assert(std::is_copy_constructible_v, + "SmartParallel algorithm callables must be copy constructible"); + if (total == 0) + return; + const std::size_t chunks = algorithm_chunk_count(total); + AlgorithmChunkCopies chunk_functions(function, chunks); + auto chunk_function = [&](std::size_t chunk) + { + chunk_functions[chunk](algorithm_chunk_range(total, chunks, chunk)); + }; + auto serial_range_function = [&](std::size_t chunk_begin, std::size_t chunk_end) + { + if (chunk_begin == 0 && chunk_end == chunks) + { + sequential_function(); + return; + } + for (std::size_t chunk = chunk_begin; chunk < chunk_end; ++chunk) + chunk_function(chunk); + }; + execute_algorithm_chunks( + chunks, + callsite_key, + AlgorithmChunkFunctionRef(chunk_function), + AlgorithmSequentialRangeFunctionRef(serial_range_function)); +} + +template +void run_chunked_algorithm(std::size_t total, + std::size_t callsite_key, + Function&& function) +{ + using ChunkFunction = std::decay_t; + ChunkFunction sequential_function(function); + run_chunked_algorithm( + total, + callsite_key, + std::forward(function), + [total, sequential_function = std::move(sequential_function)]() mutable + { + sequential_function(AlgorithmChunkRange{0, total}); + }); +} + +template +T chunked_transform_reduce_with_sequential(ParallelAlgorithmKind kind, + InputIterator first, + std::size_t total, + T init, + BinaryOperation binary_operation, + Transform transform, + SequentialFunction sequential_function, + std::size_t scheduler_callsite = 0) +{ + static_assert(std::is_copy_constructible_v, + "SmartParallel reduction operations must be copy constructible"); + static_assert(std::is_copy_constructible_v, + "SmartParallel transform operations must be copy constructible"); + if (total == 0) + return init; + + const std::size_t chunks = algorithm_chunk_count(total); + std::vector> partials; + std::once_flag partials_initialization; + const std::size_t callsite = scheduler_callsite == 0 + ? algorithm_identity(kind, binary_operation, transform) + : scheduler_callsite; + auto chunk_function = [=, &partials, &partials_initialization](std::size_t chunk) mutable + { + std::call_once(partials_initialization, [&] { partials.resize(chunks); }); + const AlgorithmChunkRange range = algorithm_chunk_range(total, chunks, chunk); + BinaryOperation local_binary = binary_operation; + Transform local_transform = transform; + T partial = std::invoke(local_transform, *algorithm_advance(first, range.begin)); + for (std::size_t index = range.begin + 1; index < range.end; ++index) + { + partial = std::invoke( + local_binary, + std::move(partial), + std::invoke(local_transform, *algorithm_advance(first, index))); + } + partials[chunk].emplace(std::move(partial)); + }; + + bool direct_sequential = false; + auto direct_function = [&]() mutable + { + init = std::invoke(sequential_function, std::move(init)); + direct_sequential = true; + }; + auto serial_range_function = [&](std::size_t chunk_begin, std::size_t chunk_end) + { + if (chunk_begin == 0 && chunk_end == chunks) + { + direct_function(); + return; + } + for (std::size_t chunk = chunk_begin; chunk < chunk_end; ++chunk) + chunk_function(chunk); + }; + execute_algorithm_chunks( + chunks, + callsite, + AlgorithmChunkFunctionRef(chunk_function), + AlgorithmSequentialRangeFunctionRef(serial_range_function)); + + if (direct_sequential) + return init; + for (std::size_t chunk = 0; chunk < chunks; ++chunk) + init = std::invoke(binary_operation, std::move(init), std::move(partials[chunk].value())); + return init; +} + +template +T chunked_transform_reduce(ParallelAlgorithmKind kind, + InputIterator first, + std::size_t total, + T init, + BinaryOperation binary_operation, + Transform transform) +{ + auto sequential_function = [=](T result) mutable + { + BinaryOperation local_binary = binary_operation; + Transform local_transform = transform; + InputIterator iterator = first; + for (std::size_t index = 0; index < total; ++index, ++iterator) + { + result = std::invoke( + local_binary, + std::move(result), + std::invoke(local_transform, *iterator)); + } + return result; + }; + return chunked_transform_reduce_with_sequential( + kind, + first, + total, + std::move(init), + std::move(binary_operation), + std::move(transform), + std::move(sequential_function)); +} + +template +T chunked_binary_transform_reduce(ParallelAlgorithmKind kind, + InputIterator1 first1, + InputIterator2 first2, + std::size_t total, + T init, + BinaryOperation binary_operation, + Transform transform) +{ + static_assert(std::is_copy_constructible_v, + "SmartParallel reduction operations must be copy constructible"); + static_assert(std::is_copy_constructible_v, + "SmartParallel transform operations must be copy constructible"); + if (total == 0) + return init; + + const std::size_t chunks = algorithm_chunk_count(total); + std::vector> partials; + std::once_flag partials_initialization; + const std::size_t callsite = algorithm_identity(kind, binary_operation, transform); + auto chunk_function = [=, &partials, &partials_initialization](std::size_t chunk) mutable + { + std::call_once(partials_initialization, [&] { partials.resize(chunks); }); + const AlgorithmChunkRange range = algorithm_chunk_range(total, chunks, chunk); + BinaryOperation local_binary = binary_operation; + Transform local_transform = transform; + T partial = std::invoke( + local_transform, + *algorithm_advance(first1, range.begin), + *algorithm_advance(first2, range.begin)); + for (std::size_t index = range.begin + 1; index < range.end; ++index) + { + partial = std::invoke( + local_binary, + std::move(partial), + std::invoke( + local_transform, + *algorithm_advance(first1, index), + *algorithm_advance(first2, index))); + } + partials[chunk].emplace(std::move(partial)); + }; + + bool direct_sequential = false; + auto sequential_function = [&]() mutable + { + BinaryOperation local_binary = binary_operation; + Transform local_transform = transform; + InputIterator1 iterator1 = first1; + InputIterator2 iterator2 = first2; + for (std::size_t index = 0; index < total; + ++index, ++iterator1, ++iterator2) + { + init = std::invoke( + local_binary, + std::move(init), + std::invoke(local_transform, *iterator1, *iterator2)); + } + direct_sequential = true; + }; + auto serial_range_function = [&](std::size_t chunk_begin, std::size_t chunk_end) + { + if (chunk_begin == 0 && chunk_end == chunks) + { + sequential_function(); + return; + } + for (std::size_t chunk = chunk_begin; chunk < chunk_end; ++chunk) + chunk_function(chunk); + }; + execute_algorithm_chunks( + chunks, + callsite, + AlgorithmChunkFunctionRef(chunk_function), + AlgorithmSequentialRangeFunctionRef(serial_range_function)); + + if (direct_sequential) + return init; + for (std::size_t chunk = 0; chunk < chunks; ++chunk) + init = std::invoke(binary_operation, std::move(init), std::move(partials[chunk].value())); + return init; +} + +template +std::size_t parallel_find_index(ParallelAlgorithmKind kind, + InputIterator first, + std::size_t total, + Predicate predicate, + std::size_t scheduler_callsite = 0) +{ + if (total == 0) + return 0; + + static_assert(std::is_copy_constructible_v, + "SmartParallel search predicates must be copy constructible"); + std::atomic best{total}; + const std::size_t callsite = scheduler_callsite == 0 + ? algorithm_identity(kind, predicate) + : scheduler_callsite; + const std::size_t chunks = algorithm_chunk_count(total); + AlgorithmChunkCopies predicates(predicate, chunks); + auto chunk_function = [=, &best, &predicates](std::size_t chunk) mutable + { + const AlgorithmChunkRange range = algorithm_chunk_range(total, chunks, chunk); + if (range.begin >= best.load(std::memory_order_relaxed)) + return; + Predicate& local_predicate = predicates[chunk]; + for (std::size_t index = range.begin; index < range.end; ++index) + { + if (index >= best.load(std::memory_order_relaxed)) + break; + if (!std::invoke(local_predicate, *algorithm_advance(first, index))) + continue; + std::size_t observed = best.load(std::memory_order_relaxed); + while (index < observed + && !best.compare_exchange_weak( + observed, + index, + std::memory_order_relaxed, + std::memory_order_relaxed)) + { + } + break; + } + }; + auto sequential_function = [&]() mutable + { + Predicate local_predicate = predicate; + const InputIterator last = algorithm_advance(first, total); + const InputIterator found = std::find_if(first, last, local_predicate); + best.store(static_cast(found - first), std::memory_order_relaxed); + }; + auto serial_range_function = [&](std::size_t chunk_begin, std::size_t chunk_end) + { + if (chunk_begin == 0 && chunk_end == chunks) + { + sequential_function(); + return; + } + for (std::size_t chunk = chunk_begin; chunk < chunk_end; ++chunk) + chunk_function(chunk); + }; + execute_algorithm_chunks( + chunks, + callsite, + AlgorithmChunkFunctionRef(chunk_function), + AlgorithmSequentialRangeFunctionRef(serial_range_function)); + return best.load(std::memory_order_relaxed); +} + +} // namespace detail + +// v1.4 deliberately requires random-access iterators. That keeps every API on +// the existing indexed scheduler and avoids introducing a second partitioning +// or traversal execution model. +template +void parallel_for_each(RandomAccessIterator first, RandomAccessIterator last, Function function) +{ + const std::size_t total = detail::algorithm_range_size(first, last, "parallel_for_each"); + const std::size_t callsite = + detail::algorithm_identity(detail::ParallelAlgorithmKind::ForEach, function); + detail::run_chunked_algorithm( + total, + callsite, + [=](detail::AlgorithmChunkRange range) mutable + { + for (std::size_t index = range.begin; index < range.end; ++index) + std::invoke(function, *detail::algorithm_advance(first, index)); + }, + [=]() mutable + { + std::for_each(first, last, function); + }); +} + +template +OutputIterator parallel_transform(InputIterator first, + InputIterator last, + OutputIterator output, + UnaryOperation operation) +{ + static_assert(detail::is_random_access_iterator_v, + "SmartParallel parallel_transform requires a random-access output iterator"); + const std::size_t total = detail::algorithm_range_size(first, last, "parallel_transform"); + const std::size_t callsite = + detail::algorithm_identity(detail::ParallelAlgorithmKind::Transform, operation); + detail::run_chunked_algorithm( + total, + callsite, + [=](detail::AlgorithmChunkRange range) mutable + { + for (std::size_t index = range.begin; index < range.end; ++index) + { + *detail::algorithm_advance(output, index) = + std::invoke(operation, *detail::algorithm_advance(first, index)); + } + }, + [=]() mutable + { + std::transform(first, last, output, operation); + }); + return detail::algorithm_advance(output, total); +} + +template +OutputIterator parallel_transform(InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2, + OutputIterator output, + BinaryOperation operation) +{ + static_assert(detail::is_random_access_iterator_v, + "SmartParallel parallel_transform requires random-access input iterators"); + static_assert(detail::is_random_access_iterator_v, + "SmartParallel parallel_transform requires a random-access output iterator"); + const std::size_t total = detail::algorithm_range_size(first1, last1, "parallel_transform"); + const std::size_t callsite = + detail::algorithm_identity(detail::ParallelAlgorithmKind::Transform, operation); + detail::run_chunked_algorithm( + total, + callsite, + [=](detail::AlgorithmChunkRange range) mutable + { + for (std::size_t index = range.begin; index < range.end; ++index) + { + *detail::algorithm_advance(output, index) = std::invoke( + operation, + *detail::algorithm_advance(first1, index), + *detail::algorithm_advance(first2, index)); + } + }, + [=]() mutable + { + std::transform(first1, last1, first2, output, operation); + }); + return detail::algorithm_advance(output, total); +} + +template +OutputIterator parallel_copy(InputIterator first, InputIterator last, OutputIterator output) +{ + static_assert(detail::is_random_access_iterator_v, + "SmartParallel parallel_copy requires a random-access output iterator"); + const std::size_t total = detail::algorithm_range_size(first, last, "parallel_copy"); + if (total == 0) + return output; + + using Value = typename std::iterator_traits::value_type; + std::size_t callsite = + detail::typed_algorithm_identity(detail::ParallelAlgorithmKind::Copy); + callsite = detail::combine_hash(callsite, typeid(InputIterator).hash_code()); + callsite = detail::combine_hash(callsite, typeid(OutputIterator).hash_code()); + + auto sequential_function = [=]() mutable + { + std::copy(first, last, output); + }; + auto scheduled_function = [=](std::size_t scheduler_callsite) mutable + { + detail::run_chunked_algorithm( + total, + scheduler_callsite, + [=](detail::AlgorithmChunkRange range) mutable + { + const InputIterator chunk_first = detail::algorithm_advance(first, range.begin); + const InputIterator chunk_last = detail::algorithm_advance(first, range.end); + const OutputIterator chunk_output = detail::algorithm_advance(output, range.begin); + std::copy(chunk_first, chunk_last, chunk_output); + }, + [=]() mutable + { + std::copy(first, last, output); + }); + }; + detail::run_hot_dispatched_algorithm( + detail::ParallelAlgorithmKind::Copy, + callsite, + total, + sizeof(Value), + sequential_function, + scheduled_function); + return detail::algorithm_advance(output, total); +} + +template +void parallel_fill(RandomAccessIterator first, RandomAccessIterator last, const T& value) +{ + using FillValue = std::decay_t; + static_assert(std::is_copy_constructible_v, + "SmartParallel parallel_fill requires a copy-constructible value"); + const std::size_t total = detail::algorithm_range_size(first, last, "parallel_fill"); + const std::size_t callsite = + detail::typed_algorithm_identity(detail::ParallelAlgorithmKind::Fill); + FillValue fill_value(value); + detail::run_chunked_algorithm( + total, + callsite, + [first, fill_value](detail::AlgorithmChunkRange range) + { + for (std::size_t index = range.begin; index < range.end; ++index) + *detail::algorithm_advance(first, index) = fill_value; + }, + [first, last, fill_value]() mutable + { + std::fill(first, last, fill_value); + }); +} + +// The generator receives the zero-based logical offset. This deterministic +// indexed contract avoids races and sequence changes from a shared stateful +// no-argument generator. +template +void parallel_generate(RandomAccessIterator first, RandomAccessIterator last, Generator generator) +{ + static_assert(std::is_invocable_v, + "SmartParallel parallel_generate requires generator(index)"); + const std::size_t total = detail::algorithm_range_size(first, last, "parallel_generate"); + const std::size_t callsite = + detail::algorithm_identity(detail::ParallelAlgorithmKind::Generate, generator); + detail::run_chunked_algorithm( + total, + callsite, + [=](detail::AlgorithmChunkRange range) mutable + { + for (std::size_t index = range.begin; index < range.end; ++index) + *detail::algorithm_advance(first, index) = std::invoke(generator, index); + }, + [=]() mutable + { + RandomAccessIterator iterator = first; + for (std::size_t index = 0; index < total; ++index, ++iterator) + *iterator = std::invoke(generator, index); + }); +} + +template +T parallel_reduce(InputIterator first, + InputIterator last, + T init, + BinaryOperation binary_operation) +{ + const std::size_t total = detail::algorithm_range_size(first, last, "parallel_reduce"); + if (total == 0) + return init; + + using InputValue = typename std::iterator_traits::value_type; + const auto identity = [](const auto& value) -> T { return static_cast(value); }; + const std::size_t callsite = detail::algorithm_identity( + detail::ParallelAlgorithmKind::Reduce, binary_operation, identity); + + auto sequential_route = [&]() mutable + { + return std::accumulate(first, last, std::move(init), binary_operation); + }; + auto scheduled_route = [&](std::size_t scheduler_callsite) mutable + { + auto scheduler_sequential = [=](T result) mutable + { + return std::accumulate(first, last, std::move(result), binary_operation); + }; + return detail::chunked_transform_reduce_with_sequential( + detail::ParallelAlgorithmKind::Reduce, + first, + total, + std::move(init), + std::move(binary_operation), + identity, + std::move(scheduler_sequential), + scheduler_callsite); + }; + return detail::run_hot_dispatched_algorithm( + detail::ParallelAlgorithmKind::Reduce, + callsite, + total, + sizeof(InputValue), + sequential_route, + scheduled_route); +} + +template +T parallel_reduce(InputIterator first, InputIterator last, T init) +{ + return parallel_reduce(first, last, std::move(init), std::plus<>{}); +} + +template +T parallel_transform_reduce(InputIterator first, + InputIterator last, + T init, + BinaryOperation binary_operation, + UnaryOperation unary_operation) +{ + const std::size_t total = + detail::algorithm_range_size(first, last, "parallel_transform_reduce"); + auto sequential_function = [=](T result) mutable + { + return std::transform_reduce( + first, last, std::move(result), binary_operation, unary_operation); + }; + return detail::chunked_transform_reduce_with_sequential( + detail::ParallelAlgorithmKind::TransformReduce, + first, + total, + std::move(init), + std::move(binary_operation), + std::move(unary_operation), + std::move(sequential_function)); +} + +template +T parallel_transform_reduce(InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2, + T init, + BinaryOperation binary_operation, + BinaryTransform binary_transform) +{ + static_assert(detail::is_random_access_iterator_v, + "SmartParallel parallel_transform_reduce requires random-access iterators"); + const std::size_t total = + detail::algorithm_range_size(first1, last1, "parallel_transform_reduce"); + return detail::chunked_binary_transform_reduce( + detail::ParallelAlgorithmKind::TransformReduce, + first1, + first2, + total, + std::move(init), + std::move(binary_operation), + std::move(binary_transform)); +} + +template +std::size_t parallel_count_if(InputIterator first, InputIterator last, Predicate predicate) +{ + const std::size_t total = detail::algorithm_range_size(first, last, "parallel_count_if"); + const auto transform = [predicate](const auto& value) mutable -> std::size_t + { + return std::invoke(predicate, value) ? 1u : 0u; + }; + auto sequential_function = [=](std::size_t result) mutable + { + return result + static_cast(std::count_if(first, last, predicate)); + }; + return detail::chunked_transform_reduce_with_sequential( + detail::ParallelAlgorithmKind::CountIf, + first, + total, + std::size_t{0}, + std::plus<>{}, + transform, + std::move(sequential_function)); +} + +template +std::size_t parallel_count(InputIterator first, InputIterator last, const T& value) +{ + const std::size_t total = detail::algorithm_range_size(first, last, "parallel_count"); + if (total == 0) + return 0; + + using InputValue = typename std::iterator_traits::value_type; + using CountValue = std::decay_t; + static_assert(std::is_copy_constructible_v, + "SmartParallel parallel_count requires a copy-constructible value"); + const CountValue count_value(value); + std::size_t callsite = + detail::typed_algorithm_identity(detail::ParallelAlgorithmKind::Count); + callsite = detail::combine_hash(callsite, typeid(InputIterator).hash_code()); + + auto sequential_route = [=]() + { + return static_cast(std::count(first, last, count_value)); + }; + auto scheduled_route = [=](std::size_t scheduler_callsite) mutable + { + const auto transform = [count_value](const auto& item) -> std::size_t + { + return item == count_value ? 1u : 0u; + }; + auto scheduler_sequential = [=](std::size_t result) + { + return result + static_cast(std::count(first, last, count_value)); + }; + return detail::chunked_transform_reduce_with_sequential( + detail::ParallelAlgorithmKind::Count, + first, + total, + std::size_t{0}, + std::plus<>{}, + transform, + std::move(scheduler_sequential), + scheduler_callsite); + }; + return detail::run_hot_dispatched_algorithm( + detail::ParallelAlgorithmKind::Count, + callsite, + total, + sizeof(InputValue), + sequential_route, + scheduled_route); +} + +template +bool parallel_any_of(InputIterator first, InputIterator last, Predicate predicate) +{ + const std::size_t total = detail::algorithm_range_size(first, last, "parallel_any_of"); + if (total == 0) + return false; + + using InputValue = typename std::iterator_traits::value_type; + const std::size_t callsite = + detail::algorithm_identity(detail::ParallelAlgorithmKind::AnyOf, predicate); + auto sequential_route = [=]() mutable + { + return std::any_of(first, last, predicate); + }; + auto scheduled_route = [=](std::size_t scheduler_callsite) mutable + { + std::atomic result{false}; + detail::run_chunked_algorithm( + total, + scheduler_callsite, + [=, &result](detail::AlgorithmChunkRange range) mutable + { + for (std::size_t index = range.begin; index < range.end; ++index) + { + if (result.load(std::memory_order_relaxed)) + break; + if (std::invoke(predicate, *detail::algorithm_advance(first, index))) + { + result.store(true, std::memory_order_relaxed); + break; + } + } + }, + [=, &result]() mutable + { + result.store(std::any_of(first, last, predicate), std::memory_order_relaxed); + }); + return result.load(std::memory_order_relaxed); + }; + return detail::run_hot_dispatched_algorithm( + detail::ParallelAlgorithmKind::AnyOf, + callsite, + total, + sizeof(InputValue), + sequential_route, + scheduled_route); +} + +template +bool parallel_all_of(InputIterator first, InputIterator last, Predicate predicate) +{ + const std::size_t total = detail::algorithm_range_size(first, last, "parallel_all_of"); + if (total == 0) + return true; + + using InputValue = typename std::iterator_traits::value_type; + const std::size_t callsite = + detail::algorithm_identity(detail::ParallelAlgorithmKind::AllOf, predicate); + auto sequential_route = [=]() mutable + { + return std::all_of(first, last, predicate); + }; + auto scheduled_route = [=](std::size_t scheduler_callsite) mutable + { + std::atomic result{true}; + detail::run_chunked_algorithm( + total, + scheduler_callsite, + [=, &result](detail::AlgorithmChunkRange range) mutable + { + for (std::size_t index = range.begin; index < range.end; ++index) + { + if (!result.load(std::memory_order_relaxed)) + break; + if (!std::invoke(predicate, *detail::algorithm_advance(first, index))) + { + result.store(false, std::memory_order_relaxed); + break; + } + } + }, + [=, &result]() mutable + { + result.store(std::all_of(first, last, predicate), std::memory_order_relaxed); + }); + return result.load(std::memory_order_relaxed); + }; + return detail::run_hot_dispatched_algorithm( + detail::ParallelAlgorithmKind::AllOf, + callsite, + total, + sizeof(InputValue), + sequential_route, + scheduled_route); +} + +template +bool parallel_none_of(InputIterator first, InputIterator last, Predicate predicate) +{ + const std::size_t total = detail::algorithm_range_size(first, last, "parallel_none_of"); + if (total == 0) + return true; + + using InputValue = typename std::iterator_traits::value_type; + const std::size_t callsite = + detail::algorithm_identity(detail::ParallelAlgorithmKind::NoneOf, predicate); + auto sequential_route = [=]() mutable + { + return std::none_of(first, last, predicate); + }; + auto scheduled_route = [=](std::size_t scheduler_callsite) mutable + { + std::atomic result{true}; + detail::run_chunked_algorithm( + total, + scheduler_callsite, + [=, &result](detail::AlgorithmChunkRange range) mutable + { + for (std::size_t index = range.begin; index < range.end; ++index) + { + if (!result.load(std::memory_order_relaxed)) + break; + if (std::invoke(predicate, *detail::algorithm_advance(first, index))) + { + result.store(false, std::memory_order_relaxed); + break; + } + } + }, + [=, &result]() mutable + { + result.store(std::none_of(first, last, predicate), std::memory_order_relaxed); + }); + return result.load(std::memory_order_relaxed); + }; + return detail::run_hot_dispatched_algorithm( + detail::ParallelAlgorithmKind::NoneOf, + callsite, + total, + sizeof(InputValue), + sequential_route, + scheduled_route); +} + +template +InputIterator parallel_find_if(InputIterator first, InputIterator last, Predicate predicate) +{ + const std::size_t total = detail::algorithm_range_size(first, last, "parallel_find_if"); + if (total == 0) + return first; + + using InputValue = typename std::iterator_traits::value_type; + const std::size_t callsite = + detail::algorithm_identity(detail::ParallelAlgorithmKind::FindIf, predicate); + auto sequential_route = [=]() mutable -> InputIterator + { + return std::find_if(first, last, predicate); + }; + auto scheduled_route = [=](std::size_t scheduler_callsite) mutable -> InputIterator + { + const std::size_t best = detail::parallel_find_index( + detail::ParallelAlgorithmKind::FindIf, + first, + total, + predicate, + scheduler_callsite); + return detail::algorithm_advance(first, best); + }; + return detail::run_hot_dispatched_algorithm( + detail::ParallelAlgorithmKind::FindIf, + callsite, + total, + sizeof(InputValue), + sequential_route, + scheduled_route); +} + +template +InputIterator parallel_find(InputIterator first, InputIterator last, const T& value) +{ + const std::size_t total = detail::algorithm_range_size(first, last, "parallel_find"); + if (total == 0) + return first; + + using InputValue = typename std::iterator_traits::value_type; + using FindValue = std::decay_t; + static_assert(std::is_copy_constructible_v, + "SmartParallel parallel_find requires a copy-constructible value"); + const FindValue find_value(value); + std::size_t callsite = + detail::typed_algorithm_identity(detail::ParallelAlgorithmKind::Find); + callsite = detail::combine_hash(callsite, typeid(InputIterator).hash_code()); + + auto sequential_route = [=]() mutable -> InputIterator + { + return std::find(first, last, find_value); + }; + auto scheduled_route = [=](std::size_t scheduler_callsite) mutable -> InputIterator + { + const auto predicate = [find_value](const auto& item) { return item == find_value; }; + const std::size_t best = detail::parallel_find_index( + detail::ParallelAlgorithmKind::Find, + first, + total, + predicate, + scheduler_callsite); + return detail::algorithm_advance(first, best); + }; + return detail::run_hot_dispatched_algorithm( + detail::ParallelAlgorithmKind::Find, + callsite, + total, + sizeof(InputValue), + sequential_route, + scheduled_route); +} +} // namespace smart diff --git a/include/smart/execution/parallel.hpp b/include/smart/execution/parallel.hpp index 4d98b19..c69824d 100644 --- a/include/smart/execution/parallel.hpp +++ b/include/smart/execution/parallel.hpp @@ -52,6 +52,15 @@ class ParallelCallsiteFunction return function_(std::forward(args)...); } + template + auto smartparallel_execute_sequential(std::size_t begin, std::size_t end) + -> decltype(std::declval().smartparallel_execute_sequential( + begin, end), + void()) + { + function_.smartparallel_execute_sequential(begin, end); + } + private: std::size_t callsite_key_ = 0; Function function_; @@ -146,6 +155,36 @@ struct HasSmartParallelCallsiteKey< { }; +template +struct HasSmartParallelSequentialRange : std::false_type +{ +}; + +template +struct HasSmartParallelSequentialRange< + T, + std::void_t().smartparallel_execute_sequential( + std::declval(), std::declval()))>> + : std::true_type +{ +}; + +template +void execute_parallel_for_sequential_range(Function& function, + std::size_t begin, + std::size_t end) +{ + if constexpr (HasSmartParallelSequentialRange::value) + { + function.smartparallel_execute_sequential(begin, end); + } + else + { + for (std::size_t index = begin; index < end; ++index) + function(index); + } +} + template std::size_t callable_identity_hash(const Function& function) noexcept { @@ -408,8 +447,7 @@ void parallel_for(std::size_t begin, std::size_t end, Function func) parent_context_pointer->telemetry->nested_call_count.fetch_add( 1, std::memory_order_relaxed); } - for (std::size_t i = begin; i < end; ++i) - func(i); + detail::execute_parallel_for_sequential_range(func, begin, end); return; } @@ -483,8 +521,7 @@ void parallel_for(std::size_t begin, std::size_t end, Function func) try { detail::ExecutionContextScope context_scope(execution_context); - for (std::size_t i = begin; i < end; ++i) - func(i); + detail::execute_parallel_for_sequential_range(func, begin, end); } catch (...) { @@ -864,8 +901,8 @@ void parallel_for(std::size_t begin, std::size_t end, Function func) { begin_cold_trace("pilot_sequential_execution", "root_pilot_sequential_learning"); - for (std::size_t i = begin + 1; i < end; ++i) - invoke(i); + detail::ExecutionContextScope context_scope(execution_context); + detail::execute_parallel_for_sequential_range(func, begin + 1, end); } } else @@ -874,8 +911,8 @@ void parallel_for(std::size_t begin, std::size_t end, Function func) use_online_root_telemetry ? "root_online_cold_learning" : "nested_online_cold_learning"); - for (std::size_t i = begin; i < end; ++i) - invoke(i); + detail::ExecutionContextScope context_scope(execution_context); + detail::execute_parallel_for_sequential_range(func, begin, end); } } catch (...) @@ -1045,8 +1082,8 @@ void parallel_for(std::size_t begin, std::size_t end, Function func) Timer execution_timer; try { - for (std::size_t i = begin; i < end; ++i) - invoke(i); + detail::ExecutionContextScope context_scope(execution_context); + detail::execute_parallel_for_sequential_range(func, begin, end); } catch (...) { @@ -1373,8 +1410,16 @@ void parallel_for(std::size_t begin, std::size_t end, Function func) { if (gap_end <= gap_begin) return; - Workload gap_workload = WorkloadBuilder::index_range(gap_end - gap_begin); detail::ExecutionContextScope backend_scope(execution_context); + if (!plan.parallel && plan.strategy == ExecutionStrategy::Sequential + && detail::HasSmartParallelSequentialRange::value) + { + detail::execute_parallel_for_sequential_range( + func, begin + gap_begin, begin + gap_end); + return; + } + + Workload gap_workload = WorkloadBuilder::index_range(gap_end - gap_begin); execute_workload(gap_workload, plan, [&](std::size_t i) diff --git a/scripts/README.md b/scripts/README.md index e803eef..4d4d1b1 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -2,6 +2,14 @@ Root-level batch files are intentionally avoided. Scripts resolve the repository root from their own path and can be launched from any working directory unless their help text says otherwise. +## Complete v1.4 algorithm validation + +```bat +set "VCPKG_ROOT=D:\Tools\vcpkg" && scripts\validation\run_v14_algorithm_release_validation.bat 7 +``` + +This configures an MSVC Release build with required oneTBB, builds the complete deterministic test suite and v1.4 benchmark target, runs CTest, then benchmarks all fourteen APIs in sequential, automatic, ThreadPool, StaticThread, and oneTBB modes. + ## Complete v1.1 real-world validation ```bat diff --git a/scripts/validation/run_v14_algorithm_release_validation.bat b/scripts/validation/run_v14_algorithm_release_validation.bat new file mode 100644 index 0000000..7f7d787 --- /dev/null +++ b/scripts/validation/run_v14_algorithm_release_validation.bat @@ -0,0 +1,136 @@ +@echo off +setlocal EnableExtensions EnableDelayedExpansion + +for %%I in ("%~dp0\..\..") do set "REPO_ROOT=%%~fI" +cd /d "%REPO_ROOT%" + +where cmake >nul 2>nul || ( + echo ERROR: cmake was not found in PATH. + exit /b 2 +) + +where cl >nul 2>nul +if errorlevel 1 call :initialize_msvc +if errorlevel 1 ( + echo ERROR: MSVC compiler "cl" was not found. + echo Install the Visual Studio 2022 Desktop development with C++ workload. + exit /b 2 +) + +if not defined VCPKG_ROOT ( + echo ERROR: VCPKG_ROOT is not defined. + echo Set it to your permanent vcpkg directory, for example: + echo set VCPKG_ROOT=D:\Tools\vcpkg + exit /b 2 +) +if not exist "%VCPKG_ROOT%\scripts\buildsystems\vcpkg.cmake" ( + echo ERROR: invalid VCPKG_ROOT: %VCPKG_ROOT% + exit /b 2 +) + +set "REPETITIONS=%~1" +if not defined REPETITIONS set "REPETITIONS=7" +set "REUSE=%~2" +set "BUILD_DIR=%REPO_ROOT%\build\v14_algorithm_release_validation" +set "OUTPUT=%REPO_ROOT%\validation\output\v1.4.0_parallel_algorithms.csv" +set "TARGET=smartparallel_v140_algorithm_benchmarks" +set "EXE=%BUILD_DIR%\benchmarks\v1.4.0\%TARGET%.exe" + +if not exist "%REPO_ROOT%\validation\output" mkdir "%REPO_ROOT%\validation\output" >nul 2>nul +if /I "%REUSE%"=="reuse" if exist "%EXE%" goto :test + +rmdir /s /q "%BUILD_DIR%" 2>nul + +echo( +echo ==== [1/4] Configure SmartParallel v1.4 Release validation ==== +cmake -S "%REPO_ROOT%" -B "%BUILD_DIR%" ^ + -G "NMake Makefiles" ^ + -DCMAKE_BUILD_TYPE=Release ^ + -DCMAKE_CXX_COMPILER=cl ^ + -DCMAKE_TOOLCHAIN_FILE="%VCPKG_ROOT%\scripts\buildsystems\vcpkg.cmake" ^ + -DVCPKG_TARGET_TRIPLET=x64-windows ^ + -DSMARTPARALLEL_BUILD_VALIDATION=ON ^ + -DSMARTPARALLEL_BUILD_V140_ALGORITHM_BENCHMARKS=ON ^ + -DSMARTPARALLEL_BUILD_BENCHMARKS=OFF ^ + -DSMARTPARALLEL_ENABLE_TBB=ON ^ + -DSMARTPARALLEL_REQUIRE_TBB=ON ^ + -DSMARTPARALLEL_INSTALL=ON +if errorlevel 1 goto :fail + +echo( +echo ==== [2/4] Build SmartParallel, validation, and v1.4 benchmarks ==== +cmake --build "%BUILD_DIR%" +if errorlevel 1 goto :fail + +:test +echo( +echo ==== [3/4] Run complete deterministic CTest suite ==== +ctest --test-dir "%BUILD_DIR%" -C Release --output-on-failure --parallel 2 +if errorlevel 1 goto :fail + +echo( +echo ==== [4/4] Run v1.4 algorithm benchmark matrix ==== +if not exist "%EXE%" ( + echo ERROR: v1.4 benchmark executable was not found: + echo %EXE% + goto :fail +) +"%EXE%" "%OUTPUT%" "%REPETITIONS%" +if errorlevel 1 goto :fail + +for %%A in ( + parallel_for_each + parallel_transform + parallel_transform_binary + parallel_copy + parallel_fill + parallel_generate + parallel_reduce + parallel_transform_reduce + parallel_transform_reduce_binary + parallel_count + parallel_count_if + parallel_any_of + parallel_all_of + parallel_none_of + parallel_find + parallel_find_if +) do ( + findstr /C:",%%A," "%OUTPUT%" >nul + if errorlevel 1 ( + echo ERROR: benchmark output is missing %%A. + goto :fail + ) +) +findstr /C:",one_tbb," "%OUTPUT%" >nul +if errorlevel 1 ( + echo ERROR: oneTBB benchmark rows were not generated. + goto :fail +) +if not exist "%OUTPUT:.csv=_raw.csv%" ( + echo ERROR: raw benchmark samples were not generated. + goto :fail +) + +echo( +echo ============================================================ +echo SMARTPARALLEL V1.4 ALGORITHM RELEASE VALIDATION PASSED +echo Summary: %OUTPUT% +echo Raw samples: %OUTPUT:.csv=_raw.csv% +echo ============================================================ +exit /b 0 + +:initialize_msvc +set "VSWHERE=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" +if not exist "%VSWHERE%" exit /b 2 +set "VS_INSTALLATION=" +for /f "usebackq tokens=*" %%I in (`"%VSWHERE%" -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath`) do set "VS_INSTALLATION=%%I" +if not defined VS_INSTALLATION exit /b 2 +call "%VS_INSTALLATION%\Common7\Tools\VsDevCmd.bat" -arch=x64 -host_arch=x64 >nul +where cl >nul 2>nul || exit /b 2 +exit /b 0 + +:fail +echo( +echo SmartParallel v1.4 algorithm release validation failed. Review the first error above. +exit /b 1 diff --git a/scripts/validation/run_v14_algorithm_release_validation.sh b/scripts/validation/run_v14_algorithm_release_validation.sh new file mode 100644 index 0000000..41de2ba --- /dev/null +++ b/scripts/validation/run_v14_algorithm_release_validation.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env sh +set -eu + +SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) +REPO_ROOT=$(CDPATH= cd -- "$SCRIPT_DIR/../.." && pwd) +REPETITIONS=${1:-7} +REUSE=${2:-} +BUILD_DIR="$REPO_ROOT/build/v14_algorithm_release_validation" +OUTPUT="$REPO_ROOT/validation/output/v1.4.0_parallel_algorithms.csv" +EXE="$BUILD_DIR/benchmarks/v1.4.0/smartparallel_v140_algorithm_benchmarks" + +if [ "$REUSE" != "reuse" ]; then + rm -rf "$BUILD_DIR" + cmake -S "$REPO_ROOT" -B "$BUILD_DIR" -G Ninja \ + -DCMAKE_BUILD_TYPE=Release \ + -DSMARTPARALLEL_BUILD_VALIDATION=ON \ + -DSMARTPARALLEL_BUILD_V140_ALGORITHM_BENCHMARKS=ON \ + -DSMARTPARALLEL_BUILD_BENCHMARKS=OFF \ + -DSMARTPARALLEL_ENABLE_TBB=ON \ + -DSMARTPARALLEL_REQUIRE_TBB=ON \ + -DSMARTPARALLEL_INSTALL=ON + cmake --build "$BUILD_DIR" --parallel +fi + +ctest --test-dir "$BUILD_DIR" --output-on-failure --parallel 2 +mkdir -p "$(dirname "$OUTPUT")" +"$EXE" "$OUTPUT" "$REPETITIONS" + +echo "SmartParallel v1.4 algorithm release validation passed." +echo "Summary: $OUTPUT" +echo "Raw samples: ${OUTPUT%.csv}_raw.csv" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index dfde3fe..c26af17 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,5 +1,6 @@ add_library( smart_parallel + algorithms.cpp decision.cpp hardware.cpp parallel.cpp diff --git a/src/algorithms.cpp b/src/algorithms.cpp new file mode 100644 index 0000000..b065a03 --- /dev/null +++ b/src/algorithms.cpp @@ -0,0 +1,48 @@ +#include + +namespace smart::detail +{ +namespace +{ +class AlgorithmSchedulerFunction +{ + public: + AlgorithmSchedulerFunction(std::size_t callsite_key, + AlgorithmChunkFunctionRef function, + AlgorithmSequentialRangeFunctionRef sequential_function) noexcept + : callsite_key_(callsite_key), + function_(function), + sequential_function_(sequential_function) + { + } + + std::size_t smartparallel_callsite_key() const noexcept { return callsite_key_; } + + void operator()(std::size_t chunk) { function_(chunk); } + + void smartparallel_execute_sequential(std::size_t begin, std::size_t end) + { + sequential_function_(begin, end); + } + + private: + std::size_t callsite_key_ = 0; + AlgorithmChunkFunctionRef function_; + AlgorithmSequentialRangeFunctionRef sequential_function_; +}; +} // namespace + +void execute_algorithm_chunks( + std::size_t chunk_count, + std::size_t callsite_key, + AlgorithmChunkFunctionRef function, + AlgorithmSequentialRangeFunctionRef sequential_function) +{ + if (chunk_count == 0) + return; + parallel_for( + std::size_t{0}, + chunk_count, + AlgorithmSchedulerFunction(callsite_key, function, sequential_function)); +} +} // namespace smart::detail diff --git a/src/hardware.cpp b/src/hardware.cpp index 0230d40..71dfffd 100644 --- a/src/hardware.cpp +++ b/src/hardware.cpp @@ -565,8 +565,10 @@ std::size_t hardware_threads() HardwareCharacteristics hardware_characteristics() { #if defined(_WIN32) - // Preserve the established Windows discovery semantics. - return discover_windows_hardware(); + // Native topology discovery allocates and walks Windows system records. + // Hardware topology is effectively immutable for the process, so cache it. + static const HardwareCharacteristics cached = discover_windows_hardware(); + return cached; #elif defined(__linux__) // Native sysfs discovery can touch many small files. Hardware topology is // effectively immutable for the process, so discover it once. diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 94c28af..2f2605f 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -205,3 +205,24 @@ if(SMARTPARALLEL_BUILD_PARALLEL_FOR_HARDENING) PROPERTIES TIMEOUT 30 ) endif() + +if(SMARTPARALLEL_BUILD_V140_ALGORITHM_VALIDATION) + add_executable( + smartparallel_v140_parallel_algorithms_validation + v1/parallel_algorithms_validation.cpp + ) + target_link_libraries( + smartparallel_v140_parallel_algorithms_validation + PRIVATE SmartParallel::smart_parallel + ) + smartparallel_copy_tbb_runtime(smartparallel_v140_parallel_algorithms_validation) + + add_test( + NAME smartparallel_v140_parallel_algorithms_validation + COMMAND smartparallel_v140_parallel_algorithms_validation + ) + set_tests_properties( + smartparallel_v140_parallel_algorithms_validation + PROPERTIES TIMEOUT 120 + ) +endif() diff --git a/tests/package-consumer/CMakeLists.txt b/tests/package-consumer/CMakeLists.txt index b9ee583..1fd937c 100644 --- a/tests/package-consumer/CMakeLists.txt +++ b/tests/package-consumer/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.20) project(SmartParallelPackageConsumer LANGUAGES CXX) -find_package(SmartParallel 1.3 CONFIG REQUIRED) +find_package(SmartParallel 1.4 CONFIG REQUIRED) add_executable(smartparallel_package_consumer main.cpp) target_compile_features(smartparallel_package_consumer PRIVATE cxx_std_17) diff --git a/tests/package-consumer/main.cpp b/tests/package-consumer/main.cpp index c8e5d09..66bd0fa 100644 --- a/tests/package-consumer/main.cpp +++ b/tests/package-consumer/main.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -10,7 +11,7 @@ int main() { static_assert(SMARTPARALLEL_VERSION_MAJOR == 1, "unexpected major version"); - static_assert(SMARTPARALLEL_VERSION_MINOR == 3, "unexpected minor version"); + static_assert(SMARTPARALLEL_VERSION_MINOR == 4, "unexpected minor version"); const smart::HardwareCharacteristics hardware = smart::hardware_characteristics(); if (hardware.logical_threads == 0 || hardware.physical_cores == 0 @@ -48,6 +49,21 @@ int main() } } + std::vector transformed(count, 0); + smart::parallel_transform( + values.begin(), values.end(), transformed.begin(), + [](std::size_t value) { return value + 2; }); + const std::size_t sum = smart::parallel_reduce( + transformed.begin(), transformed.end(), std::size_t{0}); + std::size_t expected_sum = 0; + for (std::size_t i = 0; i < count; ++i) + expected_sum += i * 3 + 3; + if (sum != expected_sum) + { + std::cerr << "consumer validation failed: v1.4 algorithm result mismatch\n"; + return 1; + } + std::cout << "SmartParallel " << SMARTPARALLEL_VERSION_STRING << " installed-package consumer passed\n"; return 0; diff --git a/tests/v1/parallel_algorithms_validation.cpp b/tests/v1/parallel_algorithms_validation.cpp new file mode 100644 index 0000000..fb6efef --- /dev/null +++ b/tests/v1/parallel_algorithms_validation.cpp @@ -0,0 +1,412 @@ +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace +{ +void require(bool condition, const char* message) +{ + if (!condition) + throw std::runtime_error(message); +} + +struct ConfigGuard +{ + smart::Config saved = smart::global_config(); + ~ConfigGuard() { smart::global_config() = saved; } +}; + +void configure_for_validation(smart::ExecutionEngineType engine) +{ + auto& config = smart::global_config(); + config.execution_engine = engine; + config.enable_experience = false; + config.enable_experience_ranking = false; + config.enable_online_exploration = false; + config.enable_parallel_for_backend_calibration = false; + config.enable_parallel_for_profile_cache = true; + config.enable_parallel_for_auto_profiling = true; + config.enable_parallel_for_cached_sequential_fast_path = false; + config.enable_parallel_for_tiny_work_bypass = false; + config.parallel_for_minimum_predicted_speedup = 0.0; + config.parallel_for_estimated_overhead_ms = 0.0; + config.small_workload_iteration_threshold = 0; + config.cheap_workload_sequential_threshold = 0; + config.enable_nested_execution_session = true; + config.nested_root_concurrency_budget = 4; + config.nested_min_iterations_per_worker = 1; + config.nested_min_parallel_work_ms = 0.0; + config.nested_plan_hysteresis = 1.0; + ++config.parallel_for_policy_generation; + smart::global_function_profile_cache().clear(); +} + +void test_empty_range_contracts() +{ + std::vector values; + std::vector output; + smart::parallel_for_each(values.begin(), values.end(), [](int&) {}); + require(smart::parallel_transform(values.begin(), values.end(), output.begin(), [](int v) { + return v + 1; + }) == output.begin(), + "empty transform returned wrong output iterator"); + require(smart::parallel_copy(values.begin(), values.end(), output.begin()) == output.begin(), + "empty copy returned wrong output iterator"); + smart::parallel_fill(values.begin(), values.end(), 7); + smart::parallel_generate(values.begin(), values.end(), [](std::size_t i) { return i; }); + require(smart::parallel_reduce(values.begin(), values.end(), 42) == 42, + "empty reduce did not preserve init"); + require(smart::parallel_transform_reduce( + values.begin(), values.end(), 9, std::plus<>{}, [](int v) { return v; }) == 9, + "empty transform_reduce did not preserve init"); + require(smart::parallel_count(values.begin(), values.end(), 1) == 0, + "empty count was nonzero"); + require(smart::parallel_count_if(values.begin(), values.end(), [](int) { return true; }) == 0, + "empty count_if was nonzero"); + require(!smart::parallel_any_of(values.begin(), values.end(), [](int) { return true; }), + "empty any_of must be false"); + require(smart::parallel_all_of(values.begin(), values.end(), [](int) { return false; }), + "empty all_of must be true"); + require(smart::parallel_none_of(values.begin(), values.end(), [](int) { return true; }), + "empty none_of must be true"); + require(smart::parallel_find(values.begin(), values.end(), 1) == values.end(), + "empty find must return end"); + require(smart::parallel_find_if(values.begin(), values.end(), [](int) { return true; }) + == values.end(), + "empty find_if must return end"); +} + +void test_single_element_and_invalid_range_contracts() +{ + std::vector values{4}; + std::vector output(1, 0); + + smart::parallel_for_each(values.begin(), values.end(), [](int& value) { value += 1; }); + require(values.front() == 5, "single-element for_each failed"); + require(smart::parallel_transform( + values.begin(), values.end(), output.begin(), [](int value) { return value * 2; }) + == output.end(), + "single-element transform returned wrong end"); + require(output.front() == 10, "single-element transform failed"); + require(smart::parallel_reduce(values.begin(), values.end(), 3) == 8, + "single-element reduce failed"); + require(smart::parallel_transform_reduce( + values.begin(), values.end(), 2, std::plus<>{}, [](int value) { return value * 3; }) + == 17, + "single-element transform_reduce failed"); + require(smart::parallel_count(values.begin(), values.end(), 5) == 1, + "single-element count failed"); + require(smart::parallel_any_of(values.begin(), values.end(), [](int value) { return value == 5; }), + "single-element any_of failed"); + require(smart::parallel_find(values.begin(), values.end(), 5) == values.begin(), + "single-element find failed"); + + bool reversed_threw = false; + try + { + smart::parallel_for_each(values.end(), values.begin(), [](int&) {}); + } + catch (const std::invalid_argument&) + { + reversed_threw = true; + } + require(reversed_threw, "reversed range did not throw invalid_argument"); +} + +void test_elementwise_algorithms() +{ + constexpr std::size_t count = 8192; + std::vector values(count); + std::iota(values.begin(), values.end(), std::size_t{0}); + std::vector> visits(count); + for (auto& visit : visits) + visit.store(0, std::memory_order_relaxed); + + smart::parallel_for_each(values.begin(), values.end(), [&](std::size_t& value) { + const std::size_t index = value; + visits[index].fetch_add(1, std::memory_order_relaxed); + value = index * 3 + 1; + }); + for (std::size_t i = 0; i < count; ++i) + { + require(visits[i].load(std::memory_order_relaxed) == 1, + "parallel_for_each duplicated or skipped an element"); + require(values[i] == i * 3 + 1, "parallel_for_each produced wrong output"); + } + + std::vector unary(count, 0); + auto unary_end = smart::parallel_transform( + values.begin(), values.end(), unary.begin(), [](std::size_t value) { return value ^ 0x55u; }); + require(unary_end == unary.end(), "unary transform returned wrong end"); + + std::vector binary(count, 0); + auto binary_end = smart::parallel_transform( + values.begin(), values.end(), unary.begin(), binary.begin(), std::plus<>{}); + require(binary_end == binary.end(), "binary transform returned wrong end"); + for (std::size_t i = 0; i < count; ++i) + require(binary[i] == values[i] + unary[i], "parallel_transform produced wrong output"); + + smart::parallel_transform(values.begin(), values.end(), values.begin(), [](std::size_t value) { + return value + 5; + }); + for (std::size_t i = 0; i < count; ++i) + require(values[i] == i * 3 + 6, "in-place transform failed"); + + std::vector copied(count, 0); + require(smart::parallel_copy(values.begin(), values.end(), copied.begin()) == copied.end(), + "parallel_copy returned wrong end"); + require(copied == values, "parallel_copy produced wrong output"); + + smart::parallel_fill(copied.begin(), copied.end(), std::size_t{17}); + require(std::all_of(copied.begin(), copied.end(), [](std::size_t v) { return v == 17; }), + "parallel_fill produced wrong output"); + + smart::parallel_generate(copied.begin(), copied.end(), [](std::size_t index) { + return index * index + 11; + }); + for (std::size_t i = 0; i < count; ++i) + require(copied[i] == i * i + 11, "parallel_generate produced wrong output"); +} + +void test_reduction_algorithms() +{ + std::vector values(10000); + std::iota(values.begin(), values.end(), std::uint64_t{1}); + const std::uint64_t expected = + std::accumulate(values.begin(), values.end(), std::uint64_t{7}); + require(smart::parallel_reduce(values.begin(), values.end(), std::uint64_t{7}) == expected, + "parallel_reduce produced wrong sum"); + + const std::uint64_t expected_squares = std::accumulate( + values.begin(), values.end(), std::uint64_t{3}, [](std::uint64_t sum, std::uint64_t value) { + return sum + value * value; + }); + require(smart::parallel_transform_reduce( + values.begin(), values.end(), std::uint64_t{3}, std::plus<>{}, + [](std::uint64_t value) { return value * value; }) == expected_squares, + "unary parallel_transform_reduce produced wrong result"); + + std::vector other(values.size()); + std::iota(other.begin(), other.end(), std::uint64_t{2}); + std::uint64_t expected_dot = 5; + for (std::size_t i = 0; i < values.size(); ++i) + expected_dot += values[i] * other[i]; + require(smart::parallel_transform_reduce( + values.begin(), values.end(), other.begin(), std::uint64_t{5}, + std::plus<>{}, std::multiplies<>{}) == expected_dot, + "binary parallel_transform_reduce produced wrong result"); + + const std::vector text{"a", "b", "c", "d", "e", "f"}; + const std::string joined = smart::parallel_reduce( + text.begin(), text.end(), std::string{"prefix:"}, + [](std::string left, const std::string& right) { return left + right; }); + require(joined == "prefix:abcdef", "parallel_reduce did not preserve chunk order"); +} + +void test_count_predicate_and_search_algorithms() +{ + std::vector values(12000); + for (std::size_t i = 0; i < values.size(); ++i) + values[i] = static_cast(i % 37); + values[321] = -7; + values[9876] = -7; + + require(smart::parallel_count(values.begin(), values.end(), -7) == 2, + "parallel_count produced wrong result"); + const std::size_t expected_even = static_cast( + std::count_if(values.begin(), values.end(), [](int value) { return value % 2 == 0; })); + require(smart::parallel_count_if(values.begin(), values.end(), [](int value) { + return value % 2 == 0; + }) == expected_even, + "parallel_count_if produced wrong result"); + + require(smart::parallel_any_of(values.begin(), values.end(), [](int value) { return value < 0; }), + "parallel_any_of missed a match"); + require(!smart::parallel_all_of(values.begin(), values.end(), [](int value) { return value >= 0; }), + "parallel_all_of missed a failure"); + require(!smart::parallel_none_of(values.begin(), values.end(), [](int value) { return value < 0; }), + "parallel_none_of missed a match"); + + const auto found = smart::parallel_find(values.begin(), values.end(), -7); + require(found == values.begin() + 321, "parallel_find did not return earliest match"); + const auto found_if = smart::parallel_find_if( + values.begin(), values.end(), [](int value) { return value == 36; }); + require(found_if == values.begin() + 36, "parallel_find_if did not return earliest match"); + require(smart::parallel_find(values.begin(), values.end(), 999) == values.end(), + "parallel_find did not return end for no match"); +} + +void test_exception_propagation() +{ + std::vector values(4096, 1); + std::vector output(values.size(), 0); + bool transform_threw = false; + std::atomic transform_calls{0}; + try + { + smart::parallel_transform(values.begin(), values.end(), output.begin(), [&](int) { + const unsigned current = transform_calls.fetch_add(1, std::memory_order_relaxed); + if (current == 0) + throw std::runtime_error("expected transform exception"); + return static_cast(current); + }); + } + catch (const std::runtime_error&) + { + transform_threw = true; + } + require(transform_threw, "parallel_transform did not propagate exception"); + + bool reduce_threw = false; + try + { + (void)smart::parallel_reduce(values.begin(), values.end(), 0, [](int left, int right) { + if (left > 32) + throw std::runtime_error("expected reduce exception"); + return left + right; + }); + } + catch (const std::runtime_error&) + { + reduce_threw = true; + } + require(reduce_threw, "parallel_reduce did not propagate exception"); + + bool predicate_threw = false; + try + { + (void)smart::parallel_find_if(values.begin(), values.end(), [](int) -> bool { + throw std::runtime_error("expected predicate exception"); + }); + } + catch (const std::runtime_error&) + { + predicate_threw = true; + } + require(predicate_threw, "parallel_find_if did not propagate exception"); +} + +void test_nested_algorithms() +{ + constexpr std::size_t outer = 24; + constexpr std::size_t inner = 2048; + std::vector results(outer, 0); + smart::parallel_for(0, outer, [&](std::size_t row) { + std::vector values(inner); + smart::parallel_generate(values.begin(), values.end(), [row](std::size_t index) { + return static_cast(row + index + 1); + }); + results[row] = smart::parallel_transform_reduce( + values.begin(), values.end(), std::uint64_t{0}, std::plus<>{}, + [](std::uint64_t value) { return value * 3; }); + }); + + for (std::size_t row = 0; row < outer; ++row) + { + std::uint64_t expected = 0; + for (std::size_t index = 0; index < inner; ++index) + expected += static_cast(row + index + 1) * 3; + require(results[row] == expected, "nested v1.4 algorithm produced wrong result"); + } +} + + +void test_scheduler_approved_direct_sequential_path() +{ + auto& config = smart::global_config(); + config.execution_engine = smart::ExecutionEngineType::Auto; + config.enable_experience = false; + config.enable_experience_ranking = false; + config.enable_online_exploration = false; + config.enable_parallel_for_backend_calibration = false; + config.enable_parallel_for_profile_cache = true; + config.enable_parallel_for_auto_profiling = true; + config.enable_parallel_for_cached_sequential_fast_path = true; + config.enable_parallel_for_tiny_work_bypass = true; + config.enable_nested_execution_session = true; + config.enable_nested_root_online_telemetry = true; + config.enable_root_analytical_cold_start = false; + config.enable_root_pilot_cold_start = false; + config.nested_root_concurrency_budget = 4; + config.parallel_for_minimum_predicted_speedup = 100.0; + config.parallel_for_sequential_fast_path_speedup_margin = 1.0; + config.parallel_for_sequential_fast_path_min_observations = 2; + config.parallel_for_profile_cache_min_hits = 1; + ++config.parallel_for_policy_generation; + smart::global_function_profile_cache().clear(); + + std::vector values(32768); + std::iota(values.begin(), values.end(), std::uint64_t{0}); + const std::uint64_t expected_sum = + std::accumulate(values.begin(), values.end(), std::uint64_t{11}); + + std::uint64_t result = 0; + for (std::size_t repetition = 0; repetition < 6; ++repetition) + result = smart::parallel_reduce(values.begin(), values.end(), std::uint64_t{11}); + require(result == expected_sum, "direct sequential reduce produced wrong result"); + require(!smart::global_last_decision_report().plan.parallel, + "direct sequential reduce did not retain a sequential plan"); + require(smart::global_last_parallel_for_profile_diagnostics().sequential_fast_path, + "direct sequential reduce did not use the cached scheduler fast path"); + + const std::size_t expected_count = static_cast( + std::count(values.begin(), values.end(), std::uint64_t{17})); + std::size_t count = 0; + for (std::size_t repetition = 0; repetition < 6; ++repetition) + count = smart::parallel_count(values.begin(), values.end(), std::uint64_t{17}); + require(count == expected_count, "direct sequential count produced wrong result"); + require(!smart::global_last_decision_report().plan.parallel, + "direct sequential count did not retain a sequential plan"); + + auto found = values.end(); + for (std::size_t repetition = 0; repetition < 6; ++repetition) + found = smart::parallel_find(values.begin(), values.end(), std::uint64_t{32767}); + require(found == values.end() - 1, "direct sequential find produced wrong result"); + require(!smart::global_last_decision_report().plan.parallel, + "direct sequential find did not retain a sequential plan"); +} + +void run_backend(smart::ExecutionEngineType engine) +{ + configure_for_validation(engine); + test_empty_range_contracts(); + test_single_element_and_invalid_range_contracts(); + test_elementwise_algorithms(); + test_reduction_algorithms(); + test_count_predicate_and_search_algorithms(); + test_exception_propagation(); + test_nested_algorithms(); +} +} // namespace + +int main() +{ + ConfigGuard guard; + try + { + run_backend(smart::ExecutionEngineType::Auto); + run_backend(smart::ExecutionEngineType::ThreadPool); + run_backend(smart::ExecutionEngineType::StaticThread); + if (smart::execution_backend_available(smart::ExecutionEngineType::OneTbb)) + run_backend(smart::ExecutionEngineType::OneTbb); + test_scheduler_approved_direct_sequential_path(); + std::cout << "SmartParallel v1.4 parallel algorithm validation: PASS\n"; + return 0; + } + catch (const std::exception& error) + { + std::cerr << "SmartParallel v1.4 parallel algorithm validation: FAIL: " + << error.what() << '\n'; + return 1; + } +} diff --git a/tools/check_documentation.py b/tools/check_documentation.py index 8edda10..6fbd3ba 100644 --- a/tools/check_documentation.py +++ b/tools/check_documentation.py @@ -36,6 +36,11 @@ def main() -> int: if not destination.exists(): errors.append(f"{path.relative_to(ROOT)}: broken link {match.group(1)!r}") + for path in (ROOT / "docs/v1.4").glob("*.md"): + text = path.read_text(encoding="utf-8") + if "v1.4" not in text[:500]: + errors.append(f"{path.relative_to(ROOT)}: missing v1.4 release marker") + for path in (ROOT / "docs/v1.3").glob("*.md"): text = path.read_text(encoding="utf-8") if "v1.3" not in text[:500]: diff --git a/tools/plot_v14_algorithm_results.py b/tools/plot_v14_algorithm_results.py new file mode 100644 index 0000000..8bf3b0a --- /dev/null +++ b/tools/plot_v14_algorithm_results.py @@ -0,0 +1,478 @@ +#!/usr/bin/env python3 +"""Generate the checked-in SmartParallel v1.4 benchmark report assets.""" + +from __future__ import annotations + +import argparse +import hashlib +import json +import math +from pathlib import Path +from typing import Iterable + +import matplotlib + +matplotlib.use("Agg") +import matplotlib.pyplot as plt +import numpy as np +import pandas as pd + +ROOT = Path(__file__).resolve().parents[1] +DEFAULT_SUMMARY = ROOT / "validation/output/v1.4.0_parallel_algorithms.csv" +DEFAULT_RAW = ROOT / "validation/output/v1.4.0_parallel_algorithms_raw.csv" +DEFAULT_OUTPUT = ROOT / "docs/v1.4/assets/benchmarks" + +ALGORITHM_ORDER = [ + "parallel_for_each", + "parallel_transform", + "parallel_transform_binary", + "parallel_copy", + "parallel_fill", + "parallel_generate", + "parallel_reduce", + "parallel_transform_reduce", + "parallel_transform_reduce_binary", + "parallel_count", + "parallel_count_if", + "parallel_any_of", + "parallel_all_of", + "parallel_none_of", + "parallel_find", + "parallel_find_if", +] + +CHEAP_DISPATCH_FAMILIES = [ + "parallel_reduce", + "parallel_count", + "parallel_find", + "parallel_find_if", + "parallel_any_of", + "parallel_all_of", + "parallel_none_of", + "parallel_copy", +] + +PARALLEL_SELECTED_FAMILIES = [ + "parallel_for_each", + "parallel_transform", + "parallel_transform_binary", + "parallel_fill", + "parallel_generate", + "parallel_transform_reduce", + "parallel_transform_reduce_binary", + "parallel_count_if", +] + +MODE_ORDER = ["sequential", "automatic", "thread_pool", "static_thread", "one_tbb"] + +DISPLAY = { + "parallel_for_each": "for_each", + "parallel_transform": "transform", + "parallel_transform_binary": "transform (binary)", + "parallel_copy": "copy", + "parallel_fill": "fill", + "parallel_generate": "generate", + "parallel_reduce": "reduce", + "parallel_transform_reduce": "transform_reduce", + "parallel_transform_reduce_binary": "transform_reduce (binary)", + "parallel_count": "count", + "parallel_count_if": "count_if", + "parallel_any_of": "any_of", + "parallel_all_of": "all_of", + "parallel_none_of": "none_of", + "parallel_find": "find", + "parallel_find_if": "find_if", +} + +MODE_DISPLAY = { + "sequential": "Sequential", + "automatic": "Automatic", + "thread_pool": "ThreadPool", + "static_thread": "StaticThread", + "one_tbb": "oneTBB", +} + +COLORS = { + "sequential": "#64748b", + "automatic": "#2563eb", + "thread_pool": "#0f766e", + "static_thread": "#c2410c", + "one_tbb": "#7c3aed", +} + + +def parse_args() -> argparse.Namespace: + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--summary", type=Path, default=DEFAULT_SUMMARY) + parser.add_argument("--raw", type=Path, default=DEFAULT_RAW) + parser.add_argument("--output", type=Path, default=DEFAULT_OUTPUT) + return parser.parse_args() + + +def sha256(path: Path) -> str: + digest = hashlib.sha256() + with path.open("rb") as stream: + for block in iter(lambda: stream.read(1024 * 1024), b""): + digest.update(block) + return digest.hexdigest() + + +def geometric_mean(values: Iterable[float]) -> float: + array = np.asarray(list(values), dtype=float) + if np.any(array <= 0): + raise ValueError("geometric mean requires positive values") + return float(np.exp(np.log(array).mean())) + + +def validate(summary: pd.DataFrame, raw: pd.DataFrame) -> None: + required_summary = { + "schema_version", + "algorithm", + "mode", + "repetitions", + "iterations", + "median_ms", + "min_ms", + "max_ms", + "sequential_median_ms", + "speedup", + "correct", + "backend_authenticated", + "observed_backend", + "parallel_observed", + } + required_raw = { + "schema_version", + "algorithm", + "mode", + "repetition", + "elapsed_ms", + "correct", + "backend_authenticated", + "observed_backend", + "parallel_observed", + } + missing_summary = required_summary.difference(summary.columns) + missing_raw = required_raw.difference(raw.columns) + if missing_summary: + raise ValueError(f"summary CSV is missing columns: {sorted(missing_summary)}") + if missing_raw: + raise ValueError(f"raw CSV is missing columns: {sorted(missing_raw)}") + + algorithms = list(dict.fromkeys(summary["algorithm"].tolist())) + if algorithms != ALGORITHM_ORDER: + raise ValueError(f"unexpected algorithm order: {algorithms}") + modes = set(summary["mode"]) + if modes != set(MODE_ORDER): + raise ValueError(f"unexpected benchmark modes: {sorted(modes)}") + if len(summary) != len(ALGORITHM_ORDER) * len(MODE_ORDER): + raise ValueError(f"expected 80 summary rows, found {len(summary)}") + repetitions = summary["repetitions"].drop_duplicates().tolist() + if len(repetitions) != 1 or int(repetitions[0]) <= 0: + raise ValueError(f"expected one positive repetition count, found {repetitions}") + expected_raw_rows = len(ALGORITHM_ORDER) * len(MODE_ORDER) * int(repetitions[0]) + if len(raw) != expected_raw_rows: + raise ValueError(f"expected {expected_raw_rows} raw rows, found {len(raw)}") + if set(raw["algorithm"]) != set(ALGORITHM_ORDER): + raise ValueError("raw CSV does not contain the complete algorithm matrix") + if set(raw["mode"]) != set(MODE_ORDER): + raise ValueError("raw CSV does not contain the complete mode matrix") + if not summary["correct"].eq(1).all() or not raw["correct"].eq(1).all(): + raise ValueError("benchmark input contains a failed correctness result") + if not summary["backend_authenticated"].eq(1).all() or not raw[ + "backend_authenticated" + ].eq(1).all(): + raise ValueError("benchmark input contains an unauthenticated backend result") + + +def prepare(summary: pd.DataFrame) -> tuple[pd.DataFrame, pd.DataFrame]: + ordered = summary.copy() + ordered["algorithm"] = pd.Categorical( + ordered["algorithm"], categories=ALGORITHM_ORDER, ordered=True + ) + ordered["mode"] = pd.Categorical(ordered["mode"], categories=MODE_ORDER, ordered=True) + ordered = ordered.sort_values(["algorithm", "mode"]).reset_index(drop=True) + automatic = ordered[ordered["mode"] == "automatic"].copy() + automatic["algorithm_name"] = automatic["algorithm"].map(DISPLAY) + return ordered, automatic + + +def configure_plot_defaults() -> None: + plt.rcParams.update( + { + "font.size": 10, + "axes.titlesize": 15, + "axes.labelsize": 11, + "axes.spines.top": False, + "axes.spines.right": False, + "figure.facecolor": "white", + "axes.facecolor": "white", + "savefig.facecolor": "white", + "svg.hashsalt": "smartparallel-v1.4-benchmarks", + "grid.alpha": 0.22, + "grid.linestyle": "-", + } + ) + + +def save_figure(fig: plt.Figure, output: Path, stem: str) -> None: + fig.tight_layout() + fig.savefig( + output / f"{stem}.png", + dpi=180, + bbox_inches="tight", + metadata={"Software": "SmartParallel v1.4 benchmark generator"}, + ) + fig.savefig( + output / f"{stem}.svg", + bbox_inches="tight", + metadata={"Date": None, "Creator": "SmartParallel v1.4 benchmark generator"}, + ) + plt.close(fig) + + +def plot_automatic_speedup(automatic: pd.DataFrame, output: Path) -> None: + frame = automatic.iloc[::-1].copy() + colors = [COLORS[str(backend)] for backend in frame["observed_backend"]] + fig, ax = plt.subplots(figsize=(10.5, 7.2)) + bars = ax.barh(frame["algorithm_name"], frame["speedup"], color=colors, height=0.68) + ax.axvline(1.0, color="#334155", linewidth=1.1, linestyle="--") + ax.set_xlabel("Automatic speedup over sequential (×)") + ax.set_title("SmartParallel v1.4 automatic performance") + ax.grid(axis="x") + upper = max(3.8, float(frame["speedup"].max()) * 1.12) + ax.set_xlim(0, upper) + for bar, value in zip(bars, frame["speedup"]): + ax.text( + min(float(value) + 0.06, upper - 0.05), + bar.get_y() + bar.get_height() / 2, + f"{float(value):.2f}×", + va="center", + fontsize=9, + ) + handles = [ + plt.Line2D([0], [0], color=COLORS[backend], lw=8, label=MODE_DISPLAY[backend]) + for backend in ("thread_pool", "sequential") + ] + ax.legend(handles=handles, title="Observed automatic route", loc="lower right") + fig.text( + 0.01, + 0.005, + "Median of 7 repetitions. Values above 1.0 are faster than the sequential baseline.", + fontsize=8.5, + color="#475569", + ) + save_figure(fig, output, "automatic-speedup-by-algorithm") + + +def plot_cheap_dispatch(automatic: pd.DataFrame, output: Path) -> None: + frame = automatic.set_index("algorithm").loc[CHEAP_DISPATCH_FAMILIES].copy() + frame["overhead_percent"] = ( + frame["median_ms"] / frame["sequential_median_ms"] - 1.0 + ) * 100.0 + frame = frame.iloc[::-1] + values = frame["overhead_percent"].astype(float) + bar_colors = ["#0f766e" if value <= 0.0 else COLORS["automatic"] for value in values] + fig, ax = plt.subplots(figsize=(9.5, 5.5)) + bars = ax.barh( + [DISPLAY[index] for index in frame.index], + values, + color=bar_colors, + height=0.65, + ) + ax.axvline(0.0, color="#334155", linewidth=1.1) + ax.axvline(5.0, color="#b45309", linewidth=1.0, linestyle="--") + ax.set_xlabel("Automatic latency difference from direct sequential (%)") + ax.set_title("Cheap-dispatch families after hot-cache learning") + ax.grid(axis="x") + low = min(-12.0, math.floor(float(values.min()) - 1.5)) + high = max(6.5, math.ceil(float(values.max()) + 1.5)) + ax.set_xlim(low, high) + for bar, value in zip(bars, values): + offset = 0.25 if value >= 0 else -0.25 + align = "left" if value >= 0 else "right" + ax.text( + float(value) + offset, + bar.get_y() + bar.get_height() / 2, + f"{float(value):+.1f}%", + va="center", + ha=align, + fontsize=9, + ) + fig.text( + 0.01, + 0.005, + "Dashed line: +5% release gate. All eight affected families pass; negative values are faster in this sample.", + fontsize=8.5, + color="#475569", + ) + save_figure(fig, output, "cheap-dispatch-relative-latency") + + +def plot_parallel_backend_comparison(summary: pd.DataFrame, output: Path) -> None: + frame = summary[summary["algorithm"].isin(PARALLEL_SELECTED_FAMILIES)].copy() + pivot = frame.pivot(index="algorithm", columns="mode", values="speedup").loc[ + PARALLEL_SELECTED_FAMILIES + ] + modes = ["automatic", "thread_pool", "static_thread", "one_tbb"] + labels = [DISPLAY[index] for index in pivot.index] + y = np.arange(len(labels)) + height = 0.19 + offsets = np.linspace(-1.5 * height, 1.5 * height, len(modes)) + + fig, ax = plt.subplots(figsize=(10.5, 6.6)) + for offset, mode in zip(offsets, modes): + ax.barh( + y + offset, + pivot[mode], + height=height, + label=MODE_DISPLAY[mode], + color=COLORS[mode], + ) + ax.axvline(1.0, color="#334155", linewidth=1.0, linestyle="--") + ax.set_yticks(y, labels) + ax.invert_yaxis() + ax.set_xlabel("Speedup over sequential (×)") + ax.set_title("Backend comparison for parallel-selected algorithms") + ax.grid(axis="x") + ax.legend(ncol=2, loc="lower right") + ax.set_xlim(0, max(4.0, float(pivot[modes].max().max()) * 1.08)) + fig.text( + 0.01, + 0.005, + "Automatic preserved the existing fast paths; the eight parallel-selected cases range from 2.67× to 3.53×.", + fontsize=8.5, + color="#475569", + ) + save_figure(fig, output, "parallel-family-backend-comparison") + + +def build_metrics( + summary_path: Path, + raw_path: Path, + summary: pd.DataFrame, + raw: pd.DataFrame, + automatic: pd.DataFrame, +) -> dict[str, object]: + parallel = automatic[automatic["parallel_observed"] == 1] + cheap = automatic[automatic["algorithm"].isin(CHEAP_DISPATCH_FAMILIES)].copy() + cheap["overhead_percent"] = ( + cheap["median_ms"] / cheap["sequential_median_ms"] - 1.0 + ) * 100.0 + backend_counts = automatic["observed_backend"].value_counts().to_dict() + + algorithms: dict[str, object] = {} + for _, row in automatic.iterrows(): + algorithms[str(row["algorithm"])] = { + "iterations": int(row["iterations"]), + "automatic_median_ms": float(row["median_ms"]), + "sequential_median_ms": float(row["sequential_median_ms"]), + "automatic_speedup": float(row["speedup"]), + "observed_backend": str(row["observed_backend"]), + "parallel_observed": bool(row["parallel_observed"]), + } + + return { + "schema_version": "1.4.0-docs-1", + "source": { + "summary": str(summary_path.relative_to(ROOT)), + "summary_sha256": sha256(summary_path), + "raw": str(raw_path.relative_to(ROOT)), + "raw_sha256": sha256(raw_path), + }, + "validation": { + "summary_rows": int(len(summary)), + "raw_rows": int(len(raw)), + "repetitions": int(summary["repetitions"].iloc[0]), + "all_correct": bool(summary["correct"].eq(1).all() and raw["correct"].eq(1).all()), + "all_backends_authenticated": bool( + summary["backend_authenticated"].eq(1).all() + and raw["backend_authenticated"].eq(1).all() + ), + }, + "automatic": { + "thread_pool_selected": int(backend_counts.get("thread_pool", 0)), + "sequential_selected": int(backend_counts.get("sequential", 0)), + "parallel_selected_geometric_mean_speedup": geometric_mean(parallel["speedup"]), + "parallel_selected_median_speedup": float(parallel["speedup"].median()), + "parallel_selected_min_speedup": float(parallel["speedup"].min()), + "parallel_selected_max_speedup": float(parallel["speedup"].max()), + "cheap_dispatch_max_slowdown_percent": float(cheap["overhead_percent"].max()), + "cheap_dispatch_max_absolute_overhead_ms": float( + (cheap["median_ms"] - cheap["sequential_median_ms"]).max() + ), + }, + "algorithms": algorithms, + } + + +def write_generated_results(metrics: dict[str, object], output: Path) -> None: + automatic = metrics["automatic"] + validation = metrics["validation"] + algorithms = metrics["algorithms"] + assert isinstance(automatic, dict) + assert isinstance(validation, dict) + assert isinstance(algorithms, dict) + + lines = [ + "# Generated v1.4 benchmark summary", + "", + "> Generated by `python tools/plot_v14_algorithm_results.py` from the checked-in", + "> `validation/output/v1.4.0_parallel_algorithms.csv` and raw sample file.", + "", + "## Release summary", + "", + f"- **{validation['summary_rows']}** summary rows and **{validation['raw_rows']}** raw samples validated.", + f"- Automatic selected ThreadPool for **{automatic['thread_pool_selected']}** cases and direct sequential for **{automatic['sequential_selected']}** cases.", + f"- The parallel-selected group achieved a **{automatic['parallel_selected_geometric_mean_speedup']:.2f}×** geometric-mean speedup.", + f"- All cheap-dispatch families were within **{automatic['cheap_dispatch_max_slowdown_percent']:.2f}%** of the direct sequential median or faster.", + "", + "## Automatic results", + "", + "| Algorithm | Sequential median | Automatic median | Speedup | Automatic route |", + "|---|---:|---:|---:|---|", + ] + for algorithm in ALGORITHM_ORDER: + item = algorithms[algorithm] + assert isinstance(item, dict) + lines.append( + f"| `{algorithm}` | {item['sequential_median_ms']:.4f} ms | " + f"{item['automatic_median_ms']:.4f} ms | {item['automatic_speedup']:.2f}× | " + f"`{item['observed_backend']}` |" + ) + lines.extend( + [ + "", + "All rows in the source CSVs passed checksum correctness and backend-authentication checks.", + ] + ) + (output / "generated-results.md").write_text("\n".join(lines) + "\n", encoding="utf-8") + + +def main() -> int: + args = parse_args() + summary_path = args.summary.resolve() + raw_path = args.raw.resolve() + output = args.output.resolve() + output.mkdir(parents=True, exist_ok=True) + + summary = pd.read_csv(summary_path) + raw = pd.read_csv(raw_path) + validate(summary, raw) + ordered, automatic = prepare(summary) + configure_plot_defaults() + plot_automatic_speedup(automatic, output) + plot_cheap_dispatch(automatic, output) + plot_parallel_backend_comparison(ordered, output) + + metrics = build_metrics(summary_path, raw_path, ordered, raw, automatic) + (output / "benchmark-metrics.json").write_text( + json.dumps(metrics, indent=2) + "\n", encoding="utf-8" + ) + write_generated_results(metrics, output) + print(f"Generated v1.4 benchmark assets in {output}") + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/validation/output/v1.4.0_parallel_algorithms.csv b/validation/output/v1.4.0_parallel_algorithms.csv new file mode 100644 index 0000000..d23aa7e --- /dev/null +++ b/validation/output/v1.4.0_parallel_algorithms.csv @@ -0,0 +1,81 @@ +schema_version,algorithm,mode,repetitions,iterations,median_ms,min_ms,max_ms,sequential_median_ms,speedup,checksum,expected_checksum,correct,backend_authenticated,observed_backend,parallel_observed +1.4.0,parallel_for_each,sequential,7,262144,3.762600,3.732400,3.793900,3.762600,1.000000,12394695018371502475,12394695018371502475,1,1,sequential,0 +1.4.0,parallel_for_each,automatic,7,262144,1.081300,1.058500,1.157100,3.762600,3.479700,12394695018371502475,12394695018371502475,1,1,thread_pool,1 +1.4.0,parallel_for_each,thread_pool,7,262144,1.193600,1.051100,1.497800,3.762600,3.152312,12394695018371502475,12394695018371502475,1,1,thread_pool,1 +1.4.0,parallel_for_each,static_thread,7,262144,1.389300,1.289100,1.627500,3.762600,2.708270,12394695018371502475,12394695018371502475,1,1,static_thread,1 +1.4.0,parallel_for_each,one_tbb,7,262144,1.106500,1.038500,1.395800,3.762600,3.400452,12394695018371502475,12394695018371502475,1,1,one_tbb,1 +1.4.0,parallel_transform,sequential,7,262144,3.751500,3.736600,3.782400,3.751500,1.000000,7293375088876815277,7293375088876815277,1,1,sequential,0 +1.4.0,parallel_transform,automatic,7,262144,1.066100,1.044800,1.172700,3.751500,3.518901,7293375088876815277,7293375088876815277,1,1,thread_pool,1 +1.4.0,parallel_transform,thread_pool,7,262144,1.063400,1.044400,1.304900,3.751500,3.527835,7293375088876815277,7293375088876815277,1,1,thread_pool,1 +1.4.0,parallel_transform,static_thread,7,262144,1.479800,1.419700,2.259000,3.751500,2.535140,7293375088876815277,7293375088876815277,1,1,static_thread,1 +1.4.0,parallel_transform,one_tbb,7,262144,1.155000,1.139800,1.356300,3.751500,3.248052,7293375088876815277,7293375088876815277,1,1,one_tbb,1 +1.4.0,parallel_transform_binary,sequential,7,262144,3.861700,3.844900,3.921600,3.861700,1.000000,3284516397851362210,3284516397851362210,1,1,sequential,0 +1.4.0,parallel_transform_binary,automatic,7,262144,1.107100,1.063400,1.686500,3.861700,3.488122,3284516397851362210,3284516397851362210,1,1,thread_pool,1 +1.4.0,parallel_transform_binary,thread_pool,7,262144,1.121800,1.076700,1.536300,3.861700,3.442414,3284516397851362210,3284516397851362210,1,1,thread_pool,1 +1.4.0,parallel_transform_binary,static_thread,7,262144,1.460100,1.341100,1.730500,3.861700,2.644819,3284516397851362210,3284516397851362210,1,1,static_thread,1 +1.4.0,parallel_transform_binary,one_tbb,7,262144,1.212500,1.144100,1.270100,3.861700,3.184907,3284516397851362210,3284516397851362210,1,1,one_tbb,1 +1.4.0,parallel_copy,sequential,7,1048576,1.117300,0.844700,1.383300,1.117300,1.000000,3108441649531108808,3108441649531108808,1,1,sequential,0 +1.4.0,parallel_copy,automatic,7,1048576,1.155900,0.841400,1.525600,1.117300,0.966606,3108441649531108808,3108441649531108808,1,1,sequential,0 +1.4.0,parallel_copy,thread_pool,7,1048576,1.211600,1.054900,1.555900,1.117300,0.922169,3108441649531108808,3108441649531108808,1,1,thread_pool,1 +1.4.0,parallel_copy,static_thread,7,1048576,1.617000,1.371700,1.955200,1.117300,0.690971,3108441649531108808,3108441649531108808,1,1,static_thread,1 +1.4.0,parallel_copy,one_tbb,7,1048576,1.065700,0.881300,1.275500,1.117300,1.048419,3108441649531108808,3108441649531108808,1,1,one_tbb,1 +1.4.0,parallel_fill,sequential,7,1048576,1.086000,0.454000,1.298300,1.086000,1.000000,8741389093274774276,8741389093274774276,1,1,sequential,0 +1.4.0,parallel_fill,automatic,7,1048576,0.406900,0.340500,0.755100,1.086000,2.668960,8741389093274774276,8741389093274774276,1,1,thread_pool,1 +1.4.0,parallel_fill,thread_pool,7,1048576,0.439100,0.347400,0.812400,1.086000,2.473241,8741389093274774276,8741389093274774276,1,1,thread_pool,1 +1.4.0,parallel_fill,static_thread,7,1048576,1.069800,0.739800,1.131600,1.086000,1.015143,8741389093274774276,8741389093274774276,1,1,static_thread,1 +1.4.0,parallel_fill,one_tbb,7,1048576,0.538100,0.361900,0.849900,1.086000,2.018212,8741389093274774276,8741389093274774276,1,1,one_tbb,1 +1.4.0,parallel_generate,sequential,7,262144,3.695700,3.675600,3.735900,3.695700,1.000000,4493962011273834418,4493962011273834418,1,1,sequential,0 +1.4.0,parallel_generate,automatic,7,262144,1.098000,1.027100,1.497500,3.695700,3.365847,4493962011273834418,4493962011273834418,1,1,thread_pool,1 +1.4.0,parallel_generate,thread_pool,7,262144,1.065300,1.017400,1.417400,3.695700,3.469164,4493962011273834418,4493962011273834418,1,1,thread_pool,1 +1.4.0,parallel_generate,static_thread,7,262144,1.363700,1.339800,1.541000,3.695700,2.710054,4493962011273834418,4493962011273834418,1,1,static_thread,1 +1.4.0,parallel_generate,one_tbb,7,262144,1.026700,1.007200,1.312500,3.695700,3.599591,4493962011273834418,4493962011273834418,1,1,one_tbb,1 +1.4.0,parallel_reduce,sequential,7,262144,0.032500,0.026900,0.051900,0.032500,1.000000,8590433753,8590433753,1,1,sequential,0 +1.4.0,parallel_reduce,automatic,7,262144,0.029200,0.027100,0.039700,0.032500,1.113014,8590433753,8590433753,1,1,sequential,0 +1.4.0,parallel_reduce,thread_pool,7,262144,0.067200,0.057100,0.128500,0.032500,0.483631,8590433753,8590433753,1,1,thread_pool,1 +1.4.0,parallel_reduce,static_thread,7,262144,0.355900,0.297900,0.644800,0.032500,0.091318,8590433753,8590433753,1,1,static_thread,1 +1.4.0,parallel_reduce,one_tbb,7,262144,0.075500,0.059000,0.095200,0.032500,0.430464,8590433753,8590433753,1,1,one_tbb,1 +1.4.0,parallel_transform_reduce,sequential,7,262144,3.785800,3.769900,3.859800,3.785800,1.000000,8587943456,8587943456,1,1,sequential,0 +1.4.0,parallel_transform_reduce,automatic,7,262144,1.071200,1.044200,1.330800,3.785800,3.534167,8587943456,8587943456,1,1,thread_pool,1 +1.4.0,parallel_transform_reduce,thread_pool,7,262144,1.061200,1.043700,1.321700,3.785800,3.567471,8587943456,8587943456,1,1,thread_pool,1 +1.4.0,parallel_transform_reduce,static_thread,7,262144,1.413300,1.317000,1.613800,3.785800,2.678695,8587943456,8587943456,1,1,static_thread,1 +1.4.0,parallel_transform_reduce,one_tbb,7,262144,1.168900,1.156200,1.196500,3.785800,3.238771,8587943456,8587943456,1,1,one_tbb,1 +1.4.0,parallel_transform_reduce_binary,sequential,7,262144,1.778400,1.724900,2.058700,1.778400,1.000000,8595455441,8595455441,1,1,sequential,0 +1.4.0,parallel_transform_reduce_binary,automatic,7,262144,0.525300,0.469400,0.677800,1.778400,3.385494,8595455441,8595455441,1,1,thread_pool,1 +1.4.0,parallel_transform_reduce_binary,thread_pool,7,262144,0.509000,0.475800,0.612800,1.778400,3.493910,8595455441,8595455441,1,1,thread_pool,1 +1.4.0,parallel_transform_reduce_binary,static_thread,7,262144,0.860100,0.758600,1.005900,1.778400,2.067667,8595455441,8595455441,1,1,static_thread,1 +1.4.0,parallel_transform_reduce_binary,one_tbb,7,262144,0.478600,0.463500,0.539900,1.778400,3.715838,8595455441,8595455441,1,1,one_tbb,1 +1.4.0,parallel_count,sequential,7,262144,0.034100,0.033800,0.034800,0.034100,1.000000,8457,8457,1,1,sequential,0 +1.4.0,parallel_count,automatic,7,262144,0.034900,0.034600,0.038400,0.034100,0.977077,8457,8457,1,1,sequential,0 +1.4.0,parallel_count,thread_pool,7,262144,0.083500,0.067800,0.240700,0.034100,0.408383,8457,8457,1,1,thread_pool,1 +1.4.0,parallel_count,static_thread,7,262144,0.373700,0.325400,0.433300,0.034100,0.091250,8457,8457,1,1,static_thread,1 +1.4.0,parallel_count,one_tbb,7,262144,0.052600,0.049800,0.092400,0.034100,0.648289,8457,8457,1,1,one_tbb,1 +1.4.0,parallel_count_if,sequential,7,262144,1.145900,1.139800,1.170000,1.145900,1.000000,32863,32863,1,1,sequential,0 +1.4.0,parallel_count_if,automatic,7,262144,0.375200,0.369200,0.439300,1.145900,3.054104,32863,32863,1,1,thread_pool,1 +1.4.0,parallel_count_if,thread_pool,7,262144,0.391400,0.364000,0.566500,1.145900,2.927695,32863,32863,1,1,thread_pool,1 +1.4.0,parallel_count_if,static_thread,7,262144,0.677400,0.591500,0.853000,1.145900,1.691615,32863,32863,1,1,static_thread,1 +1.4.0,parallel_count_if,one_tbb,7,262144,0.365200,0.343600,0.435300,1.145900,3.137733,32863,32863,1,1,one_tbb,1 +1.4.0,parallel_any_of,sequential,7,262144,0.068500,0.068200,0.097000,0.068500,1.000000,1,1,1,1,sequential,0 +1.4.0,parallel_any_of,automatic,7,262144,0.068400,0.068200,0.071600,0.068500,1.001462,1,1,1,1,sequential,0 +1.4.0,parallel_any_of,thread_pool,7,262144,0.080000,0.076400,0.093700,0.068500,0.856250,1,1,1,1,thread_pool,1 +1.4.0,parallel_any_of,static_thread,7,262144,0.313300,0.278600,1.293400,0.068500,0.218640,1,1,1,1,static_thread,1 +1.4.0,parallel_any_of,one_tbb,7,262144,0.054200,0.049400,0.059600,0.068500,1.263838,1,1,1,1,one_tbb,1 +1.4.0,parallel_all_of,sequential,7,262144,0.068100,0.067600,0.075100,0.068100,1.000000,1,1,1,1,sequential,0 +1.4.0,parallel_all_of,automatic,7,262144,0.068100,0.068000,0.075600,0.068100,1.000000,1,1,1,1,sequential,0 +1.4.0,parallel_all_of,thread_pool,7,262144,0.072300,0.066500,0.098000,0.068100,0.941909,1,1,1,1,thread_pool,1 +1.4.0,parallel_all_of,static_thread,7,262144,0.336400,0.313600,1.360000,0.068100,0.202438,1,1,1,1,static_thread,1 +1.4.0,parallel_all_of,one_tbb,7,262144,0.078800,0.058200,0.113100,0.068100,0.864213,1,1,1,1,one_tbb,1 +1.4.0,parallel_none_of,sequential,7,262144,0.068300,0.067900,0.074900,0.068300,1.000000,1,1,1,1,sequential,0 +1.4.0,parallel_none_of,automatic,7,262144,0.068500,0.068400,0.073000,0.068300,0.997080,1,1,1,1,sequential,0 +1.4.0,parallel_none_of,thread_pool,7,262144,0.069700,0.059900,0.084400,0.068300,0.979914,1,1,1,1,thread_pool,1 +1.4.0,parallel_none_of,static_thread,7,262144,0.425200,0.341300,1.582700,0.068300,0.160630,1,1,1,1,static_thread,1 +1.4.0,parallel_none_of,one_tbb,7,262144,0.131400,0.120500,0.157000,0.068300,0.519787,1,1,1,1,one_tbb,1 +1.4.0,parallel_find,sequential,7,262144,0.029100,0.029000,0.031300,0.029100,1.000000,262143,262143,1,1,sequential,0 +1.4.0,parallel_find,automatic,7,262144,0.029500,0.029400,0.033200,0.029100,0.986441,262143,262143,1,1,sequential,0 +1.4.0,parallel_find,thread_pool,7,262144,0.088000,0.071500,0.169700,0.029100,0.330682,262143,262143,1,1,thread_pool,1 +1.4.0,parallel_find,static_thread,7,262144,0.350200,0.292900,0.392100,0.029100,0.083095,262143,262143,1,1,static_thread,1 +1.4.0,parallel_find,one_tbb,7,262144,0.056600,0.053700,0.073300,0.029100,0.514134,262143,262143,1,1,one_tbb,1 +1.4.0,parallel_find_if,sequential,7,262144,0.068000,0.068000,0.110600,0.068000,1.000000,262143,262143,1,1,sequential,0 +1.4.0,parallel_find_if,automatic,7,262144,0.068500,0.068100,0.071900,0.068000,0.992701,262143,262143,1,1,sequential,0 +1.4.0,parallel_find_if,thread_pool,7,262144,0.070600,0.066900,0.096700,0.068000,0.963173,262143,262143,1,1,thread_pool,1 +1.4.0,parallel_find_if,static_thread,7,262144,0.313100,0.276000,0.445900,0.068000,0.217183,262143,262143,1,1,static_thread,1 +1.4.0,parallel_find_if,one_tbb,7,262144,0.053700,0.050500,0.072100,0.068000,1.266294,262143,262143,1,1,one_tbb,1 diff --git a/validation/output/v1.4.0_parallel_algorithms_raw.csv b/validation/output/v1.4.0_parallel_algorithms_raw.csv new file mode 100644 index 0000000..721e3b3 --- /dev/null +++ b/validation/output/v1.4.0_parallel_algorithms_raw.csv @@ -0,0 +1,561 @@ +schema_version,algorithm,mode,repetition,elapsed_ms,checksum,correct,backend_authenticated,observed_backend,parallel_observed +1.4.0,parallel_for_each,sequential,1,3.793900,12394695018371502475,1,1,sequential,0 +1.4.0,parallel_for_each,sequential,2,3.732400,12394695018371502475,1,1,sequential,0 +1.4.0,parallel_for_each,sequential,3,3.751600,12394695018371502475,1,1,sequential,0 +1.4.0,parallel_for_each,sequential,4,3.771100,12394695018371502475,1,1,sequential,0 +1.4.0,parallel_for_each,sequential,5,3.762600,12394695018371502475,1,1,sequential,0 +1.4.0,parallel_for_each,sequential,6,3.766800,12394695018371502475,1,1,sequential,0 +1.4.0,parallel_for_each,sequential,7,3.753000,12394695018371502475,1,1,sequential,0 +1.4.0,parallel_for_each,automatic,1,1.080700,12394695018371502475,1,1,thread_pool,1 +1.4.0,parallel_for_each,automatic,2,1.062200,12394695018371502475,1,1,thread_pool,1 +1.4.0,parallel_for_each,automatic,3,1.099200,12394695018371502475,1,1,thread_pool,1 +1.4.0,parallel_for_each,automatic,4,1.157100,12394695018371502475,1,1,thread_pool,1 +1.4.0,parallel_for_each,automatic,5,1.081300,12394695018371502475,1,1,thread_pool,1 +1.4.0,parallel_for_each,automatic,6,1.093000,12394695018371502475,1,1,thread_pool,1 +1.4.0,parallel_for_each,automatic,7,1.058500,12394695018371502475,1,1,thread_pool,1 +1.4.0,parallel_for_each,thread_pool,1,1.193600,12394695018371502475,1,1,thread_pool,1 +1.4.0,parallel_for_each,thread_pool,2,1.051100,12394695018371502475,1,1,thread_pool,1 +1.4.0,parallel_for_each,thread_pool,3,1.196800,12394695018371502475,1,1,thread_pool,1 +1.4.0,parallel_for_each,thread_pool,4,1.497800,12394695018371502475,1,1,thread_pool,1 +1.4.0,parallel_for_each,thread_pool,5,1.399100,12394695018371502475,1,1,thread_pool,1 +1.4.0,parallel_for_each,thread_pool,6,1.087100,12394695018371502475,1,1,thread_pool,1 +1.4.0,parallel_for_each,thread_pool,7,1.179900,12394695018371502475,1,1,thread_pool,1 +1.4.0,parallel_for_each,static_thread,1,1.454100,12394695018371502475,1,1,static_thread,1 +1.4.0,parallel_for_each,static_thread,2,1.405900,12394695018371502475,1,1,static_thread,1 +1.4.0,parallel_for_each,static_thread,3,1.389300,12394695018371502475,1,1,static_thread,1 +1.4.0,parallel_for_each,static_thread,4,1.387300,12394695018371502475,1,1,static_thread,1 +1.4.0,parallel_for_each,static_thread,5,1.289100,12394695018371502475,1,1,static_thread,1 +1.4.0,parallel_for_each,static_thread,6,1.627500,12394695018371502475,1,1,static_thread,1 +1.4.0,parallel_for_each,static_thread,7,1.362100,12394695018371502475,1,1,static_thread,1 +1.4.0,parallel_for_each,one_tbb,1,1.077700,12394695018371502475,1,1,one_tbb,1 +1.4.0,parallel_for_each,one_tbb,2,1.395800,12394695018371502475,1,1,one_tbb,1 +1.4.0,parallel_for_each,one_tbb,3,1.246900,12394695018371502475,1,1,one_tbb,1 +1.4.0,parallel_for_each,one_tbb,4,1.237400,12394695018371502475,1,1,one_tbb,1 +1.4.0,parallel_for_each,one_tbb,5,1.106500,12394695018371502475,1,1,one_tbb,1 +1.4.0,parallel_for_each,one_tbb,6,1.050800,12394695018371502475,1,1,one_tbb,1 +1.4.0,parallel_for_each,one_tbb,7,1.038500,12394695018371502475,1,1,one_tbb,1 +1.4.0,parallel_transform,sequential,1,3.744000,7293375088876815277,1,1,sequential,0 +1.4.0,parallel_transform,sequential,2,3.782400,7293375088876815277,1,1,sequential,0 +1.4.0,parallel_transform,sequential,3,3.758300,7293375088876815277,1,1,sequential,0 +1.4.0,parallel_transform,sequential,4,3.749300,7293375088876815277,1,1,sequential,0 +1.4.0,parallel_transform,sequential,5,3.751500,7293375088876815277,1,1,sequential,0 +1.4.0,parallel_transform,sequential,6,3.736600,7293375088876815277,1,1,sequential,0 +1.4.0,parallel_transform,sequential,7,3.751500,7293375088876815277,1,1,sequential,0 +1.4.0,parallel_transform,automatic,1,1.172700,7293375088876815277,1,1,thread_pool,1 +1.4.0,parallel_transform,automatic,2,1.080600,7293375088876815277,1,1,thread_pool,1 +1.4.0,parallel_transform,automatic,3,1.061000,7293375088876815277,1,1,thread_pool,1 +1.4.0,parallel_transform,automatic,4,1.066100,7293375088876815277,1,1,thread_pool,1 +1.4.0,parallel_transform,automatic,5,1.044800,7293375088876815277,1,1,thread_pool,1 +1.4.0,parallel_transform,automatic,6,1.081500,7293375088876815277,1,1,thread_pool,1 +1.4.0,parallel_transform,automatic,7,1.053000,7293375088876815277,1,1,thread_pool,1 +1.4.0,parallel_transform,thread_pool,1,1.304900,7293375088876815277,1,1,thread_pool,1 +1.4.0,parallel_transform,thread_pool,2,1.074600,7293375088876815277,1,1,thread_pool,1 +1.4.0,parallel_transform,thread_pool,3,1.063400,7293375088876815277,1,1,thread_pool,1 +1.4.0,parallel_transform,thread_pool,4,1.044400,7293375088876815277,1,1,thread_pool,1 +1.4.0,parallel_transform,thread_pool,5,1.046700,7293375088876815277,1,1,thread_pool,1 +1.4.0,parallel_transform,thread_pool,6,1.249800,7293375088876815277,1,1,thread_pool,1 +1.4.0,parallel_transform,thread_pool,7,1.058600,7293375088876815277,1,1,thread_pool,1 +1.4.0,parallel_transform,static_thread,1,2.259000,7293375088876815277,1,1,static_thread,1 +1.4.0,parallel_transform,static_thread,2,1.476600,7293375088876815277,1,1,static_thread,1 +1.4.0,parallel_transform,static_thread,3,1.479800,7293375088876815277,1,1,static_thread,1 +1.4.0,parallel_transform,static_thread,4,1.740000,7293375088876815277,1,1,static_thread,1 +1.4.0,parallel_transform,static_thread,5,1.419700,7293375088876815277,1,1,static_thread,1 +1.4.0,parallel_transform,static_thread,6,1.497700,7293375088876815277,1,1,static_thread,1 +1.4.0,parallel_transform,static_thread,7,1.430400,7293375088876815277,1,1,static_thread,1 +1.4.0,parallel_transform,one_tbb,1,1.139800,7293375088876815277,1,1,one_tbb,1 +1.4.0,parallel_transform,one_tbb,2,1.145500,7293375088876815277,1,1,one_tbb,1 +1.4.0,parallel_transform,one_tbb,3,1.275600,7293375088876815277,1,1,one_tbb,1 +1.4.0,parallel_transform,one_tbb,4,1.155000,7293375088876815277,1,1,one_tbb,1 +1.4.0,parallel_transform,one_tbb,5,1.146100,7293375088876815277,1,1,one_tbb,1 +1.4.0,parallel_transform,one_tbb,6,1.157400,7293375088876815277,1,1,one_tbb,1 +1.4.0,parallel_transform,one_tbb,7,1.356300,7293375088876815277,1,1,one_tbb,1 +1.4.0,parallel_transform_binary,sequential,1,3.921600,3284516397851362210,1,1,sequential,0 +1.4.0,parallel_transform_binary,sequential,2,3.851500,3284516397851362210,1,1,sequential,0 +1.4.0,parallel_transform_binary,sequential,3,3.857300,3284516397851362210,1,1,sequential,0 +1.4.0,parallel_transform_binary,sequential,4,3.861700,3284516397851362210,1,1,sequential,0 +1.4.0,parallel_transform_binary,sequential,5,3.844900,3284516397851362210,1,1,sequential,0 +1.4.0,parallel_transform_binary,sequential,6,3.887400,3284516397851362210,1,1,sequential,0 +1.4.0,parallel_transform_binary,sequential,7,3.868900,3284516397851362210,1,1,sequential,0 +1.4.0,parallel_transform_binary,automatic,1,1.686500,3284516397851362210,1,1,thread_pool,1 +1.4.0,parallel_transform_binary,automatic,2,1.199900,3284516397851362210,1,1,thread_pool,1 +1.4.0,parallel_transform_binary,automatic,3,1.107100,3284516397851362210,1,1,thread_pool,1 +1.4.0,parallel_transform_binary,automatic,4,1.063400,3284516397851362210,1,1,thread_pool,1 +1.4.0,parallel_transform_binary,automatic,5,1.085700,3284516397851362210,1,1,thread_pool,1 +1.4.0,parallel_transform_binary,automatic,6,1.074300,3284516397851362210,1,1,thread_pool,1 +1.4.0,parallel_transform_binary,automatic,7,1.114900,3284516397851362210,1,1,thread_pool,1 +1.4.0,parallel_transform_binary,thread_pool,1,1.103100,3284516397851362210,1,1,thread_pool,1 +1.4.0,parallel_transform_binary,thread_pool,2,1.079200,3284516397851362210,1,1,thread_pool,1 +1.4.0,parallel_transform_binary,thread_pool,3,1.076700,3284516397851362210,1,1,thread_pool,1 +1.4.0,parallel_transform_binary,thread_pool,4,1.134800,3284516397851362210,1,1,thread_pool,1 +1.4.0,parallel_transform_binary,thread_pool,5,1.536300,3284516397851362210,1,1,thread_pool,1 +1.4.0,parallel_transform_binary,thread_pool,6,1.301600,3284516397851362210,1,1,thread_pool,1 +1.4.0,parallel_transform_binary,thread_pool,7,1.121800,3284516397851362210,1,1,thread_pool,1 +1.4.0,parallel_transform_binary,static_thread,1,1.456100,3284516397851362210,1,1,static_thread,1 +1.4.0,parallel_transform_binary,static_thread,2,1.730500,3284516397851362210,1,1,static_thread,1 +1.4.0,parallel_transform_binary,static_thread,3,1.460100,3284516397851362210,1,1,static_thread,1 +1.4.0,parallel_transform_binary,static_thread,4,1.341100,3284516397851362210,1,1,static_thread,1 +1.4.0,parallel_transform_binary,static_thread,5,1.542400,3284516397851362210,1,1,static_thread,1 +1.4.0,parallel_transform_binary,static_thread,6,1.380700,3284516397851362210,1,1,static_thread,1 +1.4.0,parallel_transform_binary,static_thread,7,1.478200,3284516397851362210,1,1,static_thread,1 +1.4.0,parallel_transform_binary,one_tbb,1,1.270100,3284516397851362210,1,1,one_tbb,1 +1.4.0,parallel_transform_binary,one_tbb,2,1.144100,3284516397851362210,1,1,one_tbb,1 +1.4.0,parallel_transform_binary,one_tbb,3,1.219300,3284516397851362210,1,1,one_tbb,1 +1.4.0,parallel_transform_binary,one_tbb,4,1.202300,3284516397851362210,1,1,one_tbb,1 +1.4.0,parallel_transform_binary,one_tbb,5,1.248700,3284516397851362210,1,1,one_tbb,1 +1.4.0,parallel_transform_binary,one_tbb,6,1.212500,3284516397851362210,1,1,one_tbb,1 +1.4.0,parallel_transform_binary,one_tbb,7,1.199300,3284516397851362210,1,1,one_tbb,1 +1.4.0,parallel_copy,sequential,1,1.036400,3108441649531108808,1,1,sequential,0 +1.4.0,parallel_copy,sequential,2,1.304600,3108441649531108808,1,1,sequential,0 +1.4.0,parallel_copy,sequential,3,1.180000,3108441649531108808,1,1,sequential,0 +1.4.0,parallel_copy,sequential,4,1.093900,3108441649531108808,1,1,sequential,0 +1.4.0,parallel_copy,sequential,5,0.844700,3108441649531108808,1,1,sequential,0 +1.4.0,parallel_copy,sequential,6,1.117300,3108441649531108808,1,1,sequential,0 +1.4.0,parallel_copy,sequential,7,1.383300,3108441649531108808,1,1,sequential,0 +1.4.0,parallel_copy,automatic,1,0.874100,3108441649531108808,1,1,sequential,0 +1.4.0,parallel_copy,automatic,2,1.155900,3108441649531108808,1,1,sequential,0 +1.4.0,parallel_copy,automatic,3,0.841400,3108441649531108808,1,1,sequential,0 +1.4.0,parallel_copy,automatic,4,1.411500,3108441649531108808,1,1,sequential,0 +1.4.0,parallel_copy,automatic,5,1.525600,3108441649531108808,1,1,sequential,0 +1.4.0,parallel_copy,automatic,6,1.161300,3108441649531108808,1,1,sequential,0 +1.4.0,parallel_copy,automatic,7,0.875100,3108441649531108808,1,1,sequential,0 +1.4.0,parallel_copy,thread_pool,1,1.054900,3108441649531108808,1,1,thread_pool,1 +1.4.0,parallel_copy,thread_pool,2,1.211600,3108441649531108808,1,1,thread_pool,1 +1.4.0,parallel_copy,thread_pool,3,1.166200,3108441649531108808,1,1,thread_pool,1 +1.4.0,parallel_copy,thread_pool,4,1.509800,3108441649531108808,1,1,thread_pool,1 +1.4.0,parallel_copy,thread_pool,5,1.292500,3108441649531108808,1,1,thread_pool,1 +1.4.0,parallel_copy,thread_pool,6,1.144600,3108441649531108808,1,1,thread_pool,1 +1.4.0,parallel_copy,thread_pool,7,1.555900,3108441649531108808,1,1,thread_pool,1 +1.4.0,parallel_copy,static_thread,1,1.431600,3108441649531108808,1,1,static_thread,1 +1.4.0,parallel_copy,static_thread,2,1.660000,3108441649531108808,1,1,static_thread,1 +1.4.0,parallel_copy,static_thread,3,1.617000,3108441649531108808,1,1,static_thread,1 +1.4.0,parallel_copy,static_thread,4,1.371700,3108441649531108808,1,1,static_thread,1 +1.4.0,parallel_copy,static_thread,5,1.480200,3108441649531108808,1,1,static_thread,1 +1.4.0,parallel_copy,static_thread,6,1.955200,3108441649531108808,1,1,static_thread,1 +1.4.0,parallel_copy,static_thread,7,1.619500,3108441649531108808,1,1,static_thread,1 +1.4.0,parallel_copy,one_tbb,1,1.064000,3108441649531108808,1,1,one_tbb,1 +1.4.0,parallel_copy,one_tbb,2,1.275500,3108441649531108808,1,1,one_tbb,1 +1.4.0,parallel_copy,one_tbb,3,1.211600,3108441649531108808,1,1,one_tbb,1 +1.4.0,parallel_copy,one_tbb,4,1.182800,3108441649531108808,1,1,one_tbb,1 +1.4.0,parallel_copy,one_tbb,5,1.065700,3108441649531108808,1,1,one_tbb,1 +1.4.0,parallel_copy,one_tbb,6,0.882300,3108441649531108808,1,1,one_tbb,1 +1.4.0,parallel_copy,one_tbb,7,0.881300,3108441649531108808,1,1,one_tbb,1 +1.4.0,parallel_fill,sequential,1,1.146600,8741389093274774276,1,1,sequential,0 +1.4.0,parallel_fill,sequential,2,0.706100,8741389093274774276,1,1,sequential,0 +1.4.0,parallel_fill,sequential,3,1.098200,8741389093274774276,1,1,sequential,0 +1.4.0,parallel_fill,sequential,4,0.454000,8741389093274774276,1,1,sequential,0 +1.4.0,parallel_fill,sequential,5,1.298300,8741389093274774276,1,1,sequential,0 +1.4.0,parallel_fill,sequential,6,0.574600,8741389093274774276,1,1,sequential,0 +1.4.0,parallel_fill,sequential,7,1.086000,8741389093274774276,1,1,sequential,0 +1.4.0,parallel_fill,automatic,1,0.495500,8741389093274774276,1,1,thread_pool,1 +1.4.0,parallel_fill,automatic,2,0.405500,8741389093274774276,1,1,thread_pool,1 +1.4.0,parallel_fill,automatic,3,0.548600,8741389093274774276,1,1,thread_pool,1 +1.4.0,parallel_fill,automatic,4,0.340500,8741389093274774276,1,1,thread_pool,1 +1.4.0,parallel_fill,automatic,5,0.755100,8741389093274774276,1,1,thread_pool,1 +1.4.0,parallel_fill,automatic,6,0.383700,8741389093274774276,1,1,thread_pool,1 +1.4.0,parallel_fill,automatic,7,0.406900,8741389093274774276,1,1,thread_pool,1 +1.4.0,parallel_fill,thread_pool,1,0.629900,8741389093274774276,1,1,thread_pool,1 +1.4.0,parallel_fill,thread_pool,2,0.347400,8741389093274774276,1,1,thread_pool,1 +1.4.0,parallel_fill,thread_pool,3,0.812400,8741389093274774276,1,1,thread_pool,1 +1.4.0,parallel_fill,thread_pool,4,0.439100,8741389093274774276,1,1,thread_pool,1 +1.4.0,parallel_fill,thread_pool,5,0.418800,8741389093274774276,1,1,thread_pool,1 +1.4.0,parallel_fill,thread_pool,6,0.366400,8741389093274774276,1,1,thread_pool,1 +1.4.0,parallel_fill,thread_pool,7,0.501100,8741389093274774276,1,1,thread_pool,1 +1.4.0,parallel_fill,static_thread,1,1.092600,8741389093274774276,1,1,static_thread,1 +1.4.0,parallel_fill,static_thread,2,0.768900,8741389093274774276,1,1,static_thread,1 +1.4.0,parallel_fill,static_thread,3,1.089000,8741389093274774276,1,1,static_thread,1 +1.4.0,parallel_fill,static_thread,4,0.776700,8741389093274774276,1,1,static_thread,1 +1.4.0,parallel_fill,static_thread,5,1.069800,8741389093274774276,1,1,static_thread,1 +1.4.0,parallel_fill,static_thread,6,0.739800,8741389093274774276,1,1,static_thread,1 +1.4.0,parallel_fill,static_thread,7,1.131600,8741389093274774276,1,1,static_thread,1 +1.4.0,parallel_fill,one_tbb,1,0.824700,8741389093274774276,1,1,one_tbb,1 +1.4.0,parallel_fill,one_tbb,2,0.849900,8741389093274774276,1,1,one_tbb,1 +1.4.0,parallel_fill,one_tbb,3,0.528700,8741389093274774276,1,1,one_tbb,1 +1.4.0,parallel_fill,one_tbb,4,0.361900,8741389093274774276,1,1,one_tbb,1 +1.4.0,parallel_fill,one_tbb,5,0.538100,8741389093274774276,1,1,one_tbb,1 +1.4.0,parallel_fill,one_tbb,6,0.519400,8741389093274774276,1,1,one_tbb,1 +1.4.0,parallel_fill,one_tbb,7,0.571100,8741389093274774276,1,1,one_tbb,1 +1.4.0,parallel_generate,sequential,1,3.695800,4493962011273834418,1,1,sequential,0 +1.4.0,parallel_generate,sequential,2,3.678500,4493962011273834418,1,1,sequential,0 +1.4.0,parallel_generate,sequential,3,3.680000,4493962011273834418,1,1,sequential,0 +1.4.0,parallel_generate,sequential,4,3.702600,4493962011273834418,1,1,sequential,0 +1.4.0,parallel_generate,sequential,5,3.695700,4493962011273834418,1,1,sequential,0 +1.4.0,parallel_generate,sequential,6,3.675600,4493962011273834418,1,1,sequential,0 +1.4.0,parallel_generate,sequential,7,3.735900,4493962011273834418,1,1,sequential,0 +1.4.0,parallel_generate,automatic,1,1.337500,4493962011273834418,1,1,thread_pool,1 +1.4.0,parallel_generate,automatic,2,1.497500,4493962011273834418,1,1,thread_pool,1 +1.4.0,parallel_generate,automatic,3,1.040900,4493962011273834418,1,1,thread_pool,1 +1.4.0,parallel_generate,automatic,4,1.051900,4493962011273834418,1,1,thread_pool,1 +1.4.0,parallel_generate,automatic,5,1.027100,4493962011273834418,1,1,thread_pool,1 +1.4.0,parallel_generate,automatic,6,1.291900,4493962011273834418,1,1,thread_pool,1 +1.4.0,parallel_generate,automatic,7,1.098000,4493962011273834418,1,1,thread_pool,1 +1.4.0,parallel_generate,thread_pool,1,1.022800,4493962011273834418,1,1,thread_pool,1 +1.4.0,parallel_generate,thread_pool,2,1.190700,4493962011273834418,1,1,thread_pool,1 +1.4.0,parallel_generate,thread_pool,3,1.065300,4493962011273834418,1,1,thread_pool,1 +1.4.0,parallel_generate,thread_pool,4,1.017400,4493962011273834418,1,1,thread_pool,1 +1.4.0,parallel_generate,thread_pool,5,1.059500,4493962011273834418,1,1,thread_pool,1 +1.4.0,parallel_generate,thread_pool,6,1.417400,4493962011273834418,1,1,thread_pool,1 +1.4.0,parallel_generate,thread_pool,7,1.312000,4493962011273834418,1,1,thread_pool,1 +1.4.0,parallel_generate,static_thread,1,1.352100,4493962011273834418,1,1,static_thread,1 +1.4.0,parallel_generate,static_thread,2,1.541000,4493962011273834418,1,1,static_thread,1 +1.4.0,parallel_generate,static_thread,3,1.339800,4493962011273834418,1,1,static_thread,1 +1.4.0,parallel_generate,static_thread,4,1.363700,4493962011273834418,1,1,static_thread,1 +1.4.0,parallel_generate,static_thread,5,1.353000,4493962011273834418,1,1,static_thread,1 +1.4.0,parallel_generate,static_thread,6,1.378100,4493962011273834418,1,1,static_thread,1 +1.4.0,parallel_generate,static_thread,7,1.396500,4493962011273834418,1,1,static_thread,1 +1.4.0,parallel_generate,one_tbb,1,1.022700,4493962011273834418,1,1,one_tbb,1 +1.4.0,parallel_generate,one_tbb,2,1.312500,4493962011273834418,1,1,one_tbb,1 +1.4.0,parallel_generate,one_tbb,3,1.015100,4493962011273834418,1,1,one_tbb,1 +1.4.0,parallel_generate,one_tbb,4,1.026700,4493962011273834418,1,1,one_tbb,1 +1.4.0,parallel_generate,one_tbb,5,1.007200,4493962011273834418,1,1,one_tbb,1 +1.4.0,parallel_generate,one_tbb,6,1.028700,4493962011273834418,1,1,one_tbb,1 +1.4.0,parallel_generate,one_tbb,7,1.289700,4493962011273834418,1,1,one_tbb,1 +1.4.0,parallel_reduce,sequential,1,0.032500,8590433753,1,1,sequential,0 +1.4.0,parallel_reduce,sequential,2,0.027100,8590433753,1,1,sequential,0 +1.4.0,parallel_reduce,sequential,3,0.051900,8590433753,1,1,sequential,0 +1.4.0,parallel_reduce,sequential,4,0.035600,8590433753,1,1,sequential,0 +1.4.0,parallel_reduce,sequential,5,0.033100,8590433753,1,1,sequential,0 +1.4.0,parallel_reduce,sequential,6,0.031100,8590433753,1,1,sequential,0 +1.4.0,parallel_reduce,sequential,7,0.026900,8590433753,1,1,sequential,0 +1.4.0,parallel_reduce,automatic,1,0.027800,8590433753,1,1,sequential,0 +1.4.0,parallel_reduce,automatic,2,0.027200,8590433753,1,1,sequential,0 +1.4.0,parallel_reduce,automatic,3,0.027100,8590433753,1,1,sequential,0 +1.4.0,parallel_reduce,automatic,4,0.031300,8590433753,1,1,sequential,0 +1.4.0,parallel_reduce,automatic,5,0.039700,8590433753,1,1,sequential,0 +1.4.0,parallel_reduce,automatic,6,0.036600,8590433753,1,1,sequential,0 +1.4.0,parallel_reduce,automatic,7,0.029200,8590433753,1,1,sequential,0 +1.4.0,parallel_reduce,thread_pool,1,0.069500,8590433753,1,1,thread_pool,1 +1.4.0,parallel_reduce,thread_pool,2,0.057100,8590433753,1,1,thread_pool,1 +1.4.0,parallel_reduce,thread_pool,3,0.078900,8590433753,1,1,thread_pool,1 +1.4.0,parallel_reduce,thread_pool,4,0.066000,8590433753,1,1,thread_pool,1 +1.4.0,parallel_reduce,thread_pool,5,0.064200,8590433753,1,1,thread_pool,1 +1.4.0,parallel_reduce,thread_pool,6,0.128500,8590433753,1,1,thread_pool,1 +1.4.0,parallel_reduce,thread_pool,7,0.067200,8590433753,1,1,thread_pool,1 +1.4.0,parallel_reduce,static_thread,1,0.355900,8590433753,1,1,static_thread,1 +1.4.0,parallel_reduce,static_thread,2,0.310100,8590433753,1,1,static_thread,1 +1.4.0,parallel_reduce,static_thread,3,0.297900,8590433753,1,1,static_thread,1 +1.4.0,parallel_reduce,static_thread,4,0.304900,8590433753,1,1,static_thread,1 +1.4.0,parallel_reduce,static_thread,5,0.466000,8590433753,1,1,static_thread,1 +1.4.0,parallel_reduce,static_thread,6,0.644800,8590433753,1,1,static_thread,1 +1.4.0,parallel_reduce,static_thread,7,0.461000,8590433753,1,1,static_thread,1 +1.4.0,parallel_reduce,one_tbb,1,0.083300,8590433753,1,1,one_tbb,1 +1.4.0,parallel_reduce,one_tbb,2,0.067600,8590433753,1,1,one_tbb,1 +1.4.0,parallel_reduce,one_tbb,3,0.075500,8590433753,1,1,one_tbb,1 +1.4.0,parallel_reduce,one_tbb,4,0.076000,8590433753,1,1,one_tbb,1 +1.4.0,parallel_reduce,one_tbb,5,0.064400,8590433753,1,1,one_tbb,1 +1.4.0,parallel_reduce,one_tbb,6,0.059000,8590433753,1,1,one_tbb,1 +1.4.0,parallel_reduce,one_tbb,7,0.095200,8590433753,1,1,one_tbb,1 +1.4.0,parallel_transform_reduce,sequential,1,3.769900,8587943456,1,1,sequential,0 +1.4.0,parallel_transform_reduce,sequential,2,3.859800,8587943456,1,1,sequential,0 +1.4.0,parallel_transform_reduce,sequential,3,3.785800,8587943456,1,1,sequential,0 +1.4.0,parallel_transform_reduce,sequential,4,3.819300,8587943456,1,1,sequential,0 +1.4.0,parallel_transform_reduce,sequential,5,3.773300,8587943456,1,1,sequential,0 +1.4.0,parallel_transform_reduce,sequential,6,3.799700,8587943456,1,1,sequential,0 +1.4.0,parallel_transform_reduce,sequential,7,3.785800,8587943456,1,1,sequential,0 +1.4.0,parallel_transform_reduce,automatic,1,1.053600,8587943456,1,1,thread_pool,1 +1.4.0,parallel_transform_reduce,automatic,2,1.330800,8587943456,1,1,thread_pool,1 +1.4.0,parallel_transform_reduce,automatic,3,1.122200,8587943456,1,1,thread_pool,1 +1.4.0,parallel_transform_reduce,automatic,4,1.053100,8587943456,1,1,thread_pool,1 +1.4.0,parallel_transform_reduce,automatic,5,1.071200,8587943456,1,1,thread_pool,1 +1.4.0,parallel_transform_reduce,automatic,6,1.074400,8587943456,1,1,thread_pool,1 +1.4.0,parallel_transform_reduce,automatic,7,1.044200,8587943456,1,1,thread_pool,1 +1.4.0,parallel_transform_reduce,thread_pool,1,1.082300,8587943456,1,1,thread_pool,1 +1.4.0,parallel_transform_reduce,thread_pool,2,1.043700,8587943456,1,1,thread_pool,1 +1.4.0,parallel_transform_reduce,thread_pool,3,1.061200,8587943456,1,1,thread_pool,1 +1.4.0,parallel_transform_reduce,thread_pool,4,1.049700,8587943456,1,1,thread_pool,1 +1.4.0,parallel_transform_reduce,thread_pool,5,1.048700,8587943456,1,1,thread_pool,1 +1.4.0,parallel_transform_reduce,thread_pool,6,1.321700,8587943456,1,1,thread_pool,1 +1.4.0,parallel_transform_reduce,thread_pool,7,1.163200,8587943456,1,1,thread_pool,1 +1.4.0,parallel_transform_reduce,static_thread,1,1.515900,8587943456,1,1,static_thread,1 +1.4.0,parallel_transform_reduce,static_thread,2,1.613800,8587943456,1,1,static_thread,1 +1.4.0,parallel_transform_reduce,static_thread,3,1.415900,8587943456,1,1,static_thread,1 +1.4.0,parallel_transform_reduce,static_thread,4,1.413300,8587943456,1,1,static_thread,1 +1.4.0,parallel_transform_reduce,static_thread,5,1.409100,8587943456,1,1,static_thread,1 +1.4.0,parallel_transform_reduce,static_thread,6,1.317000,8587943456,1,1,static_thread,1 +1.4.0,parallel_transform_reduce,static_thread,7,1.390600,8587943456,1,1,static_thread,1 +1.4.0,parallel_transform_reduce,one_tbb,1,1.196500,8587943456,1,1,one_tbb,1 +1.4.0,parallel_transform_reduce,one_tbb,2,1.170200,8587943456,1,1,one_tbb,1 +1.4.0,parallel_transform_reduce,one_tbb,3,1.168900,8587943456,1,1,one_tbb,1 +1.4.0,parallel_transform_reduce,one_tbb,4,1.156200,8587943456,1,1,one_tbb,1 +1.4.0,parallel_transform_reduce,one_tbb,5,1.165500,8587943456,1,1,one_tbb,1 +1.4.0,parallel_transform_reduce,one_tbb,6,1.182200,8587943456,1,1,one_tbb,1 +1.4.0,parallel_transform_reduce,one_tbb,7,1.157100,8587943456,1,1,one_tbb,1 +1.4.0,parallel_transform_reduce_binary,sequential,1,1.993600,8595455441,1,1,sequential,0 +1.4.0,parallel_transform_reduce_binary,sequential,2,2.058700,8595455441,1,1,sequential,0 +1.4.0,parallel_transform_reduce_binary,sequential,3,1.724900,8595455441,1,1,sequential,0 +1.4.0,parallel_transform_reduce_binary,sequential,4,1.767600,8595455441,1,1,sequential,0 +1.4.0,parallel_transform_reduce_binary,sequential,5,1.886300,8595455441,1,1,sequential,0 +1.4.0,parallel_transform_reduce_binary,sequential,6,1.766800,8595455441,1,1,sequential,0 +1.4.0,parallel_transform_reduce_binary,sequential,7,1.778400,8595455441,1,1,sequential,0 +1.4.0,parallel_transform_reduce_binary,automatic,1,0.576000,8595455441,1,1,thread_pool,1 +1.4.0,parallel_transform_reduce_binary,automatic,2,0.677800,8595455441,1,1,thread_pool,1 +1.4.0,parallel_transform_reduce_binary,automatic,3,0.525300,8595455441,1,1,thread_pool,1 +1.4.0,parallel_transform_reduce_binary,automatic,4,0.562300,8595455441,1,1,thread_pool,1 +1.4.0,parallel_transform_reduce_binary,automatic,5,0.472600,8595455441,1,1,thread_pool,1 +1.4.0,parallel_transform_reduce_binary,automatic,6,0.478900,8595455441,1,1,thread_pool,1 +1.4.0,parallel_transform_reduce_binary,automatic,7,0.469400,8595455441,1,1,thread_pool,1 +1.4.0,parallel_transform_reduce_binary,thread_pool,1,0.499300,8595455441,1,1,thread_pool,1 +1.4.0,parallel_transform_reduce_binary,thread_pool,2,0.612800,8595455441,1,1,thread_pool,1 +1.4.0,parallel_transform_reduce_binary,thread_pool,3,0.532900,8595455441,1,1,thread_pool,1 +1.4.0,parallel_transform_reduce_binary,thread_pool,4,0.529300,8595455441,1,1,thread_pool,1 +1.4.0,parallel_transform_reduce_binary,thread_pool,5,0.475800,8595455441,1,1,thread_pool,1 +1.4.0,parallel_transform_reduce_binary,thread_pool,6,0.480600,8595455441,1,1,thread_pool,1 +1.4.0,parallel_transform_reduce_binary,thread_pool,7,0.509000,8595455441,1,1,thread_pool,1 +1.4.0,parallel_transform_reduce_binary,static_thread,1,0.758600,8595455441,1,1,static_thread,1 +1.4.0,parallel_transform_reduce_binary,static_thread,2,0.872100,8595455441,1,1,static_thread,1 +1.4.0,parallel_transform_reduce_binary,static_thread,3,0.974200,8595455441,1,1,static_thread,1 +1.4.0,parallel_transform_reduce_binary,static_thread,4,0.860100,8595455441,1,1,static_thread,1 +1.4.0,parallel_transform_reduce_binary,static_thread,5,0.760900,8595455441,1,1,static_thread,1 +1.4.0,parallel_transform_reduce_binary,static_thread,6,0.837700,8595455441,1,1,static_thread,1 +1.4.0,parallel_transform_reduce_binary,static_thread,7,1.005900,8595455441,1,1,static_thread,1 +1.4.0,parallel_transform_reduce_binary,one_tbb,1,0.539900,8595455441,1,1,one_tbb,1 +1.4.0,parallel_transform_reduce_binary,one_tbb,2,0.503100,8595455441,1,1,one_tbb,1 +1.4.0,parallel_transform_reduce_binary,one_tbb,3,0.488300,8595455441,1,1,one_tbb,1 +1.4.0,parallel_transform_reduce_binary,one_tbb,4,0.475100,8595455441,1,1,one_tbb,1 +1.4.0,parallel_transform_reduce_binary,one_tbb,5,0.478600,8595455441,1,1,one_tbb,1 +1.4.0,parallel_transform_reduce_binary,one_tbb,6,0.465500,8595455441,1,1,one_tbb,1 +1.4.0,parallel_transform_reduce_binary,one_tbb,7,0.463500,8595455441,1,1,one_tbb,1 +1.4.0,parallel_count,sequential,1,0.034800,8457,1,1,sequential,0 +1.4.0,parallel_count,sequential,2,0.034200,8457,1,1,sequential,0 +1.4.0,parallel_count,sequential,3,0.033900,8457,1,1,sequential,0 +1.4.0,parallel_count,sequential,4,0.034100,8457,1,1,sequential,0 +1.4.0,parallel_count,sequential,5,0.033800,8457,1,1,sequential,0 +1.4.0,parallel_count,sequential,6,0.034000,8457,1,1,sequential,0 +1.4.0,parallel_count,sequential,7,0.034200,8457,1,1,sequential,0 +1.4.0,parallel_count,automatic,1,0.038400,8457,1,1,sequential,0 +1.4.0,parallel_count,automatic,2,0.034900,8457,1,1,sequential,0 +1.4.0,parallel_count,automatic,3,0.035100,8457,1,1,sequential,0 +1.4.0,parallel_count,automatic,4,0.037900,8457,1,1,sequential,0 +1.4.0,parallel_count,automatic,5,0.034700,8457,1,1,sequential,0 +1.4.0,parallel_count,automatic,6,0.034600,8457,1,1,sequential,0 +1.4.0,parallel_count,automatic,7,0.034600,8457,1,1,sequential,0 +1.4.0,parallel_count,thread_pool,1,0.078000,8457,1,1,thread_pool,1 +1.4.0,parallel_count,thread_pool,2,0.083500,8457,1,1,thread_pool,1 +1.4.0,parallel_count,thread_pool,3,0.100700,8457,1,1,thread_pool,1 +1.4.0,parallel_count,thread_pool,4,0.072800,8457,1,1,thread_pool,1 +1.4.0,parallel_count,thread_pool,5,0.067800,8457,1,1,thread_pool,1 +1.4.0,parallel_count,thread_pool,6,0.090300,8457,1,1,thread_pool,1 +1.4.0,parallel_count,thread_pool,7,0.240700,8457,1,1,thread_pool,1 +1.4.0,parallel_count,static_thread,1,0.373700,8457,1,1,static_thread,1 +1.4.0,parallel_count,static_thread,2,0.325400,8457,1,1,static_thread,1 +1.4.0,parallel_count,static_thread,3,0.359700,8457,1,1,static_thread,1 +1.4.0,parallel_count,static_thread,4,0.428600,8457,1,1,static_thread,1 +1.4.0,parallel_count,static_thread,5,0.381500,8457,1,1,static_thread,1 +1.4.0,parallel_count,static_thread,6,0.346700,8457,1,1,static_thread,1 +1.4.0,parallel_count,static_thread,7,0.433300,8457,1,1,static_thread,1 +1.4.0,parallel_count,one_tbb,1,0.092400,8457,1,1,one_tbb,1 +1.4.0,parallel_count,one_tbb,2,0.050200,8457,1,1,one_tbb,1 +1.4.0,parallel_count,one_tbb,3,0.061600,8457,1,1,one_tbb,1 +1.4.0,parallel_count,one_tbb,4,0.052200,8457,1,1,one_tbb,1 +1.4.0,parallel_count,one_tbb,5,0.052600,8457,1,1,one_tbb,1 +1.4.0,parallel_count,one_tbb,6,0.049800,8457,1,1,one_tbb,1 +1.4.0,parallel_count,one_tbb,7,0.054100,8457,1,1,one_tbb,1 +1.4.0,parallel_count_if,sequential,1,1.157400,32863,1,1,sequential,0 +1.4.0,parallel_count_if,sequential,2,1.145900,32863,1,1,sequential,0 +1.4.0,parallel_count_if,sequential,3,1.145500,32863,1,1,sequential,0 +1.4.0,parallel_count_if,sequential,4,1.145900,32863,1,1,sequential,0 +1.4.0,parallel_count_if,sequential,5,1.170000,32863,1,1,sequential,0 +1.4.0,parallel_count_if,sequential,6,1.148200,32863,1,1,sequential,0 +1.4.0,parallel_count_if,sequential,7,1.139800,32863,1,1,sequential,0 +1.4.0,parallel_count_if,automatic,1,0.371300,32863,1,1,thread_pool,1 +1.4.0,parallel_count_if,automatic,2,0.411300,32863,1,1,thread_pool,1 +1.4.0,parallel_count_if,automatic,3,0.374900,32863,1,1,thread_pool,1 +1.4.0,parallel_count_if,automatic,4,0.375200,32863,1,1,thread_pool,1 +1.4.0,parallel_count_if,automatic,5,0.413400,32863,1,1,thread_pool,1 +1.4.0,parallel_count_if,automatic,6,0.439300,32863,1,1,thread_pool,1 +1.4.0,parallel_count_if,automatic,7,0.369200,32863,1,1,thread_pool,1 +1.4.0,parallel_count_if,thread_pool,1,0.566500,32863,1,1,thread_pool,1 +1.4.0,parallel_count_if,thread_pool,2,0.396800,32863,1,1,thread_pool,1 +1.4.0,parallel_count_if,thread_pool,3,0.391400,32863,1,1,thread_pool,1 +1.4.0,parallel_count_if,thread_pool,4,0.379300,32863,1,1,thread_pool,1 +1.4.0,parallel_count_if,thread_pool,5,0.366300,32863,1,1,thread_pool,1 +1.4.0,parallel_count_if,thread_pool,6,0.417000,32863,1,1,thread_pool,1 +1.4.0,parallel_count_if,thread_pool,7,0.364000,32863,1,1,thread_pool,1 +1.4.0,parallel_count_if,static_thread,1,0.677400,32863,1,1,static_thread,1 +1.4.0,parallel_count_if,static_thread,2,0.617700,32863,1,1,static_thread,1 +1.4.0,parallel_count_if,static_thread,3,0.703100,32863,1,1,static_thread,1 +1.4.0,parallel_count_if,static_thread,4,0.853000,32863,1,1,static_thread,1 +1.4.0,parallel_count_if,static_thread,5,0.695800,32863,1,1,static_thread,1 +1.4.0,parallel_count_if,static_thread,6,0.610500,32863,1,1,static_thread,1 +1.4.0,parallel_count_if,static_thread,7,0.591500,32863,1,1,static_thread,1 +1.4.0,parallel_count_if,one_tbb,1,0.425000,32863,1,1,one_tbb,1 +1.4.0,parallel_count_if,one_tbb,2,0.343600,32863,1,1,one_tbb,1 +1.4.0,parallel_count_if,one_tbb,3,0.363000,32863,1,1,one_tbb,1 +1.4.0,parallel_count_if,one_tbb,4,0.369000,32863,1,1,one_tbb,1 +1.4.0,parallel_count_if,one_tbb,5,0.355100,32863,1,1,one_tbb,1 +1.4.0,parallel_count_if,one_tbb,6,0.365200,32863,1,1,one_tbb,1 +1.4.0,parallel_count_if,one_tbb,7,0.435300,32863,1,1,one_tbb,1 +1.4.0,parallel_any_of,sequential,1,0.068700,1,1,1,sequential,0 +1.4.0,parallel_any_of,sequential,2,0.093400,1,1,1,sequential,0 +1.4.0,parallel_any_of,sequential,3,0.097000,1,1,1,sequential,0 +1.4.0,parallel_any_of,sequential,4,0.068300,1,1,1,sequential,0 +1.4.0,parallel_any_of,sequential,5,0.068500,1,1,1,sequential,0 +1.4.0,parallel_any_of,sequential,6,0.068200,1,1,1,sequential,0 +1.4.0,parallel_any_of,sequential,7,0.068200,1,1,1,sequential,0 +1.4.0,parallel_any_of,automatic,1,0.071600,1,1,1,sequential,0 +1.4.0,parallel_any_of,automatic,2,0.068400,1,1,1,sequential,0 +1.4.0,parallel_any_of,automatic,3,0.068300,1,1,1,sequential,0 +1.4.0,parallel_any_of,automatic,4,0.068200,1,1,1,sequential,0 +1.4.0,parallel_any_of,automatic,5,0.068200,1,1,1,sequential,0 +1.4.0,parallel_any_of,automatic,6,0.068600,1,1,1,sequential,0 +1.4.0,parallel_any_of,automatic,7,0.068600,1,1,1,sequential,0 +1.4.0,parallel_any_of,thread_pool,1,0.080000,1,1,1,thread_pool,1 +1.4.0,parallel_any_of,thread_pool,2,0.077100,1,1,1,thread_pool,1 +1.4.0,parallel_any_of,thread_pool,3,0.089100,1,1,1,thread_pool,1 +1.4.0,parallel_any_of,thread_pool,4,0.079900,1,1,1,thread_pool,1 +1.4.0,parallel_any_of,thread_pool,5,0.076400,1,1,1,thread_pool,1 +1.4.0,parallel_any_of,thread_pool,6,0.091800,1,1,1,thread_pool,1 +1.4.0,parallel_any_of,thread_pool,7,0.093700,1,1,1,thread_pool,1 +1.4.0,parallel_any_of,static_thread,1,0.363000,1,1,1,static_thread,1 +1.4.0,parallel_any_of,static_thread,2,0.309000,1,1,1,static_thread,1 +1.4.0,parallel_any_of,static_thread,3,0.313300,1,1,1,static_thread,1 +1.4.0,parallel_any_of,static_thread,4,0.278600,1,1,1,static_thread,1 +1.4.0,parallel_any_of,static_thread,5,1.293400,1,1,1,static_thread,1 +1.4.0,parallel_any_of,static_thread,6,0.316600,1,1,1,static_thread,1 +1.4.0,parallel_any_of,static_thread,7,0.300300,1,1,1,static_thread,1 +1.4.0,parallel_any_of,one_tbb,1,0.058800,1,1,1,one_tbb,1 +1.4.0,parallel_any_of,one_tbb,2,0.049400,1,1,1,one_tbb,1 +1.4.0,parallel_any_of,one_tbb,3,0.059600,1,1,1,one_tbb,1 +1.4.0,parallel_any_of,one_tbb,4,0.054200,1,1,1,one_tbb,1 +1.4.0,parallel_any_of,one_tbb,5,0.055000,1,1,1,one_tbb,1 +1.4.0,parallel_any_of,one_tbb,6,0.050000,1,1,1,one_tbb,1 +1.4.0,parallel_any_of,one_tbb,7,0.053900,1,1,1,one_tbb,1 +1.4.0,parallel_all_of,sequential,1,0.067600,1,1,1,sequential,0 +1.4.0,parallel_all_of,sequential,2,0.067800,1,1,1,sequential,0 +1.4.0,parallel_all_of,sequential,3,0.075100,1,1,1,sequential,0 +1.4.0,parallel_all_of,sequential,4,0.068100,1,1,1,sequential,0 +1.4.0,parallel_all_of,sequential,5,0.068100,1,1,1,sequential,0 +1.4.0,parallel_all_of,sequential,6,0.073800,1,1,1,sequential,0 +1.4.0,parallel_all_of,sequential,7,0.068000,1,1,1,sequential,0 +1.4.0,parallel_all_of,automatic,1,0.075600,1,1,1,sequential,0 +1.4.0,parallel_all_of,automatic,2,0.068200,1,1,1,sequential,0 +1.4.0,parallel_all_of,automatic,3,0.068000,1,1,1,sequential,0 +1.4.0,parallel_all_of,automatic,4,0.071400,1,1,1,sequential,0 +1.4.0,parallel_all_of,automatic,5,0.068100,1,1,1,sequential,0 +1.4.0,parallel_all_of,automatic,6,0.068000,1,1,1,sequential,0 +1.4.0,parallel_all_of,automatic,7,0.068000,1,1,1,sequential,0 +1.4.0,parallel_all_of,thread_pool,1,0.081600,1,1,1,thread_pool,1 +1.4.0,parallel_all_of,thread_pool,2,0.098000,1,1,1,thread_pool,1 +1.4.0,parallel_all_of,thread_pool,3,0.089800,1,1,1,thread_pool,1 +1.4.0,parallel_all_of,thread_pool,4,0.072300,1,1,1,thread_pool,1 +1.4.0,parallel_all_of,thread_pool,5,0.071600,1,1,1,thread_pool,1 +1.4.0,parallel_all_of,thread_pool,6,0.066500,1,1,1,thread_pool,1 +1.4.0,parallel_all_of,thread_pool,7,0.069300,1,1,1,thread_pool,1 +1.4.0,parallel_all_of,static_thread,1,0.434300,1,1,1,static_thread,1 +1.4.0,parallel_all_of,static_thread,2,0.322900,1,1,1,static_thread,1 +1.4.0,parallel_all_of,static_thread,3,0.318900,1,1,1,static_thread,1 +1.4.0,parallel_all_of,static_thread,4,0.313600,1,1,1,static_thread,1 +1.4.0,parallel_all_of,static_thread,5,0.336400,1,1,1,static_thread,1 +1.4.0,parallel_all_of,static_thread,6,1.360000,1,1,1,static_thread,1 +1.4.0,parallel_all_of,static_thread,7,0.365600,1,1,1,static_thread,1 +1.4.0,parallel_all_of,one_tbb,1,0.058200,1,1,1,one_tbb,1 +1.4.0,parallel_all_of,one_tbb,2,0.078800,1,1,1,one_tbb,1 +1.4.0,parallel_all_of,one_tbb,3,0.113100,1,1,1,one_tbb,1 +1.4.0,parallel_all_of,one_tbb,4,0.098500,1,1,1,one_tbb,1 +1.4.0,parallel_all_of,one_tbb,5,0.095500,1,1,1,one_tbb,1 +1.4.0,parallel_all_of,one_tbb,6,0.073800,1,1,1,one_tbb,1 +1.4.0,parallel_all_of,one_tbb,7,0.068100,1,1,1,one_tbb,1 +1.4.0,parallel_none_of,sequential,1,0.073400,1,1,1,sequential,0 +1.4.0,parallel_none_of,sequential,2,0.073400,1,1,1,sequential,0 +1.4.0,parallel_none_of,sequential,3,0.074900,1,1,1,sequential,0 +1.4.0,parallel_none_of,sequential,4,0.067900,1,1,1,sequential,0 +1.4.0,parallel_none_of,sequential,5,0.068200,1,1,1,sequential,0 +1.4.0,parallel_none_of,sequential,6,0.068300,1,1,1,sequential,0 +1.4.0,parallel_none_of,sequential,7,0.068200,1,1,1,sequential,0 +1.4.0,parallel_none_of,automatic,1,0.069700,1,1,1,sequential,0 +1.4.0,parallel_none_of,automatic,2,0.069000,1,1,1,sequential,0 +1.4.0,parallel_none_of,automatic,3,0.068500,1,1,1,sequential,0 +1.4.0,parallel_none_of,automatic,4,0.068400,1,1,1,sequential,0 +1.4.0,parallel_none_of,automatic,5,0.068400,1,1,1,sequential,0 +1.4.0,parallel_none_of,automatic,6,0.068500,1,1,1,sequential,0 +1.4.0,parallel_none_of,automatic,7,0.073000,1,1,1,sequential,0 +1.4.0,parallel_none_of,thread_pool,1,0.073400,1,1,1,thread_pool,1 +1.4.0,parallel_none_of,thread_pool,2,0.067800,1,1,1,thread_pool,1 +1.4.0,parallel_none_of,thread_pool,3,0.084400,1,1,1,thread_pool,1 +1.4.0,parallel_none_of,thread_pool,4,0.070500,1,1,1,thread_pool,1 +1.4.0,parallel_none_of,thread_pool,5,0.059900,1,1,1,thread_pool,1 +1.4.0,parallel_none_of,thread_pool,6,0.069700,1,1,1,thread_pool,1 +1.4.0,parallel_none_of,thread_pool,7,0.066300,1,1,1,thread_pool,1 +1.4.0,parallel_none_of,static_thread,1,0.425200,1,1,1,static_thread,1 +1.4.0,parallel_none_of,static_thread,2,0.341300,1,1,1,static_thread,1 +1.4.0,parallel_none_of,static_thread,3,1.582700,1,1,1,static_thread,1 +1.4.0,parallel_none_of,static_thread,4,0.383200,1,1,1,static_thread,1 +1.4.0,parallel_none_of,static_thread,5,0.415200,1,1,1,static_thread,1 +1.4.0,parallel_none_of,static_thread,6,0.460500,1,1,1,static_thread,1 +1.4.0,parallel_none_of,static_thread,7,0.441300,1,1,1,static_thread,1 +1.4.0,parallel_none_of,one_tbb,1,0.123700,1,1,1,one_tbb,1 +1.4.0,parallel_none_of,one_tbb,2,0.120500,1,1,1,one_tbb,1 +1.4.0,parallel_none_of,one_tbb,3,0.157000,1,1,1,one_tbb,1 +1.4.0,parallel_none_of,one_tbb,4,0.136800,1,1,1,one_tbb,1 +1.4.0,parallel_none_of,one_tbb,5,0.131700,1,1,1,one_tbb,1 +1.4.0,parallel_none_of,one_tbb,6,0.131400,1,1,1,one_tbb,1 +1.4.0,parallel_none_of,one_tbb,7,0.122900,1,1,1,one_tbb,1 +1.4.0,parallel_find,sequential,1,0.031300,262143,1,1,sequential,0 +1.4.0,parallel_find,sequential,2,0.030200,262143,1,1,sequential,0 +1.4.0,parallel_find,sequential,3,0.029100,262143,1,1,sequential,0 +1.4.0,parallel_find,sequential,4,0.029100,262143,1,1,sequential,0 +1.4.0,parallel_find,sequential,5,0.029000,262143,1,1,sequential,0 +1.4.0,parallel_find,sequential,6,0.029100,262143,1,1,sequential,0 +1.4.0,parallel_find,sequential,7,0.029300,262143,1,1,sequential,0 +1.4.0,parallel_find,automatic,1,0.033200,262143,1,1,sequential,0 +1.4.0,parallel_find,automatic,2,0.029800,262143,1,1,sequential,0 +1.4.0,parallel_find,automatic,3,0.029500,262143,1,1,sequential,0 +1.4.0,parallel_find,automatic,4,0.029500,262143,1,1,sequential,0 +1.4.0,parallel_find,automatic,5,0.029400,262143,1,1,sequential,0 +1.4.0,parallel_find,automatic,6,0.029400,262143,1,1,sequential,0 +1.4.0,parallel_find,automatic,7,0.029400,262143,1,1,sequential,0 +1.4.0,parallel_find,thread_pool,1,0.087000,262143,1,1,thread_pool,1 +1.4.0,parallel_find,thread_pool,2,0.135200,262143,1,1,thread_pool,1 +1.4.0,parallel_find,thread_pool,3,0.088000,262143,1,1,thread_pool,1 +1.4.0,parallel_find,thread_pool,4,0.076800,262143,1,1,thread_pool,1 +1.4.0,parallel_find,thread_pool,5,0.071500,262143,1,1,thread_pool,1 +1.4.0,parallel_find,thread_pool,6,0.169700,262143,1,1,thread_pool,1 +1.4.0,parallel_find,thread_pool,7,0.136600,262143,1,1,thread_pool,1 +1.4.0,parallel_find,static_thread,1,0.350200,262143,1,1,static_thread,1 +1.4.0,parallel_find,static_thread,2,0.360800,262143,1,1,static_thread,1 +1.4.0,parallel_find,static_thread,3,0.342800,262143,1,1,static_thread,1 +1.4.0,parallel_find,static_thread,4,0.392100,262143,1,1,static_thread,1 +1.4.0,parallel_find,static_thread,5,0.301400,262143,1,1,static_thread,1 +1.4.0,parallel_find,static_thread,6,0.361700,262143,1,1,static_thread,1 +1.4.0,parallel_find,static_thread,7,0.292900,262143,1,1,static_thread,1 +1.4.0,parallel_find,one_tbb,1,0.073300,262143,1,1,one_tbb,1 +1.4.0,parallel_find,one_tbb,2,0.058300,262143,1,1,one_tbb,1 +1.4.0,parallel_find,one_tbb,3,0.063200,262143,1,1,one_tbb,1 +1.4.0,parallel_find,one_tbb,4,0.054400,262143,1,1,one_tbb,1 +1.4.0,parallel_find,one_tbb,5,0.053700,262143,1,1,one_tbb,1 +1.4.0,parallel_find,one_tbb,6,0.054000,262143,1,1,one_tbb,1 +1.4.0,parallel_find,one_tbb,7,0.056600,262143,1,1,one_tbb,1 +1.4.0,parallel_find_if,sequential,1,0.068000,262143,1,1,sequential,0 +1.4.0,parallel_find_if,sequential,2,0.068000,262143,1,1,sequential,0 +1.4.0,parallel_find_if,sequential,3,0.068000,262143,1,1,sequential,0 +1.4.0,parallel_find_if,sequential,4,0.068000,262143,1,1,sequential,0 +1.4.0,parallel_find_if,sequential,5,0.110600,262143,1,1,sequential,0 +1.4.0,parallel_find_if,sequential,6,0.068000,262143,1,1,sequential,0 +1.4.0,parallel_find_if,sequential,7,0.068000,262143,1,1,sequential,0 +1.4.0,parallel_find_if,automatic,1,0.071900,262143,1,1,sequential,0 +1.4.0,parallel_find_if,automatic,2,0.068500,262143,1,1,sequential,0 +1.4.0,parallel_find_if,automatic,3,0.068100,262143,1,1,sequential,0 +1.4.0,parallel_find_if,automatic,4,0.068500,262143,1,1,sequential,0 +1.4.0,parallel_find_if,automatic,5,0.068400,262143,1,1,sequential,0 +1.4.0,parallel_find_if,automatic,6,0.068500,262143,1,1,sequential,0 +1.4.0,parallel_find_if,automatic,7,0.068300,262143,1,1,sequential,0 +1.4.0,parallel_find_if,thread_pool,1,0.075000,262143,1,1,thread_pool,1 +1.4.0,parallel_find_if,thread_pool,2,0.070600,262143,1,1,thread_pool,1 +1.4.0,parallel_find_if,thread_pool,3,0.096700,262143,1,1,thread_pool,1 +1.4.0,parallel_find_if,thread_pool,4,0.068700,262143,1,1,thread_pool,1 +1.4.0,parallel_find_if,thread_pool,5,0.069000,262143,1,1,thread_pool,1 +1.4.0,parallel_find_if,thread_pool,6,0.079400,262143,1,1,thread_pool,1 +1.4.0,parallel_find_if,thread_pool,7,0.066900,262143,1,1,thread_pool,1 +1.4.0,parallel_find_if,static_thread,1,0.445900,262143,1,1,static_thread,1 +1.4.0,parallel_find_if,static_thread,2,0.413000,262143,1,1,static_thread,1 +1.4.0,parallel_find_if,static_thread,3,0.323300,262143,1,1,static_thread,1 +1.4.0,parallel_find_if,static_thread,4,0.304200,262143,1,1,static_thread,1 +1.4.0,parallel_find_if,static_thread,5,0.313100,262143,1,1,static_thread,1 +1.4.0,parallel_find_if,static_thread,6,0.276000,262143,1,1,static_thread,1 +1.4.0,parallel_find_if,static_thread,7,0.303500,262143,1,1,static_thread,1 +1.4.0,parallel_find_if,one_tbb,1,0.072100,262143,1,1,one_tbb,1 +1.4.0,parallel_find_if,one_tbb,2,0.052400,262143,1,1,one_tbb,1 +1.4.0,parallel_find_if,one_tbb,3,0.056900,262143,1,1,one_tbb,1 +1.4.0,parallel_find_if,one_tbb,4,0.053700,262143,1,1,one_tbb,1 +1.4.0,parallel_find_if,one_tbb,5,0.052500,262143,1,1,one_tbb,1 +1.4.0,parallel_find_if,one_tbb,6,0.054400,262143,1,1,one_tbb,1 +1.4.0,parallel_find_if,one_tbb,7,0.050500,262143,1,1,one_tbb,1 diff --git a/vcpkg.json b/vcpkg.json index c485fe5..0f2c49e 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -1,6 +1,6 @@ { "name": "smartparallel", - "version-string": "1.3.0", + "version-string": "1.4.0", "description": "Adaptive parallel scheduling for modern C++", "builtin-baseline": "a0400024711b283056538ac19ced80b91a83c24c", "dependencies": [