Advanced Computing Platform for Theoretical Physics
Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
YI-Bo Yang
QUDA with HIP
Commits
56027fc3
Commit
56027fc3
authored
Oct 28, 2019
by
maddyscientist
Browse files
Apply clang format
parent
802120c2
Changes
5
Hide whitespace changes
Inline
Side-by-side
lib/inv_ca_gcr.cpp
View file @
56027fc3
...
...
@@ -4,9 +4,19 @@
namespace
quda
{
CAGCR
::
CAGCR
(
DiracMatrix
&
mat
,
DiracMatrix
&
matSloppy
,
SolverParam
&
param
,
TimeProfile
&
profile
)
:
Solver
(
param
,
profile
),
mat
(
mat
),
matSloppy
(
matSloppy
),
matMdagM
(
mat
.
Expose
()),
init
(
false
),
basis
(
param
.
ca_basis
),
alpha
(
nullptr
),
rp
(
nullptr
),
tmpp
(
nullptr
),
tmp_sloppy
(
nullptr
)
{
}
CAGCR
::
CAGCR
(
DiracMatrix
&
mat
,
DiracMatrix
&
matSloppy
,
SolverParam
&
param
,
TimeProfile
&
profile
)
:
Solver
(
param
,
profile
),
mat
(
mat
),
matSloppy
(
matSloppy
),
matMdagM
(
mat
.
Expose
()),
init
(
false
),
basis
(
param
.
ca_basis
),
alpha
(
nullptr
),
rp
(
nullptr
),
tmpp
(
nullptr
),
tmp_sloppy
(
nullptr
)
{
}
CAGCR
::~
CAGCR
()
{
if
(
!
param
.
is_preconditioner
)
profile
.
TPSTART
(
QUDA_PROFILE_FREE
);
...
...
lib/inv_eigcg_quda.cpp
View file @
56027fc3
...
...
@@ -45,85 +45,106 @@ namespace quda {
enum
class
libtype
{
eigen_lib
,
magma_lib
,
lapack_lib
,
mkl_lib
};
class
EigCGArgs
{
public:
//host Lanczos matrice, and its eigenvalue/vector arrays:
DenseMatrix
Tm
;
//VH A V,
//eigenvectors:
VectorSet
ritzVecs
;
//array of (m) ritz and of m length
//eigenvalues of both T[m, m ] and T[m-1, m-1] (re-used)
RealVector
Tmvals
;
//eigenvalues of T[m, m ] and T[m-1, m-1] (re-used)
//Aux matrix for computing 2k Ritz vectors:
DenseMatrix
H2k
;
int
m
;
int
k
;
int
id
;
//cuurent search spase index
int
restarts
;
double
global_stop
;
bool
run_residual_correction
;
//used in mixed precision cycles
ColorSpinorFieldSet
*
V2k
;
//eigCG accumulation vectors needed to update Tm (spinor matrix of size eigen_vector_length x (2*k))
EigCGArgs
(
int
m
,
int
k
)
:
Tm
(
DenseMatrix
::
Zero
(
m
,
m
)),
ritzVecs
(
VectorSet
::
Zero
(
m
,
m
)),
Tmvals
(
m
),
H2k
(
2
*
k
,
2
*
k
),
m
(
m
),
k
(
k
),
id
(
0
),
restarts
(
0
),
global_stop
(
0.0
),
run_residual_correction
(
false
),
V2k
(
nullptr
)
{
}
~
EigCGArgs
()
{
if
(
V2k
)
delete
V2k
;
}
class
EigCGArgs
{
//method for constructing Lanczos matrix :
inline
void
SetLanczos
(
Complex
diag_val
,
Complex
offdiag_val
)
{
if
(
run_residual_correction
)
return
;
public:
// host Lanczos matrice, and its eigenvalue/vector arrays:
DenseMatrix
Tm
;
// VH A V,
// eigenvectors:
VectorSet
ritzVecs
;
// array of (m) ritz and of m length
// eigenvalues of both T[m, m ] and T[m-1, m-1] (re-used)
RealVector
Tmvals
;
// eigenvalues of T[m, m ] and T[m-1, m-1] (re-used)
// Aux matrix for computing 2k Ritz vectors:
DenseMatrix
H2k
;
int
m
;
int
k
;
int
id
;
// cuurent search spase index
int
restarts
;
double
global_stop
;
bool
run_residual_correction
;
// used in mixed precision cycles
ColorSpinorFieldSet
*
V2k
;
// eigCG accumulation vectors needed to update Tm (spinor matrix of size eigen_vector_length x (2*k))
EigCGArgs
(
int
m
,
int
k
)
:
Tm
(
DenseMatrix
::
Zero
(
m
,
m
)),
ritzVecs
(
VectorSet
::
Zero
(
m
,
m
)),
Tmvals
(
m
),
H2k
(
2
*
k
,
2
*
k
),
m
(
m
),
k
(
k
),
id
(
0
),
restarts
(
0
),
global_stop
(
0.0
),
run_residual_correction
(
false
),
V2k
(
nullptr
)
{
}
Tm
.
diagonal
<
0
>
()[
id
]
=
diag_val
;
~
EigCGArgs
()
{
if
(
V2k
)
delete
V2k
;
}
if
(
id
<
(
m
-
1
)){
//Load Lanczos off-diagonals
:
Tm
.
diagonal
<+
1
>
()[
id
]
=
offdiag_val
;
Tm
.
diagonal
<-
1
>
()[
id
]
=
offdiag_val
;
}
// method for constructing Lanczos matrix
:
inline
void
SetLanczos
(
Complex
diag_val
,
Complex
offdiag_val
)
{
if
(
run_residual_correction
)
return
;
id
+=
1
;
Tm
.
diagonal
<
0
>
()[
id
]
=
diag_val
;
return
;
if
(
id
<
(
m
-
1
))
{
// Load Lanczos off-diagonals:
Tm
.
diagonal
<+
1
>
()[
id
]
=
offdiag_val
;
Tm
.
diagonal
<-
1
>
()[
id
]
=
offdiag_val
;
}
inline
void
ResetArgs
()
{
id
=
0
;
Tm
.
setZero
();
Tmvals
.
setZero
();
ritzVecs
.
setZero
();
id
+=
1
;
if
(
V2k
)
delete
V2k
;
V2k
=
nullptr
;
}
return
;
}
inline
void
ResetSearchIdx
()
{
id
=
2
*
k
;
restarts
+=
1
;
}
inline
void
ResetArgs
()
{
id
=
0
;
Tm
.
setZero
();
Tmvals
.
setZero
();
ritzVecs
.
setZero
();
void
RestartLanczos
(
ColorSpinorField
*
w
,
ColorSpinorFieldSet
*
v
,
const
double
inv_sqrt_r2
)
{
Tm
.
setZero
();
if
(
V2k
)
delete
V2k
;
V2k
=
nullptr
;
}
auto
s
=
std
::
make_unique
<
Complex
[]
>
(
2
*
k
);
inline
void
ResetSearchIdx
()
{
id
=
2
*
k
;
restarts
+=
1
;
}
for
(
int
i
=
0
;
i
<
2
*
k
;
i
++
)
Tm
(
i
,
i
)
=
Tmvals
(
i
);
//??
void
RestartLanczos
(
ColorSpinorField
*
w
,
ColorSpinorFieldSet
*
v
,
const
double
inv_sqrt_r2
)
{
Tm
.
setZero
();
std
::
vector
<
ColorSpinorField
*>
w_
;
w_
.
push_back
(
w
);
auto
s
=
std
::
make_unique
<
Complex
[]
>
(
2
*
k
);
std
::
vector
<
ColorSpinorField
*>
v_
(
v
->
Components
().
begin
(),
v
->
Components
().
begin
()
+
2
*
k
);
for
(
int
i
=
0
;
i
<
2
*
k
;
i
++
)
Tm
(
i
,
i
)
=
Tmvals
(
i
);
//??
blas
::
cDotProduct
(
s
.
get
(),
w_
,
v_
);
std
::
vector
<
ColorSpinorField
*>
w_
;
w_
.
push_back
(
w
);
Map
<
VectorXcd
,
Unaligned
>
s_
(
s
.
get
(),
2
*
k
);
s_
*=
inv_sqrt_r2
;
std
::
vector
<
ColorSpinorField
*>
v_
(
v
->
Components
().
begin
(),
v
->
Components
().
begin
()
+
2
*
k
);
Tm
.
col
(
2
*
k
).
segment
(
0
,
2
*
k
)
=
s_
;
Tm
.
row
(
2
*
k
).
segment
(
0
,
2
*
k
)
=
s_
.
adjoint
();
}
blas
::
cDotProduct
(
s
.
get
(),
w_
,
v_
);
Map
<
VectorXcd
,
Unaligned
>
s_
(
s
.
get
(),
2
*
k
);
s_
*=
inv_sqrt_r2
;
Tm
.
col
(
2
*
k
).
segment
(
0
,
2
*
k
)
=
s_
;
Tm
.
row
(
2
*
k
).
segment
(
0
,
2
*
k
)
=
s_
.
adjoint
();
}
};
//Rayleigh Ritz procedure:
...
...
lib/inv_gcr_quda.cpp
View file @
56027fc3
...
...
@@ -160,11 +160,20 @@ namespace quda {
delete
[]
delta
;
}
GCR
::
GCR
(
DiracMatrix
&
mat
,
DiracMatrix
&
matSloppy
,
DiracMatrix
&
matPrecon
,
SolverParam
&
param
,
TimeProfile
&
profile
)
:
Solver
(
param
,
profile
),
mat
(
mat
),
matSloppy
(
matSloppy
),
matPrecon
(
matPrecon
),
matMdagM
(
DiracMdagM
(
mat
.
Expose
())),
K
(
0
),
Kparam
(
param
),
nKrylov
(
param
.
Nkrylov
),
init
(
false
),
rp
(
nullptr
),
tmpp
(
nullptr
),
tmp_sloppy
(
nullptr
),
r_sloppy
(
nullptr
)
GCR
::
GCR
(
DiracMatrix
&
mat
,
DiracMatrix
&
matSloppy
,
DiracMatrix
&
matPrecon
,
SolverParam
&
param
,
TimeProfile
&
profile
)
:
Solver
(
param
,
profile
),
mat
(
mat
),
matSloppy
(
matSloppy
),
matPrecon
(
matPrecon
),
matMdagM
(
DiracMdagM
(
mat
.
Expose
())),
K
(
0
),
Kparam
(
param
),
nKrylov
(
param
.
Nkrylov
),
init
(
false
),
rp
(
nullptr
),
tmpp
(
nullptr
),
tmp_sloppy
(
nullptr
),
r_sloppy
(
nullptr
)
{
fillInnerSolveParam
(
Kparam
,
param
);
...
...
@@ -192,11 +201,21 @@ namespace quda {
gamma
=
new
double
[
nKrylov
];
}
GCR
::
GCR
(
DiracMatrix
&
mat
,
Solver
&
K
,
DiracMatrix
&
matSloppy
,
DiracMatrix
&
matPrecon
,
SolverParam
&
param
,
TimeProfile
&
profile
)
:
Solver
(
param
,
profile
),
mat
(
mat
),
matSloppy
(
matSloppy
),
matPrecon
(
matPrecon
),
matMdagM
(
mat
.
Expose
()),
K
(
&
K
),
Kparam
(
param
),
nKrylov
(
param
.
Nkrylov
),
init
(
false
),
rp
(
nullptr
),
tmpp
(
nullptr
),
tmp_sloppy
(
nullptr
),
r_sloppy
(
nullptr
)
GCR
::
GCR
(
DiracMatrix
&
mat
,
Solver
&
K
,
DiracMatrix
&
matSloppy
,
DiracMatrix
&
matPrecon
,
SolverParam
&
param
,
TimeProfile
&
profile
)
:
Solver
(
param
,
profile
),
mat
(
mat
),
matSloppy
(
matSloppy
),
matPrecon
(
matPrecon
),
matMdagM
(
mat
.
Expose
()),
K
(
&
K
),
Kparam
(
param
),
nKrylov
(
param
.
Nkrylov
),
init
(
false
),
rp
(
nullptr
),
tmpp
(
nullptr
),
tmp_sloppy
(
nullptr
),
r_sloppy
(
nullptr
)
{
p
.
resize
(
nKrylov
+
1
);
Ap
.
resize
(
nKrylov
);
...
...
tests/multigrid_evolve_test.cpp
View file @
56027fc3
...
...
@@ -231,11 +231,11 @@ void setMultigridParam(QudaMultigridParam &mg_param)
mg_param
.
invert_param
=
&
inv_param
;
mg_param
.
n_level
=
mg_levels
;
for
(
int
i
=
0
;
i
<
mg_param
.
n_level
;
i
++
)
{
for
(
int
j
=
0
;
j
<
4
;
j
++
)
{
for
(
int
j
=
0
;
j
<
4
;
j
++
)
{
// if not defined use 4
mg_param
.
geo_block_size
[
i
][
j
]
=
geo_block_size
[
i
][
j
]
?
geo_block_size
[
i
][
j
]
:
4
;
}
for
(
int
j
=
4
;
j
<
QUDA_MAX_DIM
;
j
++
)
mg_param
.
geo_block_size
[
i
][
j
]
=
1
;
for
(
int
j
=
4
;
j
<
QUDA_MAX_DIM
;
j
++
)
mg_param
.
geo_block_size
[
i
][
j
]
=
1
;
mg_param
.
use_eig_solver
[
i
]
=
mg_eig
[
i
]
?
QUDA_BOOLEAN_YES
:
QUDA_BOOLEAN_NO
;
mg_param
.
spin_block_size
[
i
]
=
1
;
mg_param
.
verbosity
[
i
]
=
mg_verbosity
[
i
];
...
...
@@ -868,7 +868,7 @@ int main(int argc, char **argv)
invertQuda
(
spinorOut
,
spinorIn
,
&
inv_param2
);
mg_param
.
preserve_deflation
=
mg_eig_preserve_deflation
?
QUDA_BOOLEAN_YES
:
QUDA_BOOLEAN_NO
;
for
(
int
i
=
0
;
i
<
mg_param
.
n_level
;
i
++
)
mg_param
.
setup_maxiter_refresh
[
i
]
=
0
;
for
(
int
i
=
0
;
i
<
mg_param
.
n_level
;
i
++
)
mg_param
.
setup_maxiter_refresh
[
i
]
=
0
;
mg_preconditioner
=
newMultigridQuda
(
&
mg_param
);
inv_param
.
preconditioner
=
mg_preconditioner
;
...
...
tests/multigrid_invert_test.cpp
View file @
56027fc3
...
...
@@ -217,11 +217,11 @@ void setMultigridParam(QudaMultigridParam &mg_param)
mg_param
.
invert_param
=
&
inv_param
;
mg_param
.
n_level
=
mg_levels
;
for
(
int
i
=
0
;
i
<
mg_param
.
n_level
;
i
++
)
{
for
(
int
j
=
0
;
j
<
4
;
j
++
)
{
for
(
int
j
=
0
;
j
<
4
;
j
++
)
{
// if not defined use 4
mg_param
.
geo_block_size
[
i
][
j
]
=
geo_block_size
[
i
][
j
]
?
geo_block_size
[
i
][
j
]
:
4
;
}
for
(
int
j
=
4
;
j
<
QUDA_MAX_DIM
;
j
++
)
mg_param
.
geo_block_size
[
i
][
j
]
=
1
;
for
(
int
j
=
4
;
j
<
QUDA_MAX_DIM
;
j
++
)
mg_param
.
geo_block_size
[
i
][
j
]
=
1
;
mg_param
.
use_eig_solver
[
i
]
=
mg_eig
[
i
]
?
QUDA_BOOLEAN_YES
:
QUDA_BOOLEAN_NO
;
mg_param
.
verbosity
[
i
]
=
mg_verbosity
[
i
];
mg_param
.
setup_inv_type
[
i
]
=
setup_inv
[
i
];
...
...
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