QUDA  v1.1.0
A library for QCD on GPUs
quda_internal.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <quda_api.h>
4 #include <string>
5 #include <complex>
6 #include <vector>
7 
8 #if ((defined(QMP_COMMS) || defined(MPI_COMMS)) && !defined(MULTI_GPU))
9 #error "MULTI_GPU must be enabled to use MPI or QMP"
10 #endif
11 
12 #if (!defined(QMP_COMMS) && !defined(MPI_COMMS) && defined(MULTI_GPU))
13 #error "MPI or QMP must be enabled to use MULTI_GPU"
14 #endif
15 
16 #ifdef QMP_COMMS
17 #include <qmp.h>
18 #endif
19 
20 // these are helper macros used to enable spin-1, spin-2 and spin-4 building blocks as needed
21 #if defined(GPU_WILSON_DIRAC) || defined(GPU_DOMAIN_WALL_DIRAC) || defined(GPU_CLOVER_DIRAC) \
22  || defined(GPU_TWISTED_MASS_DIRAC) || defined(GPU_TWISTED_CLOVER_DIRAC) || defined(GPU_NDEG_TWISTED_MASS_DIRAC) \
23  || defined(GPU_CLOVER_HASENBUSCH_TWIST) || defined(GPU_COVDEV)
24 #define NSPIN4
25 #endif
26 
27 #if defined(GPU_MULTIGRID)
28 #define NSPIN2
29 #endif
30 
31 #if defined(GPU_STAGGERED_DIRAC)
32 #define NSPIN1
33 #endif
34 
35 // this is a helper macro for stripping the path information from
36 // __FILE__. FIXME - convert this into a consexpr routine
37 #define KERNEL_FILE \
38  (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : \
39  strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
40 
41 #define TEX_ALIGN_REQ (512*2) //Fermi, factor 2 comes from even/odd
42 #define ALIGNMENT_ADJUST(n) ( (n+TEX_ALIGN_REQ-1)/TEX_ALIGN_REQ*TEX_ALIGN_REQ)
43 #include <enum_quda.h>
44 #include <quda.h>
45 #include <util_quda.h>
46 #include <malloc_quda.h>
47 #include <object.h>
48 
49 #ifdef __cplusplus
50 extern "C" {
51 #endif
52 
54  void *field;
55  };
56 
57  // extern cudaDeviceProp deviceProp;
58  extern qudaStream_t *streams;
59 
60 #ifdef __cplusplus
61 }
62 #endif
63 
64 namespace quda {
65 
66  struct alignas(8) char8 {
67  char4 x;
68  char4 y;
69  };
70 
71  struct alignas(16) short8 {
72  short4 x;
73  short4 y;
74  };
75 
76  struct alignas(32) float8 {
77  float4 x;
78  float4 y;
79  };
80 
81  struct alignas(64) double8 {
82  double4 x;
83  double4 y;
84  };
85 
86  typedef std::complex<double> Complex;
87 
93  template< typename T > struct fixedMaxValue{ static constexpr float value = 0.0f; };
94  template<> struct fixedMaxValue<short>{ static constexpr float value = 32767.0f; };
95  template<> struct fixedMaxValue<short2>{ static constexpr float value = 32767.0f; };
96  template<> struct fixedMaxValue<short4>{ static constexpr float value = 32767.0f; };
97  template <> struct fixedMaxValue<short8> {
98  static constexpr float value = 32767.0f;
99  };
100  template <> struct fixedMaxValue<int8_t> {
101  static constexpr float value = 127.0f;
102  };
103  template<> struct fixedMaxValue<char2>{ static constexpr float value = 127.0f; };
104  template<> struct fixedMaxValue<char4>{ static constexpr float value = 127.0f; };
105  template <> struct fixedMaxValue<char8> {
106  static constexpr float value = 127.0f;
107  };
108 
109  template <typename T> struct fixedInvMaxValue {
110  static constexpr float value = 3.402823e+38f;
111  };
112  template <> struct fixedInvMaxValue<short> {
113  static constexpr float value = 3.0518509476e-5f;
114  };
115  template <> struct fixedInvMaxValue<short2> {
116  static constexpr float value = 3.0518509476e-5f;
117  };
118  template <> struct fixedInvMaxValue<short4> {
119  static constexpr float value = 3.0518509476e-5f;
120  };
121  template <> struct fixedInvMaxValue<short8> {
122  static constexpr float value = 3.0518509476e-5f;
123  };
124  template <> struct fixedInvMaxValue<int8_t> {
125  static constexpr float value = 7.874015748031e-3f;
126  };
127  template <> struct fixedInvMaxValue<char2> {
128  static constexpr float value = 7.874015748031e-3f;
129  };
130  template <> struct fixedInvMaxValue<char4> {
131  static constexpr float value = 7.874015748031e-3f;
132  };
133  template <> struct fixedInvMaxValue<char8> {
134  static constexpr float value = 7.874015748031e-3f;
135  };
136 
137  const int Nstream = 9;
138 
144 
145 }
146 
147 #include <timer.h>
148 
QudaInvertParam inv_param
Definition: covdev_test.cpp:27
bool canReuseResidentGauge(QudaInvertParam *inv_param)
const int Nstream
std::complex< double > Complex
Definition: quda_internal.h:86
Main header file for the QUDA library.
cudaStream_t qudaStream_t
Definition: quda_api.h:9
qudaStream_t * streams
Definition: device.cpp:15
static constexpr float value
static constexpr float value
Definition: quda_internal.h:93