Skip to content

Commit e2c0535

Browse files
authored
Merge pull request #991 from I2PC/jmk_new_residuals
first version of new continuous_create_residuals
2 parents e0f6780 + 14c627f commit e2c0535

File tree

7 files changed

+1079
-1
lines changed

7 files changed

+1079
-1
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
## Release 3.24.X -
22
### Xmipp Programs
33
- New programs
4-
-
4+
- continuous_create_residuals: Make better residuals by continuous assignment updates to projections
55

66
- Programs updated
77
-
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/***************************************************************************
2+
*
3+
* Authors: Carlos Oscar S. Sorzano (coss@cnb.csic.es)
4+
* James Krieger jamesmkrieger@gmail.com
5+
*
6+
* Unidad de Bioinformatica of Centro Nacional de Biotecnologia , CSIC
7+
*
8+
* This program is free software; you can redistribute it and/or modify
9+
* it under the terms of the GNU General Public License as published by
10+
* the Free Software Foundation; either version 2 of the License, or
11+
* (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU General Public License
19+
* along with this program; if not, write to the Free Software
20+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21+
* 02111-1307 USA
22+
*
23+
* All comments concerning this program package may be sent to the
24+
* e-mail address 'xmipp@cnb.csic.es'
25+
***************************************************************************/
26+
27+
#include <reconstruction/continuous_create_residuals.h>
28+
29+
RUN_XMIPP_PROGRAM(ProgContinuousCreateResiduals)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/***************************************************************************
2+
*
3+
* Authors: Carlos Oscar Sanchez Sorzano coss@cnb.csic.es
4+
* James Krieger jamesmkrieger@gmail.com
5+
*
6+
* Unidad de Bioinformatica of Centro Nacional de Biotecnologia , CSIC
7+
*
8+
* This program is free software; you can redistribute it and/or modify
9+
* it under the terms of the GNU General Public License as published by
10+
* the Free Software Foundation; either version 2 of the License, or
11+
* (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU General Public License
19+
* along with this program; if not, write to the Free Software
20+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21+
* 02111-1307 USA
22+
*
23+
* All comments concerning this program package may be sent to the
24+
* e-mail address 'xmipp@cnb.uam.es'
25+
***************************************************************************/
26+
27+
#include <parallel/mpi_continuous_create_residuals.cpp>
28+
29+
RUN_XMIPP_PROGRAM(MpiProgContinuousCreateResiduals)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
/***************************************************************************
2+
*
3+
* Authors: Carlos Oscar Sanchez Sorzano coss@cnb.csic.es
4+
* James Krieger jamesmkrieger@gmail.com
5+
*
6+
* Unidad de Bioinformatica of Centro Nacional de Biotecnologia , CSIC
7+
*
8+
* This program is free software; you can redistribute it and/or modify
9+
* it under the terms of the GNU General Public License as published by
10+
* the Free Software Foundation; either version 2 of the License, or
11+
* (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU General Public License
19+
* along with this program; if not, write to the Free Software
20+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21+
* 02111-1307 USA
22+
*
23+
* All comments concerning this program package may be sent to the
24+
* e-mail address 'xmipp@cnb.uam.es'
25+
***************************************************************************/
26+
27+
#include <mpi.h>
28+
#include <parallel/xmipp_mpi.h>
29+
#include <reconstruction/continuous_create_residuals.h>
30+
31+
32+
class MpiProgContinuousCreateResiduals: public ProgContinuousCreateResiduals, public MpiMetadataProgram
33+
{
34+
public:
35+
36+
void defineParams()
37+
{
38+
ProgContinuousCreateResiduals::defineParams();
39+
MpiMetadataProgram::defineParams();
40+
}
41+
void readParams()
42+
{
43+
MpiMetadataProgram::readParams();
44+
ProgContinuousCreateResiduals::readParams();
45+
}
46+
void read(int argc, char **argv, bool reportErrors = true)
47+
{
48+
MpiMetadataProgram::read(argc,argv);
49+
}
50+
void preProcess()
51+
{
52+
rank=node->rank;
53+
ProgContinuousCreateResiduals::preProcess();
54+
node->barrierWait();
55+
56+
// Get the volume padded size from rank 0
57+
int realSize, origin;
58+
if (node->rank==0)
59+
{
60+
realSize = XSIZE(projector->VfourierRealCoefs);
61+
origin = STARTINGX(projector->VfourierRealCoefs);
62+
}
63+
MPI_Bcast(&realSize, 1, MPI_INT, 0, MPI_COMM_WORLD);
64+
MPI_Bcast(&origin, 1, MPI_INT, 0, MPI_COMM_WORLD);
65+
MPI_Bcast(&(projector->volumePaddedSize), 1, MPI_INT, 0, MPI_COMM_WORLD);
66+
MPI_Bcast(&(projector->volumeSize), 1, MPI_INT, 0, MPI_COMM_WORLD);
67+
68+
if (rank!=0)
69+
{
70+
projector->VfourierRealCoefs.resizeNoCopy(realSize,realSize,realSize);
71+
projector->VfourierImagCoefs.resizeNoCopy(realSize,realSize,realSize);
72+
STARTINGX(projector->VfourierRealCoefs)=STARTINGY(projector->VfourierRealCoefs)=STARTINGZ(projector->VfourierRealCoefs)=origin;
73+
STARTINGX(projector->VfourierImagCoefs)=STARTINGY(projector->VfourierImagCoefs)=STARTINGZ(projector->VfourierImagCoefs)=origin;
74+
}
75+
MPI_Bcast(MULTIDIM_ARRAY(projector->VfourierRealCoefs), MULTIDIM_SIZE(projector->VfourierRealCoefs), MPI_DOUBLE, 0, MPI_COMM_WORLD);
76+
MPI_Bcast(MULTIDIM_ARRAY(projector->VfourierImagCoefs), MULTIDIM_SIZE(projector->VfourierImagCoefs), MPI_DOUBLE, 0, MPI_COMM_WORLD);
77+
if (rank!=0)
78+
projector->produceSideInfoProjection();
79+
80+
MetaData &mdIn = *getInputMd();
81+
mdIn.addLabel(MDL_GATHER_ID);
82+
mdIn.fillLinear(MDL_GATHER_ID,1,1);
83+
createTaskDistributor(mdIn, blockSize);
84+
}
85+
void startProcessing()
86+
{
87+
if (node->rank==1)
88+
{
89+
verbose=1;
90+
ProgContinuousCreateResiduals::startProcessing();
91+
}
92+
node->barrierWait();
93+
}
94+
void showProgress()
95+
{
96+
if (node->rank==1)
97+
{
98+
time_bar_done=first+1;
99+
ProgContinuousCreateResiduals::showProgress();
100+
}
101+
}
102+
103+
virtual bool getImageToProcess(size_t &objId, size_t &objIndex) override
104+
{
105+
return getTaskToProcess(objId, objIndex);
106+
}
107+
void finishProcessing()
108+
{
109+
node->gatherMetadatas(getOutputMd(), fn_out);
110+
MetaDataVec MDaux;
111+
MDaux.sort(getOutputMd(), MDL_GATHER_ID);
112+
MDaux.removeLabel(MDL_GATHER_ID);
113+
getOutputMd()=MDaux;
114+
if (node->isMaster())
115+
ProgContinuousCreateResiduals::finishProcessing();
116+
}
117+
void wait()
118+
{
119+
distributor->wait();
120+
}
121+
};

0 commit comments

Comments
 (0)