Xmipp
v3.23.11-Nereus
xmipp
libraries
reconstruction_cuda
cuda_correlation_computer.h
Go to the documentation of this file.
1
/***************************************************************************
2
*
3
* Authors: David Strelak (davidstrelak@gmail.com)
4
*
5
* Unidad de Bioinformatica of Centro Nacional de Biotecnologia , CSIC
6
*
7
* This program is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; either version 2 of the License, or
10
* (at your option) any later version.
11
*
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
*
17
* You should have received a copy of the GNU General Public License
18
* along with this program; if not, write to the Free Software
19
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20
* 02111-1307 USA
21
*
22
* All comments concerning this program package may be sent to the
23
* e-mail address 'xmipp@cnb.csic.es'
24
***************************************************************************/
25
26
#ifndef LIBRARIES_RECONSTRUCTION_CUDA_CORRELATION_COMPUTER_H_
27
#define LIBRARIES_RECONSTRUCTION_CUDA_CORRELATION_COMPUTER_H_
28
29
#include "
reconstruction/amerit_computer.h
"
30
#include "
gpu.h
"
31
#include "
core/utils/memory_utils.h
"
32
36
template
<
typename
T>
37
class
CudaCorrelationComputer
:
public
AMeritComputer
<T> {
38
public
:
39
CudaCorrelationComputer
() {
40
setDefault();
41
}
42
43
~CudaCorrelationComputer
() {
44
release();
45
}
46
47
void
loadReference
(
const
T *ref)
override
;
48
void
compute
(T *others)
override
;
49
50
private
:
51
struct
ResRaw {
// non-normalize result
52
T corr;
53
T sum;
54
T sumSqr;
55
};
56
57
struct
ResRef {
58
T sum;
59
T sumSqr;
60
};
61
62
struct
Stat
{
63
T avg;
64
T stddev;
65
};
66
67
struct
ResNorm {
// normalized result
68
T corr;
69
};
70
71
bool
canBeReused(
const
MeritSettings
&s)
const override
;
72
void
initialize(
bool
doAllocation)
override
;
73
void
release();
74
void
setDefault();
75
void
check
()
override
;
76
void
allocate();
77
78
void
computeCorrStatOneToNNormalize();
79
void
computeAvgStddevForRef();
80
template
<
bool
NORMALIZE>
81
void
computeOneToN();
82
template
<
bool
NORMALIZE>
83
void
storeResultOneToN();
84
85
template
<
typename
U>
86
Stat
computeStat(U r,
size_t
norm
);
87
88
// GPU memory
89
T *m_d_ref;
90
T *m_d_others;
91
T *m_d_corrRes;
92
// CPU memory
93
ResRef *m_h_ref_corrRes;
// used only when normalization is requested
94
void
*m_h_corrRes;
// actual type depends on the merit type
95
// others
96
GPU
*m_stream;
97
98
};
100
#endif
/* LIBRARIES_RECONSTRUCTION_CUDA_CORRELATION_COMPUTER_H_ */
CudaCorrelationComputer
Definition:
cuda_correlation_computer.h:37
amerit_computer.h
CudaCorrelationComputer::~CudaCorrelationComputer
~CudaCorrelationComputer()
Definition:
cuda_correlation_computer.h:43
norm
T norm(const std::vector< T > &v)
Definition:
vector_ops.h:399
gpu.h
CudaCorrelationComputer::CudaCorrelationComputer
CudaCorrelationComputer()
Definition:
cuda_correlation_computer.h:39
CudaCorrelationComputer::loadReference
void loadReference(const T *ref) override
Definition:
cuda_correlation_computer.cpp:103
memory_utils.h
GPU
Definition:
gpu.h:36
Stat
struct stat Stat
Definition:
xmipp_filename.h:41
CudaCorrelationComputer::compute
void compute(T *others) override
Definition:
cuda_correlation_computer.cpp:75
AMeritComputer
Definition:
amerit_computer.h:70
check
check(nparam, nf, nfsr, &Linfty, nineq, nineqn, neq, neqn, ncsrl, ncsrn, mode, &modem, eps, bgbnd, param)
MeritSettings
Definition:
amerit_computer.h:41
Generated by
1.8.13