summaryrefslogtreecommitdiff
path: root/openmp
diff options
context:
space:
mode:
authorKevin Sala <kevin.sala@bsc.es>2023-04-11 18:41:39 +0200
committerKevin Sala <kevin.sala@bsc.es>2023-04-18 18:52:01 +0200
commit221350965a891fc4ce33ea311428448939678112 (patch)
tree4f10851daf9f10930dd6fc515ee6d371b21ab4b0 /openmp
parent37a867a5a88871f937256d6cf1248eddabd8925e (diff)
downloadllvm-221350965a891fc4ce33ea311428448939678112.tar.gz
[OpenMP][libomptarget][NFC] Remove error data member from AsyncInfoWrapperTy
This patch removes the Err data member from the AsyncInfoWrapperTy class. Now the error is stored externally, in the caller side, and it is explicitly passed to the AsyncInfoWrapperTy::finalize() function as a reference. Differential Revision: https://reviews.llvm.org/D148027
Diffstat (limited to 'openmp')
-rw-r--r--openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp64
-rw-r--r--openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.h14
2 files changed, 35 insertions, 43 deletions
diff --git a/openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp b/openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
index 982a000ab486..7ebc1d1092cd 100644
--- a/openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
+++ b/openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
@@ -202,27 +202,21 @@ public:
AsyncInfoWrapperTy::AsyncInfoWrapperTy(GenericDeviceTy &Device,
__tgt_async_info *AsyncInfoPtr)
- : Err(Plugin::success()), Device(Device),
- AsyncInfoPtr(AsyncInfoPtr ? AsyncInfoPtr : &LocalAsyncInfo) {
- // Mark the success as checked. Otherwise, it would produce an error when
- // re-assigned another error value.
- (void)!Err;
-}
+ : Device(Device),
+ AsyncInfoPtr(AsyncInfoPtr ? AsyncInfoPtr : &LocalAsyncInfo) {}
-Error AsyncInfoWrapperTy::finalize() {
+void AsyncInfoWrapperTy::finalize(Error &Err) {
assert(AsyncInfoPtr && "AsyncInfoWrapperTy already finalized");
- // If we used a local async info object we want synchronous behavior.
- // In that case, and assuming the current status code is OK, we will
- // synchronize explicitly when the object is deleted.
+ // If we used a local async info object we want synchronous behavior. In that
+ // case, and assuming the current status code is correct, we will synchronize
+ // explicitly when the object is deleted. Update the error with the result of
+ // the synchronize operation.
if (AsyncInfoPtr == &LocalAsyncInfo && LocalAsyncInfo.Queue && !Err)
Err = Device.synchronize(&LocalAsyncInfo);
// Invalidate the wrapper object.
AsyncInfoPtr = nullptr;
-
- // Return the error associated to the async operations and the synchronize.
- return std::move(Err);
}
Error GenericKernelTy::init(GenericDeviceTy &GenericDevice,
@@ -931,18 +925,18 @@ Error GenericDeviceTy::dataSubmit(void *TgtPtr, const void *HstPtr,
int64_t Size, __tgt_async_info *AsyncInfo) {
AsyncInfoWrapperTy AsyncInfoWrapper(*this, AsyncInfo);
- auto &Err = AsyncInfoWrapper.getError();
- Err = dataSubmitImpl(TgtPtr, HstPtr, Size, AsyncInfoWrapper);
- return AsyncInfoWrapper.finalize();
+ auto Err = dataSubmitImpl(TgtPtr, HstPtr, Size, AsyncInfoWrapper);
+ AsyncInfoWrapper.finalize(Err);
+ return Err;
}
Error GenericDeviceTy::dataRetrieve(void *HstPtr, const void *TgtPtr,
int64_t Size, __tgt_async_info *AsyncInfo) {
AsyncInfoWrapperTy AsyncInfoWrapper(*this, AsyncInfo);
- auto &Err = AsyncInfoWrapper.getError();
- Err = dataRetrieveImpl(HstPtr, TgtPtr, Size, AsyncInfoWrapper);
- return AsyncInfoWrapper.finalize();
+ auto Err = dataRetrieveImpl(HstPtr, TgtPtr, Size, AsyncInfoWrapper);
+ AsyncInfoWrapper.finalize(Err);
+ return Err;
}
Error GenericDeviceTy::dataExchange(const void *SrcPtr, GenericDeviceTy &DstDev,
@@ -950,9 +944,9 @@ Error GenericDeviceTy::dataExchange(const void *SrcPtr, GenericDeviceTy &DstDev,
__tgt_async_info *AsyncInfo) {
AsyncInfoWrapperTy AsyncInfoWrapper(*this, AsyncInfo);
- auto &Err = AsyncInfoWrapper.getError();
- Err = dataExchangeImpl(SrcPtr, DstDev, DstPtr, Size, AsyncInfoWrapper);
- return AsyncInfoWrapper.finalize();
+ auto Err = dataExchangeImpl(SrcPtr, DstDev, DstPtr, Size, AsyncInfoWrapper);
+ AsyncInfoWrapper.finalize(Err);
+ return Err;
}
Error GenericDeviceTy::launchKernel(void *EntryPtr, void **ArgPtrs,
@@ -970,16 +964,16 @@ Error GenericDeviceTy::launchKernel(void *EntryPtr, void **ArgPtrs,
KernelArgs.NumTeams[0], KernelArgs.ThreadLimit[0], KernelArgs.Tripcount,
AsyncInfoWrapper);
- auto &Err = AsyncInfoWrapper.getError();
- Err = GenericKernel.launch(*this, ArgPtrs, ArgOffsets, KernelArgs,
- AsyncInfoWrapper);
+ auto Err = GenericKernel.launch(*this, ArgPtrs, ArgOffsets, KernelArgs,
+ AsyncInfoWrapper);
if (RecordReplay.isRecordingOrReplaying() &&
RecordReplay.isSaveOutputEnabled())
RecordReplay.saveKernelOutputInfo(GenericKernel.getName(),
AsyncInfoWrapper);
- return AsyncInfoWrapper.finalize();
+ AsyncInfoWrapper.finalize(Err);
+ return Err;
}
Error GenericDeviceTy::initAsyncInfo(__tgt_async_info **AsyncInfoPtr) {
@@ -989,9 +983,9 @@ Error GenericDeviceTy::initAsyncInfo(__tgt_async_info **AsyncInfoPtr) {
AsyncInfoWrapperTy AsyncInfoWrapper(*this, *AsyncInfoPtr);
- auto &Err = AsyncInfoWrapper.getError();
- Err = initAsyncInfoImpl(AsyncInfoWrapper);
- return AsyncInfoWrapper.finalize();
+ auto Err = initAsyncInfoImpl(AsyncInfoWrapper);
+ AsyncInfoWrapper.finalize(Err);
+ return Err;
}
Error GenericDeviceTy::initDeviceInfo(__tgt_device_info *DeviceInfo) {
@@ -1017,17 +1011,17 @@ Error GenericDeviceTy::recordEvent(void *EventPtr,
__tgt_async_info *AsyncInfo) {
AsyncInfoWrapperTy AsyncInfoWrapper(*this, AsyncInfo);
- auto &Err = AsyncInfoWrapper.getError();
- Err = recordEventImpl(EventPtr, AsyncInfoWrapper);
- return AsyncInfoWrapper.finalize();
+ auto Err = recordEventImpl(EventPtr, AsyncInfoWrapper);
+ AsyncInfoWrapper.finalize(Err);
+ return Err;
}
Error GenericDeviceTy::waitEvent(void *EventPtr, __tgt_async_info *AsyncInfo) {
AsyncInfoWrapperTy AsyncInfoWrapper(*this, AsyncInfo);
- auto &Err = AsyncInfoWrapper.getError();
- Err = waitEventImpl(EventPtr, AsyncInfoWrapper);
- return AsyncInfoWrapper.finalize();
+ auto Err = waitEventImpl(EventPtr, AsyncInfoWrapper);
+ AsyncInfoWrapper.finalize(Err);
+ return Err;
}
Error GenericDeviceTy::syncEvent(void *EventPtr) {
diff --git a/openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.h b/openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.h
index 1045db9c51d4..a91ea81183c2 100644
--- a/openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.h
+++ b/openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.h
@@ -70,17 +70,15 @@ struct AsyncInfoWrapperTy {
/// Indicate whether there is queue.
bool hasQueue() const { return (AsyncInfoPtr->Queue != nullptr); }
- // Get a reference to the error associated with the asycnhronous operations
- // related to the async info wrapper.
- Error &getError() { return Err; }
-
/// Synchronize with the __tgt_async_info's pending operations if it's the
- /// internal async info and return the error associated with the async
- /// operations. This function must be called before destroying the object.
- Error finalize();
+ /// internal async info. The error associated to the aysnchronous operations
+ /// issued in this queue must be provided in \p Err. This function will update
+ /// the error parameter with the result of the synchronization if it was
+ /// actually executed. This function must be called before destroying the
+ /// object and only once.
+ void finalize(Error &Err);
private:
- Error Err;
GenericDeviceTy &Device;
__tgt_async_info LocalAsyncInfo;
__tgt_async_info *AsyncInfoPtr;