Skip to content

Commit 8338593

Browse files
committed
Shortcut zero-size storeChunk calls without breaking collectivity
1 parent 21adf5a commit 8338593

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

include/openPMD/RecordComponent.tpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,6 @@ RecordComponent::storeChunk(Offset o, Extent e, F &&createBuffer)
115115
IOHandler()->enqueue(IOTask(this, dCreate));
116116
}
117117

118-
if (size == 0)
119-
{
120-
// Don't forward this operation to the backend as it might create ugly
121-
// zero-blocks in ADIOS2
122-
setDirtyRecursive(true);
123-
return DynamicMemoryView<T>();
124-
}
125-
126118
Parameter<Operation::GET_BUFFER_VIEW> getBufferView;
127119
getBufferView.offset = o;
128120
getBufferView.extent = e;
@@ -136,7 +128,10 @@ RecordComponent::storeChunk(Offset o, Extent e, F &&createBuffer)
136128
// type shared_ptr<T> or shared_ptr<T[]>
137129
auto data = std::forward<F>(createBuffer)(size);
138130
out.ptr = static_cast<void *>(data.get());
139-
storeChunk(std::move(data), std::move(o), std::move(e));
131+
if (size > 0)
132+
{
133+
storeChunk(std::move(data), std::move(o), std::move(e));
134+
}
140135
}
141136
setDirtyRecursive(true);
142137
return DynamicMemoryView<T>{std::move(getBufferView), size, *this};

src/IO/ADIOS/ADIOS2IOHandler.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,6 +1299,17 @@ void ADIOS2IOHandlerImpl::getBufferView(
12991299
auto file = refreshFileFromParent(writable, /* preferParentFile = */ false);
13001300
detail::ADIOS2File &ba = getFileData(file, IfFileNotOpen::ThrowError);
13011301

1302+
if (std::any_of(
1303+
parameters.extent.begin(), parameters.extent.end(), [](auto val) {
1304+
return val == 0;
1305+
}))
1306+
{
1307+
// Refuse empty operations, ADIOS2 creates ugly zero blocks for them,
1308+
// tell the frontend to do sth about it instead
1309+
parameters.out->backendManagedBuffer = false;
1310+
return;
1311+
}
1312+
13021313
std::string name = nameOfVariable(writable);
13031314
switch (m_useSpanBasedPutByDefault)
13041315
{

0 commit comments

Comments
 (0)