-
Notifications
You must be signed in to change notification settings - Fork 14.2k
[OpenMP] Add TargetAMDGPU support for Complex argument and return types #144924
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
base: main
Are you sure you want to change the base?
Conversation
This patch adds TargetAMDGPU offloading support for Complex argument and return types.
@llvm/pr-subscribers-flang-fir-hlfir @llvm/pr-subscribers-flang-codegen Author: Akash Banerjee (TIFitis) ChangesThis patch adds TargetAMDGPU offloading support for Complex argument and return types. Full diff: https://github.com/llvm/llvm-project/pull/144924.diff 1 Files Affected:
diff --git a/flang/lib/Optimizer/CodeGen/Target.cpp b/flang/lib/Optimizer/CodeGen/Target.cpp
index 7dbf21ce0c125..b60a72e4340b9 100644
--- a/flang/lib/Optimizer/CodeGen/Target.cpp
+++ b/flang/lib/Optimizer/CodeGen/Target.cpp
@@ -1443,14 +1443,35 @@ struct TargetAMDGPU : public GenericTarget<TargetAMDGPU> {
CodeGenSpecifics::Marshalling
complexArgumentType(mlir::Location loc, mlir::Type eleTy) const override {
CodeGenSpecifics::Marshalling marshal;
- TODO(loc, "handle complex argument types");
+ const auto *sem = &floatToSemantics(kindMap, eleTy);
+ if (sem == &llvm::APFloat::IEEEsingle()) {
+ // Lower COMPLEX(KIND=4) as an array of two element values.
+ marshal.emplace_back(fir::SequenceType::get({2}, eleTy), AT{});
+ } else if (sem == &llvm::APFloat::IEEEdouble()) {
+ // Pass COMPLEX(KIND=8) as two separate arguments.
+ marshal.emplace_back(eleTy, AT{});
+ marshal.emplace_back(eleTy, AT{});
+ } else {
+ typeTodo(sem, loc, "argument");
+ }
return marshal;
}
CodeGenSpecifics::Marshalling
complexReturnType(mlir::Location loc, mlir::Type eleTy) const override {
CodeGenSpecifics::Marshalling marshal;
- TODO(loc, "handle complex return types");
+ const auto *sem = &floatToSemantics(kindMap, eleTy);
+ if (sem == &llvm::APFloat::IEEEsingle()) {
+ // Return COMPLEX(KIND=4) as an array of two elements.
+ marshal.emplace_back(fir::SequenceType::get({2}, eleTy), AT{});
+ } else if (sem == &llvm::APFloat::IEEEdouble()) {
+ // Return COMPLEX(KIND=8) via an aggregate with two fields.
+ marshal.emplace_back(mlir::TupleType::get(eleTy.getContext(),
+ mlir::TypeRange{eleTy, eleTy}),
+ AT{});
+ } else {
+ typeTodo(sem, loc, "return");
+ }
return marshal;
}
};
|
There was a problem hiding this 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 introduces offloading support for complex argument and return types for TargetAMDGPU. The key changes include:
- Adding marshalling logic in complexArgumentType to handle COMPLEX(KIND=4) and COMPLEX(KIND=8).
- Implementing similar logic in complexReturnType with requirements differing in return type aggregation.
@@ -1443,14 +1443,35 @@ struct TargetAMDGPU : public GenericTarget<TargetAMDGPU> { | |||
CodeGenSpecifics::Marshalling | |||
complexArgumentType(mlir::Location loc, mlir::Type eleTy) const override { | |||
CodeGenSpecifics::Marshalling marshal; | |||
TODO(loc, "handle complex argument types"); | |||
const auto *sem = &floatToSemantics(kindMap, eleTy); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider refactoring the common logic used to compute float semantics in both complexArgumentType and complexReturnType to reduce duplication and improve maintainability.
Copilot uses AI. Check for mistakes.
This patch adds TargetAMDGPU offloading support for Complex argument and return types.