-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[OpenACC][CIR] Finish 'private' recipe lowering by doing 'init' #161540
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 |
|---|---|---|
|
|
@@ -400,6 +400,33 @@ void OpenACCRecipeBuilderBase::createRecipeDestroySection( | |
|
|
||
| mlir::acc::YieldOp::create(builder, locEnd); | ||
| } | ||
| void OpenACCRecipeBuilderBase::makeBoundsInit( | ||
| mlir::Value alloca, mlir::Location loc, mlir::Block *block, | ||
| const VarDecl *allocaDecl, QualType origType, const Expr *initExpr, | ||
| bool isInitSection) { | ||
| mlir::OpBuilder::InsertionGuard guardCase(builder); | ||
| builder.setInsertionPointToEnd(block); | ||
| CIRGenFunction::LexicalScope ls(cgf, loc, block); | ||
|
|
||
| CIRGenFunction::AutoVarEmission tempDeclEmission{*allocaDecl}; | ||
| tempDeclEmission.EmittedAsOffload = true; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like it! I've written down a note so that I'll come back in a future patch to fix this. |
||
|
|
||
| // The init section is the only one of the handful that only has a single | ||
| // argument for the 'type', so we have to drop 1 for init, and future calls | ||
| // to this will need to drop 2. | ||
andykaylor marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| llvm::MutableArrayRef<mlir::BlockArgument> boundsRange = | ||
| block->getArguments().drop_front(isInitSection ? 1 : 2); | ||
|
|
||
| mlir::Value subscriptedValue = alloca; | ||
| for (mlir::BlockArgument boundArg : llvm::reverse(boundsRange)) | ||
| subscriptedValue = createBoundsLoop(subscriptedValue, boundArg, loc, | ||
| /*inverse=*/false); | ||
|
|
||
| tempDeclEmission.setAllocatedAddress( | ||
| Address{subscriptedValue, cgf.convertType(origType), | ||
| cgf.getContext().getDeclAlign(allocaDecl)}); | ||
| cgf.emitAutoVarInit(tempDeclEmission); | ||
| } | ||
|
|
||
| // TODO: OpenACC: When we get this implemented for the reduction/firstprivate, | ||
| // this might end up re-merging with createRecipeInitCopy. For now, keep it | ||
|
|
@@ -442,11 +469,12 @@ void OpenACCRecipeBuilderBase::createPrivateInitRecipe( | |
| cgf.emitAutoVarAlloca(*allocaDecl, builder.saveInsertionPoint()); | ||
| cgf.emitAutoVarInit(tempDeclEmission); | ||
| } else { | ||
| makeBoundsAlloca(block, exprRange, loc, "openacc.private.init", numBounds, | ||
| boundTypes); | ||
| mlir::Value alloca = makeBoundsAlloca( | ||
| block, exprRange, loc, "openacc.private.init", numBounds, boundTypes); | ||
|
|
||
| if (initExpr) | ||
| cgf.cgm.errorNYI(exprRange, "private-init with bounds initialization"); | ||
| makeBoundsInit(alloca, loc, block, allocaDecl, origType, initExpr, | ||
| /*isInitSection=*/true); | ||
| } | ||
|
|
||
| mlir::acc::YieldOp::create(builder, locEnd); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| // RUN: not %clang_cc1 -fopenacc -triple x86_64-linux-gnu -Wno-openacc-self-if-potential-conflict -emit-cir -fclangir -triple x86_64-linux-pc %s -o - | FileCheck %s | ||
| // RUN: %clang_cc1 -fopenacc -triple x86_64-linux-gnu -Wno-openacc-self-if-potential-conflict -emit-cir -fclangir -triple x86_64-linux-pc %s -o - | FileCheck %s | ||
|
|
||
| struct NoCopyConstruct {}; | ||
|
|
||
|
|
@@ -66,47 +66,134 @@ struct HasDtor { | |
| // CHECK-NEXT: acc.private.recipe @privatization__Bcnt1__ZTSA5_i : !cir.ptr<!cir.array<!s32i x 5>> init { | ||
| // CHECK-NEXT: ^bb0(%[[ARG:.*]]: !cir.ptr<!cir.array<!s32i x 5>> {{.*}}, %[[BOUND1:.*]]: !acc.data_bounds_ty {{.*}}): | ||
| // CHECK-NEXT: %[[ALLOCA:.*]] = cir.alloca !cir.array<!s32i x 5>, !cir.ptr<!cir.array<!s32i x 5>>, ["openacc.private.init"] | ||
| // TODO: Add Init here. | ||
| // CHECK-NEXT: acc.yield | ||
| // CHECK-NEXT: } | ||
| // | ||
| // float[5] with 1 'bound' | ||
| // CHECK-NEXT: acc.private.recipe @privatization__Bcnt1__ZTSA5_f : !cir.ptr<!cir.array<!cir.float x 5>> init { | ||
| // CHECK-NEXT: ^bb0(%[[ARG:.*]]: !cir.ptr<!cir.array<!cir.float x 5>> {{.*}}, %[[BOUND1:.*]]: !acc.data_bounds_ty {{.*}}): | ||
| // CHECK-NEXT: %[[ALLOCA:.*]] = cir.alloca !cir.array<!cir.float x 5>, !cir.ptr<!cir.array<!cir.float x 5>>, ["openacc.private.init"] | ||
| // TODO: Add Init here. | ||
| // CHECK-NEXT: acc.yield | ||
| // CHECK-NEXT: } | ||
| // | ||
| // NoCopyConstruct[5] with 1 'bound' | ||
| // CHECK-NEXT: acc.private.recipe @privatization__Bcnt1__ZTSA5_15NoCopyConstruct : !cir.ptr<!cir.array<!rec_NoCopyConstruct x 5>> init { | ||
| // CHECK-NEXT: ^bb0(%[[ARG:.*]]: !cir.ptr<!cir.array<!rec_NoCopyConstruct x 5>> {{.*}}, %[[BOUND1:.*]]: !acc.data_bounds_ty {{.*}}): | ||
| // CHECK-NEXT: %[[ALLOCA:.*]] = cir.alloca !cir.array<!rec_NoCopyConstruct x 5>, !cir.ptr<!cir.array<!rec_NoCopyConstruct x 5>>, ["openacc.private.init"] | ||
| // TODO: Add Init here. | ||
| // CHECK-NEXT: cir.scope { | ||
| // CHECK-NEXT: %[[LB:.*]] = acc.get_lowerbound %[[BOUND1]] : (!acc.data_bounds_ty) -> index | ||
| // CHECK-NEXT: %[[LB_CAST:.*]] = builtin.unrealized_conversion_cast %[[LB]] : index to !u64i | ||
| // CHECK-NEXT: %[[UB:.*]] = acc.get_upperbound %[[BOUND1]] : (!acc.data_bounds_ty) -> index | ||
| // CHECK-NEXT: %[[UB_CAST:.*]] = builtin.unrealized_conversion_cast %[[UB]] : index to !u64i | ||
| // CHECK-NEXT: %[[ITR:.*]] = cir.alloca !u64i, !cir.ptr<!u64i>, ["iter"] {alignment = 8 : i64} | ||
| // CHECK-NEXT: cir.store %[[LB_CAST]], %[[ITR]] : !u64i, !cir.ptr<!u64i> | ||
| // CHECK-NEXT: cir.for : cond { | ||
| // CHECK-NEXT: %[[ITR_LOAD:.*]] = cir.load %[[ITR]] : !cir.ptr<!u64i>, !u64i | ||
| // CHECK-NEXT: %[[COND:.*]] = cir.cmp(lt, %[[ITR_LOAD]], %[[UB_CAST]]) : !u64i, !cir.bool | ||
| // CHECK-NEXT: cir.condition(%[[COND]]) | ||
| // CHECK-NEXT: } body { | ||
| // CHECK-NEXT: %[[ITR_LOAD:.*]] = cir.load %[[ITR]] : !cir.ptr<!u64i>, !u64i | ||
| // CHECK-NEXT: %[[DECAY:.*]] = cir.cast array_to_ptrdecay %[[ALLOCA]] : !cir.ptr<!cir.array<!rec_NoCopyConstruct x 5>> -> !cir.ptr<!rec_NoCopyConstruct> | ||
| // CHECK-NEXT: %[[STRIDE:.*]] = cir.ptr_stride(%[[DECAY]] : !cir.ptr<!rec_NoCopyConstruct>, %[[ITR_LOAD]] : !u64i), !cir.ptr<!rec_NoCopyConstruct> | ||
| // CHECK-NEXT: cir.yield | ||
|
||
| // CHECK-NEXT: } step { | ||
| // CHECK-NEXT: %[[ITR_LOAD]] = cir.load %[[ITR]] : !cir.ptr<!u64i>, !u64i | ||
| // CHECK-NEXT: %[[INC:.*]] = cir.unary(inc, %[[ITR_LOAD]]) : !u64i, !u64i | ||
| // CHECK-NEXT: cir.store %[[INC]], %[[ITR]] : !u64i, !cir.ptr<!u64i> | ||
| // CHECK-NEXT: cir.yield | ||
| // CHECK-NEXT: } | ||
| // CHECK-NEXT: } | ||
| // CHECK-NEXT: acc.yield | ||
| // CHECK-NEXT: } | ||
| // | ||
| // CopyConstruct[5] with 1 'bound' | ||
| // CHECK-NEXT: acc.private.recipe @privatization__Bcnt1__ZTSA5_13CopyConstruct : !cir.ptr<!cir.array<!rec_CopyConstruct x 5>> init { | ||
| // CHECK-NEXT: ^bb0(%[[ARG:.*]]: !cir.ptr<!cir.array<!rec_CopyConstruct x 5>> {{.*}}, %[[BOUND1:.*]]: !acc.data_bounds_ty {{.*}}): | ||
| // CHECK-NEXT: %[[ALLOCA:.*]] = cir.alloca !cir.array<!rec_CopyConstruct x 5>, !cir.ptr<!cir.array<!rec_CopyConstruct x 5>>, ["openacc.private.init"] | ||
| // TODO: Add Init here. | ||
| // CHECK-NEXT: cir.scope { | ||
| // CHECK-NEXT: %[[LB:.*]] = acc.get_lowerbound %[[BOUND1]] : (!acc.data_bounds_ty) -> index | ||
| // CHECK-NEXT: %[[LB_CAST:.*]] = builtin.unrealized_conversion_cast %[[LB]] : index to !u64i | ||
| // CHECK-NEXT: %[[UB:.*]] = acc.get_upperbound %[[BOUND1]] : (!acc.data_bounds_ty) -> index | ||
| // CHECK-NEXT: %[[UB_CAST:.*]] = builtin.unrealized_conversion_cast %[[UB]] : index to !u64i | ||
| // CHECK-NEXT: %[[ITR:.*]] = cir.alloca !u64i, !cir.ptr<!u64i>, ["iter"] {alignment = 8 : i64} | ||
| // CHECK-NEXT: cir.store %[[LB_CAST]], %[[ITR]] : !u64i, !cir.ptr<!u64i> | ||
| // CHECK-NEXT: cir.for : cond { | ||
| // CHECK-NEXT: %[[ITR_LOAD:.*]] = cir.load %[[ITR]] : !cir.ptr<!u64i>, !u64i | ||
| // CHECK-NEXT: %[[COND:.*]] = cir.cmp(lt, %[[ITR_LOAD]], %[[UB_CAST]]) : !u64i, !cir.bool | ||
| // CHECK-NEXT: cir.condition(%[[COND]]) | ||
| // CHECK-NEXT: } body { | ||
| // CHECK-NEXT: %[[ITR_LOAD:.*]] = cir.load %[[ITR]] : !cir.ptr<!u64i>, !u64i | ||
| // CHECK-NEXT: %[[DECAY:.*]] = cir.cast array_to_ptrdecay %[[ALLOCA]] : !cir.ptr<!cir.array<!rec_CopyConstruct x 5>> -> !cir.ptr<!rec_CopyConstruct> | ||
| // CHECK-NEXT: %[[STRIDE:.*]] = cir.ptr_stride(%[[DECAY]] : !cir.ptr<!rec_CopyConstruct>, %[[ITR_LOAD]] : !u64i), !cir.ptr<!rec_CopyConstruct> | ||
| // CHECK-NEXT: cir.yield | ||
| // CHECK-NEXT: } step { | ||
| // CHECK-NEXT: %[[ITR_LOAD]] = cir.load %[[ITR]] : !cir.ptr<!u64i>, !u64i | ||
| // CHECK-NEXT: %[[INC:.*]] = cir.unary(inc, %[[ITR_LOAD]]) : !u64i, !u64i | ||
| // CHECK-NEXT: cir.store %[[INC]], %[[ITR]] : !u64i, !cir.ptr<!u64i> | ||
| // CHECK-NEXT: cir.yield | ||
| // CHECK-NEXT: } | ||
| // CHECK-NEXT: } | ||
| // CHECK-NEXT: acc.yield | ||
| // CHECK-NEXT: } | ||
| // | ||
| // NonDefaultCtor[5] with 1 'bound' | ||
| // CHECK-NEXT: acc.private.recipe @privatization__Bcnt1__ZTSA5_14NonDefaultCtor : !cir.ptr<!cir.array<!rec_NonDefaultCtor x 5>> init { | ||
| // CHECK-NEXT: ^bb0(%[[ARG:.*]]: !cir.ptr<!cir.array<!rec_NonDefaultCtor x 5>> {{.*}}, %[[BOUND1:.*]]: !acc.data_bounds_ty {{.*}}): | ||
| // CHECK-NEXT: %[[ALLOCA:.*]] = cir.alloca !cir.array<!rec_NonDefaultCtor x 5>, !cir.ptr<!cir.array<!rec_NonDefaultCtor x 5>>, ["openacc.private.init"] | ||
| // TODO: Add Init here. | ||
| // CHECK-NEXT: cir.scope { | ||
| // CHECK-NEXT: %[[LB:.*]] = acc.get_lowerbound %[[BOUND1]] : (!acc.data_bounds_ty) -> index | ||
| // CHECK-NEXT: %[[LB_CAST:.*]] = builtin.unrealized_conversion_cast %[[LB]] : index to !u64i | ||
| // CHECK-NEXT: %[[UB:.*]] = acc.get_upperbound %[[BOUND1]] : (!acc.data_bounds_ty) -> index | ||
| // CHECK-NEXT: %[[UB_CAST:.*]] = builtin.unrealized_conversion_cast %[[UB]] : index to !u64i | ||
| // CHECK-NEXT: %[[ITR:.*]] = cir.alloca !u64i, !cir.ptr<!u64i>, ["iter"] {alignment = 8 : i64} | ||
| // CHECK-NEXT: cir.store %[[LB_CAST]], %[[ITR]] : !u64i, !cir.ptr<!u64i> | ||
| // CHECK-NEXT: cir.for : cond { | ||
| // CHECK-NEXT: %[[ITR_LOAD:.*]] = cir.load %[[ITR]] : !cir.ptr<!u64i>, !u64i | ||
| // CHECK-NEXT: %[[COND:.*]] = cir.cmp(lt, %[[ITR_LOAD]], %[[UB_CAST]]) : !u64i, !cir.bool | ||
| // CHECK-NEXT: cir.condition(%[[COND]]) | ||
| // CHECK-NEXT: } body { | ||
| // CHECK-NEXT: %[[ITR_LOAD:.*]] = cir.load %[[ITR]] : !cir.ptr<!u64i>, !u64i | ||
| // CHECK-NEXT: %[[DECAY:.*]] = cir.cast array_to_ptrdecay %[[ALLOCA]] : !cir.ptr<!cir.array<!rec_NonDefaultCtor x 5>> -> !cir.ptr<!rec_NonDefaultCtor> | ||
| // CHECK-NEXT: %[[STRIDE:.*]] = cir.ptr_stride(%[[DECAY]] : !cir.ptr<!rec_NonDefaultCtor>, %[[ITR_LOAD]] : !u64i), !cir.ptr<!rec_NonDefaultCtor> | ||
| // CHECK-NEXT: cir.call @_ZN14NonDefaultCtorC1Ev(%[[STRIDE]]) : (!cir.ptr<!rec_NonDefaultCtor>) -> () | ||
| // CHECK-NEXT: cir.yield | ||
| // CHECK-NEXT: } step { | ||
| // CHECK-NEXT: %[[ITR_LOAD]] = cir.load %[[ITR]] : !cir.ptr<!u64i>, !u64i | ||
| // CHECK-NEXT: %[[INC:.*]] = cir.unary(inc, %[[ITR_LOAD]]) : !u64i, !u64i | ||
| // CHECK-NEXT: cir.store %[[INC]], %[[ITR]] : !u64i, !cir.ptr<!u64i> | ||
| // CHECK-NEXT: cir.yield | ||
| // CHECK-NEXT: } | ||
| // CHECK-NEXT: } | ||
| // CHECK-NEXT: acc.yield | ||
| // CHECK-NEXT: } | ||
| // | ||
| // HasDtor[5] with 1 'bound' | ||
| // CHECK-NEXT: acc.private.recipe @privatization__Bcnt1__ZTSA5_7HasDtor : !cir.ptr<!cir.array<!rec_HasDtor x 5>> init { | ||
| // CHECK-NEXT: ^bb0(%[[ARG:.*]]: !cir.ptr<!cir.array<!rec_HasDtor x 5>> {{.*}}, %[[BOUND1:.*]]: !acc.data_bounds_ty {{.*}}): | ||
| // CHECK-NEXT: %[[ALLOCA:.*]] = cir.alloca !cir.array<!rec_HasDtor x 5>, !cir.ptr<!cir.array<!rec_HasDtor x 5>>, ["openacc.private.init"] | ||
| // TODO: Add Init here. | ||
| // CHECK-NEXT: cir.scope { | ||
| // CHECK-NEXT: %[[LB:.*]] = acc.get_lowerbound %[[BOUND1]] : (!acc.data_bounds_ty) -> index | ||
| // CHECK-NEXT: %[[LB_CAST:.*]] = builtin.unrealized_conversion_cast %[[LB]] : index to !u64i | ||
| // CHECK-NEXT: %[[UB:.*]] = acc.get_upperbound %[[BOUND1]] : (!acc.data_bounds_ty) -> index | ||
| // CHECK-NEXT: %[[UB_CAST:.*]] = builtin.unrealized_conversion_cast %[[UB]] : index to !u64i | ||
| // CHECK-NEXT: %[[ITR:.*]] = cir.alloca !u64i, !cir.ptr<!u64i>, ["iter"] {alignment = 8 : i64} | ||
| // CHECK-NEXT: cir.store %[[LB_CAST]], %[[ITR]] : !u64i, !cir.ptr<!u64i> | ||
| // CHECK-NEXT: cir.for : cond { | ||
| // CHECK-NEXT: %[[ITR_LOAD:.*]] = cir.load %[[ITR]] : !cir.ptr<!u64i>, !u64i | ||
| // CHECK-NEXT: %[[COND:.*]] = cir.cmp(lt, %[[ITR_LOAD]], %[[UB_CAST]]) : !u64i, !cir.bool | ||
| // CHECK-NEXT: cir.condition(%[[COND]]) | ||
| // CHECK-NEXT: } body { | ||
| // CHECK-NEXT: %[[ITR_LOAD:.*]] = cir.load %[[ITR]] : !cir.ptr<!u64i>, !u64i | ||
| // CHECK-NEXT: %[[DECAY:.*]] = cir.cast array_to_ptrdecay %[[ALLOCA]] : !cir.ptr<!cir.array<!rec_HasDtor x 5>> -> !cir.ptr<!rec_HasDtor> | ||
| // CHECK-NEXT: %[[STRIDE:.*]] = cir.ptr_stride(%[[DECAY]] : !cir.ptr<!rec_HasDtor>, %[[ITR_LOAD]] : !u64i), !cir.ptr<!rec_HasDtor> | ||
| // CHECK-NEXT: cir.yield | ||
| // CHECK-NEXT: } step { | ||
| // CHECK-NEXT: %[[ITR_LOAD]] = cir.load %[[ITR]] : !cir.ptr<!u64i>, !u64i | ||
| // CHECK-NEXT: %[[INC:.*]] = cir.unary(inc, %[[ITR_LOAD]]) : !u64i, !u64i | ||
| // CHECK-NEXT: cir.store %[[INC]], %[[ITR]] : !u64i, !cir.ptr<!u64i> | ||
| // CHECK-NEXT: cir.yield | ||
| // CHECK-NEXT: } | ||
| // CHECK-NEXT: } | ||
| // CHECK-NEXT: acc.yield | ||
| // CHECK-NEXT: } destroy { | ||
| // CHECK-NEXT: ^bb0(%[[ORIG:.*]]: !cir.ptr<!cir.array<!rec_HasDtor x 5>> {{.*}}, %[[ARG:.*]]: !cir.ptr<!cir.array<!rec_HasDtor x 5>> {{.*}}, %[[BOUND1:.*]]: !acc.data_bounds_ty {{.*}}): | ||
|
|
||
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.
Why isn't
initExprused in this function?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.
Ah! Because it is now stored in the
allocaDeclasgetInit. I've returned to doing that after thinking I couldn't, so I am going to remove those after I dofirstprivate, since it depends on it existing still.