-
Notifications
You must be signed in to change notification settings - Fork 14.7k
[flang][cuda][NFC] Update to the new create APIs #152050
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
Conversation
@llvm/pr-subscribers-flang-fir-hlfir Author: Valentin Clement (バレンタイン クレメン) (clementval) ChangesSome operation creations were updated in flang directory but not all. Migrate the CUF ops to the new create APIs introduce in #147168 Full diff: https://github.com/llvm/llvm-project/pull/152050.diff 5 Files Affected:
diff --git a/flang/lib/Lower/Allocatable.cpp b/flang/lib/Lower/Allocatable.cpp
index 15cd9770b35ba..ef16b0cd4c0f2 100644
--- a/flang/lib/Lower/Allocatable.cpp
+++ b/flang/lib/Lower/Allocatable.cpp
@@ -771,10 +771,11 @@ class AllocateStmtHelper {
// Keep return type the same as a standard AllocatableAllocate call.
mlir::Type retTy = fir::runtime::getModel<int>()(builder.getContext());
- return builder
- .create<cuf::AllocateOp>(
- loc, retTy, box.getAddr(), errmsg, stream, pinned, source, cudaAttr,
- errorManager.hasStatSpec() ? builder.getUnitAttr() : nullptr)
+
+ return cuf::AllocateOp::create(
+ builder, loc, retTy, box.getAddr(), errmsg, stream, pinned,
+ source, cudaAttr,
+ errorManager.hasStatSpec() ? builder.getUnitAttr() : nullptr)
.getResult();
}
@@ -840,10 +841,9 @@ static mlir::Value genCudaDeallocate(fir::FirOpBuilder &builder,
// Keep return type the same as a standard AllocatableAllocate call.
mlir::Type retTy = fir::runtime::getModel<int>()(builder.getContext());
- return builder
- .create<cuf::DeallocateOp>(
- loc, retTy, box.getAddr(), errmsg, cudaAttr,
- errorManager.hasStatSpec() ? builder.getUnitAttr() : nullptr)
+ return cuf::DeallocateOp::create(
+ builder, loc, retTy, box.getAddr(), errmsg, cudaAttr,
+ errorManager.hasStatSpec() ? builder.getUnitAttr() : nullptr)
.getResult();
}
diff --git a/flang/lib/Lower/Bridge.cpp b/flang/lib/Lower/Bridge.cpp
index 059b467655358..1e88431b0eb1f 100644
--- a/flang/lib/Lower/Bridge.cpp
+++ b/flang/lib/Lower/Bridge.cpp
@@ -3436,8 +3436,8 @@ class FirConverter : public Fortran::lower::AbstractConverter {
}
}
- auto op = builder->create<cuf::KernelOp>(
- loc, gridValues, blockValues, streamAddr, lbs, ubs, steps, n,
+ auto op = cuf::KernelOp::create(
+ *builder, loc, gridValues, blockValues, streamAddr, lbs, ubs, steps, n,
mlir::ValueRange(reduceOperands), builder->getArrayAttr(reduceAttrs));
builder->createBlock(&op.getRegion(), op.getRegion().end(), ivTypes,
ivLocs);
diff --git a/flang/lib/Lower/ConvertVariable.cpp b/flang/lib/Lower/ConvertVariable.cpp
index 647bd0d079985..88d17ac1ac785 100644
--- a/flang/lib/Lower/ConvertVariable.cpp
+++ b/flang/lib/Lower/ConvertVariable.cpp
@@ -1239,7 +1239,7 @@ static void instantiateLocal(Fortran::lower::AbstractConverter &converter,
cuf::DataAttributeAttr dataAttr =
Fortran::lower::translateSymbolCUFDataAttribute(
builder->getContext(), *sym);
- builder->create<cuf::FreeOp>(loc, fir::getBase(exv), dataAttr);
+ cuf::FreeOp::create(*builder, loc, fir::getBase(exv), dataAttr);
});
}
}
diff --git a/flang/lib/Optimizer/Builder/FIRBuilder.cpp b/flang/lib/Optimizer/Builder/FIRBuilder.cpp
index eaad54eb9eec2..9867d2efecbf9 100644
--- a/flang/lib/Optimizer/Builder/FIRBuilder.cpp
+++ b/flang/lib/Optimizer/Builder/FIRBuilder.cpp
@@ -324,8 +324,9 @@ mlir::Value fir::FirOpBuilder::createTemporaryAlloc(
getRegion().getParentOfType<mlir::omp::OutlineableOpenMPOpInterface>();
if (cudaAttr) {
cuf::DataAttributeAttr attr = cuf::getDataAttribute(getContext(), cudaAttr);
- return create<cuf::AllocOp>(loc, type, /*unique_name=*/llvm::StringRef{},
- name, attr, lenParams, shape, attrs);
+ return cuf::AllocOp::create(*this, loc, type,
+ /*unique_name=*/llvm::StringRef{}, name, attr,
+ lenParams, shape, attrs);
} else {
return create<fir::AllocaOp>(loc, type, /*unique_name=*/llvm::StringRef{},
name, pinned, lenParams, shape, attrs);
diff --git a/flang/lib/Optimizer/Transforms/CUFOpConversion.cpp b/flang/lib/Optimizer/Transforms/CUFOpConversion.cpp
index cd7d33091f345..9834b0499b930 100644
--- a/flang/lib/Optimizer/Transforms/CUFOpConversion.cpp
+++ b/flang/lib/Optimizer/Transforms/CUFOpConversion.cpp
@@ -860,10 +860,9 @@ struct CUFLaunchOpConversion
if (auto global = symTab.lookup<fir::GlobalOp>(
addrOfOp.getSymbol().getRootReference().getValue())) {
if (cuf::isRegisteredDeviceGlobal(global)) {
- arg = rewriter
- .create<cuf::DeviceAddressOp>(op.getLoc(),
- addrOfOp.getType(),
- addrOfOp.getSymbol())
+ arg = cuf::DeviceAddressOp::create(rewriter, op.getLoc(),
+ addrOfOp.getType(),
+ addrOfOp.getSymbol())
.getResult();
}
}
|
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.
Awesome. Thank you for doing this!
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.
Whoops sorry for missing these. Thanks for changing em.
While I was updating the creation of CUF operation in #152050, I noticed some other places in flang that were not updated. This patch updates the FIR operation creations in `flang/unittests`
Some operation creations were updated in flang directory but not all. Migrate the CUF ops to the new create APIs introduce in #147168