Skip to content

Commit 8c2da6b

Browse files
authored
[libomptarget] document ActionFunctions in the amdgpu plugin. (#66397)
1 parent 5ec9699 commit 8c2da6b

File tree

1 file changed

+16
-2
lines changed
  • openmp/libomptarget/plugins-nextgen/amdgpu/src

1 file changed

+16
-2
lines changed

openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,7 +1055,7 @@ struct AMDGPUStreamTy {
10551055
return false;
10561056
}
10571057

1058-
// Callback for host-to-host memory copies.
1058+
// Callback for host-to-host memory copies. This is an asynchronous action.
10591059
static Error memcpyAction(void *Data) {
10601060
MemcpyArgsTy *Args = reinterpret_cast<MemcpyArgsTy *>(Data);
10611061
assert(Args && "Invalid arguments");
@@ -1067,7 +1067,19 @@ struct AMDGPUStreamTy {
10671067
return Plugin::success();
10681068
}
10691069

1070-
// Callback for releasing a memory buffer to a memory manager.
1070+
/// Releasing a memory buffer to a memory manager. This is a post completion
1071+
/// action. There are two kinds of memory buffers:
1072+
/// 1. For kernel arguments. This buffer can be freed after receiving the
1073+
/// kernel completion signal.
1074+
/// 2. For H2D tranfers that need pinned memory space for staging. This
1075+
/// buffer can be freed after receiving the transfer completion signal.
1076+
/// 3. For D2H tranfers that need pinned memory space for staging. This
1077+
/// buffer cannot be freed after receiving the transfer completion signal
1078+
/// because of the following asynchronous H2H callback.
1079+
/// For this reason, This action can only be taken at
1080+
/// AMDGPUStreamTy::complete()
1081+
/// Because of the case 3, all releaseBufferActions are taken at
1082+
/// AMDGPUStreamTy::complete() in the current implementation.
10711083
static Error releaseBufferAction(void *Data) {
10721084
ReleaseBufferArgsTy *Args = reinterpret_cast<ReleaseBufferArgsTy *>(Data);
10731085
assert(Args && "Invalid arguments");
@@ -1078,6 +1090,8 @@ struct AMDGPUStreamTy {
10781090
return Args->MemoryManager->deallocate(Args->Buffer);
10791091
}
10801092

1093+
/// Releasing a signal object back to SignalManager. This is a post completion
1094+
/// action. This action can only be taken at AMDGPUStreamTy::complete()
10811095
static Error releaseSignalAction(void *Data) {
10821096
ReleaseSignalArgsTy *Args = reinterpret_cast<ReleaseSignalArgsTy *>(Data);
10831097
assert(Args && "Invalid arguments");

0 commit comments

Comments
 (0)