-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[OpenACC][CIR] Implement 'reduction' combiner lowering for 5 ops #162906
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -527,16 +527,140 @@ void OpenACCRecipeBuilderBase::createFirstprivateRecipeCopy( | |||||
| // doesn't restore it aftewards. | ||||||
| void OpenACCRecipeBuilderBase::createReductionRecipeCombiner( | ||||||
| mlir::Location loc, mlir::Location locEnd, mlir::Value mainOp, | ||||||
| mlir::acc::ReductionRecipeOp recipe, size_t numBounds) { | ||||||
| mlir::acc::ReductionRecipeOp recipe, size_t numBounds, QualType origType, | ||||||
| llvm::ArrayRef<OpenACCReductionRecipe::CombinerRecipe> combinerRecipes) { | ||||||
| mlir::Block *block = | ||||||
| createRecipeBlock(recipe.getCombinerRegion(), mainOp.getType(), loc, | ||||||
| numBounds, /*isInit=*/false); | ||||||
| builder.setInsertionPointToEnd(&recipe.getCombinerRegion().back()); | ||||||
| CIRGenFunction::LexicalScope ls(cgf, loc, block); | ||||||
|
|
||||||
| mlir::BlockArgument lhsArg = block->getArgument(0); | ||||||
| mlir::Value lhsArg = block->getArgument(0); | ||||||
| mlir::Value rhsArg = block->getArgument(1); | ||||||
| llvm::MutableArrayRef<mlir::BlockArgument> boundsRange = | ||||||
| block->getArguments().drop_front(2); | ||||||
|
|
||||||
| if (llvm::any_of(combinerRecipes, [](auto &r) { return r.Op == nullptr; })) { | ||||||
| cgf.cgm.errorNYI(loc, "OpenACC Reduction combiner not generated"); | ||||||
| mlir::acc::YieldOp::create(builder, locEnd, block->getArgument(0)); | ||||||
| return; | ||||||
| } | ||||||
|
|
||||||
| // apply the bounds so that we can get our bounds emitted correctly. | ||||||
| for (mlir::BlockArgument boundArg : llvm::reverse(boundsRange)) | ||||||
| std::tie(lhsArg, rhsArg) = | ||||||
| createBoundsLoop(lhsArg, rhsArg, boundArg, loc, /*inverse=*/false); | ||||||
|
|
||||||
| // Emitter for when we know this isn't a struct or array we have to loop | ||||||
| // through. This should work for the 'field' once the get-element call has | ||||||
| // been made. | ||||||
| auto emitSingleCombiner = | ||||||
| [&](mlir::Value lhsArg, mlir::Value rhsArg, | ||||||
| const OpenACCReductionRecipe::CombinerRecipe &combiner) { | ||||||
| mlir::Type elementTy = | ||||||
| mlir::cast<cir::PointerType>(lhsArg.getType()).getPointee(); | ||||||
| CIRGenFunction::DeclMapRevertingRAII declMapRAIILhs{cgf, combiner.LHS}; | ||||||
| cgf.setAddrOfLocalVar( | ||||||
| combiner.LHS, Address{lhsArg, elementTy, | ||||||
| cgf.getContext().getDeclAlign(combiner.LHS)}); | ||||||
| CIRGenFunction::DeclMapRevertingRAII declMapRAIIRhs{cgf, combiner.RHS}; | ||||||
| cgf.setAddrOfLocalVar( | ||||||
| combiner.RHS, Address{rhsArg, elementTy, | ||||||
| cgf.getContext().getDeclAlign(combiner.RHS)}); | ||||||
|
|
||||||
| [[maybe_unused]] mlir::LogicalResult stmtRes = | ||||||
| cgf.emitStmt(combiner.Op, /*useCurrentScope=*/true); | ||||||
| }; | ||||||
|
|
||||||
| // Emitter for when we know this is either a non-array or element of an array | ||||||
| // (which also shouldn't be an array type?). This function should generate the | ||||||
| // loop to do this on each individual array or struct element (if necessary). | ||||||
|
||||||
| auto emitCombiner = [&](mlir::Value lhsArg, mlir::Value rhsArg, QualType Ty) { | ||||||
|
||||||
| auto emitCombiner = [&](mlir::Value lhsArg, mlir::Value rhsArg, QualType Ty) { | |
| auto emitCombiner = [&](mlir::Value lhsArg, mlir::Value rhsArg, QualType ty) { |
Outdated
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.
| if (const auto *RD = Ty->getAsRecordDecl()) { | |
| if (const auto *rd = Ty->getAsRecordDecl()) { |
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.
Maybe assert that it's not an array?
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.