Skip to content

[OpenMP][OMPT] Fix device identifier collision during callbacks #65595

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

Merged
merged 2 commits into from
Sep 11, 2023

Conversation

mhalk
Copy link
Contributor

@mhalk mhalk commented Sep 7, 2023

Fixes: #65104
When a user assigns devices to target regions it may happen that different identifiers will map onto the same id within different plugins. This will lead to situations where callbacks will become much harder to read, as ambiguous identifiers are reported.

We fix this by collecting the index-offset upon general RTL initialization. Which in turn, allows to calculate the unique, user-observable device id.

Fixes: llvm#65104
When a user assigns devices to target regions it may happen that different
identifiers will map onto the same id within different plugins.
This will lead to situations where callbacks will become much harder to read,
as ambiguous identifiers are reported.

We fix this by collecting the index-offset upon general RTL initialization.
Which in turn, allows to calculate the unique, user-observable device id.
@mhalk mhalk added the openmp label Sep 7, 2023
@mhalk mhalk self-assigned this Sep 7, 2023
@jplehr jplehr requested a review from a team September 7, 2023 11:10
@mhalk
Copy link
Contributor Author

mhalk commented Sep 7, 2023

This might not be the optimal solution, but somehow we have to propagate the offset value during RTL init.
Also, if there are ideas how to test this reliably, I'd be interested to hear.

Copy link
Contributor

@jplehr jplehr left a comment

Choose a reason for hiding this comment

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

Only question about the comment. Functionality LGTM.
Won't approve as of now so others can have a look.

Comment on lines 1021 to 1022
/// Offset which when added to a DeviceId will yield a unique, user-observable
/// device identifier.
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be reworded in the sense that makes it clear that this is (mainly/only?) in scenarios with multiple different supported devices?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Valid point, I'm not pushing that naming or description.

Could also be name the corresponding variable PluginDeviceStartIndex (or similar); "global" was my go-to as a globally / unique DeviceId we wanted to determine.
Or was your initial thought that a clarification in the comment would suffice?

Copy link
Contributor

Choose a reason for hiding this comment

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

Valid point, I'm not pushing that naming or description.

Could also be name the corresponding variable PluginDeviceStartIndex (or similar); "global" was my go-to as a globally / unique DeviceId we wanted to determine. Or was your initial thought that a clarification in the comment would suffice?

I like PluginDeviceStartIndex because that partially corresponds to the variable name where it originates from (libomptarget rtl.cpp).

Copy link
Contributor Author

@mhalk mhalk Sep 8, 2023

Choose a reason for hiding this comment

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

Since we are in the GenericPluginTy namespace, I'll drop the Plugin prefix and suggest: DeviceIdStartIndex.
Also go with a more verbose description as JP suggested -- so it should be more clear when this is actually useful.

Copy link
Contributor

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

@mhalk mhalk merged commit 53602e6 into llvm:main Sep 11, 2023
@mhalk mhalk deleted the fix/ompt_device_num_collision branch September 14, 2023 10:38
ZijunZhaoCCK pushed a commit to ZijunZhaoCCK/llvm-project that referenced this pull request Sep 19, 2023
…#65595)

Fixes: llvm#65104
When a user assigns devices to target regions it may happen that
different identifiers will map onto the same id within different
plugins. This will lead to situations where callbacks will become much
harder to read, as ambiguous identifiers are reported.

We fix this by collecting the index-offset upon general RTL
initialization. Which in turn, allows to calculate the unique,
user-observable device id.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[OMPT] Overlapping device_num when using multiple offloading architectures
3 participants