QUDA  1.0.0
test_util.h
Go to the documentation of this file.
1 #ifndef _TEST_UTIL_H
2 #define _TEST_UTIL_H
3 
4 #include <quda.h>
5 #include <random_quda.h>
6 
7 #define gaugeSiteSize 18 // real numbers per link
8 #define spinorSiteSize 24 // real numbers per spinor
9 #define cloverSiteSize 72 // real numbers per block-diagonal clover matrix
10 #define momSiteSize 10 // real numbers per momentum
11 #define hwSiteSize 12 // real numbers per half wilson
12 
13 #ifdef __cplusplus
14 //extern "C" {
15 #endif
16 
17  extern int Z[4];
18  extern int V;
19  extern int Vh;
20  extern int Vs_x, Vs_y, Vs_z, Vs_t;
21  extern int Vsh_x, Vsh_y, Vsh_z, Vsh_t;
22  extern int faceVolume[4];
23  extern int E1, E1h, E2, E3, E4;
24  extern int E[4];
25  extern int V_ex, Vh_ex;
26 
27  extern int Ls;
28  extern int V5;
29  extern int V5h;
30 
31  extern int mySpinorSiteSize;
32 
33  void initComms(int argc, char **argv, int *const commDims);
34  void finalizeComms();
35  void initRand();
36 
37  void setDims(int *X);
38  void dw_setDims(int *X, const int L5);
39  void setSpinorSiteSize(int n);
40  int dimPartitioned(int dim);
41 
42  bool last_node_in_t();
43 
44  int neighborIndex(int i, int oddBit, int dx4, int dx3, int dx2, int dx1);
45  int neighborIndexFullLattice(int i, int dx4, int dx3, int dx2, int dx1) ;
46 
47  int neighborIndex(int dim[], int index, int oddBit, int dx[]);
48  int neighborIndexFullLattice(int dim[], int index, int dx[]);
49 
50  int neighborIndex_mg(int i, int oddBit, int dx4, int dx3, int dx2, int dx1);
51  int neighborIndexFullLattice_mg(int i, int dx4, int dx3, int dx2, int dx1);
52 
53  void printSpinorElement(void *spinor, int X, QudaPrecision precision);
54  void printGaugeElement(void *gauge, int X, QudaPrecision precision);
55 
56  int fullLatticeIndex(int i, int oddBit);
57  int fullLatticeIndex(int dim[], int index, int oddBit);
58  int getOddBit(int X);
59 
61 
62 
63  void construct_gauge_field(void **gauge, int type, QudaPrecision precision, QudaGaugeParam *param);
64  void construct_fat_long_gauge_field(void **fatlink, void** longlink, int type,
65  QudaPrecision precision, QudaGaugeParam*,
67 
69  void construct_spinor_source(void *v, int nSpin, int nColor, QudaPrecision precision, const int *const x,
70  quda::RNG &rng);
71  void construct_clover_field(void *clover, double norm, double diag, QudaPrecision precision);
72  void createSiteLinkCPU(void** link, QudaPrecision precision, int phase) ;
73 
74  void su3_construct(void *mat, QudaReconstructType reconstruct, QudaPrecision precision);
75  void su3_reconstruct(void *mat, int dir, int ga_idx, QudaReconstructType reconstruct, QudaPrecision precision, QudaGaugeParam *param);
76 
77  void compare_spinor(void *spinor_cpu, void *spinor_gpu, int len, QudaPrecision precision);
78  void strong_check(void *spinor, void *spinorGPU, int len, QudaPrecision precision);
79  int compare_floats(void *a, void *b, int len, double epsilon, QudaPrecision precision);
80 
81  void check_gauge(void **, void **, double epsilon, QudaPrecision precision);
82 
83  int strong_check_link(void ** linkA, const char* msgA, void **linkB, const char* msgB, int len, QudaPrecision prec);
84  int strong_check_mom(void * momA, void *momB, int len, QudaPrecision prec);
85 
86  void createMomCPU(void* mom, QudaPrecision precision);
87  void createHwCPU(void* hw, QudaPrecision precision);
88 
89  //used by link fattening code
90  int x4_from_full_index(int i);
91 
92 // ---------- gauge_read.cpp ----------
93 
94  //void readGaugeField(char *filename, float *gauge[], int argc, char *argv[]);
95 
96  // additions for dw (quickly hacked on)
97  int fullLatticeIndex_4d(int i, int oddBit);
98  int fullLatticeIndex_5d(int i, int oddBit);
99  int fullLatticeIndex_5d_4dpc(int i, int oddBit);
100  int process_command_line_option(int argc, char** argv, int* idx);
101 
102  // use for some profiling
103  void stopwatchStart();
104  double stopwatchReadSeconds();
105 
106 #ifdef __cplusplus
107 //}
108 #endif
109 
110 #ifdef __cplusplus
111  extern "C" {
112 #endif
113 
114  // implemented in face_gauge.cpp
115  void exchange_cpu_sitelink(int* X,void** sitelink, void** ghost_sitelink,
116  void** ghost_sitelink_diag,
117  QudaPrecision gPrecision, QudaGaugeParam* param, int optflag);
118  void exchange_cpu_sitelink_ex(int* X, int *R, void** sitelink, QudaGaugeFieldOrder cpu_order,
119  QudaPrecision gPrecision, int optflag, int geometry);
120  void exchange_cpu_staple(int* X, void* staple, void** ghost_staple,
121  QudaPrecision gPrecision);
123  void exchange_llfat_cleanup(void);
124 
125 #ifdef __cplusplus
126  }
127 #endif
128 
130  {
131  switch (i) {
132  case 0: return QUDA_QUARTER_PRECISION;
133  case 1: return QUDA_HALF_PRECISION;
134  case 2: return QUDA_SINGLE_PRECISION;
135  case 3: return QUDA_DOUBLE_PRECISION;
136  }
137  return QUDA_INVALID_PRECISION;
138  }
139 
141  {
142  switch (recon) {
143  case QUDA_RECONSTRUCT_NO: return 4;
144  case QUDA_RECONSTRUCT_13:
145  case QUDA_RECONSTRUCT_12: return 2;
146  case QUDA_RECONSTRUCT_9:
147  case QUDA_RECONSTRUCT_8: return 1;
148  default: return 0;
149  }
150  }
151 
152 #endif // _TEST_UTIL_H
QudaDslashType dslash_type
Definition: test_util.cpp:1621
void construct_clover_field(void *clover, double norm, double diag, QudaPrecision precision)
Definition: test_util.cpp:1167
int V5h
Definition: test_util.cpp:40
void exchange_cpu_sitelink_ex(int *X, int *R, void **sitelink, QudaGaugeFieldOrder cpu_order, QudaPrecision gPrecision, int optflag, int geometry)
Definition: face_gauge.cpp:644
void dw_setDims(int *X, const int L5)
Definition: test_util.cpp:187
void createHwCPU(void *hw, QudaPrecision precision)
Definition: test_util.cpp:1487
int strong_check_mom(void *momA, void *momB, int len, QudaPrecision prec)
Definition: test_util.cpp:1559
int getReconstructNibble(QudaReconstructType recon)
Definition: test_util.h:140
int Vsh_t
Definition: test_util.cpp:30
enum QudaPrecision_s QudaPrecision
int mySpinorSiteSize
Definition: test_util.cpp:42
__host__ __device__ ValueType norm(const complex< ValueType > &z)
Returns the magnitude of z squared.
void exchange_cpu_sitelink(int *X, void **sitelink, void **ghost_sitelink, void **ghost_sitelink_diag, QudaPrecision gPrecision, QudaGaugeParam *param, int optflag)
Definition: face_gauge.cpp:512
int E3
Definition: test_util.cpp:34
int E2
Definition: test_util.cpp:34
double epsilon
Definition: test_util.cpp:1649
void createSiteLinkCPU(void **link, QudaPrecision precision, int phase)
Definition: test_util.cpp:1227
void strong_check(void *spinor, void *spinorGPU, int len, QudaPrecision precision)
void setDims(int *X)
Definition: test_util.cpp:151
void construct_spinor_source(void *v, int nSpin, int nColor, QudaPrecision precision, const int *const x, quda::RNG &rng)
Definition: test_util.cpp:1342
void printGaugeElement(void *gauge, int X, QudaPrecision precision)
Definition: test_util.cpp:231
int Ls
Definition: test_util.cpp:38
static int R[4]
void construct_fat_long_gauge_field(void **fatlink, void **longlink, int type, QudaPrecision precision, QudaGaugeParam *, QudaDslashType dslash_type)
Definition: test_util.cpp:1062
int strong_check_link(void **linkA, const char *msgA, void **linkB, const char *msgB, int len, QudaPrecision prec)
Definition: test_util.cpp:1429
int V_ex
Definition: test_util.cpp:36
void printSpinorElement(void *spinor, int X, QudaPrecision precision)
Definition: test_util.cpp:223
void finalizeComms()
Definition: test_util.cpp:128
int Z[4]
Definition: test_util.cpp:26
int Vsh_z
Definition: test_util.cpp:30
int E[4]
Definition: test_util.cpp:35
int E4
Definition: test_util.cpp:34
QudaGaugeParam param
Definition: pack_test.cpp:17
int E1h
Definition: test_util.cpp:34
int V
Definition: test_util.cpp:27
int Vh_ex
Definition: test_util.cpp:36
int neighborIndex(int i, int oddBit, int dx4, int dx3, int dx2, int dx1)
Definition: test_util.cpp:488
QudaPrecision getPrecision(int i)
Definition: test_util.h:129
static void * hw
int Vs_z
Definition: test_util.cpp:29
const int nColor
Definition: covdev_test.cpp:75
void exchange_cpu_staple(int *X, void *staple, void **ghost_staple, QudaPrecision gPrecision)
Definition: face_gauge.cpp:980
Class declaration to initialize and hold CURAND RNG states.
Definition: random_quda.h:23
int Vsh_y
Definition: test_util.cpp:30
void check_gauge(void **, void **, double epsilon, QudaPrecision precision)
Definition: test_util.cpp:1220
enum QudaGaugeFieldOrder_s QudaGaugeFieldOrder
void su3_reconstruct(void *mat, int dir, int ga_idx, QudaReconstructType reconstruct, QudaPrecision precision, QudaGaugeParam *param)
Definition: test_util.cpp:412
int fullLatticeIndex_5d(int i, int oddBit)
Definition: test_util.cpp:682
int X[4]
Definition: covdev_test.cpp:70
void exchange_llfat_init(QudaPrecision prec)
Definition: face_gauge.cpp:373
bool last_node_in_t()
Definition: test_util.cpp:118
int getOddBit(int X)
Definition: test_util.cpp:247
int x4_from_full_index(int i)
Definition: test_util.cpp:692
void exchange_llfat_cleanup(void)
void construct_gauge_field(void **gauge, int type, QudaPrecision precision, QudaGaugeParam *param)
Definition: test_util.cpp:1047
int V5
Definition: test_util.cpp:39
void compare_spinor(void *spinor_cpu, void *spinor_gpu, int len, QudaPrecision precision)
int Vs_y
Definition: test_util.cpp:29
int fullLatticeIndex_4d(int i, int oddBit)
Definition: test_util.cpp:648
void stopwatchStart()
Definition: test_util.cpp:4419
static int index(int ndim, const int *dims, const int *x)
Definition: comm_common.cpp:32
int neighborIndexFullLattice_mg(int i, int dx4, int dx3, int dx2, int dx1)
Definition: test_util.cpp:601
int neighborIndexFullLattice(int i, int dx4, int dx3, int dx2, int dx1)
Definition: test_util.cpp:556
int fullLatticeIndex_5d_4dpc(int i, int oddBit)
Definition: test_util.cpp:687
double stopwatchReadSeconds()
Definition: test_util.cpp:4423
int neighborIndex_mg(int i, int oddBit, int dx4, int dx3, int dx2, int dx1)
Definition: test_util.cpp:523
enum QudaReconstructType_s QudaReconstructType
Main header file for the QUDA library.
int Vs_x
Definition: test_util.cpp:29
void createMomCPU(void *mom, QudaPrecision precision)
Definition: test_util.cpp:1451
int fullLatticeIndex(int i, int oddBit)
Definition: test_util.cpp:452
int process_command_line_option(int argc, char **argv, int *idx)
Definition: test_util.cpp:2019
enum QudaDslashType_s QudaDslashType
void * longlink
void * fatlink
int Vsh_x
Definition: test_util.cpp:30
int compare_floats(void *a, void *b, int len, double epsilon, QudaPrecision precision)
Definition: test_util.cpp:434
void initRand()
Definition: test_util.cpp:138
void mat(void *out, void **link, void *in, int dagger_bit, int mu, QudaPrecision sPrecision, QudaPrecision gPrecision)
int faceVolume[4]
Definition: test_util.cpp:31
int E1
Definition: test_util.cpp:34
void applyGaugeFieldScaling_long(void **gauge, int Vh, QudaGaugeParam *param, QudaDslashType dslash_type, QudaPrecision local_prec)
Definition: test_util.cpp:854
QudaPrecision prec
Definition: test_util.cpp:1608
int Vs_t
Definition: test_util.cpp:29
void su3_construct(void *mat, QudaReconstructType reconstruct, QudaPrecision precision)
Definition: test_util.cpp:322
int Vh
Definition: test_util.cpp:28
cpuColorSpinorField * spinor
Definition: covdev_test.cpp:41
void setSpinorSiteSize(int n)
Definition: test_util.cpp:211
int dimPartitioned(int dim)
Definition: test_util.cpp:1776
void initComms(int argc, char **argv, int *const commDims)
Definition: test_util.cpp:88