ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
PackInfoVecSinglePrecision.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 PackInfoVecSinglePrecision.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 "communication/UniformPackInfo.h"
26#include "core/DataTypes.h"
27#include "core/cell/CellInterval.h"
28#include "domain_decomposition/IBlock.h"
29#include "field/GhostLayerField.h"
30#include "stencil/Directions.h"
31
32#include <memory>
33
34#define FUNC_PREFIX
35
36#ifdef __GNUC__
37#define RESTRICT __restrict__
38#elif _MSC_VER
39#define RESTRICT __restrict
40#else
41#define RESTRICT
42#endif
43
44namespace walberla {
45namespace pystencils {
46
48 : public ::walberla::communication::UniformPackInfo {
49public:
50 PackInfoVecSinglePrecision(BlockDataID fieldID_) : fieldID(fieldID_) {}
51 ~PackInfoVecSinglePrecision() override = default;
52
53 bool constantDataExchange() const override { return true; }
54 bool threadsafeReceiving() const override { return true; }
55
56 void unpackData(IBlock *receiver, stencil::Direction dir,
57 mpi::RecvBuffer &buffer) override {
58 const auto dataSize = size(dir, receiver);
59 auto bufferSize = dataSize + sizeof(float);
60 auto bufferPtr = reinterpret_cast<void *>(buffer.skip(bufferSize));
61 std::align(alignof(float), dataSize, bufferPtr, bufferSize);
62 unpack(dir, reinterpret_cast<unsigned char *>(bufferPtr), receiver);
63 }
64
65 void communicateLocal(const IBlock *sender, IBlock *receiver,
66 stencil::Direction dir) override {
67 mpi::SendBuffer sBuffer;
68 packData(sender, dir, sBuffer);
69 mpi::RecvBuffer rBuffer(sBuffer);
70 unpackData(receiver, stencil::inverseDir[dir], rBuffer);
71 }
72
73 void packDataImpl(const IBlock *sender, stencil::Direction dir,
74 mpi::SendBuffer &outBuffer) const override {
75 const auto dataSize = size(dir, sender);
76 auto bufferSize = dataSize + sizeof(float);
77 auto bufferPtr = reinterpret_cast<void *>(outBuffer.forward(bufferSize));
78 std::align(alignof(float), dataSize, bufferPtr, bufferSize);
79 pack(dir, reinterpret_cast<unsigned char *>(bufferPtr),
80 const_cast<IBlock *>(sender));
81 }
82
83 void pack(stencil::Direction dir, unsigned char *buffer, IBlock *block) const;
84 void unpack(stencil::Direction dir, unsigned char *buffer,
85 IBlock *block) const;
86 uint_t size(stencil::Direction dir, const IBlock *block) const;
87
88private:
89 BlockDataID fieldID;
90};
91
92} // namespace pystencils
93} // namespace walberla
void communicateLocal(const IBlock *sender, IBlock *receiver, stencil::Direction dir) override
uint_t size(stencil::Direction dir, const IBlock *block) const
void pack(stencil::Direction dir, unsigned char *buffer, IBlock *block) const
void unpackData(IBlock *receiver, stencil::Direction dir, mpi::RecvBuffer &buffer) override
void packDataImpl(const IBlock *sender, stencil::Direction dir, mpi::SendBuffer &outBuffer) const override
void unpack(stencil::Direction dir, unsigned char *buffer, IBlock *block) const
static double * block(double *p, std::size_t index, std::size_t size)
Definition elc.cpp:172
\file PackInfoPdfDoublePrecision.cpp \author pystencils