This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] Remove use of OpenCL triple environment and replace with function attribute for AMDGPU
ClosedPublic

Authored by t-tye on Feb 24 2018, 8:06 PM.

Details

Summary
  • Remove use of the opencl and amdopencl environment member of the target triple for the AMDGPU target.
  • Use function attribute to communicate to the AMDGPU backend to add implicit arguments for OpenCL kernels for the AMDHSA OS.

Diff Detail

Event Timeline

t-tye created this revision.Feb 24 2018, 8:06 PM
nhaehnle removed a subscriber: nhaehnle.Feb 25 2018, 7:36 AM

Should the same be done for "hcc" (it is currently in the docs)?

yaxunl accepted this revision.Feb 26 2018, 7:40 AM

LTGM. Thanks!

This revision is now accepted and ready to land.Feb 26 2018, 7:40 AM
arsenm added inline comments.Feb 26 2018, 8:21 AM
include/llvm/ADT/Triple.h
205

This isn't related to this. This was used in the x86 OpenCL implementation to change some lib calls I believe

lib/Target/AMDGPU/AMDGPUSubtarget.h
214–215

The naming of this is wrong. We don't want to specify the language, I thought the point of this was to specify the size of the kernel segment, so this would have a value and not be a bool indicating a source language

arsenm requested changes to this revision.Feb 26 2018, 8:21 AM
This revision now requires changes to proceed.Feb 26 2018, 8:21 AM
t-tye updated this revision to Diff 136233.Feb 27 2018, 11:35 PM
  • Changed to use function attribute that specifies the number of bytes of implicit arguments for OpenCL kernels when using the AMDHSA OS.
t-tye marked 2 inline comments as done.Mar 5 2018, 7:24 AM
t-tye added inline comments.
include/llvm/ADT/Triple.h
205

Split into separate patch D43895.

arsenm added inline comments.Mar 5 2018, 8:37 AM
lib/Target/AMDGPU/AMDGPUSubtarget.h
540

You don't need this separate check for the attribute existing. getIntegerAttribute essentially does this for you

t-tye updated this revision to Diff 137122.Mar 5 2018, 8:44 PM
t-tye marked an inline comment as done.

Address review comment.

t-tye marked an inline comment as done.Mar 5 2018, 8:44 PM
arsenm added inline comments.Mar 6 2018, 8:42 AM
lib/Target/AMDGPU/AMDGPUSubtarget.h
540–541

Is there a maximum value we could default this to instead of 0? I'm a bit worried that if this attribute is missing or mis-specified the program will be broken, i.e. this attribute could only reduce the amount used

t-tye added a subscriber: scchan.Mar 7 2018, 9:34 PM
t-tye added inline comments.
lib/Target/AMDGPU/AMDGPUSubtarget.h
540–541

I spoke to @scchan and HCC does not use any implicit arguments, so defaulting to 0 seems the right thing.

t-tye updated this revision to Diff 139081.Mar 20 2018, 12:33 AM

Address review feedback.

Add OpenCL implicit argument description.

Remove unused hcc target triple environment.

arsenm requested changes to this revision.Mar 20 2018, 12:37 PM
arsenm added inline comments.
lib/Target/AMDGPU/AMDGPUSubtarget.h
540–541

I don't see how what hcc wants is related? What is the maximum value this could be? In general attributes should make things less conservative, not more

This revision now requires changes to proceed.Mar 20 2018, 12:37 PM
t-tye added inline comments.Mar 20 2018, 3:22 PM
lib/Target/AMDGPU/AMDGPUSubtarget.h
540–541

If a language runtime does not need any implicit arguments why would we want to add some space for arguments that are never used? The original code never added implicit arguments unless it was being explicitly requested. Conceptually the maximum number is maxint since a different runtime/OS ABI may want a different set of implicit arguments.

arsenm accepted this revision.Mar 22 2018, 12:49 PM

LGTM

This revision is now accepted and ready to land.Mar 22 2018, 12:49 PM
This revision was automatically updated to reflect the committed changes.