Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Flang] Force lowering to Complex for AMDGPU#144927

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
TIFitis merged 2 commits intollvm:mainfromTIFitis:lower_to_complex
Jul 16, 2025

Conversation

TIFitis
Copy link
Member

Avoid libm when targeting AMDGPU as those symbols are not available on the device and we rely on MLIR complex operations to later map to OCML calls.

PRs#144924 &#144926 add additional related support.

Avoid libm when targeting AMDGPU as those symbols are not available on the device and we rely on MLIR complex operations to later map to OCML calls.
@llvmbotllvmbot added flangFlang issues not falling into any other category flang:fir-hlfir labelsJun 19, 2025
Copy link
Contributor

@CopilotCopilotAI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements a change to avoid using libm when targeting AMDGPU by forcing lowering to complex operations which later map to OCML calls.

  • Add a new check to detect AMDGPU targets using fir::getTargetTriple().isAMDGCN().
  • Bypass the invocation of the libm call when AMDGPU is detected.
Comments suppressed due to low confidence (1)

flang/lib/Optimizer/Builder/IntrinsicCall.cpp:1234

  • [nitpick] Consider adding unit tests to validate the AMDGPU branch, ensuring that libm is correctly bypassed when targeting AMDGPU.
    bool isAMDGPU = fir::getTargetTriple(builder.getModule()).isAMDGCN();

@llvmbot
Copy link
Member

@llvm/pr-subscribers-flang-fir-hlfir

Author: Akash Banerjee (TIFitis)

Changes

Avoid libm when targeting AMDGPU as those symbols are not available on the device and we rely on MLIR complex operations to later map to OCML calls.

PRs #144924 & #144926 add additional related support.


Full diff:https://github.com/llvm/llvm-project/pull/144927.diff

1 Files Affected:

  • (modified) flang/lib/Optimizer/Builder/IntrinsicCall.cpp (+5-2)
diff --git a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp b/flang/lib/Optimizer/Builder/IntrinsicCall.cppindex 178b6770d6b53..2ca7f2784aab3 100644--- a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp+++ b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp@@ -1228,8 +1228,11 @@ mlir::Value genComplexMathOp(fir::FirOpBuilder &builder, mlir::Location loc,   llvm::StringRef mathLibFuncName = mathOp.runtimeFunc;   if (!mathLibFuncName.empty()) {     // If we enabled MLIR complex or can use approximate operations, we should-    // NOT use libm.-    if (!forceMlirComplex && !canUseApprox) {+    // NOT use libm. Avoid libm when targeting AMDGPU as those symbols are not+    // available on the device and we rely on MLIR complex operations to+    // later map to OCML calls.+    bool isAMDGPU = fir::getTargetTriple(builder.getModule()).isAMDGCN();+    if (!forceMlirComplex && !canUseApprox && !isAMDGPU) {       result = genLibCall(builder, loc, mathOp, mathLibFuncType, args);       LLVM_DEBUG(result.dump(); llvm::dbgs() << "\n");       return result;

Copy link
Contributor

@jsjodinjsjodin left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@mjklemmmjklemm left a comment

Choose a reason for hiding this comment

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

LGTM

@TIFitisTIFitis merged commit1742966 intollvm:mainJul 16, 2025
7 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

Copilot code reviewCopilotCopilot left review comments

@jsjodinjsjodinjsjodin approved these changes

@mjklemmmjklemmmjklemm approved these changes

@krzysz00krzysz00Awaiting requested review from krzysz00

@skatrakskatrakAwaiting requested review from skatrak

@kiranchandramohankiranchandramohanAwaiting requested review from kiranchandramohan

Assignees
No one assigned
Labels
flang:fir-hlfirflangFlang issues not falling into any other category
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@TIFitis@llvmbot@jsjodin@mjklemm

[8]ページ先頭

©2009-2025 Movatter.jp