SWDEV-272496 - Detect callbacks and force AQL barrier

HIP tests require HIP callbacks to be processed in another thread.
This change will use a thread from HSA signal callbacks to make
sure a HIP callback was done asynchronously.
Also process the callback before changing the status of command

Change-Id: Icef85d0e0f808663882cf6881ff1be3e5eca29ac


[ROCm/clr commit: 7f32d0b425]
This commit is contained in:
German Andryeyev
2021-03-03 17:28:58 -05:00
parent 44eb6b02dc
commit 3a4d69def2
3 changed files with 32 additions and 7 deletions
@@ -2853,9 +2853,18 @@ void VirtualGPU::flush(amd::Command* list, bool wait) {
if (skip_cpu_wait) {
// Search for the last command in the batch to track GPU state
amd::Command* current = list;
// HIP tests expect callbacks processed from another thread, hence force AQL barrier always, so
// HSA signal callback will process HIP callback asynchronously
if (list->Callback() != nullptr) {
hasPendingDispatch_ = true;
}
while (current->getNext() != nullptr) {
current = current->getNext();
if (current->Callback() != nullptr) {
hasPendingDispatch_ = true;
}
}
// Enable profiling, so runtime can track TS
profilingBegin(*current);
+20 -7
View File
@@ -105,13 +105,26 @@ bool Event::setStatus(int32_t status, uint64_t timeStamp) {
}
}
if (!status_.compare_exchange_strong(currentStatus, status, std::memory_order_relaxed)) {
// Somebody else beat us to it, let them deal with the release/signal.
return false;
}
if (callbacks_ != (CallBackEntry*)0) {
processCallbacks(status);
if (amd::IS_HIP) {
// HIP API doesn't have any event, associated with a callback. Hence the SW status of
// the event is irrelevant, during the actual callback. At the same time HIP API requires
// to finish the callback before HIP stream can continue. Hence runtime has to process
// the callback first and then update the status.
if (callbacks_ != (CallBackEntry*)0) {
processCallbacks(status);
}
if (!status_.compare_exchange_strong(currentStatus, status, std::memory_order_relaxed)) {
// Somebody else beat us to it, let them deal with the release/signal.
return false;
}
} else {
if (!status_.compare_exchange_strong(currentStatus, status, std::memory_order_relaxed)) {
// Somebody else beat us to it, let them deal with the release/signal.
return false;
}
if (callbacks_ != (CallBackEntry*)0) {
processCallbacks(status);
}
}
if (Agent::shouldPostEventEvents() && command().type() != 0) {
+3
View File
@@ -204,6 +204,9 @@ class Event : public RuntimeObject {
//! RTTI internal implementation
virtual ObjectType objectType() const { return ObjectTypeEvent; }
//! Returns the callback for this event
const CallBackEntry* Callback() const { return callbacks_; }
};
/*! \brief An operation that is submitted to a command queue.