This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] implemented pal metadata
ClosedPublic

Authored by tpr on Sep 12 2017, 11:34 AM.

Details

Summary

For the amdpal OS type:

We write an AMDGPU_PAL_METADATA record in the .note section in the ELF
(or as an assembler directive). It contains key=value pairs of 32 bit
ints. It is a merge of metadata from codegen of the shaders, and
metadata provided by the frontend as _amdgpu_pal_metadata IR metadata.
Where both sources have a key=value with the same key, the two values
are ORed together.

We also write an AMDGPU_PAL_CODE_OBJECT_VERSION .note record, containing
a single 32 bit int giving the minor PAL ABI version, and an
AMDGPU_HSA_ISA .note record, same as used in HSA.

These .note records are part of the amdpal ABI and will be documented in
docs/AMDGPUUsage.rst in a future commit.

Eventually the amdpal OS type will stop generating the .AMDGPU.config
section once the frontend has safely moved over to using the .note
records above instead of .AMDGPU.config.

Diff Detail

Repository
rL LLVM

Event Timeline

tpr created this revision.Sep 12 2017, 11:34 AM

For HSA the ABI version is used to version the overall code object and no separate not record is used. Hor HSA the metadata note record contains a version attribute that indicates the metadata version.

For PAL what is the AMDGPU_PAL_CODE_OBJECT_VERSION .note record versioning? Is it the overall code object: if so can the same approach as HSA be used; if the metadata then suggest moving the version inside the metadata note record itself so it is self describing.

tpr updated this revision to Diff 114884.Sep 12 2017, 12:58 PM

Changed to write pal metadata in key order, as it makes it easier to write tests.

tpr updated this revision to Diff 114982.Sep 13 2017, 12:04 AM

Removed AMDGPU_PAL_CODE_OBJECT_VERSION note.

arsenm added inline comments.Sep 14 2017, 12:20 PM
lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
216 ↗(On Diff #114982)

The usual metadata naming convention uses . separators without leading _ (I also don't see any tests using this)

216–218 ↗(On Diff #114982)

These can all be early returns to reduce indentation

1022 ↗(On Diff #114982)

You shouldn't be using this here (or anywhere really). We definitely know the stack size at this point.

lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp
119 ↗(On Diff #114982)

Single quotes

tpr updated this revision to Diff 115389.Sep 15 2017, 3:49 AM

Addressed review comments.

tpr marked 3 inline comments as done.Sep 15 2017, 4:00 AM
tpr updated this revision to Diff 115828.Sep 19 2017, 5:10 AM

Fixed *S_SCRATCH_SIZE to be bytes of scratch rather than dwords of scratch.

kzhuravl added inline comments.Sep 25 2017, 3:35 PM
lib/Target/AMDGPU/AMDGPUPTNote.h
36 ↗(On Diff #115828)

Can't we use ELFOSABI_AMDGPU_PAL and ELFABIVERSION_AMDGPU_PAL instead?

37 ↗(On Diff #115828)

Can you make it 11?

tpr added inline comments.Sep 26 2017, 12:29 AM
lib/Target/AMDGPU/AMDGPUPTNote.h
36 ↗(On Diff #115828)

Oops, this is not used any more after internal discussion. I'll remove the define.

37 ↗(On Diff #115828)

Why? This is already in use within AMD as 9; this change just adds it to LLVM.

kzhuravl added inline comments.Sep 26 2017, 12:54 PM
lib/Target/AMDGPU/AMDGPUPTNote.h
37 ↗(On Diff #115828)

Because 9 is reserved. See docs.

kzhuravl added inline comments.Sep 26 2017, 1:01 PM
lib/Target/AMDGPU/AMDGPUPTNote.h
37 ↗(On Diff #115828)
tpr marked 6 inline comments as done.Sep 28 2017, 2:02 AM
tpr updated this revision to Diff 116943.Sep 28 2017, 2:03 AM

Addressed review comments.

tpr updated this revision to Diff 116945.Sep 28 2017, 2:05 AM

Really upload the changes I said I uploaded last time.

nhaehnle edited edge metadata.Sep 29 2017, 8:38 AM

I'm not too familiar with the asm printer stuff, but this all looks reasonable to me.

tstellar accepted this revision.Sep 29 2017, 8:51 AM
tstellar added a subscriber: tstellar.

Could you add tests for the AsmParser changes, otherwise LGTM.

This revision is now accepted and ready to land.Sep 29 2017, 8:51 AM
This revision was automatically updated to reflect the committed changes.