Skip to content

[flang][OpenMP] Implement HAS_DEVICE_ADDR clause #252

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

Closed
wants to merge 1 commit into from

Conversation

kparzysz
Copy link

@kparzysz kparzysz commented Feb 24, 2025

The HAS_DEVICE_ADDR indicates that the object(s) listed exists at an address that is a valid device address. Specifically, has_device_addr(x) means that (in C/C++ terms) &x is a device address.

When entering a target region, x does not need to be allocated on the device, or have its contents copied over (in the absence of additional mapping clauses). Passing its address verbatim to the region for use is sufficient, and is the intended goal of the clause.

Some Fortran objects use descriptors in their in-memory representation. If x had a descriptor, both the descriptor and the contents of x would be located in the device memory. However, the descriptors are managed by the compiler, and can be regenerated at various points as needed. The address of the effective descriptor may change, hence it's not safe to pass the address of the descriptor to the target region. Instead, the descriptor itself is always copied, but for objects like x, no further mapping takes place (as this keeps the storage pointer in the descriptor unchanged).
To accommodate this, descriptor mappings will be marked with the OMP_MAP_DESCRIPTOR flag.

This fixes #207

The HAS_DEVICE_ADDR indicates that the object(s) listed exists at an
address that is a valid device address. Specifically, `has_device_addr(x)`
means that (in C/C++ terms) `&x` is a device address.

When entering a target region, `x` does not need to be allocated on the
device, or have its contents copied over (in the absence of additional
mapping clauses). Passing its address verbatim to the region for use is
sufficient, and is the intended goal of the clause.

Some Fortran objects use descriptors in their in-memory representation.
If `x` had a descriptor, both the descriptor and the contents of `x`
would be located in the device memory. However, the descriptors are
managed by the compiler, and can be regenerated at various points as
needed. The address of the effective descriptor may change, hence it's
not safe to pass the address of the descriptor to the target region.
Instead, the descriptor itself is always copied, but for objects like
`x`, no further mapping takes place (as this keeps the storage pointer
in the descriptor unchanged).
To accommodate this, descriptor mappings will be marked with the
OMP_MAP_DESCRIPTOR flag.
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.

[Issue]: [flang][OpenMP] need has_device_addr support in flang-new
1 participant