Skip to content

[WIP] Performance optimizations for interacting with many meshes / species types #1741

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

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open
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
9 changes: 9 additions & 0 deletions include/openPMD/RecordComponent.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>();
}

Parameter<Operation::GET_BUFFER_VIEW> getBufferView;
getBufferView.offset = o;
getBufferView.extent = e;
Expand Down
5 changes: 4 additions & 1 deletion include/openPMD/Span.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions include/openPMD/backend/BaseRecord.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "openPMD/backend/Container.hpp"

#include <array>
#include <optional>
#include <stdexcept>
#include <string>
#include <type_traits> // std::remove_reference_t
Expand Down Expand Up @@ -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))
{}

Expand Down
14 changes: 12 additions & 2 deletions src/Iteration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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
{
Expand Down
15 changes: 9 additions & 6 deletions src/ParticleSpecies.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Record>::flush(path, flushParams);

Expand Down
4 changes: 2 additions & 2 deletions src/Record.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Loading