QUDA
v0.5.0
A library for QCD on GPUs
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
quda
lib
dirac_wilson.cpp
Go to the documentation of this file.
1
#include <
dirac_quda.h
>
2
#include <
blas_quda.h
>
3
#include <iostream>
4
5
namespace
quda {
6
7
DiracWilson::DiracWilson
(
const
DiracParam
&
param
) :
8
Dirac
(param), face(param.
gauge
->
X
(), 4, 12, 1, param.
gauge
->Precision()) { }
9
10
DiracWilson::DiracWilson
(
const
DiracWilson
&
dirac
) :
11
Dirac
(dirac), face(dirac.face) { }
12
13
DiracWilson::DiracWilson
(
const
DiracParam
&
param
,
const
int
nDims) :
14
Dirac
(param), face(param.
gauge
->
X
(), nDims, 12, 1, param.
gauge
->Precision(), param.
Ls
) { }
//temporal hack (for DW and TM operators)
15
16
DiracWilson::~DiracWilson
() { }
17
18
DiracWilson
&
DiracWilson::operator=
(
const
DiracWilson
&
dirac
)
19
{
20
if
(&dirac !=
this
) {
21
Dirac::operator=
(dirac);
22
face
= dirac.
face
;
23
}
24
return
*
this
;
25
}
26
27
void
DiracWilson::Dslash
(
cudaColorSpinorField
&
out
,
const
cudaColorSpinorField
&
in
,
28
const
QudaParity
parity
)
const
29
{
30
initSpinorConstants
(in);
31
checkParitySpinor
(in, out);
32
checkSpinorAlias
(in, out);
33
34
setFace
(
face
);
// FIXME: temporary hack maintain C linkage for dslashCuda
35
36
wilsonDslashCuda
(&out,
gauge
, &in, parity,
dagger
, 0, 0.0,
commDim
);
37
38
flops
+= 1320ll*in.
Volume
();
39
}
40
41
void
DiracWilson::DslashXpay
(
cudaColorSpinorField
&
out
,
const
cudaColorSpinorField
&
in
,
42
const
QudaParity
parity
,
const
cudaColorSpinorField
&
x
,
43
const
double
&k)
const
44
{
45
initSpinorConstants
(in);
46
checkParitySpinor
(in, out);
47
checkSpinorAlias
(in, out);
48
49
setFace
(
face
);
// FIXME: temporary hack maintain C linkage for dslashCuda
50
51
wilsonDslashCuda
(&out,
gauge
, &in, parity,
dagger
, &x, k,
commDim
);
52
53
flops
+= 1368ll*in.
Volume
();
54
}
55
56
void
DiracWilson::M
(
cudaColorSpinorField
&
out
,
const
cudaColorSpinorField
&
in
)
const
57
{
58
checkFullSpinor
(out, in);
59
DslashXpay
(out.
Odd
(), in.
Even
(),
QUDA_ODD_PARITY
, in.
Odd
(), -
kappa
);
60
DslashXpay
(out.
Even
(), in.
Odd
(),
QUDA_EVEN_PARITY
, in.
Even
(), -
kappa
);
61
}
62
63
void
DiracWilson::MdagM
(
cudaColorSpinorField
&
out
,
const
cudaColorSpinorField
&
in
)
const
64
{
65
checkFullSpinor
(out, in);
66
67
bool
reset =
newTmp
(&
tmp1
, in);
68
checkFullSpinor
(*
tmp1
, in);
69
70
M
(*
tmp1
, in);
71
Mdag
(out, *
tmp1
);
72
73
deleteTmp
(&
tmp1
, reset);
74
}
75
76
void
DiracWilson::prepare
(
cudaColorSpinorField
* &src,
cudaColorSpinorField
* &sol,
77
cudaColorSpinorField
&
x
,
cudaColorSpinorField
&b,
78
const
QudaSolutionType
solType)
const
79
{
80
if
(solType ==
QUDA_MATPC_SOLUTION
|| solType ==
QUDA_MATPCDAG_MATPC_SOLUTION
) {
81
errorQuda
(
"Preconditioned solution requires a preconditioned solve_type"
);
82
}
83
84
src = &b;
85
sol = &
x
;
86
}
87
88
void
DiracWilson::reconstruct
(
cudaColorSpinorField
&
x
,
const
cudaColorSpinorField
&b,
89
const
QudaSolutionType
solType)
const
90
{
91
// do nothing
92
}
93
94
DiracWilsonPC::DiracWilsonPC
(
const
DiracParam
&
param
)
95
:
DiracWilson
(param)
96
{
97
98
}
99
100
DiracWilsonPC::DiracWilsonPC
(
const
DiracWilsonPC
&
dirac
)
101
:
DiracWilson
(dirac)
102
{
103
104
}
105
106
DiracWilsonPC::~DiracWilsonPC
()
107
{
108
109
}
110
111
DiracWilsonPC
&
DiracWilsonPC::operator=
(
const
DiracWilsonPC
&
dirac
)
112
{
113
if
(&dirac !=
this
) {
114
DiracWilson::operator=
(dirac);
115
}
116
return
*
this
;
117
}
118
119
void
DiracWilsonPC::M
(
cudaColorSpinorField
&
out
,
const
cudaColorSpinorField
&
in
)
const
120
{
121
double
kappa2 = -
kappa
*
kappa
;
122
123
bool
reset =
newTmp
(&
tmp1
, in);
124
125
if
(
matpcType
==
QUDA_MATPC_EVEN_EVEN
) {
126
Dslash
(*
tmp1
, in,
QUDA_ODD_PARITY
);
127
DslashXpay
(out, *
tmp1
,
QUDA_EVEN_PARITY
, in, kappa2);
128
}
else
if
(
matpcType
==
QUDA_MATPC_ODD_ODD
) {
129
Dslash
(*
tmp1
, in,
QUDA_EVEN_PARITY
);
130
DslashXpay
(out, *
tmp1
,
QUDA_ODD_PARITY
, in, kappa2);
131
}
else
{
132
errorQuda
(
"MatPCType %d not valid for DiracWilsonPC"
,
matpcType
);
133
}
134
135
deleteTmp
(&
tmp1
, reset);
136
}
137
138
void
DiracWilsonPC::MdagM
(
cudaColorSpinorField
&
out
,
const
cudaColorSpinorField
&
in
)
const
139
{
140
#ifdef MULTI_GPU
141
bool
reset =
newTmp
(&
tmp2
, in);
142
M
(*
tmp2
, in);
143
Mdag
(out, *
tmp2
);
144
deleteTmp
(&
tmp2
, reset);
145
#else
146
M
(out, in);
147
Mdag
(out, out);
148
#endif
149
}
150
151
void
DiracWilsonPC::prepare
(
cudaColorSpinorField
* &src,
cudaColorSpinorField
* &sol,
152
cudaColorSpinorField
&
x
,
cudaColorSpinorField
&b,
153
const
QudaSolutionType
solType)
const
154
{
155
// we desire solution to preconditioned system
156
if
(solType ==
QUDA_MATPC_SOLUTION
|| solType ==
QUDA_MATPCDAG_MATPC_SOLUTION
) {
157
src = &b;
158
sol = &
x
;
159
}
else
{
160
// we desire solution to full system
161
if
(
matpcType
==
QUDA_MATPC_EVEN_EVEN
) {
162
// src = b_e + k D_eo b_o
163
DslashXpay
(x.
Odd
(), b.
Odd
(),
QUDA_EVEN_PARITY
, b.
Even
(),
kappa
);
164
src = &(x.
Odd
());
165
sol = &(x.
Even
());
166
}
else
if
(
matpcType
==
QUDA_MATPC_ODD_ODD
) {
167
// src = b_o + k D_oe b_e
168
DslashXpay
(x.
Even
(), b.
Even
(),
QUDA_ODD_PARITY
, b.
Odd
(),
kappa
);
169
src = &(x.
Even
());
170
sol = &(x.
Odd
());
171
}
else
{
172
errorQuda
(
"MatPCType %d not valid for DiracWilsonPC"
,
matpcType
);
173
}
174
// here we use final solution to store parity solution and parity source
175
// b is now up for grabs if we want
176
}
177
178
}
179
180
void
DiracWilsonPC::reconstruct
(
cudaColorSpinorField
&
x
,
const
cudaColorSpinorField
&b,
181
const
QudaSolutionType
solType)
const
182
{
183
if
(solType ==
QUDA_MATPC_SOLUTION
|| solType ==
QUDA_MATPCDAG_MATPC_SOLUTION
) {
184
return
;
185
}
186
187
// create full solution
188
189
checkFullSpinor
(x, b);
190
if
(
matpcType
==
QUDA_MATPC_EVEN_EVEN
) {
191
// x_o = b_o + k D_oe x_e
192
DslashXpay
(x.
Odd
(), x.
Even
(),
QUDA_ODD_PARITY
, b.
Odd
(),
kappa
);
193
}
else
if
(
matpcType
==
QUDA_MATPC_ODD_ODD
) {
194
// x_e = b_e + k D_eo x_o
195
DslashXpay
(x.
Even
(), x.
Odd
(),
QUDA_EVEN_PARITY
, b.
Even
(),
kappa
);
196
}
else
{
197
errorQuda
(
"MatPCType %d not valid for DiracWilsonPC"
,
matpcType
);
198
}
199
}
200
201
}
// namespace quda
Generated on Wed Mar 20 2013 12:52:14 for QUDA by
1.8.2