STIR  6.2.0
distributed_functions.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2007 - 2011/03/02, Hammersmith Imanet Ltd
3  Copyright (C) 2014, University College London
4  This file is part of STIR.
5 
6  SPDX-License-Identifier: Apache-2.0
7 
8  See STIR/LICENSE.txt for details
9 */
10 
11 #ifndef __stir_recon_buildblock_DistributedFunctions_h__
12 #define __stir_recon_buildblock_DistributedFunctions_h__
13 
40 #ifdef DOXYGEN_SKIP
41 // need to define the following to get the documentation
42 # define STIR_MPI
43 # define STIR_MPI_TIMINGS
44 #endif
45 
72 #include "mpi.h"
73 #include "stir/shared_ptr.h"
76 #include "stir/RelatedViewgrams.h"
77 #include "stir/Viewgram.h"
79 #include "stir/ProjDataInfo.h"
80 
81 namespace stir
82 {
83 class ExamInfo;
84 }
85 
86 namespace distributed
87 {
91 extern int num_processors;
93 
95 extern bool first_iteration;
96 
98 extern bool test;
99 
100 // for timings
101 extern bool rpc_time;
102 extern bool test_send_receive_times;
103 
104 extern double total_rpc_time;
105 extern double
107 extern double total_rpc_time_slaves;
108 extern double min_threshold;
109 
110 //----------------------Send operations----------------------------------
111 
116 void send_int_value(int value, int destination);
117 
123 void send_string(const std::string& str, int tag, int destination);
124 
132 void send_bool_value(bool value, int tag, int destination);
133 
140 void send_int_values(int* values, int count, int tag, int destination);
141 
148 void send_double_values(double* values, int count, int tag, int destination);
149 
155 void send_view_segment_numbers(const stir::ViewSegmentNumbers& vs_num, int tag, int destination);
156 
164 void send_projectors(const stir::shared_ptr<stir::ProjectorByBinPair>& proj_pair_sptr, int destination);
165 
178 void send_image_parameters(const stir::DiscretisedDensity<3, float>* input_image_ptr, int tag, int destination);
179 
187 void send_image_estimate(const stir::DiscretisedDensity<3, float>* input_image_ptr, int destination);
188 
204 void send_exam_and_proj_data_info(const stir::ExamInfo& exam_info, const stir::ProjDataInfo& proj_data_info, int destination);
205 
215 void send_related_viewgrams(stir::RelatedViewgrams<float>* viewgrams, int destination);
216 
226 void send_viewgram(const stir::Viewgram<float>& viewgram, int destination);
227 
228 //----------------------Receive operations----------------------------------
229 
234 int receive_int_value(int source);
235 
241 std::string receive_string(int tag, int source);
242 
255 void receive_and_initialize_projectors(stir::shared_ptr<stir::ProjectorByBinPair>& projector_pair_ptr, int source);
256 
265 bool receive_bool_value(int tag, int source);
266 
275 MPI_Status receive_int_values(int* values, int count, int tag);
276 
285 MPI_Status receive_double_values(double* values, int count, int tag);
286 
294 MPI_Status receive_view_segment_numbers(stir::ViewSegmentNumbers& vs_num, int tag);
295 
310  int& buffer,
311  int tag,
312  int source);
313 
326  int buffer_size,
327  int source);
328 
338 void receive_and_construct_exam_and_proj_data_info_ptr(stir::shared_ptr<stir::ExamInfo>& exam_info_sptr,
339  stir::shared_ptr<stir::ProjDataInfo>& proj_data_info_sptr,
340  int source);
341 
364  const stir::shared_ptr<stir::ProjDataInfo>& proj_data_info_ptr,
365  const stir::shared_ptr<stir::DataSymmetriesForViewSegmentNumbers> symmetries_sptr,
366  int source);
367 
382  const stir::shared_ptr<stir::ProjDataInfo>& proj_data_info_ptr,
383  int source);
384 
385 //-----------------------reduce operations-------------------------------------
386 
391 void reduce_received_output_image(stir::DiscretisedDensity<3, float>* output_image_ptr, int destination);
392 
402 void reduce_output_image(stir::shared_ptr<stir::DiscretisedDensity<3, float>>& output_image_ptr,
403  int image_buffer_size,
404  int my_rank,
405  int destination);
406 
409 const int INT_TAG = 7;
411 const int ARBITRARY_TAG = 8;
412 const int STIR_MPI_CONF_TAG = 9;
413 const int IMAGE_ESTIMATE_TAG = 23;
414 const int IMAGE_PARAMETER_TAG = 24;
415 const int VIEWGRAM_DIMENSIONS_TAG = 27;
416 const int VIEWGRAM_TAG = 28;
417 const int VIEWGRAM_COUNT_TAG = 29;
418 const int PROJECTION_DATA_INFO_TAG = 30;
419 const int PARAMETER_INFO_TAG = 21;
420 const int REGISTERED_NAME_TAG = 25;
422 } // namespace distributed
423 
424 #endif
Namespace for the STIR library (and some/most of its applications)
Definition: General_Reconstruction.cxx:6
bool test
enable/disable tests
Definition: distributed_functions.cxx:47
void receive_and_initialize_projectors(stir::shared_ptr< stir::ProjectorByBinPair > &projector_pair_ptr, int source)
receives all needed information to subsequently construct a ProjectorByBinPair object ...
Definition: distributed_functions.cxx:524
MPI_Status receive_image_values_and_fill_image_ptr(stir::shared_ptr< stir::DiscretisedDensity< 3, float >> &image_ptr, int buffer_size, int source)
receives the values of a DiscretisedDensity object
Definition: distributed_functions.cxx:745
void send_int_value(int value, int destination)
threshold for displaying send/receive times, initially set to 0.1 seconds
Definition: distributed_functions.cxx:66
MPI_Status receive_int_values(int *values, int count, int tag)
receives some integer values
Definition: distributed_functions.cxx:612
void reduce_received_output_image(stir::DiscretisedDensity< 3, float > *output_image_ptr, int destination)
the function called by the master to reduce the output image
Definition: distributed_functions.cxx:908
Declaration of class stir::ProjDataInfo.
const int ARBITRARY_TAG
special tag, equivalent to MPI_ANY_TAG in some functions
Definition: distributed_functions.h:411
void receive_and_set_image_parameters(stir::shared_ptr< stir::DiscretisedDensity< 3, float >> &image_ptr, int &buffer, int tag, int source)
receives the parameters of a DiscretisedDensity object
Definition: distributed_functions.cxx:679
void send_bool_value(bool value, int tag, int destination)
send or broadcast a bool value
Definition: distributed_functions.cxx:131
double total_rpc_time_2
adding up the time used for PRC_process_related_viewgrams_gradient() computation at all slaves ...
Definition: distributed_functions.cxx:46
void receive_and_construct_viewgram(stir::Viewgram< float > *&viewgram, const stir::shared_ptr< stir::ProjDataInfo > &proj_data_info_ptr, int source)
receives a Viewgram object
Definition: distributed_functions.cxx:863
Namespace for distributed computation with MPI.
void send_image_parameters(const stir::DiscretisedDensity< 3, float > *input_image_ptr, int tag, int destination)
sends or broadcasts the parameters of a DiscretisedDensity object
Definition: distributed_functions.cxx:227
Import of std::shared_ptr, std::dynamic_pointer_cast and std::static_pointer_cast (or corresponding b...
void receive_and_construct_related_viewgrams(stir::RelatedViewgrams< float > *&viewgrams, const stir::shared_ptr< stir::ProjDataInfo > &proj_data_info_ptr, const stir::shared_ptr< stir::DataSymmetriesForViewSegmentNumbers > symmetries_sptr, int source)
receives and constructs a RelatedViewgrams object
Definition: distributed_functions.cxx:833
void reduce_output_image(stir::shared_ptr< stir::DiscretisedDensity< 3, float >> &output_image_ptr, int image_buffer_size, int my_rank, int destination)
the function called by the slaves to reduce the output image
Definition: distributed_functions.cxx:956
defines the stir::DiscretisedDensity class
std::string receive_string(int tag, int source)
receives a string
Definition: distributed_functions.cxx:496
Declaration of class stir::RelatedViewgrams.
int num_processors
the number of processes used for distributed computation
Definition: distributed_functions.cxx:50
bool receive_bool_value(int tag, int source)
receives a bool value
Definition: distributed_functions.cxx:584
void send_related_viewgrams(stir::RelatedViewgrams< float > *viewgrams, int destination)
sends a RelatedViegrams object
Definition: distributed_functions.cxx:397
void send_exam_and_proj_data_info(const stir::ExamInfo &exam_info, const stir::ProjDataInfo &proj_data_info, int destination)
sends or broadcasts the information from ExamInfo and ProjDataInfo
Definition: distributed_functions.cxx:338
MPI_Status receive_double_values(double *values, int count, int tag)
receives some double values
Definition: distributed_functions.cxx:642
MPI_Status receive_view_segment_numbers(stir::ViewSegmentNumbers &vs_num, int tag)
receive a ViewSegmentNumbers object
Definition: distributed_functions.cxx:669
void send_string(const std::string &str, int tag, int destination)
sends or broadcasts a string
Definition: distributed_functions.cxx:92
Declaration of class stir::Viewgram.
void send_view_segment_numbers(const stir::ViewSegmentNumbers &vs_num, int tag, int destination)
send or broadcast ViewSegmentNumbers object
Definition: distributed_functions.cxx:218
bool first_iteration
some stuff in distributable_computation needs to be done only in the first iteration ...
Definition: distributed_functions.cxx:54
alias for ViewgramIndices
Definition: ViewSegmentNumbers.h:33
void send_double_values(double *values, int count, int tag, int destination)
send or broadcast double values
Definition: distributed_functions.cxx:190
void send_image_estimate(const stir::DiscretisedDensity< 3, float > *input_image_ptr, int destination)
sends or broadcasts the values of a DiscretisedDensity object
Definition: distributed_functions.cxx:302
void receive_and_construct_exam_and_proj_data_info_ptr(stir::shared_ptr< stir::ExamInfo > &exam_info_sptr, stir::shared_ptr< stir::ProjDataInfo > &proj_data_info_sptr, int source)
receives information of ExamInfo and ProjDataInfo objects and constructs new ones from it ...
Definition: distributed_functions.cxx:779
double total_rpc_time
enable timings for every single send/receive operation
Definition: distributed_functions.cxx:43
a class for storing information about 1 exam (or scan)
Definition: ExamInfo.h:41
defines the stir::VoxelsOnCartesianGrid class
An (abstract base) class that contains information on the projection data.
Definition: ProjDataInfo.h:69
double total_rpc_time_slaves
adding up the time used for PRC_process_related_viewgrams_gradient() computation at a single slave ...
Definition: distributed_functions.cxx:45
double min_threshold
value to reduce the total_rpc_time values
Definition: distributed_functions.cxx:44
bool test_send_receive_times
enable timings for PRC_process_related_viewgrams_gradient() computation
Definition: distributed_functions.cxx:41
void send_projectors(const stir::shared_ptr< stir::ProjectorByBinPair > &proj_pair_sptr, int destination)
send or broadcast a projector-pair object
Definition: distributed_functions.cxx:457
void send_viewgram(const stir::Viewgram< float > &viewgram, int destination)
sends a Viewgram object
Definition: distributed_functions.cxx:416
int receive_int_value(int source)
receives a single integer value
Definition: distributed_functions.cxx:469
Declares class stir::ProjectorByBinPair.
void send_int_values(int *values, int count, int tag, int destination)
sends or broadcasts some integer values
Definition: distributed_functions.cxx:161