-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[clang] [OpenMP] New OpenMP 6.0 self_maps clause - CodeGen #134131
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -236,6 +236,8 @@ enum class OpenMPOffloadMappingFlags : uint64_t { | |
// dynamic. | ||
// This is an OpenMP extension for the sake of OpenACC support. | ||
OMP_MAP_OMPX_HOLD = 0x2000, | ||
/// Self directs mapping without creating a separate device copy. | ||
OMP_MAP_SELF = 0x4000, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need this? Most things will be passed by reference (i.e. a pointer), which can be mapped as OMP_MAP_LITERAL. What do we need this extra flag for? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OMP_MAP_SELF ensures that a variable is used directly on the device without creating a new copy. As per my understanding, OMP_MAP_LITERAL maps pointers, but it doesn’t guarantee they point to device-accessible memory. This is especially useful for USM, where we don’t want unnecessary mappings. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Whoever generates the mappings has to guarantee that they are correct. The OMP_MAP_LITERAL is just a mechanism to pass the pointer[1] without any modifications. Is the OMP_MAP_SELF a part of some bigger plan? Are you planning to add more reviewers? I'd like to see what others think about this. [1] It doesn't have to be a pointer, just something that fits in a register. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 to the questions. Adding a new code requires broad discussion, because it will require changing the runtime libraries There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, I get that OMP_MAP_LITERAL just passes the pointer(or anything that fits into a register as you mentioned) as is, without changing anything. But the problem is, it doesn’t guarantee that the memory it points to is actually accessible on the device. OMP_MAP_SELF explicitly states that the memory is already available on the device and avoids unnecessary mappings. The idea was to avoid unnecessary copies, especially for USM. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kparzysz We need
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kparzysz @alexey-bataev any thoughts? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need special handling for USM? If USM is enabled, we do not map anything in the runtime, all pointers are used as is, no? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will try to recap discussion from LLVM/OpenMP meeting today. We need the separate flag for a self map for a few reasons:
|
||
/// Signal that the runtime library should use args as an array of | ||
/// descriptor_dim pointers and use args_size as dims. Used when we have | ||
/// non-contiguous list items in target update directive | ||
|
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.
I don't see why self map requires unified shared memory. Didn't we say it can use pinned memory on a dedicated memory system? There are other ways too that should allow self map w/o unified shared memory available/enabled.
If self map enabled requires USM, it seems we are back to what Alexey said, it should just work.
What I understood is:
A
map(self...)
requires the runtime to make the pointer available on the device, as is, and error out if it cannot.Assuming that is the case, I don't know what the requires is supposed to do.
At the end of the day, in the runtime, we would try if it's accessible already, if not, pin it and check again, and if that doesn't work, error out, no?
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.
A self map (e.g.,
map(self: x)
) by itself doesn't require unified shared memory. However, arequires self_maps
directive does imply theunified_shared_memory
requirement according to the spec. I suppose we could have said that USM is not implied and make them orthogonal properties, but that's not the direction we ended up taking with the requirement.