Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Codegen] Port AMDGPU device lib implementations to MLIR rewrites #20213

Open
qedawkins opened this issue Mar 11, 2025 · 2 comments
Open

[Codegen] Port AMDGPU device lib implementations to MLIR rewrites #20213

qedawkins opened this issue Mar 11, 2025 · 2 comments
Labels
codegen Shared code generation infrastructure and dialects good first issue 🌱 Good for newcomers onboarding/codegen Tasks suitable for new team member onboarding

Comments

@qedawkins
Copy link
Contributor

Overview

For accuracy and/or performance reasons, on AMDGPU backends we prefer device lib implementations of certain math functions (see #19970), for example:

https://github.com/ROCm/llvm-project/tree/amd-staging/amd/device-libs/ocml/src
Erf: https://github.com/ROCm/llvm-project/blob/amd-staging/amd/device-libs/ocml/src/erfF.cl

The erf implementation linked here is quite simple assuming a fast implementation of exp, which is a feature of AMD GPUs that makes this implementation fast. The same reasoning can apply to other targets assuming they provide a fast exp implementation.

Task

  1. Port the above device lib implementations to MLIR patterns lowering math.* ops to scf + arith (+ more primitive math ops if needed).
  2. Add a has_fast_exp pass option to MathTransformsPass that controls application of the new rewrites.
@qedawkins qedawkins added codegen Shared code generation infrastructure and dialects good first issue 🌱 Good for newcomers onboarding/codegen Tasks suitable for new team member onboarding labels Mar 11, 2025
@benvanik
Copy link
Collaborator

+1 to being able to reason about efficient math in MLIR where we can vectorize and perform other magic!

@Megan0704-1
Copy link

Hello, I'm new to contributing to IREE and would like to work on this issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
codegen Shared code generation infrastructure and dialects good first issue 🌱 Good for newcomers onboarding/codegen Tasks suitable for new team member onboarding
Projects
None yet
Development

No branches or pull requests

3 participants