1
/***************************************************************************
3
* Author: "Sjors H.W. Scheres"
4
* MRC Laboratory of Molecular Biology
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* This complete copyright notice must be included in any revised version of the
17
* source code. Additional authorship citations may be added, but existing
18
* author citations must be preserved.
19
***************************************************************************/
20
#include "src/particle_sorter_mpi.h"
22
void ParticleSorterMpi::read(int argc, char **argv)
24
// Define a new MpiNode
25
node = new MpiNode(argc, argv);
27
// First read in non-parallelisation-dependent variables
28
ParticleSorter::read(argc, argv);
30
// Don't put any output to screen for mpi slaves
31
verb = (node->isMaster()) ? 1 : 0;
33
// Possibly also read parallelisation-dependent variables here
36
printMpiNodesMachineNames(*node);
40
void ParticleSorterMpi::run()
43
int total_nr_images = MDin.numberOfObjects();
44
features.resize(total_nr_images, NR_FEATURES);
46
// Each node does part of the work
47
long int my_first_image, my_last_image, my_nr_images;
48
divide_equally(total_nr_images, node->size, node->rank, my_first_image, my_last_image);
49
my_nr_images = my_last_image - my_first_image + 1;
54
std::cout << "Calculating sorting features for all input particles..." << std::endl;
55
init_progress_bar(my_nr_images);
56
barstep = XMIPP_MAX(1, my_nr_images/ 60);
60
FOR_ALL_OBJECTS_IN_METADATA_TABLE(MDin)
63
if (ipart >= my_first_image && ipart <= my_last_image)
65
if (verb > 0 && ipart % barstep == 0)
68
calculateFeaturesOneParticle(ipart);
75
progress_bar(my_nr_images);
77
// Combine results from all nodes
78
MultidimArray<double> allnodes_features;
79
allnodes_features.resize(features);
80
MPI_Allreduce(MULTIDIM_ARRAY(features), MULTIDIM_ARRAY(allnodes_features), MULTIDIM_SIZE(features), MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
81
features = allnodes_features;
83
// Only the master writes out files