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

Conversation

zhenrongliew
Copy link

/kind bug

Summary:

In issue, our tool found a write-write data-race on array output, given certain values of col,row, and elements.
We added preconditions (which may not be the minimal preconditions) to prevent the race.

mindspore-assistant

@CLAassistant
Copy link

CLAassistant commented Mar 20, 2024

CLA assistant check
All committers have signed the CLA.

@@ -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.

…to the host side API.

Co-authored-by: AGroupofProbiotocs <[email protected]>
@AGroupofProbiotocs
Copy link

I think you might misunderstood my comment. What I actually mean is to move the conditional statement "if (col < 0 || row < 0 )..." into the host function "MatrixTranspose(...)" below the kernel function "MatrixTransposeKernel(...)".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants