QUDA  v1.1.0
A library for QCD on GPUs
plaq_test.cpp
Go to the documentation of this file.
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <time.h>
4 #include <math.h>
5 #include <string.h>
6 
7 #include <util_quda.h>
8 #include <host_utils.h>
9 #include <command_line_params.h>
10 
11 // In a typical application, quda.h is the only QUDA header required.
12 #include <quda.h>
13 
14 int main(int argc, char **argv)
15 {
16  auto app = make_app();
17  try {
18  app->parse(argc, argv);
19  } catch (const CLI::ParseError &e) {
20  return app->exit(e);
21  }
22 
23  // initialize QMP/MPI, QUDA comms grid and RNG (host_utils.cpp)
24  initComms(argc, argv, gridsize_from_cmdline);
25 
29 
32 
34 
36 
37  // call srand() with a rank-dependent seed
38  initRand();
39 
40  // Allocate host side memory for the gauge field.
41  //----------------------------------------------------------------------------
42  void *gauge[4];
43  // Allocate space on the host (always best to allocate and free in the same scope)
44  for (int dir = 0; dir < 4; dir++) gauge[dir] = malloc(V * gauge_site_size * host_gauge_data_type_size);
45  constructHostGaugeField(gauge, gauge_param, argc, argv);
46  // Load the gauge field to the device
47  loadGaugeQuda((void *)gauge, &gauge_param);
48 
49  double plaq[3];
50  plaqQuda(plaq);
51  printfQuda("Computed plaquette gauge precise is %16.15e (spatial = %16.15e, temporal = %16.15e)\n", plaq[0], plaq[1],
52  plaq[2]);
53 
54  freeGaugeQuda();
55  endQuda();
56 
57  // release memory
58  for (int dir = 0; dir < 4; dir++) { free(gauge[dir]); }
59 
60  finalizeComms();
61  return 0;
62 }
63 
64 
QudaReconstructType link_recon_sloppy
std::shared_ptr< QUDAApp > make_app(std::string app_description, std::string app_name)
QudaReconstructType link_recon
int device_ordinal
QudaVerbosity verbosity
QudaPrecision prec
std::array< int, 4 > gridsize_from_cmdline
QudaPrecision prec_sloppy
int V
Definition: host_utils.cpp:37
void setDims(int *)
Definition: host_utils.cpp:315
QudaGaugeParam gauge_param
Definition: covdev_test.cpp:26
@ QUDA_RECONSTRUCT_INVALID
Definition: enum_quda.h:76
@ QUDA_INVALID_PRECISION
Definition: enum_quda.h:66
#define gauge_site_size
Definition: face_gauge.cpp:34
size_t host_gauge_data_type_size
Definition: host_utils.cpp:65
void initComms(int argc, char **argv, std::array< int, 4 > &commDims)
Definition: host_utils.cpp:255
void finalizeComms()
Definition: host_utils.cpp:292
void constructHostGaugeField(void **gauge, QudaGaugeParam &gauge_param, int argc, char **argv)
Definition: host_utils.cpp:166
void initRand()
Definition: host_utils.cpp:302
void setWilsonGaugeParam(QudaGaugeParam &gauge_param)
Definition: set_params.cpp:37
int main(int argc, char **argv)
Definition: plaq_test.cpp:14
Main header file for the QUDA library.
void plaqQuda(double plaq[3])
QudaGaugeParam newQudaGaugeParam(void)
void freeGaugeQuda(void)
void initQuda(int device)
void loadGaugeQuda(void *h_gauge, QudaGaugeParam *param)
void endQuda(void)
int X[4]
Definition: quda.h:35
#define printfQuda(...)
Definition: util_quda.h:114
void setVerbosity(QudaVerbosity verbosity)
Definition: util_quda.cpp:25