Skip to content

Commit f4ff68b

Browse files
committed
Add is_device_ptr to mlir map flag.
1 parent a88f171 commit f4ff68b

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

flang/lib/Lower/OpenMP/ClauseProcessor.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1146,7 +1146,8 @@ bool ClauseProcessor::processIsDevicePtr(
11461146
const parser::CharBlock &source) {
11471147
mlir::Location location = converter.genLocation(source);
11481148
mlir::omp::ClauseMapFlags mapTypeBits =
1149-
mlir::omp::ClauseMapFlags::storage;
1149+
mlir::omp::ClauseMapFlags::return_param |
1150+
mlir::omp::ClauseMapFlags::is_device_ptr;
11501151
processMapObjects(stmtCtx, location, clause.v, mapTypeBits,
11511152
parentMemberIndices, result.isDevicePtrVars,
11521153
isDeviceSyms);

mlir/include/mlir/Dialect/OpenMP/OpenMPEnums.td

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ def ClauseMapFlagsAttachAuto : I32BitEnumAttrCaseBit<"attach_auto", 15>;
126126
def ClauseMapFlagsRefPtr : I32BitEnumAttrCaseBit<"ref_ptr", 16>;
127127
def ClauseMapFlagsRefPtee : I32BitEnumAttrCaseBit<"ref_ptee", 17>;
128128
def ClauseMapFlagsRefPtrPtee : I32BitEnumAttrCaseBit<"ref_ptr_ptee", 18>;
129+
def ClauseMapFlagsIsDevicePtr : I32BitEnumAttrCaseBit<"is_device_ptr", 19>;
129130

130131
def ClauseMapFlags : OpenMP_BitEnumAttr<
131132
"ClauseMapFlags",
@@ -149,7 +150,8 @@ def ClauseMapFlags : OpenMP_BitEnumAttr<
149150
ClauseMapFlagsAttachAuto,
150151
ClauseMapFlagsRefPtr,
151152
ClauseMapFlagsRefPtee,
152-
ClauseMapFlagsRefPtrPtee
153+
ClauseMapFlagsRefPtrPtee,
154+
ClauseMapFlagsIsDevicePtr
153155
]>;
154156

155157
def ClauseMapFlagsAttr : OpenMP_EnumAttr<ClauseMapFlags,

mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,6 @@ static LogicalResult checkImplementationStatus(Operation &op) {
332332
op.getInReductionSyms())
333333
result = todo("in_reduction");
334334
};
335-
auto checkIsDevicePtr = [](auto, LogicalResult &) {};
336335
auto checkLinear = [&todo](auto op, LogicalResult &result) {
337336
if (!op.getLinearVars().empty() || !op.getLinearStepVars().empty())
338337
result = todo("linear");
@@ -441,7 +440,6 @@ static LogicalResult checkImplementationStatus(Operation &op) {
441440
checkBare(op, result);
442441
checkDevice(op, result);
443442
checkInReduction(op, result);
444-
checkIsDevicePtr(op, result);
445443
})
446444
.Default([](Operation &) {
447445
// Assume all clauses for an operation can be translated unless they are
@@ -3872,6 +3870,10 @@ convertClauseMapFlags(omp::ClauseMapFlags mlirFlags) {
38723870
if (mapTypeToBool(omp::ClauseMapFlags::attach))
38733871
mapType |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_ATTACH;
38743872

3873+
// No dedicated LLVM runtime flag for is_device_ptr; handled separately.
3874+
if (mapTypeToBool(omp::ClauseMapFlags::is_device_ptr))
3875+
mapType |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_RETURN_PARAM;
3876+
38753877
return mapType;
38763878
}
38773879

@@ -3993,8 +3995,9 @@ static void collectMapDataFromMapOperands(
39933995
llvm::Value *origValue = moduleTranslation.lookupValue(offloadPtr);
39943996
auto mapType = convertClauseMapFlags(mapOp.getMapType());
39953997
auto mapTypeAlways = llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_ALWAYS;
3996-
bool isDevicePtr = (mapOp.getMapType() & omp::ClauseMapFlags::storage) ==
3997-
omp::ClauseMapFlags::storage;
3998+
bool isDevicePtr =
3999+
(mapOp.getMapType() & omp::ClauseMapFlags::is_device_ptr) !=
4000+
omp::ClauseMapFlags::none;
39984001

39994002
mapData.OriginalValue.push_back(origValue);
40004003
mapData.BasePointers.push_back(origValue);

0 commit comments

Comments
 (0)