15 if ( paramtop.count(path) == 0 ) {
17 QDPIO::cout <<
"Parameter with " << path <<
" not found. Setting default value "
18 << defValue <<
" for " << array.size() <<
" array members" << std::endl;
20 for(
int l=0;
l < array.size() ; ++
l) array[
l] = defValue;
26 if (
tmp.size() == 1 ) {
27 QDPIO::cout <<
"Broadcasting " << path <<
" = " <<
tmp[0] <<
" to " << array.size() <<
" array members" << std::endl;
29 for(
int l=0;
l < array.size(); ++
l) array[
l] =
tmp[0];
34 QDPIO::cout <<
"Copying " << path <<
" values to " << array.size() <<
" members " << std::endl;
35 if (
tmp.size() == array.size() ) {
36 for(
int l=0;
l < array.size(); ++
l) array[
l] =
tmp[
l];
39 QDPIO::cout <<
"Error: Array with path " << path <<
"has size "
40 <<
tmp.size() <<
" but " << array.size() <<
" are expected. " << std::endl;
47 MULTIGRIDSolverParams::MULTIGRIDSolverParams(XMLReader& xml,
50 XMLReader paramtop(xml, path);
53 read(paramtop,
"Verbosity", verbosity);
54 read(paramtop,
"Precision", prec);
55 read(paramtop,
"Reconstruct", reconstruct);
57 read(paramtop,
"Blocking", blocking);
58 mg_levels = blocking.size()+1;
64 nvec.resize(mg_levels-1);
65 nu_pre.resize(mg_levels-1);
66 nu_post.resize(mg_levels-1);
67 maxIterSubspaceCreate.resize(mg_levels-1);
68 maxIterSubspaceRefresh.resize(mg_levels-1);
69 rsdTargetSubspaceCreate.resize(mg_levels-1);
71 coarseSolverType.resize(mg_levels-1);
72 readArray<QudaSolverType>(paramtop,
"CoarseSolverType", coarseSolverType,
GCR);
75 tol.resize(mg_levels);
76 readArray<Real>(paramtop,
"CoarseResidual", tol, Real(0.0001));
78 maxIterations.resize(mg_levels);
79 readArray<int>(paramtop,
"MaxCoarseIterations", maxIterations, 12 );
81 smootherType.resize(mg_levels);
82 readArray<QudaSolverType>(paramtop,
"SmootherType", smootherType,
MR);
85 smootherTol.resize(mg_levels);
86 readArray<Real>(paramtop,
"SmootherTol", smootherTol, Real(0.25));
88 smootherHaloPrecision.resize(mg_levels);
89 readArray<QudaPrecisionType>(paramtop,
"SmootherHaloPrecision", smootherHaloPrecision,
DEFAULT);
91 smootherSchwarzType.resize(mg_levels);
95 smootherSchwarzCycle.resize(mg_levels);
96 readArray(paramtop,
"SmootherSchwarzCycle", smootherSchwarzCycle, 1);
98 read(paramtop,
"NullVectors", nvec);
99 read(paramtop,
"Pre-SmootherApplications", nu_pre);
100 read(paramtop,
"Post-SmootherApplications", nu_post);
101 if (nvec.size() != mg_levels-1 ) {
103 QDPIO::cout<<
"Warning. There are "<< blocking.size()
104 <<
" blockings but only " << nvec.size() <<
" sets of NullVectors" << std::endl;
108 if (nu_pre.size() != mg_levels-1 ) {
110 QDPIO::cout<<
"Error. There are "<< (mg_levels-1)
111 <<
" blockings but only " << nu_pre.size() <<
" sets pre-smoothing iterations" << std::endl;
115 subspaceSolver.resize(mg_levels-1);
116 readArray(paramtop,
"SubspaceSolver", subspaceSolver,
CG);
118 if( paramtop.count(
"./RsdTargetSubspaceCreate") == 1 ) {
119 read(paramtop,
"RsdTargetSubspaceCreate", rsdTargetSubspaceCreate);
123 for(
int l=0;
l < mg_levels-1; ++
l) {
124 rsdTargetSubspaceCreate[
l] = 5.0e-6;
128 if( paramtop.count(
"./MaxIterSubspaceCreate") == 1) {
129 read(paramtop,
"./MaxIterSubspaceCreate", maxIterSubspaceCreate);
132 for(
int l=0;
l < mg_levels-1; ++
l) {
133 maxIterSubspaceCreate[
l] = 500;
137 if( paramtop.count(
"./MaxIterSubspaceRefresh") == 1) {
138 read(paramtop,
"./MaxIterSubspaceRefresh", maxIterSubspaceRefresh);
141 for(
int l=0;
l < mg_levels-1; ++
l) {
142 maxIterSubspaceRefresh[
l] = maxIterSubspaceCreate[
l];
147 if( paramtop.count(
"./OuterGCRNKrylov") == 1 ) {
148 read(paramtop,
"OuterGCRNKrylov", outer_gcr_nkrylov);
151 outer_gcr_nkrylov = 12;
154 if( paramtop.count(
"./PrecondGCRNKrylov") == 1 ) {
155 read(paramtop,
"PrecondGCRNKrylov", precond_gcr_nkrylov);
158 precond_gcr_nkrylov = 12;
161 if (nu_post.size() != mg_levels-1 ) {
163 QDPIO::cout<<
"Warning. There are "<< blocking.size()
164 <<
" blockings but only " << nu_post.size() <<
" sets post-smoothing iterations " << std::endl;
168 read(paramtop,
"GenerateNullspace", generate_nullspace);
170 if( paramtop.count(
"./CheckMultigridSetup") == 1 ) {
171 read(paramtop,
"CheckMultigridSetup", check_multigrid_setup);
174 check_multigrid_setup =
true;
177 read(paramtop,
"GenerateAllLevels", generate_all_levels);
180 read(paramtop,
"CycleType", cycle_type);
184 if( paramtop.count(
"SchwarzType") > 0 ) {
185 read(paramtop,
"SchwarzType", schwarzType);
188 relaxationOmegaMG.resize(mg_levels);
189 readArray(paramtop,
"RelaxationOmegaMG", relaxationOmegaMG, Real(1.0));
192 if( paramtop.count(
"RelaxationOmegaOuter") > 0 ) {
193 read(paramtop,
"RelaxationOmegaOuter", relaxationOmegaOuter);
196 relaxationOmegaOuter = Real(1.0);
199 if(paramtop.count(
"SetupOnGPU") == 1) {
200 read(paramtop,
"SetupOnGPU", setup_on_gpu);
201 if ( setup_on_gpu.size() != mg_levels - 1 ) {
206 if ( setup_on_gpu.size() == 1 ) {
209 bool value = setup_on_gpu[0];
210 setup_on_gpu.resize(mg_levels-1);
211 for(
int l=0;
l < mg_levels-1; ++
l) {
212 setup_on_gpu[
l] = value;
217 QDPIO::cerr <<
"setup_on_gpu has size = " << setup_on_gpu.size() <<
218 " but it should be either 1 (broadcast to all levels) or " << mg_levels -1
219 <<
" (mg_levels -1) \n";
228 setup_on_gpu.resize(mg_levels-1);
229 for(
int l=0;
l < mg_levels-1; ++
l) {
230 setup_on_gpu[
l] =
true;
248 write(xml,
"Residual",
p.tol);
249 write(xml,
"MaxIterations",
p.maxIterations);
250 write(xml,
"SmootherType",
p.smootherType);
251 if (
p.smootherHaloPrecision[0] !=
DEFAULT ) {
252 write(xml,
"SmootherHaloPrecision",
p.smootherHaloPrecision);
254 write(xml,
"RelaxationOmegaMG",
p.relaxationOmegaMG);
255 write(xml,
"RelaxationOmegaOuter",
p.relaxationOmegaOuter);
256 write(xml,
"Verbosity",
p.verbosity);
257 write(xml,
"Precision",
p.prec);
258 write(xml,
"Reconstruct",
p.reconstruct);
259 write(xml,
"SchwarzType",
p.schwarzType);
260 write(xml,
"NullVectors",
p.nvec);
261 write(xml,
"MultiGridLevels",
p.mg_levels);
262 write(xml,
"GenerateNullSpace",
p.generate_nullspace);
263 write(xml,
"GenerateAllLevels",
p.generate_all_levels);
264 write(xml,
"CheckMultigridSetup",
p.check_multigrid_setup);
265 write(xml,
"CycleType",
p.cycle_type);
266 write(xml,
"Pre-SmootherApplications",
p.nu_pre);
267 write(xml,
"Post-SmootherApplications",
p.nu_post);
269 write(xml,
"OuterGCRNKrylov",
p.outer_gcr_nkrylov);
270 write(xml,
"PrecondGCRNKrylov",
p.precond_gcr_nkrylov);
271 write(xml,
"Blocking",
p.blocking);
272 write(xml,
"MaxIterSubspaceCreate",
p.maxIterSubspaceCreate);
273 write(xml,
"MaxIterSubspaceRefresh",
p.maxIterSubspaceRefresh);
274 write(xml,
"RsdTargetSubspaceCreate",
p.rsdTargetSubspaceCreate);
275 write(xml,
"SetupOnGPU",
p.setup_on_gpu);
Primary include file for CHROMA library code.
Asqtad Staggered-Dirac operator.
void read(XMLReader &xml, const std::string &path, MULTIGRIDSolverParams &p)
void readArray(XMLReader ¶mtop, const std::string &path, multi1d< T > &array, const T &defValue)
void write(XMLWriter &xml, const std::string &path, const MULTIGRIDSolverParams &p)
LinOpSysSolverMGProtoClover::T T
push(xml_out,"Cooled_Topology")