Add unique_ptr overloads for storeChunk calls#1294
Conversation
|
This pull request introduces 13 alerts when merging 41b5eb9 into d64365b - view on LGTM.com new alerts:
|
41b5eb9 to
c02669a
Compare
020d2dd to
dd71f38
Compare
src/IO/ADIOS/ADIOS2IOHandler.cpp
Outdated
|
|
||
| if (performDataWrite) | ||
| { | ||
| // should we really do this now? |
There was a problem hiding this comment.
| // should we really do this now? |
Should we write attributes before PerformDataWrites()?
- Yes: Then setting another value for the attribute later won't work (see e.g SerialIOTest:)
o.setOpenPMDextension( 1); // this happens intentionally "late" in this test - No: Then attributes would only be written very late, i.e. before
EndStep().
Personally, I think if preferred_flush_target = disk is selected, then everything that can be written to disk should be, so we should leave it as it is.
There was a problem hiding this comment.
I think we can revisit this once we change the defaults of frontends and avoid setting defaults of attributes too early. Writing attributes after datasets are defined can help with sensible defaults, e.g., x,y,z for 3D but only x,y for 2D mesh axis labels, etc.
01a0056 to
ed1ac70
Compare
ed1ac70 to
96b4721
Compare
1e73b45 to
8f3a93e
Compare
8f3a93e to
28ec211
Compare
|
This pull request introduces 1 alert when merging 28ec211 into 230afdd - view on LGTM.com new alerts:
|
28ec211 to
829eb3e
Compare
829eb3e to
86025de
Compare
b1e6f8b to
4acd9d1
Compare
a271126 to
7645264
Compare
|
|
||
| void storeChunk( | ||
| auxiliary::WriteBuffer buffer, Datatype datatype, Offset o, Extent e); | ||
|
|
There was a problem hiding this comment.
private, no new API
There was a problem hiding this comment.
(could nonetheless have Doxygen block for us ;-) )
7645264 to
15c5bef
Compare
| template <typename T_ContiguousContainer> | ||
| inline constexpr Datatype determineDatatype(T_ContiguousContainer &&) | ||
| template <typename T> | ||
| inline constexpr Datatype determineDatatype(T &&val) |
There was a problem hiding this comment.
This function is now aware of std::unique_ptr as well as OpenpmdUniquePtr, additionally to the previous raw and shared pointers. It's now implemented via if constexpr (previously overloads). Otherwise, the API is unchanged.
There was a problem hiding this comment.
Ok. Could be a good candidate for a C++ concept at some point.
8ef87d9 to
c685485
Compare
Refactor ::clone() to ::to_heap(), also make copy/move constructors/operators in AbstractParameter protected instead of deleting them.
No optimizations based on that yet
Not yet implemented, so test fails
c685485 to
cfa03e5
Compare
| @@ -704,9 +677,10 @@ struct OPENPMDAPI_EXPORT Parameter<Operation::DEREGISTER> | |||
| Parameter(Parameter const &) : AbstractParameter() | |||
There was a problem hiding this comment.
CodeQL: Looks like Parameter generally lacks the copy assignment operator (independent of this PR):
Parameter& operator=(const Parameter& other)https://github.com/openPMD/openPMD-api/security/code-scanning/498
|
|
||
| void storeChunk( | ||
| auxiliary::WriteBuffer buffer, Datatype datatype, Offset o, Extent e); | ||
|
|
There was a problem hiding this comment.
(could nonetheless have Doxygen block for us ;-) )
| "ADIOS2 backend: Flush of late writes was requested at the " | ||
| "wrong time."); |
There was a problem hiding this comment.
This error message is not hard to understand for me :)
There was a problem hiding this comment.
To be fair, this is an error::Internal that should only happen when there is a bug somewhere in our code. So if this error occurs, it's not really supposed to be understood by the user, but to help them report the issue in more detail.
error::Internal is always thrown in combination with a request to report it:
Internal::Internal(std::string const &what)
: Error(
"Internal error: " + what +
"\nThis is a bug. Please report at ' "
"https://github.com/openPMD/openPMD-api/issues'.")
{}There was a problem hiding this comment.
That is great!
I mean for us (devs) to remember, I would extend the half sentence about the "wrong time" a bit :D
ax3l
left a comment
There was a problem hiding this comment.
This look really good to me. I have a few inline comments that can be addressed as a follow-up :)
See #1216 for an explanation. The approach in this PR is to use
unique_ptrs instead of relying on the refcount ofshared_ptrs to make this optimization more explicit to the user.TODO
OpenpmdUniquePtrthat allows specifying dynamic destructors viastd::function<void(T*)>, similar tostd::shared_ptr. In the STL,unique_ptrs have a different type depending on their destructor, which is annoying for our use case, and the overhead of making this dynamic is negligible in our use case.This way, it's easily possible to e.g. pass ownership of pinned memory to openPMD and still let it correctly destroy it once used.
Write_Datasetoperations to acceptstd::variant<std::shared_ptr<void const>, OpenpmdUniquePtr<void const>>as a buffer.This requires some light refactoring because with this change, the IOTask is not copyable any more.
This includes making the backends deal with both types correctly.
storeChunkoverload that acceptsOpenpmdUniquePtrsEngine::close().OpenpmdUniquePtrnot leak into the public API.@ax3l This PR should not be too much work any more, so we might as well add this to 0.15.*?