Closed MathisonBao closed 1 month ago
A bug. We might need to rename the conflicting user functions using macros.
Hi, pjaaskel:
Thanks for your reply. Could you explain in detail how to solve it using macro? I'm not sure how to use macros to differentiate between device or host functions with the same function name.
Thanks, Mathison
I meant that hipcc could (force) include a header that has lines such as `#define sincos _user_sincos
that avoid the name clash. But after a bit of thinking, that's not an ideal solution as it renames user facing symbols, so we should do something similar internally for the sincos() builtin calls.
A proper way to fix this issue is to use SPIR-V builtins instead of OpenCL built-ins in the headers. E.g. HIP's sincosf
would be mapped to __spirv_ocl_sincos
.
Okay, thanks pjaaskel and linehill!
The
void sincosf(float, float *, float *)
is a CUDA built-in function, thefloat sincos(float, float *)
is a OCL built-in function but not CUDA. So the user could define a function as same as the OCL one.In the implementation of
sincosf
function,sincos
will be called. (in order to use the SPIR-V Instruction:OpExtInst sincos
), but if a user defines a function, namedsincos
, thesincosf
will return the wrong result (sincosf
will call the function that the user defined).For example:
The data in
OUT0
and the data inOUT1
will be the same. Is this a bug? Is there any solution? Thanks a lot.