[Openmp-commits] [openmp] [libomptarget] document ActionFunctions in the amdgpu plugin. (PR #66397)

Ye Luo via Openmp-commits openmp-commits at lists.llvm.org
Thu Sep 14 09:28:25 PDT 2023


https://github.com/ye-luo created https://github.com/llvm/llvm-project/pull/66397:

None

>From ffbc145ad53ffc7d2d84e7bd0747f627c7acf9e0 Mon Sep 17 00:00:00 2001
From: Ye Luo <yeluo at anl.gov>
Date: Thu, 14 Sep 2023 11:20:54 -0500
Subject: [PATCH] [libomptarget] document ActionFunctions in the amdgpu plugin.

---
 .../libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp   | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp b/openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp
index 7b4ea794fe7f0d2..6e16621c71c1afe 100644
--- a/openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp
+++ b/openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp
@@ -1055,7 +1055,7 @@ struct AMDGPUStreamTy {
     return false;
   }
 
-  // Callback for host-to-host memory copies.
+  // Callback for host-to-host memory copies. This is an asynchronous action.
   static Error memcpyAction(void *Data) {
     MemcpyArgsTy *Args = reinterpret_cast<MemcpyArgsTy *>(Data);
     assert(Args && "Invalid arguments");
@@ -1067,7 +1067,12 @@ struct AMDGPUStreamTy {
     return Plugin::success();
   }
 
-  // Callback for releasing a memory buffer to a memory manager.
+  /// Releasing a memory buffer to a memory manager. This is a post completion action.
+  /// There are two kinds of memory buffers:
+  ///   1. For kernel arguments. This buffer can be freed after receiving the kernel completion signal.
+  ///   2. For H2D tranfers that need pinned memory space for staging. This buffer can be freed after receiving the transfer completion signal.
+  ///   3. For D2H tranfers that need pinned memory space for staging. This buffer cannot be freed after receiving the transfer completion signal because of the following asynchronous H2H callback.
+  ///      For this reason, This action can only be taken at AMDGPUStreamTy::complete()
   static Error releaseBufferAction(void *Data) {
     ReleaseBufferArgsTy *Args = reinterpret_cast<ReleaseBufferArgsTy *>(Data);
     assert(Args && "Invalid arguments");
@@ -1078,6 +1083,8 @@ struct AMDGPUStreamTy {
     return Args->MemoryManager->deallocate(Args->Buffer);
   }
 
+  /// Releasing a signal object back to SignalManage. This is a post completion action.
+  /// This action can only be taken at AMDGPUStreamTy::complete()
   static Error releaseSignalAction(void *Data) {
     ReleaseSignalArgsTy *Args = reinterpret_cast<ReleaseSignalArgsTy *>(Data);
     assert(Args && "Invalid arguments");



More information about the Openmp-commits mailing list