From a4e46d09e2bef0f2daac7cd77e185dc24aa6d026 Mon Sep 17 00:00:00 2001 From: ajay Date: Tue, 11 Jan 2022 14:46:44 -0600 Subject: [PATCH] SWDEV-314307 - hipStreamWaitEvent to wait on remote IPC events Change-Id: Id97524ae9bc86d38376af2b0240f10d0dd5cc584 [ROCm/clr commit: bafc5bb30fe24556bf614b8119629b66a442458d] --- projects/clr/hipamd/CMakeLists.txt | 2 +- projects/clr/hipamd/src/hip_event_ipc.cpp | 31 ++++++++--------------- projects/clr/hipamd/src/hip_stream.cpp | 1 + 3 files changed, 13 insertions(+), 21 deletions(-) diff --git a/projects/clr/hipamd/CMakeLists.txt b/projects/clr/hipamd/CMakeLists.txt index af615cfa5f..07ace4c737 100755 --- a/projects/clr/hipamd/CMakeLists.txt +++ b/projects/clr/hipamd/CMakeLists.txt @@ -332,7 +332,6 @@ endif() execute_process(COMMAND test ${CMAKE_INSTALL_PREFIX} -ef ${CMAKE_CURRENT_SOURCE_DIR} RESULT_VARIABLE INSTALL_SOURCE) if(NOT ${INSTALL_SOURCE} EQUAL 0) - # Exclude .bat files on Linux. if(WIN32) install(DIRECTORY ${HIP_COMMON_BIN_DIR} DESTINATION . USE_SOURCE_PERMISSIONS) if (CMAKE_BUILD_TYPE STREQUAL "Debug") @@ -347,6 +346,7 @@ if(NOT ${INSTALL_SOURCE} EQUAL 0) PATTERN "libamdhsacode" EXCLUDE) endif() else() + # Exclude .bat files on Linux. install(DIRECTORY ${HIP_COMMON_BIN_DIR} DESTINATION . USE_SOURCE_PERMISSIONS PATTERN *.bat EXCLUDE) endif() diff --git a/projects/clr/hipamd/src/hip_event_ipc.cpp b/projects/clr/hipamd/src/hip_event_ipc.cpp index dea4a0e5f4..720701aac3 100644 --- a/projects/clr/hipamd/src/hip_event_ipc.cpp +++ b/projects/clr/hipamd/src/hip_event_ipc.cpp @@ -116,18 +116,18 @@ hipError_t IPCEvent::enqueueStreamWaitCommand(hipStream_t stream, amd::Command* hipError_t IPCEvent::streamWait(hipStream_t stream, uint flags) { amd::HostQueue* queue = hip::getQueue(stream); - // Access to event_ object must be lock protected + amd::ScopedLock lock(lock_); - if ((event_ == nullptr) || (event_->command().queue() == queue) || ready()) { - return hipSuccess; - } - amd::Command* command; - hipError_t status = streamWaitCommand(command, queue); - if (status != hipSuccess) { + if(query() != hipSuccess) { + amd::Command* command; + hipError_t status = streamWaitCommand(command, queue); + if (status != hipSuccess) { + return status; + } + status = enqueueStreamWaitCommand(stream, command); return status; } - status = enqueueStreamWaitCommand(stream, command); - return status; + return hipSuccess; } hipError_t IPCEvent::recordCommand(amd::Command*& command, amd::HostQueue* queue) { @@ -163,17 +163,8 @@ hipError_t IPCEvent::enqueueRecordCommand(hipStream_t stream, amd::Command* comm return hipErrorInvalidHandle; } command->enqueue(); - tEvent.notifyCmdQueue(); - - // Add the new barrier to stall the stream, until the callback is done - amd::Command::EventWaitList eventWaitList; - eventWaitList.push_back(command); - amd::Command* block_command = new amd::Marker(*queue, !kMarkerDisableFlush, eventWaitList); - if (block_command == nullptr) { - return hipErrorInvalidValue; - } - block_command->enqueue(); - block_command->release(); + // waiting for the call back to be called + command->awaitCompletion(); // Update read index to indicate new signal. int expected = write_index - 1; diff --git a/projects/clr/hipamd/src/hip_stream.cpp b/projects/clr/hipamd/src/hip_stream.cpp index 678af44fc5..9c8ee495f0 100644 --- a/projects/clr/hipamd/src/hip_stream.cpp +++ b/projects/clr/hipamd/src/hip_stream.cpp @@ -430,6 +430,7 @@ void WaitThenDecrementSignal(hipStream_t stream, hipError_t status, void* user_d int offset = data->previous_read_index % IPC_SIGNALS_PER_EVENT; while (data->shmem->read_index < data->previous_read_index + IPC_SIGNALS_PER_EVENT && data->shmem->signal[offset] != 0) { + amd::Os::sleep(1); } delete data; }