[Openmp-commits] [PATCH] D153837: Synchronize after each GPU action in the nextgen plugin

Eric Wright via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Fri Jul 14 09:56:24 PDT 2023


efwright updated this revision to Diff 540467.
efwright edited the summary of this revision.
efwright added a comment.

Moved the functionality to the AsyncInfoWrapperTy.finalize() function. Stores the error and it will be returned from the function to reported properly. Looked into the BoolEnvar as recommended. was thinking of storing it in the AsyncInfoWrapperTy class, but since that class gets created and destroyed frequently it's probably a better idea to store it somewhere more permanent.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D153837/new/

https://reviews.llvm.org/D153837

Files:
  openmp/docs/design/Runtimes.rst
  openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp


Index: openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
===================================================================
--- openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
+++ openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
@@ -208,6 +208,12 @@
 void AsyncInfoWrapperTy::finalize(Error &Err) {
   assert(AsyncInfoPtr && "AsyncInfoWrapperTy already finalized");
 
+  // If the LIBOMPTARGET_FORCE_SYNCHRONIZE environment variable is set,
+  // synchronize early here.
+  BoolEnvar ForceSynchronize("LIBOMPTARGET_FORCE_SYNCHRONIZE");
+  if (ForceSynchronize && !Err)
+    Err = Device.synchronize(AsyncInfoPtr);
+
   // 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
@@ -926,6 +932,7 @@
   AsyncInfoWrapperTy AsyncInfoWrapper(*this, AsyncInfo);
 
   auto Err = dataSubmitImpl(TgtPtr, HstPtr, Size, AsyncInfoWrapper);
+
   AsyncInfoWrapper.finalize(Err);
   return Err;
 }
@@ -935,6 +942,7 @@
   AsyncInfoWrapperTy AsyncInfoWrapper(*this, AsyncInfo);
 
   auto Err = dataRetrieveImpl(HstPtr, TgtPtr, Size, AsyncInfoWrapper);
+
   AsyncInfoWrapper.finalize(Err);
   return Err;
 }
@@ -945,6 +953,7 @@
   AsyncInfoWrapperTy AsyncInfoWrapper(*this, AsyncInfo);
 
   auto Err = dataExchangeImpl(SrcPtr, DstDev, DstPtr, Size, AsyncInfoWrapper);
+
   AsyncInfoWrapper.finalize(Err);
   return Err;
 }
Index: openmp/docs/design/Runtimes.rst
===================================================================
--- openmp/docs/design/Runtimes.rst
+++ openmp/docs/design/Runtimes.rst
@@ -1160,6 +1160,7 @@
 * ``LIBOMPTARGET_AMDGPU_TEAMS_PER_CU``
 * ``LIBOMPTARGET_AMDGPU_MAX_ASYNC_COPY_BYTES``
 * ``LIBOMPTARGET_AMDGPU_NUM_INITIAL_HSA_SIGNALS``
+* ``LIBOMPTARGET_FORCE_SYNCHRONIZE``
 
 The environment variables ``LIBOMPTARGET_SHARED_MEMORY_SIZE``,
 ``LIBOMPTARGET_STACK_SIZE`` and ``LIBOMPTARGET_HEAP_SIZE`` are described in
@@ -1238,6 +1239,14 @@
 streams. More HSA signals will be created dynamically throughout the execution
 if needed. The default value is ``64``.
 
+LIBOMPTARGET_FORCE_SYNCHRONIZE
+""""""""""""""""""""""""""""""
+
+This environment variable causes the NextGen plugin to synchronize immediately
+after a kernel is launched or after a data transfer, instead of the default
+behavior. Doing so aims to make identifying the source of code crashes
+easier.
+
 .. _remote_offloading_plugin:
 
 Remote Offloading Plugin:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153837.540467.patch
Type: text/x-patch
Size: 2610 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20230714/2eeff864/attachment-0001.bin>


More information about the Openmp-commits mailing list