QUDA
v0.5.0
A library for QCD on GPUs
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
quda
include
quda_internal.h
Go to the documentation of this file.
1
#ifndef _QUDA_INTERNAL_H
2
#define _QUDA_INTERNAL_H
3
4
#include <cuda.h>
5
#include <cuda_runtime.h>
6
#include <sys/time.h>
7
#include <string>
8
9
#ifdef USE_QDPJIT
10
#include "qdp_quda.h"
11
#endif
12
13
#ifdef QMP_COMMS
14
#include <qmp.h>
15
#endif
16
17
#define MAX_SHORT 32767.0f
18
19
// The "Quda" prefix is added to avoid collisions with other libraries.
20
21
#define GaugeFieldOrder QudaGaugeFieldOrder
22
#define DiracFieldOrder QudaDiracFieldOrder
23
#define CloverFieldOrder QudaCloverFieldOrder
24
#define InverterType QudaInverterType
25
#define MatPCType QudaMatPCType
26
#define SolutionType QudaSolutionType
27
#define MassNormalization QudaMassNormalization
28
#define PreserveSource QudaPreserveSource
29
#define DagType QudaDagType
30
#define TEX_ALIGN_REQ (512*2) //Fermi, factor 2 comes from even/odd
31
#define ALIGNMENT_ADJUST(n) ( (n+TEX_ALIGN_REQ-1)/TEX_ALIGN_REQ*TEX_ALIGN_REQ)
32
#include <
enum_quda.h
>
33
#include <
quda.h
>
34
#include <
util_quda.h
>
35
#include <
malloc_quda.h
>
36
37
// Use bindless texture on Kepler
38
#if (__COMPUTE_CAPABILITY__ >= 300) && (CUDA_VERSION >= 5000)
39
#define USE_TEXTURE_OBJECTS
40
#endif
41
42
43
#ifdef __cplusplus
44
extern
"C"
{
45
#endif
46
47
typedef
void
*
ParityGauge
;
48
49
// replace below with ColorSpinorField
50
typedef
struct
{
51
size_t
bytes
;
52
QudaPrecision
precision
;
53
int
length
;
// total length
54
int
volume
;
// geometric volume (single parity)
55
int
X
[
QUDA_MAX_DIM
];
// the geometric lengths (single parity)
56
int
Nc
;
// length of color dimension
57
int
Ns
;
// length of spin dimension
58
void
*
data
;
// either (double2*), (float4 *) or (short4 *), depending on precision
59
float
*
dataNorm
;
// used only when precision is QUDA_HALF_PRECISION
60
}
ParityHw
;
61
62
typedef
struct
{
63
ParityHw
odd
;
64
ParityHw
even
;
65
}
FullHw
;
66
67
struct
QUDA_DiracField
{
68
void
*
field
;
69
};
70
71
extern
cudaDeviceProp
deviceProp
;
72
extern
cudaStream_t *
streams
;
73
74
#ifdef __cplusplus
75
}
76
#endif
77
78
namespace
quda {
79
85
struct
Timer
{
87
double
time
;
88
90
double
last
;
91
93
timeval
start
;
94
96
timeval
stop
;
97
99
bool
running
;
100
101
Timer
() :
time
(0.0),
last
(0.0),
running
(false) { ; }
102
103
void
Start
() {
104
if
(
running
)
errorQuda
(
"Cannot start an already running timer"
);
105
gettimeofday(&
start
, NULL);
106
running
=
true
;
107
}
108
109
void
Stop
() {
110
if
(!
running
)
errorQuda
(
"Cannot start an already running timer"
);
111
gettimeofday(&
stop
, NULL);
112
113
long
ds =
stop
.tv_sec -
start
.tv_sec;
114
long
dus =
stop
.tv_usec -
start
.tv_usec;
115
last
= ds + 0.000001*dus;
116
time
+=
last
;
117
118
running
=
false
;
119
}
120
121
double
Last
() {
return
last
; }
122
123
};
124
126
enum
QudaProfileType
{
127
QUDA_PROFILE_H2D
,
128
QUDA_PROFILE_D2H
,
129
QUDA_PROFILE_INIT
,
130
QUDA_PROFILE_PREAMBLE
,
131
QUDA_PROFILE_COMPUTE
,
132
QUDA_PROFILE_EPILOGUE
,
133
QUDA_PROFILE_FREE
,
134
QUDA_PROFILE_TOTAL
,
135
QUDA_PROFILE_COUNT
136
};
137
138
struct
TimeProfile
{
139
std::string
fname
;
141
Timer
profile
[
QUDA_PROFILE_COUNT
];
142
static
std::string
pname
[];
143
144
TimeProfile
(std::string
fname
) : fname(fname) { ; }
145
147
void
Print
();
148
150
Timer
&
operator[]
(
int
idx
) {
return
profile
[
idx
]; }
151
};
152
153
#ifdef MULTI_GPU
154
const
int
Nstream
= 9;
155
#else
156
const
int
Nstream
= 1;
157
#endif
158
159
}
// namespace quda
160
161
extern
int
verbose
;
162
163
#endif // _QUDA_INTERNAL_H
Generated on Wed Mar 20 2013 12:52:14 for QUDA by
1.8.2