-
Notifications
You must be signed in to change notification settings - Fork 128
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 std::complex<long double> Support #1907
Conversation
2a90064
to
54bde93
Compare
@germasch Can you please take a look if I updated the C bindings completely and properly with the new type? I also added the missing support for |
4a74974
to
7da7f67
Compare
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 don't think I'm specifically responsible for the C bindings (all I did was improve handling of strings there at some point), but anyway, those changes there look good to me.
I have some concerns about "long double" in general, though. It's not a standard type, and the way that I'm familiar with it is the 80-bit x87 floating point type, which has pretty much outlived its usefulness, I thought, as most compilers will by default use 64-bit SSE/AVX instructions when dealing with it, anyway. That's not to say that I'm opposed to providing support for it if it's needed by some application.
I don't think it should be called "r128", though, since at least on the most common arch, it's not 128-bit. In fact, one of the things I did early on is kinda put a boundary between C++ primitive types on one hand (the C/C++ interface) and stdint types (used internally). E.g., unsigned long
can be 32 or 64 bit depending on system, and so while the C++/C interface take unsigned long, the adios2 will internally map it to u32 or u64, and hence handle its actual size without regard to which system you're reading/writing on.
So if one wants to support longer than 64-bit precision, one should introduce probably both "r80" and "r128" separately,. Because otherwise things will go wrong when reading long double on a system where it's 80 bit, while having written it on a system that's 128 bit (it looks like that may be the case on IBM Power -- I'm in China and have trouble googling.)
So FWIW, I was wrong that Also, I had thought |
Thank you for the review! I just saw your name in several of the C binding files and assumed you authored a larger part of it. The length handling of ADIOS is generally not fixed size, simply by the definition that in C/C++ ( In terms of variable namings, which are not critical, I just used the default size on x86 64bit linux platforms as assumed in all other places for |
testing/adios2/engine/hdf5/TestHDF5WriteMemorySelectionRead.cpp
Outdated
Show resolved
Hide resolved
7da7f67
to
95df861
Compare
What happens for integer is that the C++ primitive type (say For float and double, no such mapping actually happens, though it probably should. The thing is, though, that on all current systems that I'm familiar with,
Yes, it's preexisting to this PR, though this PR exposes the problem in additional ways. I'm not saying it's a showstopper, but it'd probably be good to think about what to do with
Maybe most notably, apparently with MSVC
Unfortunately, even on 64-bit Linux, the binary representation of |
I thought so as well for long, but it's exactly the other way around. Implementing the fundamental types in the user-facing API overloads, as now, is generally the right thing to do. Implementing just the fixed (alias) types leads to problems, namely that some types a user provides will not map overloads. Assuming the type is known/identical between systems is not good on the file format level, but I don't even know if this is happening here. Nevertheless, this is all very off topic for this PR. |
I know that -- I guess I wasn't clear. ADIOS2 internally maps the C++ primitive types (short, int, ...) to stdint types. And yes, those stdint types themselves are in fact typedefs for primitive types. The point however, is that it takes the ambiguity away. On x86_64, both
Yes, even though there was some discussion about that at the time, that's the approach I pushed for, and that got adopted eventually. Obviously, when you support all primitive types, the stdint types, which are aliases for a subset of the primitive types, work just fine as well. Before that change, essentially only the stdint types themselves (and whatever they happen to alias to) were properly supported, and as you say, that lead to problems.
That's why it maps to the stdint types internally, which are identical on the filesystem level. The same can't be said of |
8bf1f4b
to
4dfbf03
Compare
4dfbf03
to
3bbd968
Compare
Ha, the PGI Fortran compiler still does not support quad precision. Welcome to 2020. |
7a6cd04
to
b2db6e5
Compare
m_PropertyTxfID = H5Pcreate(H5P_DATASET_XFER); | ||
} | ||
|
||
HDF5Common::~HDF5Common() | ||
{ | ||
H5Tclose(m_DefH5TypeComplexLongDouble); |
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.
@guj this seams to write some H5Tclose(): not a datatype
errors to stderr in some tests.
3e25ba0
to
461edf7
Compare
Updated C++/C/Python frontend to soley refer to the missing fundamental (complex) long double types. "Serialization" (aka portability of fundamental types) is not touched by this PR and is an independent task that needs to be generally fixed for the BP file format. The problem is not new with I moved the Fortran binding updates for real16 kinds to a follow-up PR in #1921. This should allow us to review (and potentially merge) this PR now. @chuckatkins please remove the |
ea4d6b1
to
860561a
Compare
FWIW, this alleviates my main concern, ie., the Fortran bindings that use It looks like even though you separated out the Python interface changes into a separate PR #1922, that PR is missing most of the Python-related updates (the python tests in particular), while this PR still has all of the Python changes, so if you want them to be separate, you should still remove them from here. (I didn't look deeply into the Python changes, but I don't think I have fundamental concerns about them -- |
860561a
to
73731be
Compare
Implement support for the `long double` complex type.
Add long double and long double complex types in Python bindings.
73731be
to
b916b3c
Compare
@williamfgc @pnorbert @guj ready for review :) |
I didn't see an issue with PGI but relied on CI for that, which passed. Update: just tried to compile on Summit with GCC 6.4.0 which results in
@chuckatkins do you potentially want to add Travis-CI's new PPC64le architecture to CI? |
This seams to be an internal GCC 6.4.0 issue which is fixed on Summit/PPC64le with GCC 7.4.0, 8.1.0, 8.1.1, 9.1.0 - these are the versions I tested now. |
@ax3l I was making reference to your comment above wrt PGI, thanks for checking that's not an issue. After reviewing the topic we decided to go for a more robust solution to map currently available non-standard types. @chuckatkins will kickstart the work on the CMake side and we can propagate to BP as in this PR. We can use parts of this PR or build on top. Thanks for double-checking that there are outstanding issues with gcc <= 6.4.0. My preference is not to merge this PR as-is (breaks |
@ax3l In yesterday's dev meeting the team agreed to do the following (which will be done for the next release)
We thought accepting this PR as is so you can move on, and then do the above as updates but the requirement to use GCC 7 or newer scares us. Can we hold on to this PR for a while, until we have the CMake magic (@chuckatkins) to get the support for long double and conditional compilation to avoid breaking ADIOS with GCC 5 and 6? A followup development later will be to implement conversions between types as Operators and add them automatically when application type does not match data type in input. |
Ah I see, no that's only a Fortran binding issue and has been moved to #1921 and got a CMake feature test and pre-compiler guards. |
Thanks @williamfgc and @pnorbert for the updates! |
Just to update this issue: I guess the general goal should be multi-precision float support, especially for half-precision types (bfloat & float16) which already landed in the development branch of e.g. OpenMPI and are actively used in math libraries and apps already. Support for long double is just a very similar problem. |
It looks to me like this got closed when @chuckatkins pulled in the upstream pybind11, which fixed a pybind11 issue which happened to have the same issue number. |
@chuckatkins @pnorbert I forgot what the status on this is. Is there any progress on how to add |
Add support for complex numbers as fundamental data type. Close #203 - [x] Tests - [x] internals: new types, comparisons, allowed casts, record components, patches and attributes, etc. - [x] JSON (writes to pairs, read re-identification as complex is todo) - [x] HDF5 - [x] ADIOS1 (no long double complex; no attributes of arrays of complex: ornladios/ADIOS#212) - [x] ADIOS2: (complex attributes: ornladios/ADIOS2#1908); (no long double complex ornladios/ADIOS2#1907) - [x] Python bindings
@ax3l We're trying to close old, impossible-to-merge-as-is PRs. It looks like there were action items on this that never actually got addressed. CMake issues for @chuckatkins, maybe something for @pnorbert... The comment on half-precision types is likely something we should be thinking about for GPUs too (@anagainaru) . I think those are unlikely to be addressed prior to our next release, but it's also the case that this PR is applicable to a two-year-old code base and developments like BP5 change the landscape significantly. Can I suggest closing this PR and maybe creating a summary Issue (if these concerns aren't adequately represented in an issue already)? |
Implement support for the
std::complex< long double >
type.We need this downstream in openPMD-api and it's generally a missing type (since we also have a type for
long double
).Help wanted :)
To Do
float
anddouble
complex: anything to do?long double
type): [WIP] Fortran: Real16 (complex) Support #1921long double
type?)long double
type)As a follow-up, a native ADIOS
bool
type would be great for C++ codes, too.