Skip to content
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

Introduce more flexible storeChunk() syntax, use to add ADIOS2 memory selection #1620

Open
wants to merge 41 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
baf28f5
Remove explicit T[] loadChunk and storeChunk overload
franzpoeschel May 17, 2024
7e4b80a
Add class structure for LoadChunk
franzpoeschel May 17, 2024
7e6552b
use std::conditional_t
franzpoeschel May 17, 2024
5e89f09
Implement storeChunkSpan()
franzpoeschel May 17, 2024
68c118a
Remove accidentally compiled bool dataset store from Python APIs
franzpoeschel May 17, 2024
8825248
Implement for normal storeChunk()
franzpoeschel May 17, 2024
88773cb
StoreChunk completely moved over to new syntax
franzpoeschel May 17, 2024
10bc56c
Rename TypedConfigureStoreChunk -> ConfigureStoreChunkFromBuffer
franzpoeschel May 21, 2024
bc987d4
Implement memory selection in ADIOS2
franzpoeschel May 21, 2024
7507729
Throw errors in JSON/HDF5 when supplying memory selection
franzpoeschel May 21, 2024
d7a786f
Test memory selection
franzpoeschel May 21, 2024
e9445fc
Directly reset memory selection after applying
franzpoeschel May 22, 2024
cb72d3d
Rename in preparation for storeChunk adaptations
franzpoeschel May 22, 2024
86fb124
Prepare class structure for load_chunk
franzpoeschel May 22, 2024
cb5a0db
WIP loadChunk
franzpoeschel May 22, 2024
6e54a42
Implement this for loadChunk
franzpoeschel May 22, 2024
1b86794
Test new loadChunk syntax
franzpoeschel May 22, 2024
d9c5eab
Fix CI issues
franzpoeschel May 22, 2024
fee8553
Add variant-based loadChunk
franzpoeschel May 24, 2024
a09c2b4
Renaming
franzpoeschel May 24, 2024
1d0d9d2
Use another workaround for fixing the wrong lint
franzpoeschel Jun 24, 2024
36b0129
Guard against memory selections in reading
franzpoeschel Jun 24, 2024
60bfd7f
Some documentation and cleanup
franzpoeschel Jun 24, 2024
e13a3e7
Frontend support for unique pointers with const value types
franzpoeschel Jun 24, 2024
a5ddd6d
Workaround for annoying compilers that dont move
franzpoeschel Jun 25, 2024
37f54c4
Transform load calls to use std::future
franzpoeschel Jul 19, 2024
1324cfa
Extract non-template members to ConfigureStoreChunkCore
franzpoeschel Jul 19, 2024
5584b22
Some cleanup needed, but change class structure
franzpoeschel Jul 19, 2024
83a6a50
WIP: Cleanup
franzpoeschel Jul 22, 2024
7781e03
Same for store API
franzpoeschel Jul 22, 2024
347da49
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 22, 2024
f8e1bb5
Use own wrapper class DeferredFuture
franzpoeschel Jul 22, 2024
be3d441
Avoid wrong warnings
franzpoeschel Jul 22, 2024
9c9368f
Type hints for old compilers' benefit
franzpoeschel Jul 22, 2024
738e17f
Fixes
franzpoeschel Jul 22, 2024
55b2ca1
Fix rebasing error
franzpoeschel Jul 23, 2024
0abc68b
Don't use std::packaged_task
franzpoeschel Aug 1, 2024
d4fbf3e
Add a bit more verbose output
franzpoeschel Sep 4, 2024
aeca4db
Add missing future return type
franzpoeschel Sep 4, 2024
43d26f7
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 15, 2024
8e455b4
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 10, 2024
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 @@ -394,6 +394,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 @@ -405,6 +406,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/Mpi.cpp
src/backend/Attributable.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 @@ -321,7 +321,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
3 changes: 3 additions & 0 deletions include/openPMD/IO/ADIOS/ADIOS2File.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@
*/
#pragma once

#include "openPMD/Dataset.hpp"
#include "openPMD/IO/ADIOS/ADIOS2Auxiliary.hpp"
#include "openPMD/IO/AbstractIOHandler.hpp"
#include "openPMD/IO/IOTask.hpp"
#include "openPMD/IO/InvalidatableFile.hpp"
#include "openPMD/config.hpp"
#include <optional>

#if openPMD_HAVE_ADIOS2
#include <adios2.h>
Expand Down Expand Up @@ -106,6 +108,7 @@ struct BufferedUniquePtrPut
std::string name;
Offset offset;
Extent extent;
std::optional<MemorySelection> memorySelection;
UniquePtrWithLambda<void> data;
Datatype dtype = Datatype::UNDEFINED;

Expand Down
16 changes: 16 additions & 0 deletions include/openPMD/IO/ADIOS/ADIOS2IOHandler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@
*/
#pragma once

#include "openPMD/Dataset.hpp"
#include "openPMD/Error.hpp"
#include "openPMD/IO/ADIOS/ADIOS2Auxiliary.hpp"
#include "openPMD/IO/ADIOS/ADIOS2FilePosition.hpp"
#include "openPMD/IO/ADIOS/macros.hpp"
#include "openPMD/IO/AbstractIOHandler.hpp"
#include "openPMD/IO/AbstractIOHandlerImpl.hpp"
#include "openPMD/IO/AbstractIOHandlerImplCommon.hpp"
Expand Down Expand Up @@ -430,6 +432,7 @@ class ADIOS2IOHandlerImpl
adios2::Variable<T> verifyDataset(
Offset const &offset,
Extent const &extent,
std::optional<MemorySelection> const &memorySelection,
adios2::IO &IO,
std::string const &varName)
{
Expand Down Expand Up @@ -511,13 +514,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
20 changes: 20 additions & 0 deletions include/openPMD/IO/ADIOS/macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,26 @@
#define openPMD_HAVE_ADIOS2_BP5 0
#endif

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;

#else

#define openPMD_HAS_ADIOS_2_8 0
Expand Down
2 changes: 2 additions & 0 deletions include/openPMD/IO/IOTask.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <cstddef>
#include <map>
#include <memory>
#include <optional>
#include <string>
#include <utility>
#include <variant>
Expand Down Expand Up @@ -450,6 +451,7 @@ struct OPENPMDAPI_EXPORT Parameter<Operation::WRITE_DATASET>

Extent extent = {};
Offset offset = {};
std::optional<MemorySelection> memorySelection = std::nullopt;
Datatype dtype = Datatype::UNDEFINED;
auxiliary::WriteBuffer data;
};
Expand Down
Loading
Loading