Flang only supports OpenMP offload for AMDGPU. I’m interested in adding support for NVPTX -the patch is less than 20 lines; however, I found that the current name mangling scheme is incompatible with PTX, as it uses dots .
to separate some identifiers, which results in invalid identifiers in PTX.
There are two possible approaches:
- Replacing the dot
.
mangling scheme with underscores _
.
- Adding a pass that re-mangles the names to PTX-compatible names.
I prefer the first option as it results in a more uniform offloading path. However, it means breaking the ABI.
Thoughts and comments?
which name do you see mangled with a . Do you have an example?
Compiling basic_target_region.f90 produces a couple of mangled names with dots, for example:
@_QQcl.78203D20
Which corresponds to the string "x = "
. The fact that the string ends up in the device module when it shouldn’t is a different can of worms.
Thanks in advance for this.
Which ABI are you referring to here?
1 Like
The name mangling scheme, so that no .
appear in names. My reasoning is that the impact is not going to be that big as flang
is not in production yet.
We had the same problem with OpenMP. _
is not a good alternative to .
because the former is often allowed in base language identifiers. We opted to use “$”, IIRC, for compiler generated names. That said, if we are sure the .
in names will not clash with user provided names we can go for it.
@Artem-B What do you think about option 2? I’m not a fan but it might be worth having as a fallback anyway.
Quick question, are you using $
in identifiers regardless of the target or just for NVPTX?
Quick question, are you using $
in identifiers regardless of the target or just for NVPTX?
We use it for all GPU targets but only in Clangs OpenMP offloading name gen. IIRC. Consistency is generally worth a lot.
Currently there are only few places in flang using dots, it might be worth considering changing the separator in all cases for the sake of consistency.
Here’s a PR on changing the separator [flang] Change `uniqueCGIdent` separator from `.` to `_` by fabianmcg · Pull Request #71338 · llvm/llvm-project · GitHub