-
Notifications
You must be signed in to change notification settings - Fork 12k
Fix ROCM build by relaxing constness #3895
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
Conversation
Can we do this in a way that doesn't generate warnings? |
The code up above it with the Do you have a suggestion for a way to do it that doesn't cause the warnings? |
This is still necessary to compile with ROCM. I checked with the latest changes. |
Currently, building |
From what I understand, ROCM's "nvcc" is clang. If you build with clang, you'll probably see the massive warning spam I mentioned.
Unfortunately, it's kind of far above my pay grade. I messed around a bit and couldn't find a solution. The HIPBLAS function needs a I feel like (and am probably wrong) this has something to do with the fact that it's one chunk of memory we're saying is both const and not? But if that's the case then you'd have to malloc more than one chunk of memory, but from what I know allocation has a non-trivial performance cost. |
I think we can fix the warnings if we go back to 2 separate arrays with pointers instead of 1 array. The first array will hold the const src pointers and the second will hold the dst pointers. I will give it a try later if @KerfuffleV2 is not able to figure it out. |
I honestly don't know anything about this except my change got it to compile. I don't really know enough to refactor the actual code. We can hold off on merging this in hopes of a better solution from someone who actually knows what they're doing. Worst case, this pull is available. Would be nice to not leave it broken for too long though. All 7 ROCM users will be sad! |
This is the warning:
This is because casting to The hipBLAS API does seem to require that the const pointers and non-const pointers are stored in separate arrays, as there is no safe way to cast between those types. |
We could just remove |
If we do, I'd prefer to do it for only that part of the code with something like: #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wcast-qual"
// offending code here
#pragma GCC diagnostic pop |
Can you elaborate on why you think that this warning is important? What is the value of complaining about converting a non-const pointer to const, beyond acknowledging a flaw in C's type system? I very much would prefer to not litter the code with pragmas that are irrelevant to the code. This is not the first case either, I pretty much gave up on trying to make the ggml hash tables at least somewhat const-correct because of this warning. |
I guess what he's getting at is that it's probably not always a useless warning. Presumably someone thought it was worth adding to the compiler to warn the user about. So if it got disabled globally, maybe some mistakes would slip by that otherwise may have been caught - even if it's benign in this particular case. Playing devil's advocate a bit, I care more about, you know... actually being able to compile the thing on my system. :) |
Superseded by #3913 |
This change seems necessary to build with ROCM, at least on my system.
Similar to a previous change that got "accepted"...