New attribute layout: Read from either int8_t or uint8_t#926
New attribute layout: Read from either int8_t or uint8_t#926ax3l merged 6 commits intoopenPMD:devfrom
Conversation
8545d4e to
493b70d
Compare
Thanks! Can you then cross-link the ADIOS2 bug report and this PR please?
That's correct - there are three distinct char types in C++. I think we used schar at some point or skipped it for using it for something else (like bools) but have not gotten back to it (also in part b/c adios never supported it). But yes, ideally that would just be another distinct type. |
|
Alright, the reproducer for ADIOS2 interestingly shows no broken behavior, other than the differing signed-ness cross-platform. I'll put it on the agenda for this evening/morning's VC whether this should be considered a bug or not. |
|
I think that making things portable across platforms requires introducing a clear distinction between |
| std::cout << "location.dt=" << location.dt << | ||
| "\tdetermineDatatype=" << determineDatatype< T > () << std::endl; |
There was a problem hiding this comment.
Is this a leftover debug message and should go into the error message?
There was a problem hiding this comment.
Yep, will merge that with the error message
| std::vector< std::string > res( height ); | ||
| for( size_t i = 0; i < height; ++i ) | ||
| std::vector< std::string > res( height ); | ||
| if( std::is_signed< char >::value == |
There was a problem hiding this comment.
Is it ok to add a bit more in-code comments for this part? Just to make it easier for our future selves, reading the workaround.
2bdb725 to
ed5f462
Compare
|
Hm, the Windows error in the newly added test is exactly the same one that already made me deactivate the EDIT: I rebased this on your EDIT: It's not an ADIOS issue. MSVC doesn't like that I use placement new to put a string into the char array of |
ed5f462 to
b6377dd
Compare
55bfcb0 to
312e77d
Compare
10b20b4 to
f548f33
Compare
|
I think I've found out why the new ADIOS2 schema never worked on MSVC: It apparently has trouble understanding placement new for arrays. The recent commit replaces: new( dest ) T[ numItems ]{};by: for( size_t i = 0; i < numItems; ++i )
{
new( dest + i ) T();
}And suddenly, things are working. |
|
Ouch, seems to be fixed in Visual Studio 2019: https://developercommunity.visualstudio.com/t/c-placement-new-is-incorrectly-compiled/206439 Do you want to add a comment? |
Ah, it's good to have a link for that, thanks for figuring that out. |
f3cb0a9 to
b23ec1a
Compare
chars may become uint8_t on disk which our reading procedures can't handle
b23ec1a to
d424b02
Compare
CppReference on
char:When doing
IO::DefineVariable<char>()in ADIOS2, the resulting variable will be stored in a platform-dependent way:Both of the above options may be seen on different platforms.
This PR fixes reading char-based variables if they were written on a platform with the same representation for the char type.
I've done some cross-platform testing and come to the conclusion that char/string-based variables are currently not implemented in a portable way in ADIOS2.
Case: Writing on some local x86-based machine where
charis an unsigned type, reading on Summit wherecharis a signed type:Variable<string>. The variable will not even occur inIO::AvailableVariables().Variable<char>.IO::InquireVariable<char>()will fail.Interestingly, writing on Summit and reading on the local machine works fine.
I'll write up a simple reproducer for a bug report, in the meantime this PR allows interaction within the same platform at least.
Also, I think our
Datatypeenum is also broken in this regard: We listCHARandUCHAR, but notSCHAR.charcan be eithersigned charorunsigned char, but our defintions imply thatcharis simply the signed variant. ADIOS2 gives us types with explicit signedness (uint8_torint8_t) and I cannot represent this sensibly with our datatypes.OPENPMD_NEW_ATTRIBUTE_LAYOUTis set manually, fix that