diff --git a/projects/hip/vdi/hip_internal.hpp b/projects/hip/vdi/hip_internal.hpp index b4c9f60e77..129978dd68 100755 --- a/projects/hip/vdi/hip_internal.hpp +++ b/projects/hip/vdi/hip_internal.hpp @@ -129,7 +129,7 @@ namespace hip { struct Stream { amd::HostQueue* queue; - + amd::Monitor lock; Device* device; amd::CommandQueue::Priority priority; unsigned int flags; diff --git a/projects/hip/vdi/hip_stream.cpp b/projects/hip/vdi/hip_stream.cpp index b66b525699..eac42c0203 100644 --- a/projects/hip/vdi/hip_stream.cpp +++ b/projects/hip/vdi/hip_stream.cpp @@ -57,7 +57,7 @@ void syncStreams() { } Stream::Stream(hip::Device* dev, amd::CommandQueue::Priority p, unsigned int f) : - queue(nullptr), device(dev), priority(p), flags(f) {} + queue(nullptr), lock("Stream Callback lock"), device(dev), priority(p), flags(f) {} void Stream::create() { cl_command_queue_properties properties = CL_QUEUE_PROFILING_ENABLE; @@ -90,10 +90,12 @@ void Stream::finish() { }; void CL_CALLBACK ihipStreamCallback(cl_event event, cl_int command_exec_status, void* user_data) { - hipError_t status = hipSuccess; StreamCallback* cbo = reinterpret_cast(user_data); - cbo->callBack_(cbo->stream_, status, cbo->userData_); + { + amd::ScopedLock lock(reinterpret_cast(cbo->stream_)->lock); + cbo->callBack_(cbo->stream_, status, cbo->userData_); + } cbo->command_->release(); delete cbo; }