From 3c623309cd273542d1faa5f63ed46572e693c4c5 Mon Sep 17 00:00:00 2001 From: Christophe Paquot Date: Fri, 20 Mar 2020 13:06:11 -0700 Subject: [PATCH] hipStreamAddCallback test seg faults Change-Id: If419d2fad490d0ed50eb1315af809fc1deda1ce3 SWDEV-227875: Add a lock in streams to lock when the callback is call so we make sure things aren't moving forward in the stream [ROCm/hip commit: 653277bd3f6e3332f318423519b4dfce6b492ff5] --- projects/hip/vdi/hip_internal.hpp | 2 +- projects/hip/vdi/hip_stream.cpp | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) 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; }