This is an archive of the discontinued LLVM Phabricator instance.

[mlir][ROCDL] Translate known block size attributes to ROCDL
ClosedPublic

Authored by krzysz00 on Dec 12 2022, 11:24 AM.

Details

Summary
  1. When converting from the GPU dialect to the ROCDL dialect, if the

function that contains a gpu.thread_id or gpu.block_id op is annotated
with gpu.known_{block,grid}_size, use that size to set a "range"
attribute on the corresponding rocdl intrinsic so that the LLVM
frontend can optimize based on that range information.
1b. When translating from the rocdl dialect to LLVM IR, use the
"range" attribute, if present, to set !range metadata on the relevant
function call.

  1. Deprecate the old rocdl.max_flat_work_group_size attribute, which

was used in a tensorflow backend. Instead, use
rocdl.flat_work_group_size going forward to allow kernel generators to
specify the minimum and maximum work group sizes a kernel may be
launched with in one attribute, thus more closely matching the backend.

  1. When translating from gpu.func to llvm.func within gpu-to-rocdl,

copy the known_block_size attribute as rocdl.reqd_work_group_size to
enable further translations to set the corresponding metadata on the
LLVM IR function. Also, set the rocdl.flat_work_group_size attribute
to ensure that the reqd_work_group_size metadata and the
amdgpu-flat-work-group-size metadata are consistent.
3b. Extend the ROCDL to LLVM IR translation to set the
!reqd_work_group_size metadata on LLVM functions

Also update tests and add functions to the ROCDL dialect to ensure
attribute names are used consistently.

Depends on D139865

Diff Detail

Event Timeline

krzysz00 created this revision.Dec 12 2022, 11:24 AM
krzysz00 requested review of this revision.Dec 12 2022, 11:24 AM
krzysz00 updated this revision to Diff 482906.Dec 14 2022, 9:57 AM

Remove stray debug print

krzysz00 updated this revision to Diff 484958.Dec 22 2022, 1:52 PM

Rebase again to pick up changes from previous commit

Pulling in @antiagainst since they reviewed the previous patch in this series

antiagainst accepted this revision.Dec 29 2022, 3:11 PM
This revision is now accepted and ready to land.Dec 29 2022, 3:11 PM