-
Notifications
You must be signed in to change notification settings - Fork 769
[SYCL] C++ User-Literals Broken #2187
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
Comments
Work-around for DPC++ beta08 bug in: intel/llvm#2187
Work-around for DPC++ beta08 bug in: intel/llvm#2187
Work-around for DPC++ beta08 bug in: intel/llvm#2187
Work-around for DPC++ beta08 bug in: intel/llvm#2187
This is probably caused by #1512. The PR doesn't contain a lot of info about the motivation: the one reason I can guess is that if However, I don't know why we are not mapping |
I've found it. It was introduced here in this commit: For SYCL, those lines (1728 - 1737 of the link above) are redundant. We already have checks for illegal The difference is that the checks in Sema.cpp that are causing the issue are performed early, during parsing, I believe. But the ones performed in SemaSYCL.cpp are being performed later, after there is more type information in the QualTypes. The lifecycle stage is important, because otherwise types get missed or mis-interpreted. I haven't looked at that type block in Sema.cpp carefully yet, but if it is redundant, then at least for SYCL we could check Question: does OpenMP have the same issue? I would think it should. @Fznamznon @AlexeySachkov @bader - what do you think? I will investigate a bit more to double check. |
AFAIK they works only for variable declarations inside device code. The checks that you claim about is added by me through review with community. They have other underlying idea - diagnose on attempt to use (not declare!) something in device code, so they work for cases like captured illegal variables in the device code and calling a function with illegal type in parameters and return value. The community's idea was to replace illegal types with byte arrays in resulting code and diagnose when such replacement is not possible. Right now replacement doesn't happen, so we still need our checks in SemaSYCL.cpp to keep SPIR-V valid.
I believe they happen a bit later, on attempt to use some declaration. See (diagnoseUseOfDecl Sema function).
Probably yes. But is it an issue? Although I would expect that everything should be fine if 64 bit long type is requested, since this check (cf6cc66#diff-2856c75f844d1133220fc68717852bf1R1727) should claim only about 128 bit size. Other interesting question is "Does SYCL device code has support for long double at all?".
After that I would expect that all types that are supported in C++11 also supported in SYCL.
And there is no |
In this particular case But, regardless, would it be ok with you if I bracketed that code with a SYCL check so it's not run with SYCL, and added a new test for UDL functions? That would fix this bug in the short term, and the UDL test could be sent back to the community because I think, ultimately, they'll need to address this problem as well. Let me know your thoughts. |
Why it is replaced? I see a function with long double argument in resulting LLVM IR for such literal, see https://godbolt.org/z/xPGW57 . Am I misunderstanding something? |
You are correct, apparently UDL functions can be runtime, have their address taken, etc. But my understanding is that they are normally compiled away. And, in your example, the _rt() function does not end up in the machine code ( but, Hmm - so maybe the problem isn't a lifecycle problem like I originally posited. |
Unfortunately, the two standards place us in a position where we cannot allow these when the target size long-double is an int-128 (like linux). The host and target size of variables HAS to remain the same. In the example, the variable 'rand' is not evaluated in a constant expression, so the frontend HAS to treat it like it is going to be emitted to machine code (because it WILL when optimizations are omitted). That said, there are actually TWO other bugs with the 128-bit-size 'long double' support that need to be fixed. First, when the variable is compelled to be a constexpr, we shouldn't be diagnosing (such as when you change your code to be constexpr auto rand = 3.14_rt). So the fix there is likely that we have to not-descend the call-graph in the case where the call is constant-evaluated (or not ODR used). SECOND: (and @Fznamznon may need to look into this), the diagnostic doesn't seem to be paying attention to -mlong-double-64, which configures 'long double' to be a 64 bit type. (mlong-double-80 and -mlong-double-128 do the obvious thing though). |
Hmm... This seems to affect all of the deferred diagnostic targets in clang (that is, assigning to a constexpr). I filed a bug against openMP where I think the maintainer did a lot of work on it (https://bugs.llvm.org/show_bug.cgi?id=46910), to see if he can figure out a good way to solve THAT. |
I'll take a look. |
This one #2295 should fix the |
@Fznamznon we are currently validating the fixed The error in beta09 is still:
(C++ user literals worked with Further help is greatly appreciated, because user-literals is literally (no pun intended) how we express mixed precision in our downstream, modern C++ code bases. One idea could also be to add the above example to the |
So, when command line like "clang++ -fsycl -mlong-double-64 test.cpp |
Thanks for the hint with the pass-through issue. Now only the public apt-repos for oneAPI beta09 need to become un-broken (AMReX-Codes/amrex#1366 // supporttickets.intel.com no. 04801443). Please keep us posted when the pass-through of |
Looks like -mlong-double is being restricted for the device compilation (only goes through for x86, ppc) |
Hi everyone, is there any progress on this? |
It looks like -mlong-double-64 should work through our driver now, based on my downstream's nightly. Were you able to give it a try? |
The issue of restricting |
Hi @bader @mdtoguchi, I just realized that even with the latest oneAPI release (2021.3.0), we still need to pass Is this the permanent solution or will this still be relaxed/adjusted? |
@ax3l, sorry for the delay. |
## Summary `IntelLLVM` is now a recognized CMake compiler, so we don't need to add a Clang-ish identification anymore. Also fix a CMake -Wdev warning (DPC++/SYCL) - beta08 work-around: `-mlong-double-64` (intel/llvm#2187) -> still needed! - beta09 work-around: `-fno-sycl-early-optimizations` (link to upstream issue?) -> keep for now, RT tests pending to verify fix ## Additional background setting the CXX compiler ID was a work-around for the 2021.1 DPC++ release / CMake 3.19.0-3.19.1 https://gitlab.kitware.com/cmake/cmake/-/issues/21551#note_869580
Hi,
our code-base defines a C++ user-defined literal of the form
prior to beta08 of oneAPI this worked quite well, but now it leads to a
Specifically for C++ user-defined literals this is odd, since they are only defined with
long double
as floating point type:Overloading user-defined literals with
double
does not work:Tried as a work-around
-mlong-double-64
, but this seems to have no effect (still reported as 128 bit).Seen with beta08 on Ubuntu 18.04.
The text was updated successfully, but these errors were encountered: