Skip to content

Commit

Permalink
Merge pull request #118 from TIFitis/akash/atd-device_ptr-bug
Browse files Browse the repository at this point in the history
[OpenMP] Fix use_device_ptr(addr) mapping in absence of explicit map clause

This patch fixes a bug which was preventing proper processing of all the MapInfoOps related to use_device_addr(ptr) clauses when map clauses for these are absent.

Related to https://ontrack-internal.amd.com/browse/SWDEV-471469
  • Loading branch information
TIFitis authored Jul 16, 2024
2 parents 2e3ab04 + 3667fa6 commit 726e5c1
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2089,6 +2089,8 @@ getRefPtrIfDeclareTarget(mlir::Value value,
struct MapInfoData : llvm::OpenMPIRBuilder::MapInfosTy {
llvm::SmallVector<bool, 4> IsDeclareTarget;
llvm::SmallVector<bool, 4> IsAMember;
// Identify if mapping was added by mapClause or use_device clauses.
llvm::SmallVector<bool, 4> IsAMapping;
llvm::SmallVector<mlir::Operation *, 4> MapClause;
llvm::SmallVector<llvm::Value *, 4> OriginalValue;
// Stripped off array/pointer to get the underlying
Expand Down Expand Up @@ -2208,6 +2210,7 @@ void collectMapDataFromMapOperands(
mapData.Names.push_back(LLVM::createMappingInformation(
mapOp.getLoc(), *moduleTranslation.getOpenMPBuilder()));
mapData.DevicePointers.push_back(llvm::OpenMPIRBuilder::DeviceInfoTy::None);
mapData.IsAMapping.push_back(true);

// Check if this is a member mapping and correctly assign that it is, if
// it is a member of a larger object.
Expand All @@ -2234,7 +2237,7 @@ void collectMapDataFromMapOperands(
bool found = false;
index = 0;
for (llvm::Value *basePtr : mapData.OriginalValue) {
if (basePtr == val) {
if (basePtr == val && mapData.IsAMapping[index]) {
found = true;
mapData.Types[index] |=
llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_RETURN_PARAM;
Expand Down Expand Up @@ -2272,6 +2275,7 @@ void collectMapDataFromMapOperands(
mapData.Names.push_back(LLVM::createMappingInformation(
mapOp.getLoc(), *moduleTranslation.getOpenMPBuilder()));
mapData.DevicePointers.push_back(devInfoTy);
mapData.IsAMapping.push_back(false);

// Check if this is a member mapping and correctly assign that it is, if
// it is a member of a larger object.
Expand Down

0 comments on commit 726e5c1

Please sign in to comment.