Skip to content
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
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ set(CORE_SOURCE
src/Format.cpp
src/Iteration.cpp
src/IterationEncoding.cpp
src/LoadStoreChunk.cpp
src/Mesh.cpp
src/ParticlePatches.cpp
src/ParticleSpecies.cpp
Expand All @@ -411,6 +412,7 @@ set(CORE_SOURCE
src/version.cpp
src/auxiliary/Date.cpp
src/auxiliary/Filesystem.cpp
src/auxiliary/Future.cpp
src/auxiliary/JSON.cpp
src/auxiliary/JSONMatcher.cpp
src/auxiliary/Memory.cpp
Expand Down
6 changes: 6 additions & 0 deletions include/openPMD/Dataset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ namespace openPMD
using Extent = std::vector<std::uint64_t>;
using Offset = std::vector<std::uint64_t>;

struct MemorySelection
{
Offset offset;
Extent extent;
};

class Dataset
{
friend class RecordComponent;
Expand Down
3 changes: 2 additions & 1 deletion include/openPMD/Datatype.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,8 @@ template <typename T>
inline constexpr Datatype determineDatatype(T &&val)
{
(void)val; // don't need this, it only has a name for Doxygen
using T_stripped = std::remove_cv_t<std::remove_reference_t<T>>;
using T_stripped =
std::remove_extent_t<std::remove_cv_t<std::remove_reference_t<T>>>;
if constexpr (auxiliary::IsPointer_v<T_stripped>)
{
return determineDatatype<auxiliary::IsPointer_t<T_stripped>>();
Expand Down
2 changes: 2 additions & 0 deletions include/openPMD/IO/ADIOS/ADIOS2File.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
*/
#pragma once

#include "openPMD/Dataset.hpp"
#include "openPMD/IO/ADIOS/ADIOS2Auxiliary.hpp"
#include "openPMD/IO/ADIOS/ADIOS2PreloadAttributes.hpp"
#include "openPMD/IO/ADIOS/ADIOS2PreloadVariables.hpp"
Expand Down Expand Up @@ -112,6 +113,7 @@ struct BufferedUniquePtrPut
std::string name;
Offset offset;
Extent extent;
std::optional<MemorySelection> memorySelection;
UniquePtrWithLambda<void> data;
Datatype dtype = Datatype::UNDEFINED;

Expand Down
19 changes: 17 additions & 2 deletions include/openPMD/IO/ADIOS/ADIOS2IOHandler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
*/
#pragma once

#include "openPMD/Dataset.hpp"
#include "openPMD/Error.hpp"
#include "openPMD/IO/ADIOS/ADIOS2Auxiliary.hpp"
#include "openPMD/IO/ADIOS/ADIOS2FilePosition.hpp"
Expand Down Expand Up @@ -509,6 +510,7 @@ class ADIOS2IOHandlerImpl
adios2::Variable<T> verifyDataset(
Offset const &offset,
Extent const &extent,
std::optional<MemorySelection> const &memorySelection,
adios2::IO &IO,
adios2::Engine &engine,
std::string const &varName,
Expand Down Expand Up @@ -622,13 +624,26 @@ class ADIOS2IOHandlerImpl
var.SetSelection(
{adios2::Dims(offset.begin(), offset.end()),
adios2::Dims(extent.begin(), extent.end())});

if (memorySelection.has_value())
{
var.SetMemorySelection(
{adios2::Dims(
memorySelection->offset.begin(),
memorySelection->offset.end()),
adios2::Dims(
memorySelection->extent.begin(),
memorySelection->extent.end())});
}

return var;
}

struct
{
bool noGroupBased = false;
bool blosc2bp5 = false;
bool memorySelection = false;
} printedWarningsAlready;
}; // ADIOS2IOHandlerImpl

Expand Down Expand Up @@ -942,7 +957,7 @@ class ADIOS2IOHandler : public AbstractIOHandler
try
{
auto params = internal::defaultParsedFlushParams;
this->flush(params);
this->flush_impl(params);
}
catch (std::exception const &ex)
{
Expand Down Expand Up @@ -990,6 +1005,6 @@ class ADIOS2IOHandler : public AbstractIOHandler
return true;
}

std::future<void> flush(internal::ParsedFlushParams &) override;
std::future<void> flush_impl(internal::ParsedFlushParams &) override;
}; // ADIOS2IOHandler
} // namespace openPMD
23 changes: 23 additions & 0 deletions include/openPMD/IO/ADIOS/macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,29 @@
#define openPMD_HAVE_ADIOS2_BP5 0
#endif

namespace openPMD
{
namespace detail
{
template <typename Variable, typename SFINAE = void>
struct CanTheMemorySelectionBeReset
{
static constexpr bool value = false;
};

template <typename Variable>
struct CanTheMemorySelectionBeReset<
Variable,
decltype(std::declval<Variable>().SetMemorySelection())>
{
static constexpr bool value = true;
};
} // namespace detail

constexpr bool CanTheMemorySelectionBeReset =
detail::CanTheMemorySelectionBeReset<adios2::Variable<int>>::value;
} // namespace openPMD

#else

#define openPMD_HAS_ADIOS_2_8 0
Expand Down
7 changes: 6 additions & 1 deletion include/openPMD/IO/AbstractIOHandler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,13 +265,15 @@ class AbstractIOHandler
* backends that decide to implement this operation asynchronously.
*/
std::future<void> flush(internal::FlushParams const &);
std::shared_ptr<unsigned long long> m_flushCounter =
std::make_shared<unsigned long long>(0);

/** Process operations in queue according to FIFO.
*
* @return Future indicating the completion state of the operation for
* backends that decide to implement this operation asynchronously.
*/
virtual std::future<void> flush(internal::ParsedFlushParams &) = 0;
std::future<void> flush(internal::ParsedFlushParams &);

/** The currently used backend */
virtual std::string backendName() const = 0;
Expand Down Expand Up @@ -315,6 +317,9 @@ class AbstractIOHandler
IterationEncoding m_encoding = IterationEncoding::groupBased;
OpenpmdStandard m_standard = auxiliary::parseStandard(getStandardDefault());
bool m_verify_homogeneous_extents = true;

protected:
virtual std::future<void> flush_impl(internal::ParsedFlushParams &) = 0;
}; // AbstractIOHandler

} // namespace openPMD
2 changes: 1 addition & 1 deletion include/openPMD/IO/DummyIOHandler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class DummyIOHandler : public AbstractIOHandler
/** No-op consistent with the IOHandler interface to enable library use
* without IO.
*/
std::future<void> flush(internal::ParsedFlushParams &) override;
std::future<void> flush_impl(internal::ParsedFlushParams &) override;
std::string backendName() const override;
}; // DummyIOHandler
} // namespace openPMD
2 changes: 1 addition & 1 deletion include/openPMD/IO/HDF5/HDF5IOHandler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class HDF5IOHandler : public AbstractIOHandler
return "HDF5";
}

std::future<void> flush(internal::ParsedFlushParams &) override;
std::future<void> flush_impl(internal::ParsedFlushParams &) override;

private:
std::unique_ptr<HDF5IOHandlerImpl> m_impl;
Expand Down
2 changes: 1 addition & 1 deletion include/openPMD/IO/HDF5/ParallelHDF5IOHandler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class ParallelHDF5IOHandler : public AbstractIOHandler
return "MPI_HDF5";
}

std::future<void> flush(internal::ParsedFlushParams &) override;
std::future<void> flush_impl(internal::ParsedFlushParams &) override;

private:
std::unique_ptr<ParallelHDF5IOHandlerImpl> m_impl;
Expand Down
1 change: 1 addition & 0 deletions include/openPMD/IO/IOTask.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,7 @@ struct OPENPMDAPI_EXPORT

Extent extent = {};
Offset offset = {};
std::optional<MemorySelection> memorySelection = std::nullopt;
Datatype dtype = Datatype::UNDEFINED;
auxiliary::WriteBuffer data;
};
Expand Down
2 changes: 1 addition & 1 deletion include/openPMD/IO/JSON/JSONIOHandler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class JSONIOHandler : public AbstractIOHandler
return "JSON";
}

std::future<void> flush(internal::ParsedFlushParams &) override;
std::future<void> flush_impl(internal::ParsedFlushParams &) override;

private:
JSONIOHandlerImpl m_impl;
Expand Down
Loading
Loading