STIR  6.2.0
distributable.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2000 PARAPET partners
3  Copyright (C) 2000 - 2011, Hammersmith Imanet Ltd
4  Copyright (C) 2013, University College London
5  Copyright (C) 2022, University of Pennsylvania
6  This file is part of STIR.
7 
8  SPDX-License-Identifier: Apache-2.0 AND License-ref-PARAPET-license
9 
10  See STIR/LICENSE.txt for details
11 */
12 
13 #ifndef __stir_recon_buildblock_DISTRIBUTABLE_H__
14 #define __stir_recon_buildblock_DISTRIBUTABLE_H__
15 
29 #include "stir/shared_ptr.h"
30 #include "stir/Bin.h"
31 #include <vector>
32 
33 START_NAMESPACE_STIR
34 
35 template <typename elemT>
36 class RelatedViewgrams;
37 template <int num_dimensions, typename elemT>
38 class DiscretisedDensity;
39 class BinNormalisation;
40 class ProjData;
41 class ProjDataInfo;
42 class ExamInfo;
43 class DataSymmetriesForViewSegmentNumbers;
44 class ForwardProjectorByBin;
45 class BackProjectorByBin;
46 class ProjectorByBinPair;
47 class DistributedCachingInformation;
48 class ProjMatrixByBin;
49 
51 
52 const int task_stop_processing = 0;
54 const int task_setup_distributable_computation = 200;
55 const int task_do_distributable_gradient_computation = 42;
56 const int task_do_distributable_loglikelihood_computation = 43;
57 const int task_do_distributable_sensitivity_computation = 44;
59 
61 
69 void setup_distributable_computation(const shared_ptr<ProjectorByBinPair>& proj_pair_sptr,
70  const shared_ptr<const ExamInfo>& exam_info_sptr,
71  const shared_ptr<const ProjDataInfo> proj_data_info_sptr,
72  const shared_ptr<const DiscretisedDensity<3, float>>& target_sptr,
73  const bool zero_seg0_end_planes,
74  const bool distributed_cache_enabled);
75 
77 
82 
84 
93 typedef void RPC_process_related_viewgrams_type(const shared_ptr<ForwardProjectorByBin>& forward_projector_sptr,
94  const shared_ptr<BackProjectorByBin>& back_projector_sptr,
95  RelatedViewgrams<float>* measured_viewgrams_ptr,
96  int& count,
97  int& count2,
98  double* log_likelihood_ptr,
99  const RelatedViewgrams<float>* additive_binwise_correction_ptr,
100  const RelatedViewgrams<float>* mult_viewgrams_ptr);
101 
163 void distributable_computation(const shared_ptr<ForwardProjectorByBin>& forward_projector_sptr,
164  const shared_ptr<BackProjectorByBin>& back_projector_sptr,
165  const shared_ptr<DataSymmetriesForViewSegmentNumbers>& symmetries_sptr,
166  DiscretisedDensity<3, float>* output_image_ptr,
167  const DiscretisedDensity<3, float>* input_image_ptr,
168  const shared_ptr<ProjData>& proj_data_ptr,
169  const bool read_from_proj_data,
170  int subset_num,
171  int num_subsets,
172  int min_segment_num,
173  int max_segment_num,
174  bool zero_seg0_end_planes,
175  double* double_out_ptr,
176  const shared_ptr<ProjData>& additive_binwise_correction,
177  const shared_ptr<BinNormalisation> normalise_sptr,
178  const double start_time_of_frame,
179  const double end_time_of_frame,
180  RPC_process_related_viewgrams_type* RPC_process_related_viewgrams,
181  DistributedCachingInformation* caching_info_ptr,
182  int min_timing_pos_num,
183  int max_timing_pos_num);
184 
194 template <typename CallBackT>
195 void LM_distributable_computation(const shared_ptr<ProjMatrixByBin> PM_sptr,
196  const shared_ptr<ProjDataInfo>& proj_data_info_sptr,
197  DiscretisedDensity<3, float>* output_image_ptr,
198  const DiscretisedDensity<3, float>* input_image_ptr,
199  const std::vector<BinAndCorr>& record_cache,
200  const int subset_num,
201  const int num_subsets,
202  const bool has_add,
203  const bool accumulate,
204  double* double_out_ptr,
205  CallBackT&& call_back);
206 
210 const int AVAILABLE_NOTIFICATION_TAG = 2;
212 const int END_ITERATION_TAG = 3;
213 const int END_RECONSTRUCTION_TAG = 4;
214 const int END_NOTIFICATION_TAG = 5;
215 const int BINWISE_CORRECTION_TAG = 6;
216 const int BINWISE_MULT_TAG = 66;
217 const int REUSE_VIEWGRAM_TAG = 10;
218 const int NEW_VIEWGRAM_TAG = 11;
219 const int USE_DOUBLE_ARG_TAG = 70;
220 const int USE_OUTPUT_IMAGE_ARG_TAG = 71;
221 
223 
224 END_NAMESPACE_STIR
225 
226 #endif // __stir_recon_buildblock_DISTRIBUTABLE_H__
void RPC_process_related_viewgrams_type(const shared_ptr< ForwardProjectorByBin > &forward_projector_sptr, const shared_ptr< BackProjectorByBin > &back_projector_sptr, RelatedViewgrams< float > *measured_viewgrams_ptr, int &count, int &count2, double *log_likelihood_ptr, const RelatedViewgrams< float > *additive_binwise_correction_ptr, const RelatedViewgrams< float > *mult_viewgrams_ptr)
typedef for callback functions for distributable_computation()
Definition: distributable.h:93
This class implements the logic needed to support caching in a distributed manner.
Definition: DistributedCachingInformation.h:62
void LM_distributable_computation(const shared_ptr< ProjMatrixByBin > PM_sptr, const shared_ptr< ProjDataInfo > &proj_data_info_sptr, DiscretisedDensity< 3, float > *output_image_ptr, const DiscretisedDensity< 3, float > *input_image_ptr, const std::vector< BinAndCorr > &record_cache, const int subset_num, const int num_subsets, const bool has_add, const bool accumulate, double *double_out_ptr, CallBackT &&call_back)
This function essentially implements a loop over a cached listmode file.
Import of std::shared_ptr, std::dynamic_pointer_cast and std::static_pointer_cast (or corresponding b...
void end_distributable_computation()
clean-up after a sequence of computations
Definition: distributable.cxx:132
Declaration of class stir::Bin.
void distributable_computation(const shared_ptr< ForwardProjectorByBin > &forward_projector_sptr, const shared_ptr< BackProjectorByBin > &back_projector_sptr, const shared_ptr< DataSymmetriesForViewSegmentNumbers > &symmetries_sptr, DiscretisedDensity< 3, float > *output_image_ptr, const DiscretisedDensity< 3, float > *input_image_ptr, const shared_ptr< ProjData > &proj_data_ptr, const bool read_from_proj_data, int subset_num, int num_subsets, int min_segment_num, int max_segment_num, bool zero_seg0_end_planes, double *double_out_ptr, const shared_ptr< ProjData > &additive_binwise_correction, const shared_ptr< BinNormalisation > normalise_sptr, const double start_time_of_frame, const double end_time_of_frame, RPC_process_related_viewgrams_type *RPC_process_related_viewgrams, DistributedCachingInformation *caching_info_ptr, int min_timing_pos_num, int max_timing_pos_num)
This function essentially implements a loop over segments and all views in the current subset...
Definition: distributable.cxx:273
void setup_distributable_computation(const shared_ptr< ProjectorByBinPair > &proj_pair_sptr, const shared_ptr< const ExamInfo > &exam_info_sptr, const shared_ptr< const ProjDataInfo > proj_data_info_sptr, const shared_ptr< const DiscretisedDensity< 3, float >> &target_sptr, const bool zero_seg0_end_planes, const bool distributed_cache_enabled)
set-up parameters before calling distributable_computation()
Definition: distributable.cxx:80
const int task_stop_processing
Definition: distributable.h:53