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.4+1.ge851f4e, lbmpy v1.4+1.ge9efe34,
21// sympy v1.12.1, lbmpy_walberla/pystencils_walberla from waLBerla commit
22// 007e77e077ad9d22b5eed6f3d3118240993e553c
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#else
39#define RESTRICT
40#endif
41
42namespace walberla {
43namespace pystencils {
44
46 : public ::walberla::communication::UniformPackInfo {
47public:
48 PackInfoVecSinglePrecision(BlockDataID fieldID_) : fieldID(fieldID_) {}
49 ~PackInfoVecSinglePrecision() override = default;
50
51 bool constantDataExchange() const override { return true; }
52 bool threadsafeReceiving() const override { return true; }
53
54 void unpackData(IBlock *receiver, stencil::Direction dir,
55 mpi::RecvBuffer &buffer) override {
56 const auto dataSize = size(dir, receiver);
57 auto bufferSize = dataSize + sizeof(float);
58 auto bufferPtr = reinterpret_cast<void *>(buffer.skip(bufferSize));
59 std::align(alignof(float), dataSize, bufferPtr, bufferSize);
60 unpack(dir, reinterpret_cast<unsigned char *>(bufferPtr), receiver);
61 }
62
63 void communicateLocal(const IBlock *sender, IBlock *receiver,
64 stencil::Direction dir) override {
65 mpi::SendBuffer sBuffer;
66 packData(sender, dir, sBuffer);
67 mpi::RecvBuffer rBuffer(sBuffer);
68 unpackData(receiver, stencil::inverseDir[dir], rBuffer);
69 }
70
71 void packDataImpl(const IBlock *sender, stencil::Direction dir,
72 mpi::SendBuffer &outBuffer) const override {
73 const auto dataSize = size(dir, sender);
74 auto bufferSize = dataSize + sizeof(float);
75 auto bufferPtr = reinterpret_cast<void *>(outBuffer.forward(bufferSize));
76 std::align(alignof(float), dataSize, bufferPtr, bufferSize);
77 pack(dir, reinterpret_cast<unsigned char *>(bufferPtr),
78 const_cast<IBlock *>(sender));
79 }
80
81 void pack(stencil::Direction dir, unsigned char *buffer, IBlock *block) const;
82 void unpack(stencil::Direction dir, unsigned char *buffer,
83 IBlock *block) const;
84 uint_t size(stencil::Direction dir, const IBlock *block) const;
85
86private:
87 BlockDataID fieldID;
88};
89
90} // namespace pystencils
91} // 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:176
\file PackInfoPdfDoublePrecision.cpp \author pystencils