-
Notifications
You must be signed in to change notification settings - Fork 51
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
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
@@ -387,6 +404,9 @@ class RecordComponent : public BaseRecordComponent | |||
*/ | |||
RecordComponent &makeEmpty(Dataset d); | |||
|
|||
void storeChunk( | |||
auxiliary::WriteBuffer buffer, Datatype datatype, Offset o, Extent e); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private, no new API
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
@@ -387,6 +404,9 @@ class RecordComponent : public BaseRecordComponent | |||
*/ | |||
RecordComponent &makeEmpty(Dataset d); | |||
|
|||
void storeChunk( | |||
auxiliary::WriteBuffer buffer, Datatype datatype, Offset o, Extent e); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This error message is not hard to understand for me :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is great!
I mean for us (devs) to remember, I would extend the half sentence about the "wrong time" a bit :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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_ptr
s instead of relying on the refcount ofshared_ptr
s to make this optimization more explicit to the user.TODO
OpenpmdUniquePtr
that allows specifying dynamic destructors viastd::function<void(T*)>
, similar tostd::shared_ptr
. In the STL,unique_ptr
s 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_Dataset
operations 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.
storeChunk
overload that acceptsOpenpmdUniquePtr
sEngine::close()
.OpenpmdUniquePtr
not 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.*?