44 #ifndef RUN_IMP_ON_INPUT_BP_H_
45 #define RUN_IMP_ON_INPUT_BP_H_
50 #if defined(OPTIMIZED_CPU_RUN)
54 template <RunData_t T,
unsigned int DISP_VALS, run_environment::AccSetting ACCELERATION>
59 #if defined(OPTIMIZED_CUDA_RUN)
63 template <RunData_t T,
unsigned int DISP_VALS, run_environment::AccSetting ACCELERATION>
81 inline std::map<std::array<filepathtype, 2>, std::tuple<std::chrono::duration<double>,
RunData,
filepathtype>>
94 template<RunData_t T, run_environment::AccSetting OPT_IMP_ACCEL,
unsigned int NUM_INPUT>
132 bool loop_iters_templated)
const override;
148 std::shared_ptr<ParallelParams> parallel_params,
149 bool run_opt_imp_only,
150 bool run_imp_templated_loop_iters)
const override;
159 run_bp_stereo_single_thread_;
167 run_opt_bp_num_iters_templated_;
171 std::unique_ptr<RunBpOnStereoSet<T, 0, OPT_IMP_ACCEL>>
172 run_opt_bp_num_iters_no_template_;
183 template<RunData_t T, run_environment::AccSetting OPT_IMP_ACCEL,
unsigned int NUM_INPUT>
188 alg_settings_.num_disp_vals =
190 alg_settings_.disc_k_bp =
191 (float)alg_settings_.num_disp_vals / 7.5f;
197 run_bp_stereo_single_thread_ =
211 run_opt_bp_num_iters_templated_ =
212 std::make_unique<RunBpOptimized<
216 constexpr
bool run_w_loop_iters_templated{
true};
218 sizeof(T), NUM_INPUT, run_w_loop_iters_templated);
221 this->RunEvalBenchmark(
223 run_w_loop_iters_templated)});
228 run_opt_bp_num_iters_no_template_ =
229 std::make_unique<RunBpOptimized<T, 0, OPT_IMP_ACCEL>>();
230 constexpr
bool run_w_loop_iters_templated{
false};
232 sizeof(T), NUM_INPUT, run_w_loop_iters_templated);
235 this->RunEvalBenchmark(
237 run_w_loop_iters_templated)});
246 template<RunData_t T, run_environment::AccSetting OPT_IMP_ACCEL,
unsigned int NUM_INPUT>
247 std::shared_ptr<ParallelParams>
253 return std::make_shared<ParallelParamsBp>(
255 alg_settings_.num_levels,
261 template<RunData_t T, run_environment::AccSetting OPT_IMP_ACCEL,
unsigned int NUM_INPUT>
263 bool loop_iters_templated)
const
269 curr_run_data.
AppendData(this->InputAndParamsRunData(loop_iters_templated));
270 curr_run_data.
AppendData(alg_settings_.AsRunData());
272 return curr_run_data;
279 template<RunData_t T, run_environment::AccSetting OPT_IMP_ACCEL,
unsigned int NUM_INPUT>
281 std::shared_ptr<ParallelParams> parallel_params,
282 bool run_opt_imp_only,
283 bool run_imp_templated_loop_iters)
const
288 const std::array<filepathtype, 2> ref_test_image_path{
295 const unsigned int num_imps_run{run_opt_imp_only ? 1u : 2u};
296 std::array<filepathtype, 2> output_disp;
297 for (
unsigned int i=0; i < num_imps_run; i++) {
304 const std::string opt_imp_run_description{
305 run_imp_templated_loop_iters ?
306 run_opt_bp_num_iters_templated_->BpRunDescription() :
307 run_opt_bp_num_iters_no_template_->BpRunDescription()};
308 std::cout <<
"Running belief propagation on reference image "
309 << ref_test_image_path[0] <<
" and test image "
310 << ref_test_image_path[1] <<
" on " << opt_imp_run_description;
311 if (!run_opt_imp_only) {
312 std::cout <<
" and " << run_bp_stereo_single_thread_->BpRunDescription();
314 std::cout << std::endl;
315 std::cout <<
"Data size: " <<
sizeof(T) << std::endl;
316 std::cout <<
"run_imp_templated_loop_iters: " << run_imp_templated_loop_iters << std::endl;
317 std::cout <<
"Acceleration: " << run_environment::AccelerationString<OPT_IMP_ACCEL>() << std::endl;
318 std::cout << std::endl;
322 std::map<run_environment::AccSetting, std::optional<beliefprop::BpRunOutput>>
324 if (run_imp_templated_loop_iters) {
325 run_output[OPT_IMP_ACCEL] = run_opt_bp_num_iters_templated_->operator()(
326 {ref_test_image_path[0].string(), ref_test_image_path[1].string()},
331 run_output[OPT_IMP_ACCEL] = run_opt_bp_num_iters_no_template_->operator()(
332 {ref_test_image_path[0].string(), ref_test_image_path[1].string()},
341 opt_imp_run_description);
342 if (!(run_output[OPT_IMP_ACCEL])) {
347 run_data.
AppendData(run_output[OPT_IMP_ACCEL]->run_data);
350 run_output[OPT_IMP_ACCEL]->run_time.count());
353 run_output[OPT_IMP_ACCEL]->out_disparity_map.SaveDisparityMap(
354 output_disp[0].
string(),
359 if (!run_opt_imp_only) {
368 run_bp_stereo_single_thread_->operator()(
369 {ref_test_image_path[0].string(), ref_test_image_path[1].string()},
378 output_disp[1].
string(),
385 {ref_test_image_path,
409 for (
unsigned int i = 0; i < num_imps_run; i++) {
410 const std::string run_description{(i == 0) ?
411 opt_imp_run_description :
412 run_bp_stereo_single_thread_->BpRunDescription()};
413 std::cout <<
"Output disparity map from " << run_description
414 <<
" run at " << output_disp[i] << std::endl;
416 std::cout << std::endl;
422 ground_truth_disp.string(),
425 opt_imp_run_description +
" output vs. Ground Truth result",
428 run_output[OPT_IMP_ACCEL]->out_disparity_map.OutputComparison(
429 ground_truth_disparity_map,
431 if (!run_opt_imp_only) {
433 run_bp_stereo_single_thread_->BpRunDescription() +
" output vs. Ground Truth result",
437 ground_truth_disparity_map,
440 opt_imp_run_description +
" output vs. " +
441 run_bp_stereo_single_thread_->BpRunDescription() +
" result",
444 run_output[OPT_IMP_ACCEL]->out_disparity_map.OutputComparison(
File with namespace for enums, constants, structures, and functions specific to belief propagation pr...
Header file that contains information about the stereo sets used for evaluation of the bp implementat...
Declares class to retrieve path of stereo set files for reading and for output.
std::map< InputSignature, std::optional< std::map< run_environment::ParallelParamsSetting, RunData > >> MultRunData
Alias mapping input signature to run data for each parallel parameters setting Run data is null if r...
Declares child class of RunBpOnStereoSet to run CUDA implementation of belief propagation on a given ...
Declares child class of RunBpOnStereoSet to run optimized CPU implementation of belief propagation on...
Contains namespace with enums and constants for implementation run evaluation.
Declares and defines structure that stores settings for current implementation run as well as functio...
Define constraints for data type in processing.
Class to retrieve path of stereo set files for reading and for output.
std::filesystem::path RefImagePath() const
Return path to reference image with valid extension if found, otherwise throw filesystem error.
const std::filesystem::path GroundTruthDisparityFilePath() const
Get file path to ground truth disparity map.
const std::filesystem::path GetCurrentOutputDisparityFilePathAndIncrement()
Return path to use for current output disparity and then increment (to support multiple computed outp...
std::filesystem::path TestImagePath() const
Return path to test image with valid extension if found, otherwise throw filesystem error.
Child class of RunBpOnStereoSet to run CUDA implementation of belief propagation on a given stereo se...
Abstract class to set up and run belief propagation on target device using specified acceleration.
Child class of RunBpOnStereoSet to run optimized CPU implementation of belief propagation on a given ...
Child class of RunBpOnStereoSet to run single-threaded CPU implementation of belief propagation on a ...
Class to store headers with data corresponding to current program run and evaluation.
void AppendData(const RunData &rundata)
Append current RunData with input RunData.
void AddDataWHeader(const std::string &header, const std::string &data)
Add string data with header describing added data.
constexpr std::string_view kStereoSetHeader
RunData RunSettings()
Retrieve run settings as a RunData object for output.
constexpr std::array< BpStereoSet, 8 > kStereoSetsToProcess
Declare stereo sets to process with name, num disparity values, and scale factor currently conesFullS...
Namespace with setting of whether or not to run single thread implementation a single time for each i...
constexpr bool kRunSingleThreadOnceForSet
Setting of whether or not to run single thread implementation once for each stereo set in evaluation.
std::map< std::array< filepathtype, 2 >, std::tuple< std::chrono::duration< double >, RunData, filepathtype > > single_thread_run_output
Map to store output and run results for single thread implementation for each stereo set.
constexpr std::string_view kAccelerationDescHeader
Constant string for acceleration.
constexpr std::string_view kOptimizedRuntimeHeader
Structure with output disparity map, runtime, and other evaluation data.
Structure to store the belief propagation settings including the number of levels and iterations.
Struct to store parameters for evaluation of disparity map from stereo processing.
Structure that stores settings for current implementation run.
TemplatedItersSetting templated_iters_setting
std::pair< std::array< unsigned int, 2 >, std::set< std::array< unsigned int, 2 > > > p_params_default_alt_options
OptParallelParamsSetting opt_parallel_params_setting