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

Add new pass for math to rocdl. #93

Merged
merged 4 commits into from
Jun 18, 2024
Merged

Conversation

jsjodin
Copy link

@jsjodin jsjodin commented May 23, 2024

There are math operations that are not yet being converted, but it works for most operations. The changes to the flang codegen enables the pass for AMDGCN and disables the MathToLLVM and MathToLibm passes.

@jsjodin jsjodin requested a review from DominikAdamski May 23, 2024 00:09
searlmc1 pushed a commit that referenced this pull request May 24, 2024
@jsjodin jsjodin marked this pull request as ready for review May 25, 2024 15:01
Copy link

@agozillon agozillon left a comment

Choose a reason for hiding this comment

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

The PR LGTM :-) feel free to wait on a secondary reviewer approval or not, I'll leave it up to you!

@@ -3559,6 +3560,14 @@ class FIRToLLVMLowering
// as passes here.
mlir::OpPassManager mathConvertionPM("builtin.module");

bool isAMDGCN = fir::getTargetTriple(mod).isAMDGCN();
// If compiling for AMD target some math operations must be lowered to ocml

Choose a reason for hiding this comment

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

Nit: would it be possible to get the full name for ocml in the comments? Maybe a weird request, just unfamiliar with the library so would be handy to have in the comment! if not that's not a big deal.

Copy link
Author

Choose a reason for hiding this comment

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

I think ocml stands for OpenCL Math Library, so I'm not sure that will help or confuse more. I should perhaps use "AMD GPU math library" or something like that.

@@ -3567,6 +3576,7 @@ class FIRToLLVMLowering
mathConvertionPM.addPass(
mlir::createConvertMathToFuncs(mathToFuncsOptions));
mathConvertionPM.addPass(mlir::createConvertComplexToStandardPass());

Choose a reason for hiding this comment

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

Nit: Unnecessary space addition

@jsjodin jsjodin changed the title [WIP] Add new pass for math to rocdl. Add new pass for math to rocdl. Jun 12, 2024
Copy link

@skatrak skatrak left a comment

Choose a reason for hiding this comment

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

Thank you Jan, LGTM as well. It'd be good to add a Lit test for this as well, to make sure it doesn't inadvertently break later on.

// library calls, the rest can be converted to LLVM intrinsics, which is
// handled in the mathToLLVM conversion. The lowering to libm calls is not
// needed since all math operations are handled this way.
if (isAMDGCN) {
Copy link

Choose a reason for hiding this comment

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

Nit: Braces

@jsjodin jsjodin merged commit 9167cb0 into amd-trunk-dev Jun 18, 2024
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants