Skip to content

[MLIR][OpenMP] Updated fix for intermixed TargetDataOp and TargetOp #56

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

Merged
merged 2 commits into from
Mar 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2515,8 +2515,12 @@ convertOmpTargetData(Operation *op, llvm::IRBuilderBase &builder,
argIndex++;
}

bodyGenStatus = inlineConvertOmpRegions(region, "omp.data.region",
builder, moduleTranslation);
SmallVector<llvm::PHINode *> phis;
llvm::BasicBlock *continuationBlock =
convertOmpOpRegions(region, "omp.data.region", builder,
moduleTranslation, bodyGenStatus, &phis);
builder.SetInsertPoint(continuationBlock,
continuationBlock->getFirstInsertionPt());
Comment on lines +2518 to +2523
Copy link
Member

Choose a reason for hiding this comment

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

Just out of curiosity: Why did the original call break things? I see the only difference is that it does some special handling if there is a single block in the region.

Copy link
Author

Choose a reason for hiding this comment

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

The special case assumes that that no new basic blocks are created, which does happen for omp.target, so it seems to generate code in the wrong place because of this.

Copy link
Member

Choose a reason for hiding this comment

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

We currently still have this change only in ATD, should we upstream it or has it somehow become unnecessary? I don't actually know how to reproduce the issue it fixes, that's why I ask instead of checking myself @jsjodin @TIFitis

}
break;
case BodyGenTy::DupNoPriv:
Expand All @@ -2525,8 +2529,12 @@ convertOmpTargetData(Operation *op, llvm::IRBuilderBase &builder,
// If device info is available then region has already been generated
if (info.DevicePtrInfoMap.empty()) {
builder.restoreIP(codeGenIP);
bodyGenStatus = inlineConvertOmpRegions(region, "omp.data.region",
builder, moduleTranslation);
SmallVector<llvm::PHINode *> phis;
llvm::BasicBlock *continuationBlock =
convertOmpOpRegions(region, "omp.data.region", builder,
moduleTranslation, bodyGenStatus, &phis);
builder.SetInsertPoint(continuationBlock,
continuationBlock->getFirstInsertionPt());
}
break;
}
Expand Down Expand Up @@ -3543,6 +3551,8 @@ convertTopLevelTargetOp(Operation *op, llvm::IRBuilderBase &builder,
LLVM::ModuleTranslation &moduleTranslation) {
if (isa<omp::TargetOp>(op))
return convertOmpTarget(*op, builder, moduleTranslation);
if (isa<omp::TargetDataOp>(op))
return convertOmpTargetData(op, builder, moduleTranslation);
bool interrupted =
op->walk<WalkOrder::PreOrder>([&](omp::TargetOp targetOp) {
if (failed(convertOmpTarget(*targetOp, builder, moduleTranslation)))
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't we need to find nested omp.target_data ops here as well?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, I forgot this wasn't a recursive function, so there should be a case for the TargetDataOp as well.

Expand Down