-
Notifications
You must be signed in to change notification settings - Fork 787
[SYCL][ESIMD] Add more compile time checks to rdregion and wrregion API #13158
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
AMD/HIP test failures are not related to the change |
I understand this change as ESIMD developer and it is correct, but... If add such constraints, then they should be added in a user friendly manner. I.e. at the user's functions calling __esimd_rdregion/wrregion or at the places where the simd_view objects are created to prohibit potential reads/writes beyond simd object scope. |
Yes, originally, these constraints were introduced for emulator that used to crash when read/write out of bounds was performed, but I believe it still has some value as it would allow to uncover some hidden bugs that would be impossible to detect otherwise. I don' have strong opinion about that though. |
@@ -209,6 +209,23 @@ auto accessorToPointer(AccessorTy Acc, OffsetTy Offset = 0) { | |||
} | |||
#endif // __ESIMD_FORCE_STATELESS_MEM | |||
|
|||
template <int N, int M, int VStride, int Width, int Stride> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please write a detailed comment to these 2 functions and their params. Otherwise, it is really difficult (or impossible) to understand what they verify.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. It is still difficult to understand why the constraint is such: Width == M || ((M / Width) - 1) * VStride + (Width - 1) * Stride < N
. It would help a lot if the pseudo-code would be copied from __esimd_rdregion/wrregion to the commend of these check functions, e.g.;
// This intrinsic computes a vector Result:
//
// \code{.cpp}
// uint16_t EltOffset = Offset / sizeof(T);
// assert(Offset % sizeof(T) == 0);
//
// int NumRows = M / Width;
// assert(M % Width == 0);
//
// int Index = 0;
// for (int i = 0; i < NumRows; ++i) {
// for (int j = 0; j < Width; ++j) {
// Result[Index++] = Input[i * VStride + j * Stride +
// EltOffset];
// }
// }
// \endcode
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you do the same for __esimd_wrregion please?
Perhaps, fix the comment in both places too - comment does not say that the write is skipped if mask is 0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, for confusion. the pseudo-code for __esimd_wrregion is correct. Please just copy it to check function here.
The __esimd_rdregion does not have a mask operand, thus is is all right in the pseudo-code for rdregion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Co-authored-by: Vyacheslav Klochkov <[email protected]>
No description provided.