Skip to content

Commit edb6d5e

Browse files
committed
Directly reset memory selection after applying
1 parent c833209 commit edb6d5e

File tree

2 files changed

+32
-22
lines changed

2 files changed

+32
-22
lines changed

include/openPMD/IO/ADIOS/ADIOS2IOHandler.hpp

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -492,28 +492,6 @@ class ADIOS2IOHandlerImpl
492492
adios2::Dims(
493493
memorySelection->extent.begin(),
494494
memorySelection->extent.end())});
495-
if constexpr (!CanTheMemorySelectionBeReset)
496-
{
497-
if (!printedWarningsAlready.memorySelection)
498-
{
499-
std::cerr
500-
<< "[Warning] Using a version of ADIOS2 that cannot "
501-
"reset memory selections on a variable, once "
502-
"specified. When using memory selections, then "
503-
"please specify it explicitly on all storeChunk() "
504-
"calls. Further info: "
505-
"https://github.com/ornladios/ADIOS2/pull/4169."
506-
<< std::endl;
507-
printedWarningsAlready.memorySelection = true;
508-
}
509-
}
510-
}
511-
else
512-
{
513-
if constexpr (CanTheMemorySelectionBeReset)
514-
{
515-
var.SetMemorySelection();
516-
}
517495
}
518496

519497
return var;

src/IO/ADIOS/ADIOS2File.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "openPMD/IO/ADIOS/ADIOS2File.hpp"
2323
#include "openPMD/Error.hpp"
2424
#include "openPMD/IO/ADIOS/ADIOS2IOHandler.hpp"
25+
#include "openPMD/IO/ADIOS/macros.hpp"
2526
#include "openPMD/auxiliary/Environment.hpp"
2627
#include <optional>
2728

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

75+
static constexpr char const *warningMemorySelection =
76+
"[Warning] Using a version of ADIOS2 that cannot reset memory selections "
77+
"on a variable, once specified. When using memory selections, then please "
78+
"specify it explicitly on all storeChunk() calls. Further info: "
79+
"https://github.com/ornladios/ADIOS2/pull/4169.";
80+
7481
template <typename T>
7582
void WriteDataset::call(ADIOS2File &ba, detail::BufferedPut &bp)
7683
{
@@ -93,6 +100,19 @@ void WriteDataset::call(ADIOS2File &ba, detail::BufferedPut &bp)
93100
bp.name);
94101

95102
ba.getEngine().Put(var, ptr);
103+
if (bp.param.memorySelection.has_value())
104+
{
105+
if constexpr (CanTheMemorySelectionBeReset)
106+
{
107+
var.SetMemorySelection();
108+
}
109+
else if (!ba.m_impl->printedWarningsAlready.memorySelection)
110+
{
111+
std::cerr << warningMemorySelection << std::endl;
112+
ba.m_impl->printedWarningsAlready.memorySelection =
113+
true;
114+
}
115+
}
96116
}
97117
else if constexpr (std::is_same_v<
98118
ptr_type,
@@ -155,6 +175,18 @@ struct RunUniquePtrPut
155175
ba.m_IO,
156176
bufferedPut.name);
157177
ba.getEngine().Put(var, ptr);
178+
if (bufferedPut.memorySelection.has_value())
179+
{
180+
if constexpr (CanTheMemorySelectionBeReset)
181+
{
182+
var.SetMemorySelection();
183+
}
184+
else if (!ba.m_impl->printedWarningsAlready.memorySelection)
185+
{
186+
std::cerr << warningMemorySelection << std::endl;
187+
ba.m_impl->printedWarningsAlready.memorySelection = true;
188+
}
189+
}
158190
}
159191

160192
static constexpr char const *errorMsg = "RunUniquePtrPut";

0 commit comments

Comments
 (0)