Skip to content

[rocdl] Create basic code structure for ROCDL CodeGen - #16342

Merged
antiagainst merged 8 commits into
iree-org:mainfrom
antiagainst:rocdl-base
Feb 13, 2024
Merged

antiagainst merged 8 commits into
iree-org:mainfrom
antiagainst:rocdl-base

Conversation

@antiagainst

@antiagainst antiagainst commented Feb 7, 2024 •

Copy link
Copy Markdown
Member

This commit starts the rework of LLVMGPU compiler backend for future production. Specifically it starts a set of new source code files for ROCDL CodeGen configuration. The goal is to start with a minimal working structure and gradually port over relevant pass pipelines with proper target handling and heuristics. So in this commit we only pick the warp reduction pipeline which sort of matches the criteria here. Also we don't shuffle the passes around yet--the new ROCDL library just depends on the existing LLVMGPU library and its passes directly to get started. This is meant to avoid churns and we can do the mechanical change once everything is sorted.

Progress towards #16341

@antiagainst antiagainst added the codegen/rocm ROCm code generation compiler backend (HIP/HSA) label Feb 7, 2024
This commit starts the rework of LLVMGPU compiler backend for
future production. Specifically it starts a subdirectory for
ROCDL CodeGen. The goal is to start with a minimal working
structure and gradually port over relevant pass pipelines with
proper target handling and heuristics. So in this commit we
only pick the warp reduction pipeline which sort of matches
the criteria here.

Progress towards iree-org#16341
@antiagainst
antiagainst marked this pull request as ready for review February 7, 2024 21:48

@raikonenfnu raikonenfnu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this is not integrated into e2e iree-compile yet?

@antiagainst

Copy link
Copy Markdown
Member Author

No this is detached from the normal compilation flow now and will remain so until we have cleaned up and ported over all rocdl related pass pipelines. And then we switch the rocm target to use this new strategy selection and codegen pipeline. See detailed steps in #16341. This means we can better isolate the two worlds and balance short-/long-term development goals and have clear cut boundaries regarding certain cleanups (like the KernelConfig etc.)

@raikonenfnu raikonenfnu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for setting this up, overall LGTM! some minor NITs.

@raikonenfnu

Copy link
Copy Markdown
Collaborator

No this is detached from the normal compilation flow now and will remain so until we have cleaned up and ported over all rocdl related pass pipelines. And then we switch the rocm target to use this new strategy selection and codegen pipeline. See detailed steps in #16341. This means we can better isolate the two worlds and balance short-/long-term development goals and have clear cut boundaries regarding certain cleanups (like the KernelConfig etc.)

Understood :)

@MaheshRavishankar MaheshRavishankar left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like we are branching the whole LLVMGPU compiler. I am not sure if that kind of fracturing is worth it. Could we get an idea of why this fracturing is needed? Somethings I understand is

  1. We need to set different tile sizes, etc. But just like on the SPIR-V side for different vendors you have different tile sizes picked, same should work here
  2. Do we need separate lowering pipelines for ROCDL as opposed to what we've been doing in LLVMGPU.

Or is the plan that we start from clean slate for ROCDL, and deprecate LLVMGPU?

@antiagainst

Copy link
Copy Markdown
Member Author

The goal of having ROCDL subdirectory is indeed to start from a clean state so we can port over pieces gradually. I find it super hard to untangle while maintaining functionality / perf not regressing in the current working e2e compiler path. Better to separate and avoid adding more conditions and branches in the current flow to differentiate alpha vs. beta state development further.

Regarding duplication, I anticipate only duplications over policy parts, like the KernelConfig, LowerExecutableTarget pass switch statement, etc. The majority of the code like passes and pipelines should be common (with target description accepted to control the CodeGen). That is reflected with the current code change, where you see only a few passes are copied over and cleaned up. It still relies on LLVMGPU for all the concrete passes. So in the end state I won't expect to see a lot of duplication in general. Even for the policy parts, we can also unify if we, say, can find common heuristics for both. I'd like to avoid shuffling code too much or unify too early until we cleaned up ROCDL and NVVM. Then we can move passes properly to some common directory.

I've listed some more detailed backgrounds / plans / steps in #16341. Let's also touch base on this in the next CodeGen sync. :)

@antiagainst

Copy link
Copy Markdown
Member Author

Okay as chatted offline, for now we will still keep all the source files in the same lLVMGPU directory to get started. I've revised the code to do that.

@qedawkins qedawkins left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice first step, new pipeline looks so clean :D

@antiagainst antiagainst self-assigned this Feb 11, 2024

@MaheshRavishankar MaheshRavishankar left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @antiagainst . This seems much better to me.

@antiagainst
antiagainst merged commit 91ee20f into iree-org:main Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codegen/rocm ROCm code generation compiler backend (HIP/HSA)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants