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

OpenMPTarget: Guard scratch memory usage in ParallelReduce #6585

Merged
merged 1 commit into from
Nov 13, 2023

Conversation

masterleinad
Copy link
Contributor

This should fix the occasional openmptarget.partitioning_by_args failures. AFAIK, we don't guard the usage of scratch memory in the OpenMPTarget backend so that we could run into race conditions when executing parallel_reduce from multiple simultaneously like partitioning_by_args does.
Names of the variables are up for bikeshedding, of course.

@rgayatri23
Copy link
Contributor

Can we push this one post #6380 . That is where we actually start using scratch memory?
I am working on why it fails one of the algorithm unit tests.

@masterleinad
Copy link
Contributor Author

masterleinad commented Nov 8, 2023

Can we push this one post #6380 . That is where we actually start using scratch memory?

That pull request is really for the user-requested L0 scratch memory space in TeamPolicy and doesn't touch resize_scratch, right? The guard here really only is for the use of global/non-shared/L1 scratch space.

@masterleinad
Copy link
Contributor Author

Retest this please.

@masterleinad masterleinad marked this pull request as ready for review November 10, 2023 04:32
@rgayatri23
Copy link
Contributor

Can we push this one post #6380 . That is where we actually start using scratch memory?

That pull request is really for the user-requested L0 scratch memory space in TeamPolicy and doesn't touch resize_scratch, right? The guard here really only is for the use of global/non-shared/L1 scratch space.

Until the #6380 is merged, there is only global scratch in OpenMPTarget. Even if L0 is requested it comes from global memory.

@masterleinad
Copy link
Contributor Author

Until the #6380 is merged, there is only global scratch in OpenMPTarget. Even if L0 is requested it comes from global memory.

Right, so the two pull requests are orthogonal.

@rgayatri23
Copy link
Contributor

Its a good idea, since the scratch is on global memory, we want to avoid multiple instances accessing that location.
Where are you unlocking the mutex, or does it get destroyed when the instance is completed with its work?

Copy link
Member

@dalg24 dalg24 left a comment

Choose a reason for hiding this comment

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

Looks good besides the static.

@masterleinad
Copy link
Contributor Author

Where are you unlocking the mutex, or does it get destroyed when the instance is completed with its work?

All the scope_guards have a comment that says

// The constructor acquires the mutex which is released in the destructor.

Copy link
Contributor

@rgayatri23 rgayatri23 left a comment

Choose a reason for hiding this comment

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

Oh, missed the comment. Thanks!

@dalg24 dalg24 merged commit 2f5723b into kokkos:develop Nov 13, 2023
28 checks passed
@masterleinad masterleinad mentioned this pull request Feb 9, 2024
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.

None yet

3 participants