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
[Feature]: Make the options
parameter to hiprtcCompileProgram
const char* const *`
#3426
Comments
one concern is that this will change the mangled name therefore old HIP apps won't be able to resolve the symbol in the new HIPRTC shared library. One solution might be to keep the old API as an overloaded function that calls the new API. |
At least in ROCm 5.7 and 6.0, the HIP libraries use C linkage, so there should be no problem with mangled names (but also no way to have an overload): $ nm -D /opt/rocm-5.7.1/hip/lib/libhiprtc.so | grep hiprtcCompileProgram
0000000000043420 T hiprtcCompileProgram
$ nm -D /opt/rocm-6.0.0/lib/libhiprtc.so.6 | grep hiprtcCompileProgram
000000000000fee0 T hiprtcCompileProgram |
@yxsamliu Currently, we have a similar task internally to match the signature of hiprtcCreateProgram with nvrtc. i.e, to change the argument types from const char ** to const char* const*. But this was considered breaking backward compatibility and put on hold until 7.0. @al42and I believe this change will need to wait until next major release ROCm 7.0. CC @mangupta |
Okay, that works for us. Why, though? It is not breaking ABI, and I don't think the API change breaks any backward compatibility in this case. |
You are right. This API is actually declared with extern "C" (https://github.com/ROCm/HIP/blob/develop/include/hip/hiprtc.h), therefore it is not mangled. |
There are some HIP apps or libraries take address of this function. If they hardcode the function type, changing the function signature may break them. |
On the other hand, as you said this is in |
they could write code like:
If the signature changes, it breaks (https://godbolt.org/z/fGqKxKbbf) |
Yes, but this was not defined in an |
Per my understanding, the problem is not with linkage, but with C++ type system: a pointer to And |
Sure, but in that case it is an API issue, not an ABI issue. Once you ship the new headers with this updated |
In C++ mode, it would be reasonable to add an API with namespaces like |
Which means waiting for ROCm 7 (as long as semantic versioning is followed) :(
A story about runtime compilers with a nice C++ API would be interesting indeed. |
Suggestion Description
Currently, the function has the following signature:
However, this triggers
-Wcast-qual
warnings with a typical usage:We cannot simply use
(const char **)opts
either: https://c-faq.com/ansi/constmismatch.htmlSince the function accepts a constant pointer to constant strings, it is reasonable to make its signature read
This will both explicitly communicate what the function does and also allow to write the code like above safely by using and explicit cast to
(const char* const*)opts
Operating System
Ubuntu
GPU
MI50
ROCm Component
HIP RTC
The text was updated successfully, but these errors were encountered: