From a1713453b5bb0960271d8af11aa92cfaadb8aded Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20P=C3=B6schel?= Date: Fri, 28 Mar 2025 11:37:58 +0100 Subject: [PATCH 1/4] Emplace scalar tuple only when needed --- include/openPMD/backend/BaseRecord.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/openPMD/backend/BaseRecord.hpp b/include/openPMD/backend/BaseRecord.hpp index 87364b46f4..cdddf422ad 100644 --- a/include/openPMD/backend/BaseRecord.hpp +++ b/include/openPMD/backend/BaseRecord.hpp @@ -28,6 +28,7 @@ #include "openPMD/backend/Container.hpp" #include +#include #include #include #include // std::remove_reference_t @@ -113,8 +114,7 @@ namespace internal {} ScalarIterator(T_BaseRecord *baseRecord, Left iterator) : m_baseRecordData(&baseRecord->get()) - , m_scalarTuple(std::make_pair( - RecordComponent::SCALAR, T_RecordComponent(*baseRecord))) + , m_scalarTuple(std::nullopt) , m_iterator(std::move(iterator)) {} From 0ab5c5f7690e4e999327ed0652fe97030eccdf14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20P=C3=B6schel?= Date: Fri, 28 Mar 2025 12:17:42 +0100 Subject: [PATCH 2/4] Flush only dirty meshes/species TODO: Maybe do this in more places, and also when reading --- src/Iteration.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Iteration.cpp b/src/Iteration.cpp index c991c2b79b..2a01aaede1 100644 --- a/src/Iteration.cpp +++ b/src/Iteration.cpp @@ -363,7 +363,12 @@ void Iteration::flush(internal::FlushParams const &flushParams) } meshes.flush(s.meshesPath(), flushParams); for (auto &m : meshes) - m.second.flush(m.first, flushParams); + { + if (m.second.dirtyRecursive()) + { + m.second.flush(m.first, flushParams); + } + } } else { @@ -379,7 +384,12 @@ void Iteration::flush(internal::FlushParams const &flushParams) } particles.flush(s.particlesPath(), flushParams); for (auto &species : particles) - species.second.flush(species.first, flushParams); + { + if (species.second.dirtyRecursive()) + { + species.second.flush(species.first, flushParams); + } + } } else { From b0dfe64bac66eccd22d74cce8a479bdd53508df8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20P=C3=B6schel?= Date: Fri, 28 Mar 2025 12:28:02 +0100 Subject: [PATCH 3/4] Improved specification of standards --- src/ParticleSpecies.cpp | 15 +++++++++------ src/Record.cpp | 4 ++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/ParticleSpecies.cpp b/src/ParticleSpecies.cpp index 4006cc82ba..0c0be3ef4b 100644 --- a/src/ParticleSpecies.cpp +++ b/src/ParticleSpecies.cpp @@ -168,12 +168,15 @@ void ParticleSpecies::flush( } else { - auto it = find("position"); - if (it != end()) - it->second.setUnitDimension({{UnitDimension::L, 1}}); - it = find("positionOffset"); - if (it != end()) - it->second.setUnitDimension({{UnitDimension::L, 1}}); + if (flushParams.flushLevel != FlushLevel::SkeletonOnly) + { + auto it = find("position"); + if (it != end()) + it->second.setUnitDimension({{UnitDimension::L, 1}}); + it = find("positionOffset"); + if (it != end()) + it->second.setUnitDimension({{UnitDimension::L, 1}}); + } Container::flush(path, flushParams); diff --git a/src/Record.cpp b/src/Record.cpp index 7d41fce5c2..5be926d0e0 100644 --- a/src/Record.cpp +++ b/src/Record.cpp @@ -45,8 +45,8 @@ Record &Record::setUnitDimension(unit_representations::AsMap const &udim) } Record &Record::setUnitDimension(unit_representations::AsArray const &udim) { - return setUnitDimension( - unit_representations::asMap(udim, /* skip_zeros = */ false)); + setAttribute("unitDimension", udim); + return *this; } void Record::flush_impl( From a4df35d1b62bea80731d101c397f0243c3f567f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20P=C3=B6schel?= Date: Mon, 31 Mar 2025 18:42:20 +0200 Subject: [PATCH 4/4] Don't forward empty Span operations to backend --- include/openPMD/RecordComponent.tpp | 9 +++++++++ include/openPMD/Span.hpp | 5 ++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/include/openPMD/RecordComponent.tpp b/include/openPMD/RecordComponent.tpp index 7beaae8b9d..0ae1508bd1 100644 --- a/include/openPMD/RecordComponent.tpp +++ b/include/openPMD/RecordComponent.tpp @@ -370,6 +370,15 @@ RecordComponent::storeChunk(Offset o, Extent e, F &&createBuffer) dCreate.options = rc.m_dataset.value().options; IOHandler()->enqueue(IOTask(this, dCreate)); } + + if (size == 0) + { + // Don't forward this operation to the backend as it might create ugly + // zero-blocks in ADIOS2 + setDirtyRecursive(true); + return DynamicMemoryView(); + } + Parameter getBufferView; getBufferView.offset = o; getBufferView.extent = e; diff --git a/include/openPMD/Span.hpp b/include/openPMD/Span.hpp index 93bc0d24f7..85570fd148 100644 --- a/include/openPMD/Span.hpp +++ b/include/openPMD/Span.hpp @@ -113,7 +113,10 @@ class DynamicMemoryView } public: - explicit DynamicMemoryView() = default; + explicit DynamicMemoryView() + { + m_param.out->backendManagedBuffer = false; + } /** * @brief Acquire the underlying buffer at its current position in memory.