Skip to content

[epic] Rework various GPU compiler backends #16341

Open

Description

@antiagainst

This is the tracking issue for a collections of tasks to rework various GPU compiler backends to be more consistent.

Background

In IREE we have LLVMGPU for CUDA/ROCm, SPIR-V for Vulkan/Metal/WebGPU/etc. Due to historical reasons and different cycles of development focus, these backends are in quite irregular support situation. We were taking on efforts to clean up in order to productionize both the CUDA and ROCm HAL driver impl. Here similarly we want to clean up various technical debts for better future production.

High-level goals and tasks

Overall the goal is to make the LLVMGPU and SPIR-V backends to be more consistent, by sharing similar mechanisms (target description, passes, pipelines, etc. whenever reasonable) while maintaining their flexiblity for targeting special hardware features. Specifically, we'd want to achieve the following high-level goals:

High-level goals

  • Use common GPU target description for LLVMGPU and SPIR-V
  • Plumb through multi-target CodeGen for both LLVMGPU and SPIR-V
  • Decouple CUDA and ROCm in LLVMGPU
  • Use simple heuristics to replace hardcoded configuration in LLVMGPU
  • Migrate more compiler heuristics to runtime probing

Note that the above items focus more on the overall structure and scaffolding of those GPU backends. We also want to modernize and consolidate various LLVMGPU and SPIR-V pipelines. But that's disjoint with the items listed above.

Detailed steps

Right now we have separate ways to specify GPU targets for LLVMGPU and SPIR-V. SPIR-V side it's also too coupled with Vulkan. The goal is to use one unified #iree_gpu.target for all of them, and the delete the Vulkan-specific target management.

Use common GPU target description

Support GPU multi-targeting

  • Change SPIR-V default target to null and do multi-targeting
  • Plumb multi-targeting support for HIP
  • Plumb multi-targeting support for CUDA
  • Change HIP default target to null and do multi-targeting
  • Change CUDA default target to null and do multi-targeting
  • Avoid using a fixed subgroup size for SPIR-V default target

CUDA and ROCm support in LLVMGPU is highly connected in the current LLVMGPU backend. It's hard to decouple working on the codebase while making sure everything works fine / does not regress greatly. So we start with a base ROCDL CodeGen subdirectory along side. And gradually port over existing functionalities over. During the porting, we make sure stuff are cleaned up, target description is threaded, basic heuristics are used for configuration deduction to avoid hardcoded knobs, etc. Once everything is up to speed, we then delete the ROCm cases in LLVMGPU subdirectory and rename LLVMGPU subdirectory to NVVM and cleanup accordingly.

Decouple CUDA and ROCm

Activity

  1. added
    codegen/spirv
    codegen/nvvm
    codegen/rocm
    on Feb 7, 2024
  2. self-assigned this
    on Feb 7, 2024
  3. raikonenfnu commented on Feb 7, 2024

    @raikonenfnu
    Collaborator

    Switch ROCm target to use the new pipelines

    @antiagainst Just curious, where can I read up on these new pipelines? :)

  4. antiagainst commented on Feb 7, 2024

    @antiagainst
    MemberAuthor

    @antiagainst Just curious, where can I read up on these new pipelines? :)

    This is future steps. They don't exist yet. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

codegen/nvvmcodegen/rocmcodegen/spirv

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions