QUDA  0.9.0
quda_fortran.F90
Go to the documentation of this file.
1 !===============================================================================
2 !
3 ! quda_fortran.F90
4 !
5 !-------------------------------------------------------------------------------
6 !
7 ! This is a Fortran module that implements the C structs defined in
8 ! quda.h as Fortran modules. This is currently generated by hand, and
9 ! so must be matched against an appropriate version of QUDA. It would
10 ! be nice to auto-generate this from quda.h.
11 !
12 !-------------------------------------------------------------------------------
13 # include <enum_quda_fortran.h>
14 
15 !-------------------------------------------------------------------------------
16 
17 #include <quda_constants.h>
18 
20 
21  ! This corresponds to the QudaGaugeParam struct in quda.h
23 
24  qudafieldlocation :: location !The location of the gauge field
25 
26  integer(4), dimension(4) :: x
27 
28  real(8) :: anisotropy !Used for Wilson and Wilson-clover
29  real(8) :: tadpole_coeff !Used for staggered only
30  real(8) :: scale !Used by staggered long links
31 
32  qudalinktype :: link_type
33  qudagaugefieldorder :: gauge_order
34  qudatboundary :: t_boundary
35  qudaprecision :: cpu_prec
36  qudaprecision :: cuda_prec
37  qudareconstructtype :: reconstruct
38  qudaprecision :: cuda_prec_sloppy
39  qudareconstructtype :: reconstruct_sloppy
40  qudaprecision :: cuda_prec_precondition
41  qudareconstructtype :: reconstruct_precondition
42  qudagaugefixed :: gauge_fix
43 
44  integer(4) :: ga_pad
45 
46  integer(4) :: site_ga_pad ! Used by link fattening and the gauge and fermion forces
47 
48  integer(4) :: staple_pad ! Used by link fattening
49  integer(4) :: llfat_ga_pad ! Used by link fattening
50  integer(4) :: mom_ga_pad ! Used by the gauge and fermion forces
51  real(8) :: gauge_gib
52 
53  ! Set the staggered phase type of the links
54  qudastaggeredphase :: staggered_phase_type
55  ! Whether the staggered phase has already been applied to the links
56  integer(4) :: staggered_phase_applied
57 
58  ! Imaginary chemical potential
59  real(8) :: i_mu
60 
61  integer(4) :: overlap ! width of domain overlap
62 
63  ! When computing momentum, should we overwrite it or accumulate
64  ! to it (only presenty support in gauge-force)
65  integer(4) :: overwrite_mom
66 
67  integer(4) :: use_resident_gauge ! Use the resident gauge field
68  integer(4) :: use_resident_mom ! Use the resident momentume field
69  integer(4) :: make_resident_gauge ! Make the result gauge field resident
70  integer(4) :: make_resident_mom ! Make the result momentum field resident
71  integer(4) :: return_result_gauge ! Return the result gauge field
72  integer(4) :: return_result_mom ! Return the result momentum field
73 
74  integer(8) :: gauge_offset ! Offset into MILC site struct to the gauge field (only if gauge_order=MILC_SITE_GAUGE_ORDER)
75  integer(8) :: mom_offset ! Offset into MILC site struct to the momentum field (only if gauge_order=MILC_SITE_GAUGE_ORDER)
76  integer(8) :: site_size ! Size of MILC site struct (only if gauge_order=MILC_SITE_GAUGE_ORDER)
77 
78  end type quda_gauge_param
79 
80  ! This module corresponds to the QudaInvertParam struct in quda.h
82 
83  qudafieldlocation :: input_location ! The location of the input field
84  qudafieldlocation :: output_location ! The location of the output field
85 
86  qudadslashtype :: dslash_type
87  qudainvertertype :: inv_type
88 
89  real(8) :: mass ! Used for staggered only
90  real(8) :: kappa ! Used for Wilson and Wilson-clover
91 
92  real(8) :: m5 ! Domain wall height
93  integer(4) :: ls ! Extent of the 5th dimension (for domain wall)
94 
95  real(8), dimension(QUDA_MAX_DWF_LS) :: b_5 ! MDWF coefficients
96  real(8), dimension(QUDA_MAX_DWF_LS) :: c_5 ! will be used only for the mobius type of Fermion
97 
98  real(8) :: mu ! Twisted mass parameter
99  real(8) :: epsilon ! Twisted mass parameter
100  qudatwistflavortype :: twist_flavor ! Twisted mass flavor
101 
102  real(8) :: tol ! Requested L2 residual norm
103  real(8) :: tol_restart ! Solver tolerance in the L2 residual norm (used to restart InitCG)
104  real(8) :: tol_hq ! Requested heavy quark residual norm
105  integer(4) :: compute_true_res ! Whether to compute the true residual post solve
106  real(8) :: true_res ! Actual L2 residual norm achieved in solver
107  real(8) :: true_res_hq ! Actual heavy quark residual norm achieved in solver
108  integer(4) :: maxiter
109  real(8) :: reliable_delta ! Reliable update tolerance
110  integer(4) :: use_sloppy_partial_accumulator ! Whether to keep the partial solution accumuator in sloppy precision
111  integer(4) :: solution_accumulator_pipeline ! How many direction vectors we accumulate into the solution vector at once
112  integer(4) :: max_res_increase ! How many residual increases we tolerate when doing reliable updates
113  integer(4) :: max_res_increase_total ! Total number of residual increases we tolerate
114  integer(4) :: heavy_quark_check ! After how many iterations shall the heavy quark residual be updated
115  integer(4) :: pipeline ! Whether to enable pipeline solver option
116  integer(4) :: num_offset ! Number of offsets in the multi-shift solver
117  integer(4) :: num_src ! Number of sources in the multiple source solver
118  integer(4) :: overlap ! width of domain overlaps
119  real(8), dimension(QUDA_MAX_MULTI_SHIFT) :: offset ! Offsets for multi-shift solver
120  real(8), dimension(QUDA_MAX_MULTI_SHIFT) :: tol_offset ! Solver tolerance for each offset
121 
122  ! Solver tolerance for each shift when refinement is applied using the heavy-quark residual
123  real(8), dimension(QUDA_MAX_MULTI_SHIFT) :: tol_hq_offset
124 
125  ! Actual L2 residual norm achieved in solver for each offset
126  real(8), dimension(QUDA_MAX_MULTI_SHIFT) :: true_res_offset
127 
128  ! Iterated L2 residual achieved in multi shift solver for each offset
129  real(8), dimension(QUDA_MAX_MULTI_SHIFT) :: iter_res_offset
130 
131  ! Actual heavy quark residual norm achieved in solver for each offset
132  real(8), dimension(QUDA_MAX_MULTI_SHIFT) :: true_res_hq_offset
133 
134  ! Residuals in the partial faction expansion
135  real(8), dimension(QUDA_MAX_MULTI_SHIFT) :: residue
136 
137  ! Whether we should evaluate the action after the linear solve
138  integer(4) :: compute_action
139 
140  ! Computed value of the bilinear action (complex valued)
141  ! invert: \phi^\dagger A^{-1} \phi
142  ! multishift: \phi^\dagger r(x) \phi = \phi^\dagger (sum_k residue[k] * (A + offset[k])^{-1} ) \phi
143  real(8), dimension(2) :: action
144 
145  qudasolutiontype :: solution_type ! Type of system to solve
146  qudasolvetype :: solve_type ! How to solve it
147  qudamatpctype :: matpc_type
148  qudadagtype :: dagger
149  qudamassnormalization :: mass_normalization
150 
151  qudasolvernormalization :: solver_normalization
152  qudapreservesource :: preserve_source
153 
154  qudaprecision :: cpu_prec
155  qudaprecision :: cuda_prec
156  qudaprecision :: cuda_prec_sloppy
157  qudaprecision :: cuda_prec_precondition
158 
159  qudadiracfieldorder :: dirac_order
160 
161  ! Gamma basis of the input and output host fields
162  qudagammabasis :: gamma_basis
163 
164  qudafieldlocation :: clover_location ! The location of the clover field
165  qudaprecision :: clover_cpu_prec
166  qudaprecision :: clover_cuda_prec
167  qudaprecision :: clover_cuda_prec_sloppy
168  qudaprecision :: clover_cuda_prec_precondition
169 
170  qudacloverfieldorder :: clover_order
171  qudauseinitguess :: use_init_guess
172 
173  real(8) :: clover_coeff ! Coefficient of the clover term
174  real(8) :: clover_rho ! Real number added to the clover diagonal (not to inverse)
175  integer(4) :: compute_clover_trlog ! Whether to compute the trace log of the clover term
176  real(8), dimension(2) :: trloga ! The trace log of the clover term (even/odd computed separately)
177 
178  integer(4) :: compute_clover ! Whether to compute the clover field
179  integer(4) :: compute_clover_inverse ! Whether to compute the clover inverse field
180  integer(4) :: return_clover ! Whether to copy back the clover matrix field
181  integer(4) :: return_clover_inverse ! Whether to copy back the inverted clover matrix field
182 
183  qudaverbosity :: verbosity ! The verbosity setting to use in the solver
184 
185  integer(4) :: sp_pad
186  integer(4) :: cl_pad
187 
188  integer(4) :: iter
189  real(8) :: spinor_gib
190  real(8) :: clover_gib
191  real(8) :: gflops
192  real(8) :: secs
193 
194  ! Enable auto-tuning?
195  qudatune :: tune
196 
197  ! Number of steps in s-step algorithms
198  integer(4) :: nsteps
199 
200  ! Maximum size of Krylov space used by solver
201  integer(4) :: gcr_nkrylov
202 
203  ! The following parameters are related to the domain-decomposed preconditioner.
204 
205  ! The inner Krylov solver used in the preconditioner. Set to
206  ! QUDA_INVALID_INVERTER to disable the preconditioner entirely.
207  qudainvertertype :: inv_type_precondition
208 
209  integer(8) :: preconditioner ! pointer to preconditioner instance
210 
211  integer(8) :: deflation_op ! pointer to deflation instance
212 
213  ! Dslash used in the inner Krylov solver
214  qudadslashtype :: dslash_type_precondition
215 
216  ! Verbosity of the inner Krylov solver
217  qudaverbosity :: verbosity_precondition
218 
219  ! Tolerance in the inner solver
220  real(8) :: tol_precondition
221 
222  ! Maximum number of iterations allowed in the inner solver
223  integer(4) :: maxiter_precondition
224 
225  ! Relaxation parameter used in GCR-DD (default = 1.0)
226  real(8) :: omega
227 
228  ! Number of preconditioner cycles to perform per iteration
229  integer(4) :: precondition_cycle
230 
231  ! Whether to use additive or multiplicative Schwarz preconditioning
232  qudaschwarztype :: schwarz_type
233 
234  ! Whether to use the Fermilab heavy-quark residual or standard residual to gauge convergence
235  qudaresidualtype ::residual_type
236 
237  ! Parameters for deflated solvers
238  qudaprecision :: cuda_prec_ritz ! The precision of the Ritz vectors
239  integer(4)::nev
240  integer(4)::max_search_dim ! for magma library this parameter must be multiple 16?
241  integer(4)::rhs_idx
242  integer(4)::deflation_grid !total deflation space is nev*deflation_grid
243  integer(4)::use_reduced_vector_set ! eigCG: specifies whether to use reduced eigenvector set
244  real(8):: eigenval_tol ! eigCG: selection criterion for the reduced eigenvector set
245  integer(4)::use_cg_updates ! mixed precision eigCG:whether to use cg refinement corrections in the incremental stage
246  real(8)::cg_iterref_tol ! mixed precision eigCG: tolerance for cg refinement corrections in the incremental stage
247  integer(4)::eigcg_max_restarts ! mixed precision eigCG tuning parameter: minimum search vector space restarts
248  integer(4)::max_restart_num ! initCG tuning parameter: maximum restarts
249  real(8)::inc_tol ! initCG tuning parameter: decrease in absolute value of the residual within each restart cycle
250 
251  ! Parameters for setting data residency of the solver
252  integer(4)::make_resident_solution ! Whether to make the solution vector(s) after the solve
253  integer(4)::use_resident_solution ! Whether to use the resident solution vector(s)
254 
255  ! Whether to use the solution vector to augment the chronological forecast
256  integer(4)::make_resident_chrono
257 
258  ! Whether to use the resident chronological basis
259  integer(4)::use_resident_chrono
260 
261  ! The maximum length of the chronological history to store
262  integer(4)::max_chrono_dim
263 
264  ! The index to indeicate which chrono history we are augmenting */
265  integer(4)::chrono_index
266 
267  ! Which external library to use in the linear solvers (MAGMA or Eigen) */
268  qudaextlibtype::extlib_type
269 
270  end type quda_invert_param
271 
272 end module quda_fortran
273 !===============================================================================
#define m5