27 #include <sys/resource.h> 40 this->
read(argc, argv);
65 double comms_t=0., aux_comm_t;
72 double comms_t_it, aux_t;
82 total_t = MPI_Wtime();
89 std::cout <<
" ---------------------------------------------------------------------" << std::endl;
96 aux_comm_t = MPI_Wtime();
98 comms_t += MPI_Wtime() - aux_comm_t;
120 num_img_tot = artPrm.
numIMG;
122 Npart = (int)((
float)num_img_tot / (float)
nProcs);
124 num_img_node = Npart;
126 remaining = num_img_tot %
nProcs;
129 if (
node->rank < remaining)
132 myFirst =
node->rank * Npart +
node->rank;
135 myFirst = Npart *
node->rank + remaining;
157 std::cout <<
" Parallel mode : " ;
159 std::cout <<
"pSART " <<
"BlockSize = " << artPrm.
block_size << std::endl;
161 std::cout <<
"pSIRT" << std::endl;
163 std::cout <<
"pfSIRT" << std::endl;
165 std::cout <<
"pBiCAV " <<
"BlockSize = " << artPrm.
block_size << std::endl;
167 std::cout <<
"pAVSP" << std::endl;
169 std::cout <<
"pCAV" << std::endl;
171 std::cout <<
"ART" << std::endl;
173 std::cout <<
"SIRT" << std::endl;
174 std::cout <<
" Number of processors : " << nProcs << std::endl;
175 std::cout <<
" ---------------------------------------------------------------------" << std::endl;
190 GVNeq_aux = *(artPrm.
GVNeq);
192 MPI_Barrier(MPI_COMM_WORLD);
193 for (
size_t n = 0 ;
n < (artPrm.
GVNeq)->VolumesNo();
n++)
195 aux_comm_t = MPI_Wtime();
199 comms_t += MPI_Wtime() - aux_comm_t;
200 (*(artPrm.
GVNeq))(
n)() = GVNeq_aux(
n)();
203 std::cout <<
"Elapsed time for pCAV weights computation : " << MPI_Wtime() - cav_t << std::endl;
209 int num_iter = artPrm.
no_it;
212 for (
int i = 0;
i < num_iter;
i++)
223 int numsteps = num_img_node / artPrm.
block_size;
227 bool oneMoreStep = (stepR = num_img_node % artPrm.
block_size) != 0;
235 for (
int ns = 0; ns < numsteps ; ns++)
238 if (ns == numsteps - 2 && oneMoreStep)
239 blockSizeTot = (artPrm.
block_size - 1) * nProcs + stepR;
240 else if (ns == numsteps - 1)
244 blockSizeTot = artPrm.
numIMG * stepR;
250 vol_aux2(
j)() = vol_basis(
j)();
262 vol_basis(
j)() = vol_basis(
j)() - vol_aux2(
j)();
263 aux_comm_t = MPI_Wtime();
267 MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
268 aux_t = MPI_Wtime() - aux_comm_t;
271 vol_basis(
j)() = vol_aux2(
j)() + (vol_basis_aux(
j)() / (
double) blockSizeTot);
280 int numsteps = num_img_node / artPrm.
block_size;
293 for (
int ns = 0; ns < numsteps ; ns++)
295 if (ns == numsteps - 1)
296 artPrm.
numIMG = num_img_node - processed;
307 GVNeq_aux = *(artPrm.
GVNeq);
313 for (
size_t n = 0 ;
n < (artPrm.
GVNeq)->VolumesNo();
n++)
315 aux_comm_t = MPI_Wtime();
319 aux_t = MPI_Wtime() - aux_comm_t;
322 (*(artPrm.
GVNeq))(
n)() = GVNeq_aux(
n)();
324 cavk_it_t += MPI_Wtime() - cav_t;
326 for (
size_t jj = 0 ; jj < vol_basis.
VolumesNo() ; jj++)
327 vol_aux2(jj)() = vol_basis(jj)();
331 if (ns < (numsteps - 1))
334 processed += artPrm.
numIMG;
340 for (
size_t jj = 0 ; jj < vol_basis.
VolumesNo() ; jj++)
342 vol_basis(jj)() = vol_basis(jj)() - vol_aux2(jj)();
343 aux_comm_t = MPI_Wtime();
347 MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
348 aux_t = MPI_Wtime() - aux_comm_t;
375 vol_aux2(
j)() = vol_basis(
j)();
377 artPrm.
numIMG = num_img_node;
385 MPI_Barrier(MPI_COMM_WORLD);
386 for (
size_t jj = 0 ; jj < vol_basis.
VolumesNo() ; jj++)
388 vol_basis(jj)() = vol_basis(jj)() - vol_aux2(jj)();
389 aux_comm_t = MPI_Wtime();
393 MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
394 aux_t = MPI_Wtime() - aux_comm_t;
418 artPrm.
numIMG = num_img_node;
425 for (
size_t jj = 0 ; jj < vol_basis.
VolumesNo() ; jj++)
426 vol_aux2(jj)() = vol_basis(jj)();
433 MPI_Barrier(MPI_COMM_WORLD);
434 for (
size_t jj = 0 ; jj < vol_basis.
VolumesNo() ; jj++)
439 vol_basis(jj)() = vol_basis(jj)() - vol_aux2(jj)();
441 aux_comm_t = MPI_Wtime();
446 MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
448 aux_t = MPI_Wtime() - aux_comm_t;
454 auto norm_value = (double) num_img_tot;
455 vol_basis(jj)() = vol_aux2(jj)() + (vol_basis_aux(jj)() / norm_value);
459 double norm_value = (double) num_img_tot * (
double)(artPrm.
ProjXdim() * artPrm.
ProjYdim());
460 vol_basis(jj)() = vol_aux2(jj)() + (vol_basis_aux(jj)() / norm_value);
464 vol_basis(jj)() = vol_basis_aux(jj)();
465 vol_basis(jj)() /= nProcs;
469 cavk_total_t += cavk_it_t;
474 std::cout <<
"\nIteration " <<
i << std::endl;
475 std::cout <<
"Time: " << MPI_Wtime() - it_t <<
" secs." << std::endl;
476 std::cout <<
"Comms. time: " << comms_t_it <<
" secs." << std::endl;
478 std::cout <<
"BiCAV weighting time: " << cavk_it_t << std::endl;
486 if (
node->isMaster())
495 Zoutput_volume_size, Youtput_volume_size, Xoutput_volume_size);
504 std::cout <<
"\n\n------ FINAL STATISTICS ------" << std::endl;
505 std::cout <<
"\nTOTAL EXECUTION TIME: " << recons_t.
wall - total_t << std::endl;
506 std::cout <<
"Communications time: " << comms_t <<
" secs." << std::endl;
507 std::cout <<
"CPU time: " << recons_t.
user + recons_t.
sys <<
" secs." << std::endl;
508 std::cout <<
"USER: " << recons_t.
user <<
" SYSTEM: " << recons_t.
sys << std::endl;
510 std::cout <<
"\nTotal pBiCAV Weighting time: " << cavk_total_t << std::endl;
523 struct rusage buffer;
525 tm->
wall = MPI_Wtime();
526 getrusage(RUSAGE_SELF, &buffer);
527 tm->
user = (double) buffer.ru_utime.tv_sec + 1.0e-6 * buffer.ru_utime.tv_usec;
528 tm->
sys = (
double) buffer.ru_stime.tv_sec + 1.0e-6 * buffer.ru_stime.tv_usec;
int numIMG
Total number of images to process (taking symmetries into account)
size_t projXdim
Projection X dimension.
Basis basis
Basis function. By default, blobs.
#define REPORT_ERROR(nerr, ErrormMsg)
void initHistory(const GridVolume &vol_basis0)
void write(const FileName &name="", size_t select_img=ALL_IMAGES, bool isStack=false, int mode=WRITE_OVERWRITE, CastWriteMode castMode=CW_CAST, int _swapWrite=0)
#define MULTIDIM_ARRAY(v)
String integerToString(int I, int _width, char fill_with)
std::ofstream * fh_hist
File handler for the history file.
size_t projYdim
Projection Y dimension.
void changeToVoxels(GridVolume &vol_basis, MultidimArray< double > *vol_voxels, int Zdim, int Ydim, int Xdim, int threads=1) const
ql0001_ & k(htemp+1),(cvec+1),(atemp+1),(bj+1),(bl+1),(bu+1),(x+1),(clamda+1), &iout, infoqp, &zero,(w+1), &lenw,(iw+1), &leniw, &glob_grd.epsmac
int block_size
Number of projections for each parallel block.
#define A3D_ELEM(V, k, i, j)
int argc
Original command line arguments.
#define FOR_ALL_ELEMENTS_IN_ARRAY3D(V)
void uswtime(USWtime_t *tm)
GridVolumeT< int > * GVNeq
ARTReconsBase * artRecons
virtual void preProcess(GridVolume &vol_basis0, int level=FULL, int rank=-1)
Produce Plain side information from the Class parameters.
std::shared_ptr< MpiNode > node
ARTParallelMode parallel_mode
int verbose
Verbosity level.
void computeCAVWeights(GridVolume &vol_basis0, int numProjs_node, int debug_level=0)
int no_it
Number of iterations.
void write(const FileName &fn) const
MultidimArray< int > ordered_list
Order in which projections will be presented to algorithm.
void setNode(const std::shared_ptr< MpiNode > &node)
void iterations(GridVolume &vol_basis, int rank=-1)
BasicARTParameters artPrm
Incorrect value received.
void read(int argc, char **argv)
Matrix1D< double > lambda_list
Relaxation parameter.