Integer dot product translation#1174
Conversation
|
Approved for testing. @Quetzonarch could you please rebase your PR to exclude "Fix support of SPV_INTEL_vector_compute extension" from it as it was merged? |
f3c123f to
3e5ffbd
Compare
|
|
|
At first glance, the description led me to believe this was an optimization which was using pattern matching to detect cases where a floating point dot product has been used with floating point vectors that have been converted from integer vectors, i.e. optimizing OpDot(OpConvertStoF(some_int)) → OpSDot(some_int). I now see that this is not what was intended, but that this is a correctness fix for translation of IR produced from source using the cl_khr_integer_dot_product extension. I haven't looked very closely at the tests, but the code looks fine as far as I can see. However, I'd request that the commit message and description be updated to make it clearer that this is adding support for cl_khr_integer_dot_product, rather than adding an optimization. |
svenvh
left a comment
There was a problem hiding this comment.
Like @StuartDBrady I initially also got misled by the description. As I understand now, this is not an optimization but actually fixing a bug in the translator: it currently translates calls such as dot(uchar4, uchar4) into OpDot %i8, which is wrong because OpDot only operates on floating point types. Clarifying in the description that the current behaviour is wrong would be great, as Stuart mentioned.
I think we should work towards accepting this PR and am keen to help; we've left this for too long!
@Quetzonarch I guess first you should try to rebase onto latest main and then you'll probably hit some issues. I have left some comments that should help you solve some problems that I expect will appear after rebasing, plus some other improvements.
test/transcoding/SPV_KHR_integer_dot_product_OCLtoSPIRV_char4.ll
Outdated
Show resolved
Hide resolved
|
Thank you for the comments and suggestions regarding the change. Yes, the point of this is to fix incorrect translations of IR produced from source using the cl_khr_integer_dot_product extension, sorry for the misleading description. I've begun implementing suggested changes. I'll try to push the update as soon as possible. |
96b0670 to
3e5ffbd
Compare
Added additional translation when dot function is called in OpenCL with integer arguments (packed int or vectors of 4 chars or 2 shorts) so that it's translated into proper OpCodes from SPV_KHR_integer_dot_product extension and not OpDot, which works on floats.
Added additional translation when dot function is called in OpenCL with integer arguments (packed int or vectors of 4 chars or 2 shorts) so that it's translated into proper OpCodes from SPV_KHR_integer_dot_product extension and not OpDot, which works on floats.
Fixed translation of IR from source when dot function is called with integer arguments (ints, vectors of chars or shorts) to properly support cl_khr_integer_dot_product extension. Previously dot would always be translated to its version with floating point arguments. Additionally updated with suggested changes.
3e5ffbd to
e2c96a4
Compare
|
I've rebased the branch onto the latest main and applied suggested changes. Everything seemed to work alright, but some parts might need some additional checking (for example my use of mutateCallInstSPIRV function, as I wasn't too familiar with that one). |
svenvh
left a comment
There was a problem hiding this comment.
Thanks for the update @Quetzonarch! I've left a few more comments and the CI has found some issues; other than that it looks good to me.
Fixed some small mistakes in comments; added extension in tests and changed one variable name to resolve CI issues. Additionally refactored argument swapping as per suggestion.
defcc8d to
08ac086
Compare
|
I've seen that CI had found some issues, so I've applied small changes to the last commit (slight code formatting in OCLToSPIRV and missing spir_func words in tests). |
Fix translation of IR from source when dot function is called with integer arguments (ints, vectors of chars or shorts) to properly support cl_khr_integer_dot_product extension. Previously it translated calls such as dot(uchar4, uchar4) into OpDot %i8, which is wrong because OpDot only operates on floating point types. (cherry picked from commit c8cd2f6)
Fix translation of IR from source when dot function is called with integer arguments (ints, vectors of chars or shorts) to properly support cl_khr_integer_dot_product extension. Previously it translated calls such as dot(uchar4, uchar4) into OpDot %i8, which is wrong because OpDot only operates on floating point types. (cherry picked from commit c8cd2f6)
Fix translation of IR from source when dot function is called with integer arguments (ints, vectors of chars or shorts) to properly support cl_khr_integer_dot_product extension. Previously it translated calls such as dot(uchar4, uchar4) into OpDot %i8, which is wrong because OpDot only operates on floating point types. (cherry picked from commit c8cd2f6)
#1174 implements translating integer dot product OCL builtins to SPIR-V builtins. This pull request is to do the reverse translation.
This proposed change is a fix for translation of IR from OCL-like source when dot function is called with integer arguments (ints or vectors of chars or shorts) to properly support cl_khr_integer_dot_product extension. Previously dot would always be translated to its version with floating point arguments. With this fix the call to dot function should be translated into a proper OpCode, based on the arguments used.