Skip to content

Commit

Permalink
Directly reset memory selection after applying
Browse files Browse the repository at this point in the history
  • Loading branch information
franzpoeschel committed May 22, 2024
1 parent c833209 commit edb6d5e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 22 deletions.
22 changes: 0 additions & 22 deletions include/openPMD/IO/ADIOS/ADIOS2IOHandler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -492,28 +492,6 @@ class ADIOS2IOHandlerImpl
adios2::Dims(
memorySelection->extent.begin(),
memorySelection->extent.end())});
if constexpr (!CanTheMemorySelectionBeReset)
{
if (!printedWarningsAlready.memorySelection)
{
std::cerr
<< "[Warning] Using a version of ADIOS2 that cannot "
"reset memory selections on a variable, once "
"specified. When using memory selections, then "
"please specify it explicitly on all storeChunk() "
"calls. Further info: "
"https://github.com/ornladios/ADIOS2/pull/4169."
<< std::endl;
printedWarningsAlready.memorySelection = true;
}
}
}
else
{
if constexpr (CanTheMemorySelectionBeReset)
{
var.SetMemorySelection();
}
}

return var;
Expand Down
32 changes: 32 additions & 0 deletions src/IO/ADIOS/ADIOS2File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "openPMD/IO/ADIOS/ADIOS2File.hpp"
#include "openPMD/Error.hpp"
#include "openPMD/IO/ADIOS/ADIOS2IOHandler.hpp"
#include "openPMD/IO/ADIOS/macros.hpp"
#include "openPMD/auxiliary/Environment.hpp"
#include <optional>

Expand Down Expand Up @@ -71,6 +72,12 @@ void DatasetReader::call(
template <class>
inline constexpr bool always_false_v = false;

static constexpr char const *warningMemorySelection =
"[Warning] Using a version of ADIOS2 that cannot reset memory selections "
"on a variable, once specified. When using memory selections, then please "
"specify it explicitly on all storeChunk() calls. Further info: "
"https://github.com/ornladios/ADIOS2/pull/4169.";

template <typename T>
void WriteDataset::call(ADIOS2File &ba, detail::BufferedPut &bp)
{
Expand All @@ -93,6 +100,19 @@ void WriteDataset::call(ADIOS2File &ba, detail::BufferedPut &bp)
bp.name);

ba.getEngine().Put(var, ptr);
if (bp.param.memorySelection.has_value())
{
if constexpr (CanTheMemorySelectionBeReset)
{
var.SetMemorySelection();
}
else if (!ba.m_impl->printedWarningsAlready.memorySelection)
{
std::cerr << warningMemorySelection << std::endl;
ba.m_impl->printedWarningsAlready.memorySelection =
true;
}
}
}
else if constexpr (std::is_same_v<
ptr_type,
Expand Down Expand Up @@ -155,6 +175,18 @@ struct RunUniquePtrPut
ba.m_IO,
bufferedPut.name);
ba.getEngine().Put(var, ptr);
if (bufferedPut.memorySelection.has_value())
{
if constexpr (CanTheMemorySelectionBeReset)
{
var.SetMemorySelection();
}
else if (!ba.m_impl->printedWarningsAlready.memorySelection)
{
std::cerr << warningMemorySelection << std::endl;
ba.m_impl->printedWarningsAlready.memorySelection = true;
}
}
}

static constexpr char const *errorMsg = "RunUniquePtrPut";
Expand Down

0 comments on commit edb6d5e

Please sign in to comment.