@@ -1055,7 +1055,7 @@ struct AMDGPUStreamTy {
1055
1055
return false ;
1056
1056
}
1057
1057
1058
- // Callback for host-to-host memory copies.
1058
+ // Callback for host-to-host memory copies. This is an asynchronous action.
1059
1059
static Error memcpyAction (void *Data) {
1060
1060
MemcpyArgsTy *Args = reinterpret_cast <MemcpyArgsTy *>(Data);
1061
1061
assert (Args && " Invalid arguments" );
@@ -1067,7 +1067,19 @@ struct AMDGPUStreamTy {
1067
1067
return Plugin::success ();
1068
1068
}
1069
1069
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.
1071
1083
static Error releaseBufferAction (void *Data) {
1072
1084
ReleaseBufferArgsTy *Args = reinterpret_cast <ReleaseBufferArgsTy *>(Data);
1073
1085
assert (Args && " Invalid arguments" );
@@ -1078,6 +1090,8 @@ struct AMDGPUStreamTy {
1078
1090
return Args->MemoryManager ->deallocate (Args->Buffer );
1079
1091
}
1080
1092
1093
+ // / Releasing a signal object back to SignalManager. This is a post completion
1094
+ // / action. This action can only be taken at AMDGPUStreamTy::complete()
1081
1095
static Error releaseSignalAction (void *Data) {
1082
1096
ReleaseSignalArgsTy *Args = reinterpret_cast <ReleaseSignalArgsTy *>(Data);
1083
1097
assert (Args && " Invalid arguments" );
0 commit comments