-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathddd_in_h.h
334 lines (276 loc) · 10.1 KB
/
ddd_in_h.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
//****************************************************************************************
//
// Copyright (c) 2015-2020, Yoshifumi Nakamura <[email protected]>
// Copyright (c) 2015-2020, Yuta Mukai <[email protected]>
// Copyright (c) 2018-2020, Ken-Ichi Ishikawa <[email protected]>
// Copyright (c) 2019-2020, Issaku Kanamori <[email protected]>
//
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer listed
// in this license in the documentation and/or other materials
// provided with the distribution.
//
// * Neither the name of the copyright holders nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//----------------------------------------------------------------------------------------
// ACKNOWLEDGMENT
//
// This software has been developed in a co-design working group for the lattice QCD
// supported by MEXT's programs for the Development and Improvement for the Next
// Generation Ultra High-Speed Computer System, under its Subsidies for Operating the
// Specific Advanced Large Research Facilities, and Priority Issue 9
// (Elucidation of the Fundamental Laws and Evolution of the Universe) to be tackled by
// using the Supercomputer Fugaku.
//
//****************************************************************************************
#ifndef _DDD_IN_H_H
#define _DDD_IN_H_H
//---------------------------------------------------------------------------------------- mult D in bulk
void ddd_in_h_(sch_t * __restrict__ out, const sch_t * __restrict__ in, const int *DEO)
//
// Multiply Wilson/Clover opeartor on a quark field in a even/odd domain
//
// oute = Dee ine
// or
// outo = Dee ino
//
// out : output quark field in an even/odd domain
// in : input quark field in an even/odd domain
// DEO : even/odd-domain index, 0 for even domain, 1 for odd domain
//
{
const __restrict__ pgluh_t gx = &gluh[vols*0 + NDIM*vols*(*DEO)];
const __restrict__ pgluh_t gy = &gluh[vols*1 + NDIM*vols*(*DEO)];
const __restrict__ pgluh_t gz = &gluh[vols*2 + NDIM*vols*(*DEO)];
const __restrict__ pgluh_t gt = &gluh[vols*3 + NDIM*vols*(*DEO)];
const __restrict__ pclvh_t cl = &clvh[ vols*(*DEO)];
#pragma omp parallel for collapse(3) schedule(static)
for(int t = 0; t < nt; ++t) {
for(int z = 0; z < nz; ++z) {
for(int y = 0; y < ny; ++y) {
for(int x = 0; x < nxs; ++x) {
int i0 = x + nxs*y + nxs*ny*z + nxs*ny*nz*t;
int ixf = (x+1) + nxs*y + nxs*ny*z + nxs*ny*nz*t;
int ixb = (x-1) + nxs*y + nxs*ny*z + nxs*ny*nz*t;
int iyf = x + (y+1)*nxs + nxs*ny*z + nxs*ny*nz*t;
int iyb = x + (y-1)*nxs + nxs*ny*z + nxs*ny*nz*t;
int izf = x + nxs*y + (z+1)*nxs*ny + nxs*ny*nz*t;
int izb = x + nxs*y + (z-1)*nxs*ny + nxs*ny*nz*t;
int itf = x + nxs*y + nxs*ny*z + (t+1)*nxs*ny*nz;
int itb = x + nxs*y + nxs*ny*z + (t-1)*nxs*ny*nz;
#ifdef PREFETCH
#endif
sch_t tmp0 __attribute__((aligned(_ALIGN_SIZE)));
for (int c = 0; c < 3; c++) {
for (int s = 0; s < 4; s++) {
for (int ri = 0; ri < 2; ri++) {
for (int j = 0; j<VLENS; j++) {
tmp0.c[c][s][ri][j] = half(0.0f);
}
}
}
}
//
// X-forward
//
{
__attribute__((aligned(_ALIGN_SIZE))) projsch_t a,ua;
half ff[3][4][2][VLENS*2] __attribute__((aligned(4)));
if ( x != nxs-1 ) {
for(int c = 0; c < 3; ++c) {
for(int s = 0; s < 4; ++s) {
for(int ri = 0; ri < 2; ++ri) {
for(int j = 0; j < VLENS; ++j) {
ff[c][s][ri][j ] = in[i0 ].c[c][s][ri][j];
ff[c][s][ri][j+VLENS] = in[ixf].c[c][s][ri][j];
}
}
}
}
} else {
for(int c = 0; c < 3; ++c) {
for(int s = 0; s < 4; ++s) {
for(int ri = 0; ri < 2; ++ri) {
for(int j = 0; j < VLENS; ++j) {
ff[c][s][ri][j ] = in[i0 ].c[c][s][ri][j];
ff[c][s][ri][j+VLENS] = half(0.0f);
}
}
}
}
}
__mult_x_forw_pre_2_(a,ff); // with forward simd-site-shift
__mult_u_y_(ua,a,(*(gx + i0)));
__mult_x_forw_pst_(tmp0,ua);
}
//
// X-backward
//
{
__attribute__((aligned(_ALIGN_SIZE))) projsch_t a,ua;
half ff_in[3][4][2][VLENS*2] __attribute__((aligned(4)));
half ff_g [3][3][2][VLENS*2] __attribute__((aligned(4)));
if ( x != 0 ) {
for(int c = 0; c < 3; ++c) {
for(int s = 0; s < 4; ++s) {
for(int ri = 0; ri < 2; ++ri) {
for(int j = 0; j < VLENS; ++j) {
ff_in[c][s][ri][j ] = in[ixb].c[c][s][ri][j];
ff_in[c][s][ri][j+VLENS] = in[i0 ].c[c][s][ri][j];
}
}
}
}
//
// load link U. WITHOUT taking Hermitian-conjugate
//
for (int c2 = 0; c2 < 3; ++c2) {
for (int c1 = 0; c1 < 3; ++c1) {
for(int ri = 0; ri < 2; ++ri) {
for(int j = 0; j < VLENS; ++j) {
ff_g[c2][c1][ri][j ] = (*(gx+ixb)).c[c2][c1][ri][j];
ff_g[c2][c1][ri][j+VLENS] = (*(gx+i0 )).c[c2][c1][ri][j];
}
}
}
}
} else {
for (int c = 0; c < 3; ++c) {
for (int s = 0; s < 4; ++s) {
for(int ri = 0; ri < 2; ++ri) {
for(int j = 0; j < VLENS; ++j) {
ff_in[c][s][ri][j ] = half(0.0f);
ff_in[c][s][ri][j+VLENS] = in[i0 ].c[c][s][ri][j];
}
}
}
}
//
// load link U. WITHOUT taking Hermitian-conjugate
//
for (int c2 = 0; c2 < 3; ++c2) {
for (int c1 = 0; c1 < 3; ++c1) {
for(int ri = 0; ri < 2; ++ri) {
for(int j = 0; j < VLENS; ++j) {
ff_g[c2][c1][ri][j ] = half(0.0f);
ff_g[c2][c1][ri][j+VLENS] = (*(gx+i0 )).c[c2][c1][ri][j];
}
}
}
}
}
__mult_x_back_pre_2_(a,ff_in);// with backward simd-site-shift
__mult_udag_y_2_(ua,a,ff_g); // with backward simd-site-shift
__mult_x_back_pst_(tmp0,ua);
}
//
// Y-forward
//
#ifdef PREFETCH
#endif
if ( y != ny-1 ) {
__attribute__((aligned(_ALIGN_SIZE))) projsch_t a,ua;
__mult_y_forw_pre_(a,(*(in + iyf)));
__mult_u_y_(ua,a,(*(gy + i0)));
__mult_y_forw_pst_(tmp0,ua);
}
//
// Y-backward
//
#ifdef PREFETCH
#endif
if ( y != 0 ) {
__attribute__((aligned(_ALIGN_SIZE))) projsch_t a,ua;
__mult_y_back_pre_(a,(*(in + iyb)));
__mult_udag_y_(ua,a,(*(gy + iyb)));
__mult_y_back_pst_(tmp0,ua);
}
//
// Z-forward
//
#ifdef PREFETCH
#endif
if ( z != nz-1 ) {
__attribute__((aligned(_ALIGN_SIZE))) projsch_t a,ua;
__mult_z_forw_pre_(a,(*(in + izf)));
__mult_u_y_(ua,a,(*(gz + i0)));
__mult_z_forw_pst_(tmp0,ua);
}
//
// Z-backward
//
#ifdef PREFETCH
#endif
if ( z != 0 ) {
__attribute__((aligned(_ALIGN_SIZE))) projsch_t a,ua;
__mult_z_back_pre_(a,(*(in + izb)));
__mult_udag_y_(ua,a,(*(gz + izb)));
__mult_z_back_pst_(tmp0,ua);
}
//
// T-forward
//
#ifdef PREFETCH
#endif
if ( t != nt-1 ) {
__attribute__((aligned(_ALIGN_SIZE))) projsch_t a,ua;
__mult_t_forw_pre_(a,(*(in + itf)));
__mult_u_y_(ua,a,(*(gt + i0)));
__mult_t_forw_pst_(tmp0,ua);
}
//
// T-backward
//
#ifdef PREFETCH
#endif
if ( t != 0 ) {
__attribute__((aligned(_ALIGN_SIZE))) projsch_t a,ua;
__mult_t_back_pre_(a,(*(in + itb)));
__mult_udag_y_(ua,a,(*(gt + itb)));
__mult_t_back_pst_(tmp0,ua);
}
#ifdef PREFETCH
#endif
__mult_clvh(tmp0.cv, cl[i0].cv);
#ifdef PREFETCH
#endif
//#pragma loop norecurrence
for (int c = 0; c < 3; ++c){
for (int s = 0; s < 4; ++s){
for (int ri = 0; ri < 2; ++ri){
for (int j = 0; j < VLENS; ++j){
(*(out + i0)).c[c][s][ri][j] = (*(in + i0)).c[c][s][ri][j] + tmp0.c[c][s][ri][j] * (half)mkappa;
}
}
}
}
}
}
}
}
}
#endif