aboutsummaryrefslogtreecommitdiff
path: root/offload/libomptarget
diff options
context:
space:
mode:
Diffstat (limited to 'offload/libomptarget')
-rw-r--r--offload/libomptarget/OpenMP/InteropAPI.cpp2
-rw-r--r--offload/libomptarget/OpenMP/Mapping.cpp20
-rw-r--r--offload/libomptarget/PluginManager.cpp6
-rw-r--r--offload/libomptarget/omptarget.cpp40
4 files changed, 40 insertions, 28 deletions
diff --git a/offload/libomptarget/OpenMP/InteropAPI.cpp b/offload/libomptarget/OpenMP/InteropAPI.cpp
index a694af1..2eaf376 100644
--- a/offload/libomptarget/OpenMP/InteropAPI.cpp
+++ b/offload/libomptarget/OpenMP/InteropAPI.cpp
@@ -219,7 +219,7 @@ omp_interop_val_t *__tgt_interop_get(ident_t *LocRef, int32_t InteropType,
auto DeviceOrErr = PM->getDevice(DeviceNum);
if (!DeviceOrErr) {
- [[maybe_unused]] std::string ErrStr = toString(DeviceOrErr.takeError());
+ std::string ErrStr = toString(DeviceOrErr.takeError());
ODBG(ODT_Interface) << "Couldn't find device " << DeviceNum
<< " while constructing interop object: " << ErrStr;
return omp_interop_none;
diff --git a/offload/libomptarget/OpenMP/Mapping.cpp b/offload/libomptarget/OpenMP/Mapping.cpp
index c71728c..b8edd79 100644
--- a/offload/libomptarget/OpenMP/Mapping.cpp
+++ b/offload/libomptarget/OpenMP/Mapping.cpp
@@ -83,10 +83,14 @@ int MappingInfoTy::associatePtr(void *HstPtrBegin, void *TgtPtrBegin,
/*UseHoldRefCount=*/false, /*Name=*/nullptr,
/*IsRefCountINF=*/true))
.first->HDTT;
- ODBG(ODT_Mapping) << "Creating new map entry: HstBase=" << NewEntry.HstPtrBase
- << ", HstBegin=" << NewEntry.HstPtrBegin
- << ", HstEnd=" << NewEntry.HstPtrEnd
- << ", TgtBegin=" << NewEntry.TgtPtrBegin
+ ODBG(ODT_Mapping) << "Creating new map entry: HstBase="
+ << reinterpret_cast<void *>(NewEntry.HstPtrBase)
+ << ", HstBegin="
+ << reinterpret_cast<void *>(NewEntry.HstPtrBegin)
+ << ", HstEnd="
+ << reinterpret_cast<void *>(NewEntry.HstPtrEnd)
+ << ", TgtBegin="
+ << reinterpret_cast<void *>(NewEntry.TgtPtrBegin)
<< ", DynRefCount=" << NewEntry.dynRefCountToStr()
<< ", HoldRefCount=" << NewEntry.holdRefCountToStr();
(void)NewEntry;
@@ -502,9 +506,11 @@ int MappingInfoTy::deallocTgtPtrAndEntry(HostDataToTargetTy *Entry,
int64_t Size) {
assert(Entry && "Trying to deallocate a null entry.");
- ODBG(ODT_Mapping) << "Deleting tgt data " << Entry->TgtPtrBegin << " of size "
- << Size << " by freeing allocation "
- << "starting at " << Entry->TgtAllocBegin;
+ ODBG(ODT_Mapping) << "Deleting tgt data "
+ << reinterpret_cast<void *>(Entry->TgtPtrBegin)
+ << " of size " << Size << " by freeing allocation "
+ << "starting at "
+ << reinterpret_cast<void *>(Entry->TgtAllocBegin);
void *Event = Entry->getEvent();
if (Event && Device.destroyEvent(Event) != OFFLOAD_SUCCESS) {
diff --git a/offload/libomptarget/PluginManager.cpp b/offload/libomptarget/PluginManager.cpp
index 924a986..41b653a 100644
--- a/offload/libomptarget/PluginManager.cpp
+++ b/offload/libomptarget/PluginManager.cpp
@@ -59,7 +59,7 @@ void PluginManager::deinit() {
continue;
if (auto Err = Plugin->deinit()) {
- [[maybe_unused]] std::string InfoMsg = toString(std::move(Err));
+ std::string InfoMsg = toString(std::move(Err));
ODBG(ODT_Deinit) << "Failed to deinit plugin: " << InfoMsg;
}
Plugin.release();
@@ -73,7 +73,7 @@ bool PluginManager::initializePlugin(GenericPluginTy &Plugin) {
return true;
if (auto Err = Plugin.init()) {
- [[maybe_unused]] std::string InfoMsg = toString(std::move(Err));
+ std::string InfoMsg = toString(std::move(Err));
ODBG(ODT_Init) << "Failed to init plugin: " << InfoMsg;
return false;
}
@@ -106,7 +106,7 @@ bool PluginManager::initializeDevice(GenericPluginTy &Plugin,
auto Device = std::make_unique<DeviceTy>(&Plugin, UserId, DeviceId);
if (auto Err = Device->init()) {
- [[maybe_unused]] std::string InfoMsg = toString(std::move(Err));
+ std::string InfoMsg = toString(std::move(Err));
ODBG(ODT_Init) << "Failed to init device " << DeviceId << ": " << InfoMsg;
return false;
}
diff --git a/offload/libomptarget/omptarget.cpp b/offload/libomptarget/omptarget.cpp
index 676fda5..bd99ede 100644
--- a/offload/libomptarget/omptarget.cpp
+++ b/offload/libomptarget/omptarget.cpp
@@ -600,8 +600,7 @@ int targetDataBegin(ident_t *Loc, DeviceTy &Device, int32_t ArgNum,
// then no argument is marked as TARGET_PARAM ("omp target data map" is not
// associated with a target region, so there are no target parameters). This
// may be considered a hack, we could revise the scheme in the future.
- bool UpdateRef =
- !(ArgTypes[I] & OMP_TGT_MAPTYPE_MEMBER_OF) && !(FromMapper && I == 0);
+ bool UpdateRef = !(ArgTypes[I] & OMP_TGT_MAPTYPE_MEMBER_OF);
MappingInfoTy::HDTTMapAccessorTy HDTTMap =
Device.getMappingInfo().HostDataToTargetMap.getExclusiveAccessor();
@@ -707,14 +706,20 @@ int targetDataBegin(ident_t *Loc, DeviceTy &Device, int32_t ArgNum,
// to references to a local device pointer that refers to this device
// address.
//
- // TODO: Add a new map-type bit to support OpenMP 6.1's `fb_nullify`
- // and set the result to `nullptr - Delta`. Note that `fb_nullify` is
- // already the default for `need_device_ptr`, but clang/flang do not
- // support its codegen yet.
- TgtPtrBase = reinterpret_cast<void *>(
- reinterpret_cast<uintptr_t>(HstPtrBegin) - Delta);
- ODBG(ODT_Mapping) << "Returning host pointer " << TgtPtrBase
- << " as fallback (lookup failed)";
+ // OpenMP 6.1's `fb_nullify` fallback behavior: when the FB_NULLIFY bit
+ // is set by the compiler, e.g. for `use/need_device_ptr(fb_nullify)`),
+ // return `nullptr - Delta` when lookup fails.
+ if (ArgTypes[I] & OMP_TGT_MAPTYPE_FB_NULLIFY) {
+ TgtPtrBase = reinterpret_cast<void *>(
+ reinterpret_cast<uintptr_t>(nullptr) - Delta);
+ ODBG(ODT_Mapping) << "Returning offsetted null pointer " << TgtPtrBase
+ << " as fallback (lookup failed)";
+ } else {
+ TgtPtrBase = reinterpret_cast<void *>(
+ reinterpret_cast<uintptr_t>(HstPtrBegin) - Delta);
+ ODBG(ODT_Mapping) << "Returning host pointer " << TgtPtrBase
+ << " as fallback (lookup failed)";
+ }
}
ArgsBase[I] = TgtPtrBase;
}
@@ -1104,9 +1109,8 @@ int targetDataEnd(ident_t *Loc, DeviceTy &Device, int32_t ArgNum,
void *HstPtrBegin = Args[I];
int64_t DataSize = ArgSizes[I];
bool IsImplicit = ArgTypes[I] & OMP_TGT_MAPTYPE_IMPLICIT;
- bool UpdateRef = (!(ArgTypes[I] & OMP_TGT_MAPTYPE_MEMBER_OF) ||
- (ArgTypes[I] & OMP_TGT_MAPTYPE_PTR_AND_OBJ)) &&
- !(FromMapper && I == 0);
+ bool UpdateRef = !(ArgTypes[I] & OMP_TGT_MAPTYPE_MEMBER_OF) ||
+ (ArgTypes[I] & OMP_TGT_MAPTYPE_PTR_AND_OBJ);
bool ForceDelete = ArgTypes[I] & OMP_TGT_MAPTYPE_DELETE;
bool HasPresentModifier = ArgTypes[I] & OMP_TGT_MAPTYPE_PRESENT;
bool HasHoldModifier = ArgTypes[I] & OMP_TGT_MAPTYPE_OMPX_HOLD;
@@ -1254,12 +1258,12 @@ static int targetDataContiguous(ident_t *Loc, DeviceTy &Device, void *ArgsBase,
<< "Restoring target descriptor " << ShadowPtr.TgtPtrAddr
<< " to its original content (" << ShadowPtr.PtrSize
<< " bytes), containing pointee address "
- << ShadowPtr.TgtPtrContent.data();
+ << static_cast<const void *>(ShadowPtr.TgtPtrContent.data());
} else {
ODBG(ODT_Mapping)
<< "Restoring target pointer " << ShadowPtr.TgtPtrAddr
<< " to its original value "
- << ShadowPtr.TgtPtrContent.data();
+ << static_cast<const void *>(ShadowPtr.TgtPtrContent.data());
}
Ret = Device.submitData(ShadowPtr.TgtPtrAddr,
ShadowPtr.TgtPtrContent.data(),
@@ -1299,12 +1303,14 @@ static int targetDataContiguous(ident_t *Loc, DeviceTy &Device, void *ArgsBase,
<< "Restoring host descriptor " << ShadowPtr.HstPtrAddr
<< " to its original content (" << ShadowPtr.PtrSize
<< " bytes), containing pointee address "
- << ShadowPtr.HstPtrContent.data();
+ << static_cast<const void *>(
+ ShadowPtr.HstPtrContent.data());
} else {
ODBG(ODT_Mapping)
<< "Restoring host pointer " << ShadowPtr.HstPtrAddr
<< " to its original value "
- << ShadowPtr.HstPtrContent.data();
+ << static_cast<const void *>(
+ ShadowPtr.HstPtrContent.data());
}
std::memcpy(ShadowPtr.HstPtrAddr, ShadowPtr.HstPtrContent.data(),
ShadowPtr.PtrSize);