add citation information
[LbmBenchmarkKernelsPublic.git] / src / BenchKernelD3Q19Common.h
1 // --------------------------------------------------------------------------
2 //
3 // Copyright
4 //   Markus Wittmann, 2016-2017
5 //   RRZE, University of Erlangen-Nuremberg, Germany
6 //   markus.wittmann -at- fau.de or hpc -at- rrze.fau.de
7 //
8 //   Viktor Haag, 2016
9 //   LSS, University of Erlangen-Nuremberg, Germany
10 //
11 //  This file is part of the Lattice Boltzmann Benchmark Kernels (LbmBenchKernels).
12 //
13 //  LbmBenchKernels is free software: you can redistribute it and/or modify
14 //  it under the terms of the GNU General Public License as published by
15 //  the Free Software Foundation, either version 3 of the License, or
16 //  (at your option) any later version.
17 //
18 //  LbmBenchKernels is distributed in the hope that it will be useful,
19 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
20 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 //  GNU General Public License for more details.
22 //
23 //  You should have received a copy of the GNU General Public License
24 //  along with LbmBenchKernels.  If not, see <http://www.gnu.org/licenses/>.
25 //
26 // --------------------------------------------------------------------------
27 #ifndef __BENCH_KERNEL_D3Q19_COMMON_H__
28 #define __BENCH_KERNEL_D3Q19_COMMON_H__
29
30 #include "Kernel.h"
31
32 typedef struct KernelDataEx_
33 {
34         KernelData kd;
35         int Blk[3];                     // Blocking in X, Y, and Z direction, value of 0 disables blocking.
36 } KernelDataEx;
37
38
39 // Build a function name extended by the propagation model name and the data layout.
40 // FNANEM(test) will be expanded to test_PushSoA if DATA_LAYOUT_NAME is defined
41 // as SoA and PROP_MODEL is defined as Push.
42 #define FNAME(functionName)     JOIN(JOIN(functionName,_),JOIN(PROP_MODEL_NAME,DATA_LAYOUT_NAME))
43
44 #ifndef DATA_LAYOUT_NAME
45         #error DATA_LAYOUT_NAME must be defined
46 #endif
47
48 #ifndef PROP_MODEL_NAME
49         #error PROP_MODEL_NAME must be defined
50 #endif
51
52 // -----------------------------------------------------------------------
53 // Index function for accesssing PDF array for different data layouts.
54
55 #define P_INDEX_5               FNAME(PINDEX5)
56
57 static inline int FNAME(PINDEX5)(int dims[3], int x, int y, int z, int d)
58 {
59         Assert(dims[0] > 0);
60         Assert(dims[1] > 0);
61         Assert(dims[2] > 0);
62
63         Assert(x >= 0);
64         Assert(x < dims[0]);
65         Assert(y >= 0);
66         Assert(y < dims[1]);
67         Assert(z >= 0);
68         Assert(z < dims[2]);
69         Assert(d >= 0);
70 #ifdef D3Q19
71         Assert(d < N_D3Q19);
72 #else
73 #error Not implemented for this discretization.
74 #endif
75
76 #ifdef DATA_LAYOUT_SOA
77         return d * dims[0] * dims[1] * dims[2] + x * dims[1] * dims[2] + y * dims[2] + z;
78 #elif DATA_LAYOUT_AOS
79         return x * dims[1] * dims[2] * N_D3Q19 + y * dims[2] * N_D3Q19 + z * N_D3Q19 + d;
80 #else
81 #error P_INDEX_5 function no implemented for chosen data layout.
82 #endif
83 }
84
85 #endif // __BENCH_KERNEL_D3Q19_COMMON_H__
86
This page took 0.048966 seconds and 4 git commands to generate.