SWDEV-480209 - Make internal callbacks non-blocking

Change-Id: Ic918d08f341abfd9a7c167d09f9c723cdc43157f
This commit is contained in:
Anusha GodavarthySurya
2024-10-28 09:23:25 +00:00
committed by Anusha Godavarthy Surya
parent c9dd95bf6c
commit 683a942364
11 changed files with 38 additions and 34 deletions
+2
View File
@@ -1476,6 +1476,8 @@ hipError_t hipGraphExecDestroy(hipGraphExec_t pGraphExec) {
}
hip::GraphExec* ge = reinterpret_cast<hip::GraphExec*>(pGraphExec);
ge->release();
amd::ScopedLock lock(GraphExec::graphExecSetLock_);
GraphExec::graphExecSet_.erase(ge);
HIP_RETURN(hipSuccess);
}
+2 -12
View File
@@ -732,21 +732,11 @@ hipError_t GraphExec::Run(hipStream_t graph_launch_stream) {
// we may not need to flush any caches.
CallbackCommand->setEventScope(amd::Device::kCacheStateIgnore);
amd::Event& event = CallbackCommand->event();
if (!event.setCallback(CL_COMPLETE, GraphExec::DecrementRefCount, this)) {
constexpr bool kBlocking = false;
if (!event.setCallback(CL_COMPLETE, GraphExec::DecrementRefCount, this, kBlocking)) {
return hipErrorInvalidHandle;
}
CallbackCommand->enqueue();
// Add the new barrier to stall the stream, until the callback is done
amd::Command::EventWaitList eventWaitList;
eventWaitList.push_back(CallbackCommand);
amd::Command* block_command = new amd::Marker(*launch_stream, kMarkerDisableFlush, eventWaitList);
// we may not need to flush any caches.
block_command->setEventScope(amd::Device::kCacheStateIgnore);
if (block_command == nullptr) {
return hipErrorInvalidValue;
}
block_command->enqueue();
block_command->release();
CallbackCommand->release();
return status;
}
+2 -4
View File
@@ -750,12 +750,10 @@ struct GraphExec : public amd::ReferenceCountedObject, public Graph {
~GraphExec() {
for (auto stream : parallel_streams_) {
if (stream != nullptr) {
stream->finish();
hip::Stream::Destroy(stream);
constexpr bool kForceDestroy = true;
hip::Stream::Destroy(stream, kForceDestroy);
}
}
amd::ScopedLock lock(graphExecSetLock_);
graphExecSet_.erase(this);
if (DEBUG_CLR_GRAPH_PACKET_CAPTURE) {
if (kernArgManager_ != nullptr) {
kernArgManager_->release();
+1 -1
View File
@@ -372,7 +372,7 @@ public:
/// Check whether any blocking stream running
static bool StreamCaptureBlocking();
static void Destroy(hip::Stream* stream);
static void Destroy(hip::Stream* stream, bool forceDestroy = false);
virtual bool terminate();
+2 -1
View File
@@ -72,8 +72,9 @@ bool Stream::Create() {
}
// ================================================================================================
void Stream::Destroy(hip::Stream* stream) {
void Stream::Destroy(hip::Stream* stream, bool forceDestroy) {
stream->device_->RemoveStream(stream);
stream->SetForceDestroy(forceDestroy);
stream->release();
stream = nullptr;
}