Boundary.tmpl.cpp 3.75 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//======================================================================================================================
//
//  This file is part of waLBerla. waLBerla is free software: you can
//  redistribute it and/or modify it under the terms of the GNU General Public
//  License as published by the Free Software Foundation, either version 3 of
//  the License, or (at your option) any later version.
//
//  waLBerla is distributed in the hope that it will be useful, but WITHOUT
//  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
//  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
//  for more details.
//
//  You should have received a copy of the GNU General Public License along
//  with waLBerla (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>.
//
//! \\file {{class_name}}.cpp
17
//! \\author pystencils
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
//======================================================================================================================

#include <cmath>

#include "core/DataTypes.h"
#include "core/Macros.h"
#include "{{class_name}}.h"
{% if target == 'gpu' -%}
#include "cuda/ErrorChecking.h"
{%- endif %}


{% if target == 'cpu' -%}
#define FUNC_PREFIX
{%- elif target == 'gpu' -%}
#define FUNC_PREFIX __global__
{%- endif %}

using namespace std;

namespace walberla {
namespace {{namespace}} {

#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wconversion"
#endif

#ifdef __CUDACC__
#pragma push
50
51
52
53
54
#ifdef __NVCC_DIAG_PRAGMA_SUPPORT__
#pragma nv_diag_suppress 177
#else
#pragma diag_suppress 177
#endif
55
56
#endif

57
{{kernel|generate_definitions(target)}}
58
59
60
61
62
63
64
65
66

#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif

#ifdef __CUDACC__
#pragma pop
#endif

Markus Holzer's avatar
Markus Holzer committed
67

68
69
70
71
72
void {{class_name}}::run_impl(
   {{- ["IBlock * block", "IndexVectors::Type type",
        kernel.kernel_selection_parameters, ["cudaStream_t stream"] if target == 'gpu' else []]
       | type_identifier_list -}}
)
73
{
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
   auto * indexVectors = block->getData<IndexVectors>(indexVectorID);
   int64_t indexVectorSize = int64_c( indexVectors->indexVector(type).size() );
   if( indexVectorSize == 0)
      return;

   {% if target == 'gpu' -%}
   auto pointer = indexVectors->pointerGpu(type);
   {% else %}
   auto pointer = indexVectors->pointerCpu(type);
   {% endif %}

   uint8_t * _data_indexVector = reinterpret_cast<uint8_t*>(pointer);

   {{kernel|generate_block_data_to_field_extraction(['indexVector', 'indexVectorSize'])|indent(4)}}
   {{kernel|generate_refs_for_kernel_parameters(prefix='', parameters_to_ignore=['indexVectorSize'], ignore_fields=True)|indent(4) }}
   {{kernel|generate_call(spatial_shape_symbols=['indexVectorSize'], stream='stream')|indent(4)}}
90
91
}

92
93
94
void {{class_name}}::run(
   {{- ["IBlock * block", kernel.kernel_selection_parameters, ["cudaStream_t stream"] if target == 'gpu' else []] | type_identifier_list -}}
)
95
{
96
   run_impl( {{- ["block", "IndexVectors::ALL", kernel.kernel_selection_parameters, ["stream"] if target == 'gpu' else []] | identifier_list -}} );
97
98
}

99
100
101
void {{class_name}}::inner(
   {{- ["IBlock * block", kernel.kernel_selection_parameters, ["cudaStream_t stream"] if target == 'gpu' else []] | type_identifier_list -}}
)
102
{
103
   run_impl( {{- ["block", "IndexVectors::INNER", kernel.kernel_selection_parameters, ["stream"] if target == 'gpu' else []] | identifier_list -}} );
104
105
}

106
107
108
void {{class_name}}::outer(
   {{- ["IBlock * block", kernel.kernel_selection_parameters, ["cudaStream_t stream"] if target == 'gpu' else []] | type_identifier_list -}}
)
109
{
110
   run_impl( {{- ["block", "IndexVectors::OUTER", kernel.kernel_selection_parameters, ["stream"] if target == 'gpu' else []] | identifier_list -}} );
111
112
113
114
115
116
}

} // namespace {{namespace}}
} // namespace walberla