SWDEV-486602 - Add tracking of HSA handlers

Add an atomic counter to track the outstanding HSA handlers.
Wait on CPU for the callbacks if the number exceeds the value
in DEBUG_HIP_BLOCK_SYNC env variable.

Change-Id: I95dc8c4bf0258c7e59411b7504220709ed6898c5
Этот коммит содержится в:
German Andryeyev
2024-10-23 16:15:46 -04:00
родитель 556390f9c7
Коммит 403f624bf8
4 изменённых файлов: 17 добавлений и 9 удалений
+2 -7
Просмотреть файл
@@ -359,14 +359,9 @@ hipError_t hipStreamSynchronize_common(hipStream_t stream) {
}
bool wait = (stream == nullptr || stream == hipStreamLegacy) ? true : false;
auto hip_stream = hip::getStream(stream, wait);
bool wait_for_cpu = false;
// Force blocking wait if requested. That allows to avoid a build up of unreleased CPU commands
if (DEBUG_HIP_BLOCK_SYNC != 0) {
static std::atomic<uint64_t> flush = 0;
wait_for_cpu = ((++flush % DEBUG_HIP_BLOCK_SYNC) == 0) ? true : false;
}
// Wait for the current host queue
hip_stream->finish(wait_for_cpu);
hip_stream->finish();
// Release freed memory for all memory pools on the device
hip_stream->GetDevice()->ReleaseFreedMemory();
return hipSuccess;