This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP][OpenMPIRBuilder] Make outlined function parameters i64 and ptr
ClosedPublic

Authored by jsjodin on Jul 18 2023, 11:43 AM.

Details

Summary

This patch ensures that all outlined functions parameters are i64 and ptr when compiling for a target device, which is what the OpenMP runtime expects. The values are then cast to the correct type inside the kernel.

Diff Detail

Event Timeline

jsjodin created this revision.Jul 18 2023, 11:43 AM
Herald added a project: Restricted Project. · View Herald Transcript
jsjodin requested review of this revision.Jul 18 2023, 11:43 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJul 18 2023, 11:43 AM

I would strongly recommend to make sure the arguments are 64 bit without i2p/p2i casts. This has all sorts of bad effects and it is a reason our clang kernels perform often poorly.

I would strongly recommend to make sure the arguments are 64 bit without i2p/p2i casts. This has all sorts of bad effects and it is a reason our clang kernels perform often poorly.

If the size of a pointer is 64-bit can we use the pointers directly, unless pointers are 32-bit and then fall back on the i2p/p2i casts?

arsenm added a subscriber: arsenm.Jul 19 2023, 8:20 AM

I would strongly recommend to make sure the arguments are 64 bit without i2p/p2i casts. This has all sorts of bad effects and it is a reason our clang kernels perform often poorly.

If the size of a pointer is 64-bit can we use the pointers directly, unless pointers are 32-bit and then fall back on the i2p/p2i casts?

clang ABI lowering adds padding arguments and/or structs to account for this, for the 32-bit case it would emit something like { ptr, i32 }

I would strongly recommend to make sure the arguments are 64 bit without i2p/p2i casts. This has all sorts of bad effects and it is a reason our clang kernels perform often poorly.

If the size of a pointer is 64-bit can we use the pointers directly, unless pointers are 32-bit and then fall back on the i2p/p2i casts?

Sure. IIRC, we only support 64 bit pointers right now for offload.

jsjodin updated this revision to Diff 542093.Jul 19 2023, 10:13 AM

Change the code to use both ptr and i64 to pass values.

jsjodin retitled this revision from [OpenMP][OpenMPIRBuilder] Make outlined function parameters i64 to [OpenMP][OpenMPIRBuilder] Make outlined function parameters i64 and ptr.Jul 19 2023, 10:13 AM
jsjodin edited the summary of this revision. (Show Details)
arsenm added inline comments.Jul 19 2023, 10:15 AM
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
4299

Assuming 64-bit pointer

jsjodin added inline comments.Jul 19 2023, 11:30 AM
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
4299

Assuming 64-bit pointer

Yes, should there be a comment?

arsenm added inline comments.Jul 19 2023, 11:55 AM
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
4299

Yes, I was also more thinking it's assuming a 64-bit address space specifically

jsjodin added inline comments.Jul 19 2023, 12:07 PM
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
4299

Yes, both the given address space and the generic. Does LLVM allow different pointer sizes for different address spaces?

jsjodin updated this revision to Diff 542145.Jul 19 2023, 12:12 PM

Update comment.

This revision is now accepted and ready to land.Jul 24 2023, 9:37 AM
This revision was landed with ongoing or failed builds.Jul 25 2023, 10:07 AM
This revision was automatically updated to reflect the committed changes.