From 960c2adefb0a2da5dd30316734860affb3a94d77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-No=C3=ABl=20Grad?= Date: Fri, 20 Sep 2024 21:18:36 +0200 Subject: [PATCH] PackInfo MPI buffer alignment bugfix --- .../generated_kernels/PackInfoPdfDoublePrecision.cpp | 4 ++++ .../generated_kernels/PackInfoPdfDoublePrecision.h | 5 +++-- .../generated_kernels/PackInfoPdfSinglePrecision.cpp | 4 ++++ .../generated_kernels/PackInfoPdfSinglePrecision.h | 5 +++-- .../generated_kernels/PackInfoVecDoublePrecision.cpp | 4 ++++ .../generated_kernels/PackInfoVecDoublePrecision.h | 5 +++-- .../generated_kernels/PackInfoVecSinglePrecision.cpp | 4 ++++ .../generated_kernels/PackInfoVecSinglePrecision.h | 5 +++-- 8 files changed, 28 insertions(+), 8 deletions(-) diff --git a/src/walberla_bridge/src/lattice_boltzmann/generated_kernels/PackInfoPdfDoublePrecision.cpp b/src/walberla_bridge/src/lattice_boltzmann/generated_kernels/PackInfoPdfDoublePrecision.cpp index abee661f39..1ab45417dc 100644 --- a/src/walberla_bridge/src/lattice_boltzmann/generated_kernels/PackInfoPdfDoublePrecision.cpp +++ b/src/walberla_bridge/src/lattice_boltzmann/generated_kernels/PackInfoPdfDoublePrecision.cpp @@ -24,6 +24,8 @@ #include "core/cell/CellInterval.h" #include "stencil/Directions.h" +#include + #if (defined WALBERLA_CXX_COMPILER_IS_GNU) || (defined WALBERLA_CXX_COMPILER_IS_CLANG) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wfloat-equal" @@ -519,6 +521,7 @@ static FUNC_PREFIX void unpack_NE(double *RESTRICT const _data_buffer, double *R } // namespace internal_unpack_NE void PackInfoPdfDoublePrecision::pack(Direction dir, unsigned char *byte_buffer, IBlock *block) const { + byte_buffer += sizeof(double) - (reinterpret_cast(byte_buffer) - (reinterpret_cast(byte_buffer) / sizeof(double)) * sizeof(double)); double *buffer = reinterpret_cast(byte_buffer); auto pdfs = block->getData>(pdfsID); @@ -893,6 +896,7 @@ void PackInfoPdfDoublePrecision::pack(Direction dir, unsigned char *byte_buffer, } void PackInfoPdfDoublePrecision::unpack(Direction dir, unsigned char *byte_buffer, IBlock *block) const { + byte_buffer += sizeof(double) - (reinterpret_cast(byte_buffer) - (reinterpret_cast(byte_buffer) / sizeof(double)) * sizeof(double)); double *buffer = reinterpret_cast(byte_buffer); auto pdfs = block->getData>(pdfsID); diff --git a/src/walberla_bridge/src/lattice_boltzmann/generated_kernels/PackInfoPdfDoublePrecision.h b/src/walberla_bridge/src/lattice_boltzmann/generated_kernels/PackInfoPdfDoublePrecision.h index d2c205023c..6c2b00a8e3 100644 --- a/src/walberla_bridge/src/lattice_boltzmann/generated_kernels/PackInfoPdfDoublePrecision.h +++ b/src/walberla_bridge/src/lattice_boltzmann/generated_kernels/PackInfoPdfDoublePrecision.h @@ -54,7 +54,7 @@ class PackInfoPdfDoublePrecision void unpackData(IBlock *receiver, stencil::Direction dir, mpi::RecvBuffer &buffer) { const auto dataSize = size(dir, receiver); - unpack(dir, buffer.skip(dataSize), receiver); + unpack(dir, buffer.skip(dataSize + sizeof(double)), receiver); } void communicateLocal(const IBlock *sender, IBlock *receiver, @@ -68,7 +68,8 @@ class PackInfoPdfDoublePrecision void packDataImpl(const IBlock *sender, stencil::Direction dir, mpi::SendBuffer &outBuffer) const { const auto dataSize = size(dir, sender); - pack(dir, outBuffer.forward(dataSize), const_cast(sender)); + pack(dir, outBuffer.forward(dataSize + sizeof(double)), + const_cast(sender)); } void pack(stencil::Direction dir, unsigned char *buffer, IBlock *block) const; diff --git a/src/walberla_bridge/src/lattice_boltzmann/generated_kernels/PackInfoPdfSinglePrecision.cpp b/src/walberla_bridge/src/lattice_boltzmann/generated_kernels/PackInfoPdfSinglePrecision.cpp index 5beb6eb918..e55017ab21 100644 --- a/src/walberla_bridge/src/lattice_boltzmann/generated_kernels/PackInfoPdfSinglePrecision.cpp +++ b/src/walberla_bridge/src/lattice_boltzmann/generated_kernels/PackInfoPdfSinglePrecision.cpp @@ -24,6 +24,8 @@ #include "core/cell/CellInterval.h" #include "stencil/Directions.h" +#include + #if (defined WALBERLA_CXX_COMPILER_IS_GNU) || (defined WALBERLA_CXX_COMPILER_IS_CLANG) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wfloat-equal" @@ -519,6 +521,7 @@ static FUNC_PREFIX void unpack_NE(float *RESTRICT const _data_buffer, float *RES } // namespace internal_unpack_NE void PackInfoPdfSinglePrecision::pack(Direction dir, unsigned char *byte_buffer, IBlock *block) const { + byte_buffer += sizeof(float) - (reinterpret_cast(byte_buffer) - (reinterpret_cast(byte_buffer) / sizeof(float)) * sizeof(float)); float *buffer = reinterpret_cast(byte_buffer); auto pdfs = block->getData>(pdfsID); @@ -893,6 +896,7 @@ void PackInfoPdfSinglePrecision::pack(Direction dir, unsigned char *byte_buffer, } void PackInfoPdfSinglePrecision::unpack(Direction dir, unsigned char *byte_buffer, IBlock *block) const { + byte_buffer += sizeof(float) - (reinterpret_cast(byte_buffer) - (reinterpret_cast(byte_buffer) / sizeof(float)) * sizeof(float)); float *buffer = reinterpret_cast(byte_buffer); auto pdfs = block->getData>(pdfsID); diff --git a/src/walberla_bridge/src/lattice_boltzmann/generated_kernels/PackInfoPdfSinglePrecision.h b/src/walberla_bridge/src/lattice_boltzmann/generated_kernels/PackInfoPdfSinglePrecision.h index 9dd84b0c62..40cb206890 100644 --- a/src/walberla_bridge/src/lattice_boltzmann/generated_kernels/PackInfoPdfSinglePrecision.h +++ b/src/walberla_bridge/src/lattice_boltzmann/generated_kernels/PackInfoPdfSinglePrecision.h @@ -54,7 +54,7 @@ class PackInfoPdfSinglePrecision void unpackData(IBlock *receiver, stencil::Direction dir, mpi::RecvBuffer &buffer) { const auto dataSize = size(dir, receiver); - unpack(dir, buffer.skip(dataSize), receiver); + unpack(dir, buffer.skip(dataSize + sizeof(float)), receiver); } void communicateLocal(const IBlock *sender, IBlock *receiver, @@ -68,7 +68,8 @@ class PackInfoPdfSinglePrecision void packDataImpl(const IBlock *sender, stencil::Direction dir, mpi::SendBuffer &outBuffer) const { const auto dataSize = size(dir, sender); - pack(dir, outBuffer.forward(dataSize), const_cast(sender)); + pack(dir, outBuffer.forward(dataSize + sizeof(float)), + const_cast(sender)); } void pack(stencil::Direction dir, unsigned char *buffer, IBlock *block) const; diff --git a/src/walberla_bridge/src/lattice_boltzmann/generated_kernels/PackInfoVecDoublePrecision.cpp b/src/walberla_bridge/src/lattice_boltzmann/generated_kernels/PackInfoVecDoublePrecision.cpp index 5e94631ed0..6cbf3cb98d 100644 --- a/src/walberla_bridge/src/lattice_boltzmann/generated_kernels/PackInfoVecDoublePrecision.cpp +++ b/src/walberla_bridge/src/lattice_boltzmann/generated_kernels/PackInfoVecDoublePrecision.cpp @@ -24,6 +24,8 @@ #include "core/cell/CellInterval.h" #include "stencil/Directions.h" +#include + #if (defined WALBERLA_CXX_COMPILER_IS_GNU) || (defined WALBERLA_CXX_COMPILER_IS_CLANG) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wfloat-equal" @@ -67,6 +69,7 @@ static FUNC_PREFIX void unpack_SW_BW_W_TW_NW_BS_S_TS_B_C_T_BN_N_TN_SE_BE_E_TE_NE } // namespace internal_1ccccad4ca561e07a0934cadb07d0fc1 void PackInfoVecDoublePrecision::pack(Direction dir, unsigned char *byte_buffer, IBlock *block) const { + byte_buffer += sizeof(double) - (reinterpret_cast(byte_buffer) - (reinterpret_cast(byte_buffer) / sizeof(double)) * sizeof(double)); double *buffer = reinterpret_cast(byte_buffer); auto field = block->getData>(fieldID); @@ -119,6 +122,7 @@ void PackInfoVecDoublePrecision::pack(Direction dir, unsigned char *byte_buffer, } void PackInfoVecDoublePrecision::unpack(Direction dir, unsigned char *byte_buffer, IBlock *block) const { + byte_buffer += sizeof(double) - (reinterpret_cast(byte_buffer) - (reinterpret_cast(byte_buffer) / sizeof(double)) * sizeof(double)); double *buffer = reinterpret_cast(byte_buffer); auto field = block->getData>(fieldID); diff --git a/src/walberla_bridge/src/lattice_boltzmann/generated_kernels/PackInfoVecDoublePrecision.h b/src/walberla_bridge/src/lattice_boltzmann/generated_kernels/PackInfoVecDoublePrecision.h index 4cd1dc0869..0445249235 100644 --- a/src/walberla_bridge/src/lattice_boltzmann/generated_kernels/PackInfoVecDoublePrecision.h +++ b/src/walberla_bridge/src/lattice_boltzmann/generated_kernels/PackInfoVecDoublePrecision.h @@ -54,7 +54,7 @@ class PackInfoVecDoublePrecision void unpackData(IBlock *receiver, stencil::Direction dir, mpi::RecvBuffer &buffer) { const auto dataSize = size(dir, receiver); - unpack(dir, buffer.skip(dataSize), receiver); + unpack(dir, buffer.skip(dataSize + sizeof(double)), receiver); } void communicateLocal(const IBlock *sender, IBlock *receiver, @@ -68,7 +68,8 @@ class PackInfoVecDoublePrecision void packDataImpl(const IBlock *sender, stencil::Direction dir, mpi::SendBuffer &outBuffer) const { const auto dataSize = size(dir, sender); - pack(dir, outBuffer.forward(dataSize), const_cast(sender)); + pack(dir, outBuffer.forward(dataSize + sizeof(double)), + const_cast(sender)); } void pack(stencil::Direction dir, unsigned char *buffer, IBlock *block) const; diff --git a/src/walberla_bridge/src/lattice_boltzmann/generated_kernels/PackInfoVecSinglePrecision.cpp b/src/walberla_bridge/src/lattice_boltzmann/generated_kernels/PackInfoVecSinglePrecision.cpp index a9dea10421..3ddeee01b6 100644 --- a/src/walberla_bridge/src/lattice_boltzmann/generated_kernels/PackInfoVecSinglePrecision.cpp +++ b/src/walberla_bridge/src/lattice_boltzmann/generated_kernels/PackInfoVecSinglePrecision.cpp @@ -24,6 +24,8 @@ #include "core/cell/CellInterval.h" #include "stencil/Directions.h" +#include + #if (defined WALBERLA_CXX_COMPILER_IS_GNU) || (defined WALBERLA_CXX_COMPILER_IS_CLANG) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wfloat-equal" @@ -67,6 +69,7 @@ static FUNC_PREFIX void unpack_SW_BW_W_TW_NW_BS_S_TS_B_C_T_BN_N_TN_SE_BE_E_TE_NE } // namespace internal_1ccccad4ca561e07a0934cadb07d0fc1 void PackInfoVecSinglePrecision::pack(Direction dir, unsigned char *byte_buffer, IBlock *block) const { + byte_buffer += sizeof(float) - (reinterpret_cast(byte_buffer) - (reinterpret_cast(byte_buffer) / sizeof(float)) * sizeof(float)); float *buffer = reinterpret_cast(byte_buffer); auto field = block->getData>(fieldID); @@ -119,6 +122,7 @@ void PackInfoVecSinglePrecision::pack(Direction dir, unsigned char *byte_buffer, } void PackInfoVecSinglePrecision::unpack(Direction dir, unsigned char *byte_buffer, IBlock *block) const { + byte_buffer += sizeof(float) - (reinterpret_cast(byte_buffer) - (reinterpret_cast(byte_buffer) / sizeof(float)) * sizeof(float)); float *buffer = reinterpret_cast(byte_buffer); auto field = block->getData>(fieldID); diff --git a/src/walberla_bridge/src/lattice_boltzmann/generated_kernels/PackInfoVecSinglePrecision.h b/src/walberla_bridge/src/lattice_boltzmann/generated_kernels/PackInfoVecSinglePrecision.h index 1d0e7936f9..04a360cbed 100644 --- a/src/walberla_bridge/src/lattice_boltzmann/generated_kernels/PackInfoVecSinglePrecision.h +++ b/src/walberla_bridge/src/lattice_boltzmann/generated_kernels/PackInfoVecSinglePrecision.h @@ -54,7 +54,7 @@ class PackInfoVecSinglePrecision void unpackData(IBlock *receiver, stencil::Direction dir, mpi::RecvBuffer &buffer) { const auto dataSize = size(dir, receiver); - unpack(dir, buffer.skip(dataSize), receiver); + unpack(dir, buffer.skip(dataSize + sizeof(float)), receiver); } void communicateLocal(const IBlock *sender, IBlock *receiver, @@ -68,7 +68,8 @@ class PackInfoVecSinglePrecision void packDataImpl(const IBlock *sender, stencil::Direction dir, mpi::SendBuffer &outBuffer) const { const auto dataSize = size(dir, sender); - pack(dir, outBuffer.forward(dataSize), const_cast(sender)); + pack(dir, outBuffer.forward(dataSize + sizeof(float)), + const_cast(sender)); } void pack(stencil::Direction dir, unsigned char *buffer, IBlock *block) const;