Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
BioEM
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MPIBP-Hummer
BioEM
Commits
860031e3
Commit
860031e3
authored
Jul 07, 2014
by
David Rohr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
create angular probabilites only if writeAngles set
parent
88c93497
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
58 additions
and
44 deletions
+58
-44
bioem.cpp
bioem.cpp
+13
-8
bioem_algorithm.h
bioem_algorithm.h
+26
-23
bioem_cuda.cu
bioem_cuda.cu
+3
-3
include/map.h
include/map.h
+5
-2
include/param.h
include/param.h
+2
-2
map.cpp
map.cpp
+8
-5
param.cpp
param.cpp
+1
-1
No files found.
bioem.cpp
View file @
860031e3
...
...
@@ -92,7 +92,7 @@ int bioem::configure(int ac, char* av[])
// *** Inizialzing default variables ***
std
::
string
infile
,
modelfile
,
mapfile
;
Model
.
readPDB
=
false
;
param
.
writeAngles
=
false
;
param
.
param_device
.
writeAngles
=
false
;
param
.
dumpMap
=
false
;
param
.
loadMap
=
false
;
RefMap
.
readMRC
=
false
;
...
...
@@ -280,6 +280,8 @@ int bioem::run()
pProbMap
.
Total
=
0.0
;
pProbMap
.
Constoadd
=
-
9999999
;
pProbMap
.
max_prob
=
-
9999999
;
if
(
param
.
param_device
.
writeAngles
)
{
for
(
int
iOrient
=
0
;
iOrient
<
param
.
nTotGridAngles
;
iOrient
++
)
{
bioem_Probability_angle
&
pProbAngle
=
pProb
.
getProbAngle
(
iRefMap
,
iOrient
);
...
...
@@ -288,6 +290,7 @@ int bioem::run()
pProbAngle
.
ConstAngle
=
-
99999999
;
}
}
}
// **************************************************************************************
deviceStartRun
();
{
...
...
@@ -377,7 +380,7 @@ int bioem::run()
// *** Angular Probability ***
ofstream
angProbfile
;
if
(
param
.
writeAngles
)
if
(
param
.
param_device
.
writeAngles
)
{
angProbfile
.
open
(
"ANG_PROB"
);
}
...
...
@@ -407,7 +410,7 @@ int bioem::run()
// *** For individual files*** //angProbfile.open ("ANG_PROB_"iRefMap);
if
(
param
.
writeAngles
)
if
(
param
.
param_device
.
writeAngles
)
{
for
(
int
iOrient
=
0
;
iOrient
<
param
.
nTotGridAngles
;
iOrient
++
)
{
...
...
@@ -418,7 +421,7 @@ int bioem::run()
}
}
if
(
param
.
writeAngles
)
if
(
param
.
param_device
.
writeAngles
)
{
angProbfile
.
close
();
}
...
...
@@ -540,6 +543,7 @@ int bioem::createProjection(int iMap, mycomplex_t* mapFFT)
}
// **** Output Just to check****
#ifdef PILAR_DEBUG
if
(
iMap
==
10
)
{
ofstream
myexamplemap
;
...
...
@@ -556,6 +560,7 @@ int bioem::createProjection(int iMap, mycomplex_t* mapFFT)
myexamplemap
.
close
();
myexampleRot
.
close
();
}
#endif
// ***** Converting projection to Fourier Space for Convolution later with kernel****
// ********** Omp Critical is necessary with FFTW*******
...
...
bioem_algorithm.h
View file @
860031e3
...
...
@@ -21,18 +21,21 @@
#endif
template
<
int
GPUAlgo
>
__device__
static
inline
void
update_prob
(
const
myfloat_t
logpro
,
const
int
iRefMap
,
const
int
iOrient
,
const
int
iConv
,
const
int
cent_x
,
const
int
cent_y
,
bioem_Probability
&
pProb
,
myfloat_t
*
buf3
=
NULL
,
int
*
bufint
=
NULL
)
__device__
static
inline
void
update_prob
(
const
myfloat_t
logpro
,
const
int
iRefMap
,
const
int
iOrient
,
const
int
iConv
,
const
int
cent_x
,
const
int
cent_y
,
bioem_Probability
&
pProb
,
bool
doAngle
,
myfloat_t
*
buf3
=
NULL
,
int
*
bufint
=
NULL
)
{
// ******* Summing total Probabilities *************
// ******* Need a constant because of numerical divergence*****
bioem_Probability_map
&
pProbMap
=
pProb
.
getProbMap
(
iRefMap
);
bioem_Probability_angle
&
pProbAngle
=
pProb
.
getProbAngle
(
iRefMap
,
iOrient
);
if
(
pProbMap
.
Constoadd
<
logpro
)
{
pProbMap
.
Total
=
pProbMap
.
Total
*
exp
(
-
logpro
+
pProbMap
.
Constoadd
);
pProbMap
.
Constoadd
=
logpro
;
}
if
(
GPUAlgo
!=
2
)
pProbMap
.
Total
+=
exp
(
logpro
-
pProbMap
.
Constoadd
);
if
(
doAngle
)
{
bioem_Probability_angle
&
pProbAngle
=
pProb
.
getProbAngle
(
iRefMap
,
iOrient
);
//Summing probabilities for each orientation
if
(
pProbAngle
.
ConstAngle
<
logpro
)
...
...
@@ -41,10 +44,7 @@ __device__ static inline void update_prob(const myfloat_t logpro, const int iRef
pProbAngle
.
ConstAngle
=
logpro
;
}
if
(
GPUAlgo
!=
2
)
{
pProbMap
.
Total
+=
exp
(
logpro
-
pProbMap
.
Constoadd
);
pProbAngle
.
forAngles
+=
exp
(
logpro
-
pProbAngle
.
ConstAngle
);
if
(
GPUAlgo
!=
2
)
pProbAngle
.
forAngles
+=
exp
(
logpro
-
pProbAngle
.
ConstAngle
);
}
// ********** Getting parameters that maximize the probability ***********
...
...
@@ -90,11 +90,9 @@ __device__ static inline void calProb(int iRefMap, int iOrient, int iConv, myflo
const
myfloat_t
logpro
=
calc_logpro
(
param
,
sumC
,
sumsquareC
,
value
,
RefMap
.
sum_RefMap
[
iRefMap
],
RefMap
.
sumsquare_RefMap
[
iRefMap
]);
bioem_Probability_map
&
pProbMap
=
pProb
.
getProbMap
(
iRefMap
);
bioem_Probability_angle
&
pProbAngle
=
pProb
.
getProbAngle
(
iRefMap
,
iOrient
);
//GCC is too stupid to inline properly, so the code is copied here
//update_prob<-1>(logpro, iRefMap, iOrient, iConv, disx, disy, pProb);
//update_prob<-1>(logpro, iRefMap, iOrient, iConv, disx, disy, pProb, param.writeAngles);
bioem_Probability_map
&
pProbMap
=
pProb
.
getProbMap
(
iRefMap
);
if
(
pProbMap
.
Constoadd
<
logpro
)
{
pProbMap
.
Total
=
pProbMap
.
Total
*
exp
(
-
logpro
+
pProbMap
.
Constoadd
);
...
...
@@ -102,12 +100,17 @@ __device__ static inline void calProb(int iRefMap, int iOrient, int iConv, myflo
}
pProbMap
.
Total
+=
exp
(
logpro
-
pProbMap
.
Constoadd
);
if
(
param
.
writeAngles
)
{
bioem_Probability_angle
&
pProbAngle
=
pProb
.
getProbAngle
(
iRefMap
,
iOrient
);
if
(
pProbAngle
.
ConstAngle
<
logpro
)
{
pProbAngle
.
forAngles
=
pProbAngle
.
forAngles
*
exp
(
-
logpro
+
pProbAngle
.
ConstAngle
);
pProbAngle
.
ConstAngle
=
logpro
;
}
pProbAngle
.
forAngles
+=
exp
(
logpro
-
pProbAngle
.
ConstAngle
);
}
if
(
pProbMap
.
max_prob
<
logpro
)
{
...
...
@@ -291,7 +294,7 @@ __device__ static inline void compareRefMap(const int iRefMap, const int iOrient
if
(
myShift
==
0
&&
iRefMap
<
RefMap
.
ntotRefMap
)
{
const
myfloat_t
logpro_max
=
vbuf
[
myThreadIdxX
];
update_prob
<
GPUAlgo
>
(
logpro_max
,
iRefMap
,
iOrient
,
iConv
,
-
1
,
-
1
,
pProb
,
buf3
,
bufint
);
update_prob
<
GPUAlgo
>
(
logpro_max
,
iRefMap
,
iOrient
,
iConv
,
-
1
,
-
1
,
pProb
,
param
.
writeAngles
,
buf3
,
bufint
);
}
}
...
...
@@ -399,7 +402,7 @@ __device__ static inline void compareRefMap(const int iRefMap, const int iOrient
else
#endif
{
update_prob
<
-
1
>
(
logpro
,
iRefMap
,
iOrient
,
iConv
,
cent_x
,
cent_y
,
pProb
);
update_prob
<
-
1
>
(
logpro
,
iRefMap
,
iOrient
,
iConv
,
cent_x
,
cent_y
,
pProb
,
param
.
writeAngles
);
}
}
...
...
bioem_cuda.cu
View file @
860031e3
...
...
@@ -374,7 +374,7 @@ int bioem_cuda::deviceInit()
gpumap
->
sum_RefMap
=
sum
;
gpumap
->
sumsquare_RefMap
=
sumsquare
;
checkCudaErrors
(
cudaMalloc
(
&
pProb_memory
,
pProb_device
.
get_size
(
RefMap
.
ntotRefMap
,
param
.
nTotGridAngles
)));
checkCudaErrors
(
cudaMalloc
(
&
pProb_memory
,
pProb_device
.
get_size
(
RefMap
.
ntotRefMap
,
param
.
nTotGridAngles
,
param
.
param_device
.
writeAngles
)));
for
(
int
i
=
0
;
i
<
2
;
i
++
)
{
checkCudaErrors
(
cudaStreamCreate
(
&
cudaStream
[
i
]));
...
...
@@ -466,7 +466,7 @@ int bioem_cuda::deviceStartRun()
pProb_device
=
*
pProb_host
;
pProb_device
.
ptr
=
pProb_memory
;
pProb_device
.
set_pointers
();
checkCudaErrors
(
cudaMemcpyAsync
(
pProb_device
.
ptr
,
pProb_host
->
ptr
,
pProb_host
->
get_size
(
maxRef
,
param
.
nTotGridAngles
),
cudaMemcpyHostToDevice
,
cudaStream
[
0
]));
checkCudaErrors
(
cudaMemcpyAsync
(
pProb_device
.
ptr
,
pProb_host
->
ptr
,
pProb_host
->
get_size
(
maxRef
,
param
.
nTotGridAngles
,
param
.
param_device
.
writeAngles
),
cudaMemcpyHostToDevice
,
cudaStream
[
0
]));
if
(
FFTAlgo
)
{
...
...
@@ -501,7 +501,7 @@ int bioem_cuda::deviceStartRun()
int
bioem_cuda
::
deviceFinishRun
()
{
if
(
GPUAsync
)
cudaStreamSynchronize
(
cudaStream
[
0
]);
checkCudaErrors
(
cudaMemcpyAsync
(
pProb_host
->
ptr
,
pProb_device
.
ptr
,
pProb_host
->
get_size
(
maxRef
,
param
.
nTotGridAngles
),
cudaMemcpyDeviceToHost
,
cudaStream
[
0
]));
checkCudaErrors
(
cudaMemcpyAsync
(
pProb_host
->
ptr
,
pProb_device
.
ptr
,
pProb_host
->
get_size
(
maxRef
,
param
.
nTotGridAngles
,
param
.
param_device
.
writeAngles
),
cudaMemcpyDeviceToHost
,
cudaStream
[
0
]));
if
(
FFTAlgo
)
{
...
...
include/map.h
View file @
860031e3
...
...
@@ -2,6 +2,7 @@
#define BIOEM_MAP_H
#include "defs.h"
#include "param.h"
#include <complex>
#include <math.h>
...
...
@@ -107,9 +108,11 @@ public:
bioem_Probability_map
*
ptr_map
;
bioem_Probability_angle
*
ptr_angle
;
static
size_t
get_size
(
size_t
maps
,
size_t
angles
)
static
size_t
get_size
(
size_t
maps
,
size_t
angles
,
bool
writeAngles
)
{
return
(
maps
*
(
angles
*
sizeof
(
bioem_Probability_angle
)
+
sizeof
(
bioem_Probability_map
)));
size_t
size
=
sizeof
(
bioem_Probability_map
);
if
(
writeAngles
)
size
+=
angles
*
sizeof
(
bioem_Probability_angle
);
return
(
maps
*
size
);
}
void
init
(
size_t
maps
,
size_t
angles
,
bioem
&
bio
);
...
...
include/param.h
View file @
860031e3
...
...
@@ -18,6 +18,8 @@ public:
int
NtotDist
;
myfloat_t
Ntotpi
;
myfloat_t
volu
;
// If to write Probabilities of Angles from Model
bool
writeAngles
;
};
class
bioem_param
...
...
@@ -38,8 +40,6 @@ public:
mycomplex_t
*
refCTF
;
myfloat3_t
*
CtfParam
;
// If to write Probabilities of Angles from Model
bool
writeAngles
;
myfloat_t
pixelSize
;
// Grid Points in Euler angles, assuming uniform sampling d_alpha=d_gamma (in 2pi) & cos(beta)=-1,1
int
angleGridPointsAlpha
;
...
...
map.cpp
View file @
860031e3
...
...
@@ -276,7 +276,7 @@ void bioem_Probability::init(size_t maps, size_t angles, bioem& bio)
{
nMaps
=
maps
;
nAngles
=
angles
;
ptr
=
bio
.
malloc_device_host
(
get_size
(
maps
,
angles
));
ptr
=
bio
.
malloc_device_host
(
get_size
(
maps
,
angles
,
bio
.
param
.
param_device
.
writeAngles
));
set_pointers
();
}
...
...
@@ -286,12 +286,15 @@ void bioem_Probability::copyFrom(bioem_Probability* from, bioem& bio)
bioem_Probability_map
&
pProbMapFrom
=
from
->
getProbMap
(
0
);
memcpy
(
&
pProbMap
,
&
pProbMapFrom
,
from
->
nMaps
*
sizeof
(
bioem_Probability_map
));
if
(
bio
.
param
.
param_device
.
writeAngles
)
{
for
(
int
iOrient
=
0
;
iOrient
<
bio
.
param
.
nTotGridAngles
;
iOrient
++
)
{
bioem_Probability_angle
&
pProbAngle
=
getProbAngle
(
0
,
iOrient
);
bioem_Probability_angle
&
pProbAngleFrom
=
from
->
getProbAngle
(
0
,
iOrient
);
memcpy
(
&
pProbAngle
,
&
pProbAngleFrom
,
from
->
nMaps
*
sizeof
(
bioem_Probability_angle
));
}
}
}
int
bioem_RefMap
::
read_MRC
(
const
char
*
filename
,
bioem_param
&
param
)
...
...
param.cpp
View file @
860031e3
...
...
@@ -209,7 +209,7 @@ int bioem_param::readParameters(const char* fileinput)
}
else
if
(
strcmp
(
token
,
"WRITE_PROB_ANGLES"
)
==
0
)
{
writeAngles
=
true
;
param_device
.
writeAngles
=
true
;
cout
<<
"Writing Probabilies of each angle
\n
"
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment