Loading [MathJax]/extensions/TeX/AMSmath.js
ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages Concepts
StreamSweepSinglePrecisionCUDA.h
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 StreamSweepSinglePrecisionCUDA.h
17//! \\author pystencils
18//======================================================================================================================
19
20// kernel generated with pystencils v1.3.7, lbmpy v1.3.7, sympy v1.12.1,
21// lbmpy_walberla/pystencils_walberla from waLBerla commit
22// f36fa0a68bae59f0b516f6587ea8fa7c24a41141
23
24#pragma once
25#include "core/DataTypes.h"
26#include "core/logging/Logging.h"
27
28#include "gpu/GPUField.h"
29#include "gpu/GPUWrapper.h"
30
31#include "domain_decomposition/BlockDataID.h"
32#include "domain_decomposition/IBlock.h"
33#include "domain_decomposition/StructuredBlockStorage.h"
34#include "field/SwapableCompare.h"
35
36#include <functional>
37#include <unordered_map>
38
39#ifdef __GNUC__
40#define RESTRICT __restrict__
41#elif _MSC_VER
42#define RESTRICT __restrict
43#else
44#define RESTRICT
45#endif
46
47#if (defined WALBERLA_CXX_COMPILER_IS_GNU) || \
48 (defined WALBERLA_CXX_COMPILER_IS_CLANG)
49#pragma GCC diagnostic push
50#pragma GCC diagnostic ignored "-Wunused-parameter"
51#pragma GCC diagnostic ignored "-Wreorder"
52#endif
53
54namespace walberla {
55namespace pystencils {
56
58public:
59 StreamSweepSinglePrecisionCUDA(BlockDataID forceID_, BlockDataID pdfsID_,
60 BlockDataID velocityID_)
61 : forceID(forceID_), pdfsID(pdfsID_), velocityID(velocityID_) {}
62
64 for (auto p : cache_pdfs_) {
65 delete p.second;
66 }
67 }
68
69 void run(IBlock *block, gpuStream_t stream = nullptr);
70
71 void runOnCellInterval(const shared_ptr<StructuredBlockStorage> &blocks,
72 const CellInterval &globalCellInterval,
73 cell_idx_t ghostLayers, IBlock *block,
74 gpuStream_t stream = nullptr);
75
76 void operator()(IBlock *block, gpuStream_t stream = nullptr) {
78 }
79
80 static std::function<void(IBlock *)>
81 getSweep(const shared_ptr<StreamSweepSinglePrecisionCUDA> &kernel) {
82 return [kernel](IBlock *b) { kernel->run(b); };
83 }
84
85 static std::function<void(IBlock *, gpuStream_t)> getSweepOnCellInterval(
86 const shared_ptr<StreamSweepSinglePrecisionCUDA> &kernel,
87 const shared_ptr<StructuredBlockStorage> &blocks,
88 const CellInterval &globalCellInterval, cell_idx_t ghostLayers = 1) {
89 return [kernel, blocks, globalCellInterval,
90 ghostLayers](IBlock *b, gpuStream_t stream = nullptr) {
91 kernel->runOnCellInterval(blocks, globalCellInterval, ghostLayers, b,
92 stream);
93 };
94 }
95
96 std::function<void(IBlock *)> getSweep(gpuStream_t stream = nullptr) {
97 return [this, stream](IBlock *b) { this->run(b, stream); };
98 }
99
100 std::function<void(IBlock *)>
101 getSweepOnCellInterval(const shared_ptr<StructuredBlockStorage> &blocks,
102 const CellInterval &globalCellInterval,
103 cell_idx_t ghostLayers = 1,
104 gpuStream_t stream = nullptr) {
105 return [this, blocks, globalCellInterval, ghostLayers, stream](IBlock *b) {
106 this->runOnCellInterval(blocks, globalCellInterval, ghostLayers, b,
107 stream);
108 };
109 }
110
111 void configure(const shared_ptr<StructuredBlockStorage> & /*blocks*/,
112 IBlock * /*block*/) {}
113
114private:
115 BlockDataID forceID;
116 BlockDataID pdfsID;
117 BlockDataID velocityID;
118 std::unordered_map<IBlock *, gpu::GPUField<float> *> cache_pdfs_;
119};
120
121} // namespace pystencils
122} // namespace walberla
123
124#if (defined WALBERLA_CXX_COMPILER_IS_GNU) || \
125 (defined WALBERLA_CXX_COMPILER_IS_CLANG)
126#pragma GCC diagnostic pop
127#endif
void configure(const shared_ptr< StructuredBlockStorage > &, IBlock *)
static std::function< void(IBlock *, gpuStream_t)> getSweepOnCellInterval(const shared_ptr< StreamSweepSinglePrecisionCUDA > &kernel, const shared_ptr< StructuredBlockStorage > &blocks, const CellInterval &globalCellInterval, cell_idx_t ghostLayers=1)
std::function< void(IBlock *)> getSweep(gpuStream_t stream=nullptr)
std::function< void(IBlock *)> getSweepOnCellInterval(const shared_ptr< StructuredBlockStorage > &blocks, const CellInterval &globalCellInterval, cell_idx_t ghostLayers=1, gpuStream_t stream=nullptr)
void runOnCellInterval(const shared_ptr< StructuredBlockStorage > &blocks, const CellInterval &globalCellInterval, cell_idx_t ghostLayers, IBlock *block, gpuStream_t stream=nullptr)
void operator()(IBlock *block, gpuStream_t stream=nullptr)
static std::function< void(IBlock *)> getSweep(const shared_ptr< StreamSweepSinglePrecisionCUDA > &kernel)
StreamSweepSinglePrecisionCUDA(BlockDataID forceID_, BlockDataID pdfsID_, BlockDataID velocityID_)
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:172
\file PackInfoPdfDoublePrecision.cpp \author pystencils