Skip to content

Commit 6846880

Browse files
committed
strided_update_offloading
1 parent 06c7835 commit 6846880

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

clang/lib/CodeGen/CGOpenMPRuntime.cpp

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7384,7 +7384,40 @@ class MappableExprsHandler {
73847384
// dimension.
73857385
uint64_t DimSize = 1;
73867386

7387-
bool IsNonContiguous = CombinedInfo.NonContigInfo.IsNonContiguous;
7387+
// Detects non-contiguous updates due to strided accesses.
7388+
// Sets the 'IsNonContiguous' flag so that the 'MapType' bits are set
7389+
// correctly when generating information to be passed to the runtime. The
7390+
// flag is set to true if any array section has a stride not equal to 1, or
7391+
// if the stride is not a constant expression (conservatively assumed
7392+
// non-contiguous).
7393+
bool IsNonContiguous = false;
7394+
for (const auto &Component : Components) {
7395+
const auto *OASE =
7396+
dyn_cast<ArraySectionExpr>(Component.getAssociatedExpression());
7397+
if (OASE) {
7398+
const Expr *StrideExpr = OASE->getStride();
7399+
if (StrideExpr) {
7400+
// Check if the stride is a constant integer expression
7401+
if (StrideExpr->isIntegerConstantExpr(CGF.getContext())) {
7402+
if (auto Constant =
7403+
StrideExpr->getIntegerConstantExpr(CGF.getContext())) {
7404+
int64_t StrideVal = Constant->getExtValue();
7405+
if (StrideVal != 1) {
7406+
// Set flag if stride is not 1 (i.e., non-contiguous update)
7407+
IsNonContiguous = true;
7408+
break;
7409+
}
7410+
}
7411+
} else {
7412+
// If stride is not a constant, conservatively treat as
7413+
// non-contiguous
7414+
IsNonContiguous = true;
7415+
break;
7416+
}
7417+
}
7418+
}
7419+
}
7420+
73887421
bool IsPrevMemberReference = false;
73897422

73907423
bool IsPartialMapped =

0 commit comments

Comments
 (0)