Skip to content

Commit

Permalink
[libomptarget] document ActionFunctions in the amdgpu plugin. (#66397)
Browse files Browse the repository at this point in the history
  • Loading branch information
ye-luo committed Sep 14, 2023
1 parent 5ec9699 commit 8c2da6b
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -1067,7 +1067,19 @@ 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()
/// Because of the case 3, all releaseBufferActions are taken at
/// AMDGPUStreamTy::complete() in the current implementation.
static Error releaseBufferAction(void *Data) {
ReleaseBufferArgsTy *Args = reinterpret_cast<ReleaseBufferArgsTy *>(Data);
assert(Args && "Invalid arguments");
Expand All @@ -1078,6 +1090,8 @@ struct AMDGPUStreamTy {
return Args->MemoryManager->deallocate(Args->Buffer);
}

/// Releasing a signal object back to SignalManager. 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");
Expand Down

0 comments on commit 8c2da6b

Please sign in to comment.