CaptureMoment 0.1.0
Free and open-source non-destructive photo editor
Loading...
Searching...
No Matches
benchmarking_backend_decider.h
Go to the documentation of this file.
1
14#pragma once
15
17#include <chrono>
18#include <optional>
19
20#include "Halide.h"
21
22namespace CaptureMoment::Core {
23
24namespace ImageProcessing {
25
53public:
54 ~BenchmarkingBackendDecider() override = default;
55
70 [[nodiscard]] Common::MemoryType decide() override;
71
81 [[nodiscard]] const Halide::Target& getWinningTarget() const { return m_winning_target; };
82
83private:
84 // ============================================================
85 // Configuration Constants
86 // ============================================================
87
93 static constexpr int k_benchmark_width = 1920;
94
99 static constexpr int k_benchmark_height = 1080;
100
105 static constexpr int k_benchmark_channels = 4;
106
114 static constexpr double k_gpu_advantage_threshold = 0.9;
115
116 // ============================================================
117 // Benchmarking Methods
118 // ============================================================
119
131 [[nodiscard]] std::chrono::milliseconds benchmark_cpu() const;
132
149 [[nodiscard]] std::optional<std::chrono::milliseconds>
150 benchmark_gpu_feature(Halide::Target::Feature feature, const Halide::Buffer<float>& test_buffer) const;
151
155 Halide::Target m_winning_target;
156};
157
158} // namespace ImageProcessing
159
160} // namespace CaptureMoment::Core
Implements IBackendDecider using a runtime performance comparison strategy.
Common::MemoryType decide() override
Decides the optimal memory type (CPU or GPU) by running benchmarks.
const Halide::Target & getWinningTarget() const
Gets the winning Halide::Target object selected by decide().
Abstract interface defining the strategy for hardware backend selection.
Abstract interface for deciding the hardware backend (CPU or GPU) for image processing.
MemoryType
Enum representing the memory type where image data is stored.
Definition memory_type.h:24
@ ImageProcessing
Errors related to Image Processing, GPU, or Memory.
Manages the lifecycle of a single IWorkingImage instance.
CaptureMoment — footer