Skip to content
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

Added preconditions to avoid write-write data-race #266

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ using Complex = mindspore::utils::Complex<T>;

template <typename T>
__global__ void MatrixTransposeKernel(const T *input, int elements, int row, int col, T *output) {
if (col <= 0 || row <= 0 || row != col) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your code committion!Could you explain why the case of non-square matrix is skipped here? And have you really encountered a situation that the col or row is less or equal than 0? If so, this should be intercepted earlier on the host side.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry about that, the constraint that the matrix is square was mistakenly added because we were looking at an old version of the kernel. I've fixed the constraint to ensure that both row/col are positive numbers.

return;
}
const int matrix_size = row * col;
for (int pos = blockIdx.x * blockDim.x + threadIdx.x; pos < elements; pos += blockDim.x * gridDim.x) {
const int b = pos / matrix_size;
Expand Down