ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
Dirichlet_single_precision_CUDA.cu
Go to the documentation of this file.
1//======================================================================================================================
2//
3// This file is part of waLBerla. waLBerla is free software: you can
4// redistribute it and/or modify it under the terms of the GNU General Public
5// License as published by the Free Software Foundation, either version 3 of
6// the License, or (at your option) any later version.
7//
8// waLBerla is distributed in the hope that it will be useful, but WITHOUT
9// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11// for more details.
12//
13// You should have received a copy of the GNU General Public License along
14// with waLBerla (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>.
15//
16//! \\file Dirichlet_single_precision_CUDA.cpp
17//! \\author pystencils
18//======================================================================================================================
19
20// kernel generated with pystencils v1.4+1.ge851f4e, lbmpy v1.4+1.ge9efe34, sympy v1.12.1, lbmpy_walberla/pystencils_walberla from waLBerla commit 007e77e077ad9d22b5eed6f3d3118240993e553c
21
23#include "core/DataTypes.h"
24#include "core/Macros.h"
25#include "gpu/ErrorChecking.h"
26
27#define FUNC_PREFIX __global__
28
29using namespace std;
30
31namespace walberla {
32namespace pystencils {
33
34#if defined(__NVCC__)
35#define RESTRICT __restrict__
36#if defined(__NVCC_DIAG_PRAGMA_SUPPORT__)
37#pragma nv_diagnostic push
38#pragma nv_diag_suppress 177 // unused variable
39#else
40#pragma push
41#pragma diag_suppress 177 // unused variable
42#endif // defined(__NVCC_DIAG_PRAGMA_SUPPORT__)
43#elif defined(__clang__)
44#if defined(__CUDA__)
45#if defined(__CUDA_ARCH__)
46// clang compiling CUDA code in device mode
47#define RESTRICT __restrict__
48#pragma clang diagnostic push
49#pragma clang diagnostic ignored "-Wstrict-aliasing"
50#pragma clang diagnostic ignored "-Wunused-variable"
51#pragma clang diagnostic ignored "-Wconversion"
52#pragma clang diagnostic ignored "-Wsign-compare"
53#else
54// clang compiling CUDA code in host mode
55#define RESTRICT __restrict__
56#pragma clang diagnostic push
57#pragma clang diagnostic ignored "-Wstrict-aliasing"
58#pragma clang diagnostic ignored "-Wunused-variable"
59#pragma clang diagnostic ignored "-Wconversion"
60#pragma clang diagnostic ignored "-Wsign-compare"
61#endif // defined(__CUDA_ARCH__)
62#endif // defined(__CUDA__)
63#elif defined(__GNUC__) or defined(__GNUG__)
64#define RESTRICT __restrict__
65#pragma GCC diagnostic push
66#pragma GCC diagnostic ignored "-Wstrict-aliasing"
67#pragma GCC diagnostic ignored "-Wunused-variable"
68#pragma GCC diagnostic ignored "-Wconversion"
69#elif defined(_MSC_VER)
70#define RESTRICT __restrict
71#else
72#define RESTRICT
73#endif
74
75// NOLINTBEGIN(readability-non-const-parameter*)
76namespace internal_dirichlet_single_precision_cuda_boundary_Dirichlet_single_precision_CUDA {
77static FUNC_PREFIX __launch_bounds__(256) void dirichlet_single_precision_cuda_boundary_Dirichlet_single_precision_CUDA(float *RESTRICT _data_field, uint8_t *RESTRICT const _data_indexVector, int64_t const _stride_field_0, int64_t const _stride_field_1, int64_t const _stride_field_2, int32_t indexVectorSize) {
78 if (blockDim.x * blockIdx.x + threadIdx.x < indexVectorSize) {
79 uint8_t *RESTRICT _data_indexVector_10 = _data_indexVector;
80 const int32_t x = *((int32_t *)(&_data_indexVector_10[20 * blockDim.x * blockIdx.x + 20 * threadIdx.x]));
81 uint8_t *RESTRICT _data_indexVector_14 = _data_indexVector + 4;
82 const int32_t y = *((int32_t *)(&_data_indexVector_14[20 * blockDim.x * blockIdx.x + 20 * threadIdx.x]));
83 uint8_t *RESTRICT _data_indexVector_18 = _data_indexVector + 8;
84 const int32_t z = *((int32_t *)(&_data_indexVector_18[20 * blockDim.x * blockIdx.x + 20 * threadIdx.x]));
85
86 float *RESTRICT _data_field_10_20 = _data_field + _stride_field_1 * y + _stride_field_2 * z;
87 uint8_t *RESTRICT _data_indexVector_116 = _data_indexVector + 16;
88 _data_field_10_20[_stride_field_0 * x] = *((float *)(&_data_indexVector_116[20 * blockDim.x * blockIdx.x + 20 * threadIdx.x]));
89 }
90}
91} // namespace internal_dirichlet_single_precision_cuda_boundary_Dirichlet_single_precision_CUDA
92
93// NOLINTEND(readability-non-const-parameter*)
94
95#if defined(__NVCC__)
96#if defined(__NVCC_DIAG_PRAGMA_SUPPORT__)
97#pragma nv_diagnostic pop
98#else
99#pragma pop
100#endif // defined(__NVCC_DIAG_PRAGMA_SUPPORT__)
101#elif defined(__clang__)
102#if defined(__CUDA__)
103#if defined(__CUDA_ARCH__)
104// clang compiling CUDA code in device mode
105#pragma clang diagnostic pop
106#else
107// clang compiling CUDA code in host mode
108#pragma clang diagnostic pop
109#endif // defined(__CUDA_ARCH__)
110#endif // defined(__CUDA__)
111#elif defined(__GNUC__) or defined(__GNUG__)
112#pragma GCC diagnostic pop
113#endif
114
115void Dirichlet_single_precision_CUDA::run_impl(IBlock *block, IndexVectors::Type type, gpuStream_t stream) {
116 auto *indexVectors = block->getData<IndexVectors>(indexVectorID);
117 int32_t indexVectorSize = int32_c(indexVectors->indexVector(type).size());
118 if (indexVectorSize == 0)
119 return;
120
121 auto pointer = indexVectors->pointerGpu(type);
122
123 uint8_t *_data_indexVector = reinterpret_cast<uint8_t *>(pointer);
124
125 auto field = block->getData<gpu::GPUField<float>>(fieldID);
126
127 WALBERLA_ASSERT_GREATER_EQUAL(0, -int_c(field->nrOfGhostLayers()))
128 float *RESTRICT _data_field = field->dataAt(0, 0, 0, 0);
129 const int64_t _stride_field_0 = int64_t(field->xStride());
130 const int64_t _stride_field_1 = int64_t(field->yStride());
131 const int64_t _stride_field_2 = int64_t(field->zStride());
132 dim3 _block(uint32_c(((256 < indexVectorSize) ? 256 : indexVectorSize)), uint32_c(1), uint32_c(1));
133 dim3 _grid(uint32_c(((indexVectorSize) % (((256 < indexVectorSize) ? 256 : indexVectorSize)) == 0 ? (int64_t)(indexVectorSize) / (int64_t)(((256 < indexVectorSize) ? 256 : indexVectorSize)) : ((int64_t)(indexVectorSize) / (int64_t)(((256 < indexVectorSize) ? 256 : indexVectorSize))) + 1)), uint32_c(1), uint32_c(1));
134 internal_dirichlet_single_precision_cuda_boundary_Dirichlet_single_precision_CUDA::dirichlet_single_precision_cuda_boundary_Dirichlet_single_precision_CUDA<<<_grid, _block, 0, stream>>>(_data_field, _data_indexVector, _stride_field_0, _stride_field_1, _stride_field_2, indexVectorSize);
135}
136
137void Dirichlet_single_precision_CUDA::run(IBlock *block, gpuStream_t stream) {
138 run_impl(block, IndexVectors::ALL, stream);
139}
140
142 run_impl(block, IndexVectors::INNER, stream);
143}
144
146 run_impl(block, IndexVectors::OUTER, stream);
147}
148
149} // namespace pystencils
150} // namespace walberla
#define FUNC_PREFIX
\file AdvectiveFluxKernel_double_precision.cpp \author pystencils
#define RESTRICT
\file AdvectiveFluxKernel_double_precision.h \author pystencils
cudaStream_t stream[1]
CUDA streams for parallel computing on CPU and GPU.
static double * block(double *p, std::size_t index, std::size_t size)
Definition elc.cpp:177
STL namespace.
static FUNC_PREFIX uint8_t *RESTRICT const int64_t const int64_t const int64_t const _stride_field_2
static FUNC_PREFIX __launch_bounds__(256) void dirichlet_single_precision_cuda_boundary_Dirichlet_single_precision_CUDA(float *RESTRICT _data_field
\file PackInfoPdfDoublePrecision.cpp \author pystencils