Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't force initialization for buffers whose contents we will immediately destroy #4031

Merged
merged 3 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions source/adios2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ add_library(adios2_core
toolkit/format/buffer/chunk/ChunkV.cpp
toolkit/format/buffer/ffs/BufferFFS.cpp
toolkit/format/buffer/heap/BufferSTL.cpp
toolkit/format/buffer/heap/BufferMalloc.cpp
toolkit/format/buffer/malloc/MallocV.cpp

toolkit/format/bp/BPBase.cpp toolkit/format/bp/BPBase.tcc
Expand Down
23 changes: 14 additions & 9 deletions source/adios2/engine/bp5/BP5Reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ void BP5Reader::InstallMetadataForTimestep(size_t Step)
{
// variable metadata for timestep
size_t ThisMDSize =
helper::ReadValue<uint64_t>(m_Metadata.m_Buffer, Position, m_Minifooter.IsLittleEndian);
char *ThisMD = m_Metadata.m_Buffer.data() + MDPosition;
helper::ReadValue<uint64_t>(m_Metadata.Data(), Position, m_Minifooter.IsLittleEndian);
char *ThisMD = m_Metadata.Data() + MDPosition;
if (m_OpenMode == Mode::ReadRandomAccess)
{
m_BP5Deserializer->InstallMetaData(ThisMD, ThisMDSize, WriterRank, Step);
Expand All @@ -86,8 +86,8 @@ void BP5Reader::InstallMetadataForTimestep(size_t Step)
{
// attribute metadata for timestep
size_t ThisADSize =
helper::ReadValue<uint64_t>(m_Metadata.m_Buffer, Position, m_Minifooter.IsLittleEndian);
char *ThisAD = m_Metadata.m_Buffer.data() + MDPosition;
helper::ReadValue<uint64_t>(m_Metadata.Data(), Position, m_Minifooter.IsLittleEndian);
char *ThisAD = m_Metadata.Data() + MDPosition;
if (ThisADSize > 0)
m_BP5Deserializer->InstallAttributeData(ThisAD, ThisADSize);
MDPosition += ThisADSize;
Expand Down Expand Up @@ -820,8 +820,7 @@ void BP5Reader::UpdateBuffer(const TimePoint &timeoutInstant, const Seconds &pol
for (auto p : m_FilteredMetadataInfo)
{
m_JSONProfiler.AddBytes("metadataread", p.second);
m_MDFileManager.ReadFile(m_Metadata.m_Buffer.data() + mempos, p.second,
p.first);
m_MDFileManager.ReadFile(m_Metadata.Data() + mempos, p.second, p.first);
mempos += p.second;
}
m_MDFileAlreadyReadSize = expectedMinFileSize;
Expand Down Expand Up @@ -863,14 +862,20 @@ void BP5Reader::UpdateBuffer(const TimePoint &timeoutInstant, const Seconds &pol
}
}

// broadcast buffer to all ranks from zero
m_Comm.BroadcastVector(m_Metadata.m_Buffer);

// broadcast metadata index buffer to all ranks from zero
m_Comm.BroadcastVector(m_MetaMetadata.m_Buffer);

InstallMetaMetaData(m_MetaMetadata);

size_t inputSize = m_Comm.BroadcastValue(m_Metadata.Size(), 0);

if (m_Comm.Rank() != 0)
{
m_Metadata.Resize(inputSize, "metadata broadcast");
}

m_Comm.Bcast(m_Metadata.Data(), inputSize, 0);

if (m_OpenMode == Mode::ReadRandomAccess)
{
for (size_t Step = 0; Step < m_MetadataIndexTable.size(); Step++)
Expand Down
5 changes: 2 additions & 3 deletions source/adios2/engine/bp5/BP5Reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
*
* BP5Reader.h
*
* Created on: Aug 1, 2018
* Author: Lipeng Wan wanl@ornl.gov
*/

#ifndef ADIOS2_ENGINE_BP5_BP5READER_H_
Expand All @@ -18,6 +16,7 @@
#include "adios2/helper/adiosComm.h"
#include "adios2/helper/adiosRangeFilter.h"
#include "adios2/toolkit/format/bp5/BP5Deserializer.h"
#include "adios2/toolkit/format/buffer/heap/BufferMalloc.h"
#include "adios2/toolkit/remote/Remote.h"
#include "adios2/toolkit/transportman/TransportMan.h"

Expand Down Expand Up @@ -225,7 +224,7 @@ class BP5Reader : public BP5Engine, public Engine

format::BufferSTL m_MetadataIndex;
format::BufferSTL m_MetaMetadata;
format::BufferSTL m_Metadata;
format::BufferMalloc m_Metadata;

void InstallMetaMetaData(format::BufferSTL MetaMetadata);
void InstallMetadataForTimestep(size_t Step);
Expand Down
9 changes: 5 additions & 4 deletions source/adios2/helper/adiosMemory.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
* adiosMemory.h : Memory copy operations functions using std::copy std::insert
* and std::memcpy
*
* Created on: May 17, 2017
* Author: William F Godoy godoywf@ornl.gov
*/

#ifndef ADIOS2_HELPER_ADIOSMEMORY_H_
Expand Down Expand Up @@ -83,7 +81,7 @@ void CopyToBufferThreads(std::vector<char> &buffer, size_t &position, const T *s
const size_t elements = 1, const unsigned int threads = 1) noexcept;

template <class T>
void ReverseCopyFromBuffer(const std::vector<char> &buffer, size_t &position, T *destination,
void ReverseCopyFromBuffer(const char *buffer, size_t &position, T *destination,
const size_t elements = 1) noexcept;

/**
Expand All @@ -95,7 +93,7 @@ void ReverseCopyFromBuffer(const std::vector<char> &buffer, size_t &position, T
* @param elements number of elements of destination type
*/
template <class T>
void CopyFromBuffer(const std::vector<char> &buffer, size_t &position, T *destination,
void CopyFromBuffer(const char *buffer, size_t &position, T *destination,
const size_t elements = 1) noexcept;

/**
Expand All @@ -110,6 +108,9 @@ template <class T>
T ReadValue(const std::vector<char> &buffer, size_t &position,
const bool isLittleEndian = true) noexcept;

template <class T>
T ReadValue(const char *buffer, size_t &position, const bool isLittleEndian = true) noexcept;

/** Read in 'nElems' elements from buffer into output array
* output must be pre-allocated.
*/
Expand Down
Loading
Loading