STIR 6.4.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
23
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
48
71
72#include "mpi.h"
73#include "stir/shared_ptr.h"
77#include "stir/Viewgram.h"
79#include "stir/ProjDataInfo.h"
80
81namespace stir
82{
83class ExamInfo;
84}
85
86namespace distributed
87{
91
92extern int num_processors;
93
95extern bool first_iteration;
96
98extern bool test;
99
100// for timings
101extern bool rpc_time;
102extern bool test_send_receive_times;
103
104extern double total_rpc_time;
105extern double
107extern double total_rpc_time_slaves;
108extern double min_threshold;
109
110//----------------------Send operations----------------------------------
111
116void send_int_value(int value, int destination);
117
123void send_string(const std::string& str, int tag, int destination);
124
132void send_bool_value(bool value, int tag, int destination);
133
140void send_int_values(int* values, int count, int tag, int destination);
141
148void send_double_values(double* values, int count, int tag, int destination);
149
155void send_view_segment_numbers(const stir::ViewSegmentNumbers& vs_num, int tag, int destination);
156
164void send_projectors(const stir::shared_ptr<stir::ProjectorByBinPair>& proj_pair_sptr, int destination);
165
178void send_image_parameters(const stir::DiscretisedDensity<3, float>* input_image_ptr, int tag, int destination);
179
187void send_image_estimate(const stir::DiscretisedDensity<3, float>* input_image_ptr, int destination);
188
204void send_exam_and_proj_data_info(const stir::ExamInfo& exam_info, const stir::ProjDataInfo& proj_data_info, int destination);
205
215void send_related_viewgrams(stir::RelatedViewgrams<float>* viewgrams, int destination);
216
226void send_viewgram(const stir::Viewgram<float>& viewgram, int destination);
227
228//----------------------Receive operations----------------------------------
229
234int receive_int_value(int source);
235
241std::string receive_string(int tag, int source);
242
255void receive_and_initialize_projectors(stir::shared_ptr<stir::ProjectorByBinPair>& projector_pair_ptr, int source);
256
265bool receive_bool_value(int tag, int source);
266
275MPI_Status receive_int_values(int* values, int count, int tag);
276
285MPI_Status receive_double_values(double* values, int count, int tag);
286
294MPI_Status receive_view_segment_numbers(stir::ViewSegmentNumbers& vs_num, int tag);
295
309void receive_and_set_image_parameters(stir::shared_ptr<stir::DiscretisedDensity<3, float>>& image_ptr,
310 int& buffer,
311 int tag,
312 int source);
313
325MPI_Status receive_image_values_and_fill_image_ptr(stir::shared_ptr<stir::DiscretisedDensity<3, float>>& image_ptr,
326 int buffer_size,
327 int source);
328
338void 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
363void receive_and_construct_related_viewgrams(stir::RelatedViewgrams<float>*& viewgrams,
364 const stir::shared_ptr<stir::ProjDataInfo>& proj_data_info_ptr,
365 const stir::shared_ptr<stir::DataSymmetriesForViewSegmentNumbers> symmetries_sptr,
366 int source);
367
381void receive_and_construct_viewgram(stir::Viewgram<float>*& viewgram,
382 const stir::shared_ptr<stir::ProjDataInfo>& proj_data_info_ptr,
383 int source);
384
385//-----------------------reduce operations-------------------------------------
386
391void reduce_received_output_image(stir::DiscretisedDensity<3, float>* output_image_ptr, int destination);
392
402void 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
410const int INT_TAG = 7;
411const int ARBITRARY_TAG = 8;
412const int STIR_MPI_CONF_TAG = 9;
413const int IMAGE_ESTIMATE_TAG = 23;
414const int IMAGE_PARAMETER_TAG = 24;
415const int VIEWGRAM_DIMENSIONS_TAG = 27;
416const int VIEWGRAM_TAG = 28;
417const int VIEWGRAM_COUNT_TAG = 29;
418const int PROJECTION_DATA_INFO_TAG = 30;
419const int PARAMETER_INFO_TAG = 21;
420const int REGISTERED_NAME_TAG = 25;
422} // namespace distributed
423
424#endif
defines the stir::DiscretisedDensity class
Declaration of class stir::ProjDataInfo.
Declares class stir::ProjectorByBinPair.
Declaration of class stir::RelatedViewgrams.
Declaration of class stir::Viewgram.
defines the stir::VoxelsOnCartesianGrid class
Namespace for distributed computation with MPI.
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 send_view_segment_numbers(const stir::ViewSegmentNumbers &vs_num, int tag, int destination)
send or broadcast ViewSegmentNumbers object
Definition distributed_functions.cxx:218
void send_int_values(int *values, int count, int tag, int destination)
sends or broadcasts some integer values
Definition distributed_functions.cxx:161
MPI_Status receive_double_values(double *values, int count, int tag)
receives some double values
Definition distributed_functions.cxx:642
bool first_iteration
some stuff in distributable_computation needs to be done only in the first iteration
Definition distributed_functions.cxx:54
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
bool test
enable/disable tests
Definition distributed_functions.cxx:47
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
std::string receive_string(int tag, int source)
receives a string
Definition distributed_functions.cxx:496
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
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
bool test_send_receive_times
enable timings for PRC_process_related_viewgrams_gradient() computation
Definition distributed_functions.cxx:41
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
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
void send_related_viewgrams(stir::RelatedViewgrams< float > *viewgrams, int destination)
sends a RelatedViegrams object
Definition distributed_functions.cxx:397
void send_double_values(double *values, int count, int tag, int destination)
send or broadcast double values
Definition distributed_functions.cxx:190
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
const int ARBITRARY_TAG
special tag, equivalent to MPI_ANY_TAG in some functions
Definition distributed_functions.h:411
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
MPI_Status receive_int_values(int *values, int count, int tag)
receives some integer values
Definition distributed_functions.cxx:612
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
bool receive_bool_value(int tag, int source)
receives a bool value
Definition distributed_functions.cxx:584
double min_threshold
value to reduce the total_rpc_time values
Definition distributed_functions.cxx:44
MPI_Status receive_view_segment_numbers(stir::ViewSegmentNumbers &vs_num, int tag)
receive a ViewSegmentNumbers object
Definition distributed_functions.cxx:669
int receive_int_value(int source)
receives a single integer value
Definition distributed_functions.cxx:469
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
void send_bool_value(bool value, int tag, int destination)
send or broadcast a bool value
Definition distributed_functions.cxx:131
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
double total_rpc_time
enable timings for every single send/receive operation
Definition distributed_functions.cxx:43
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 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
void send_viewgram(const stir::Viewgram< float > &viewgram, int destination)
sends a Viewgram object
Definition distributed_functions.cxx:416
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
void send_string(const std::string &str, int tag, int destination)
sends or broadcasts a string
Definition distributed_functions.cxx:92
int num_processors
the number of processes used for distributed computation
Definition distributed_functions.cxx:50
Namespace for the STIR library (and some/most of its applications)
Definition General_Reconstruction.h:19
Import of std::shared_ptr, std::dynamic_pointer_cast and std::static_pointer_cast into the stir names...