SWDEV-559166 - Fix race condition in getDemangledName (#1868)
This commit is contained in:
committed by
GitHub
parent
7313c3752a
commit
36029ea1a8
@@ -48,20 +48,14 @@ class Kernel : public device::Kernel {
|
||||
|
||||
//! Pull demangled name, used only for logging
|
||||
const std::string& getDemangledName() {
|
||||
if (demangled_name_.empty()) {
|
||||
initDemangledName();
|
||||
}
|
||||
std::call_once(demangle_once_, [this] {
|
||||
amd::Os::CxaDemangle(name(), &demangled_name_);
|
||||
});
|
||||
return demangled_name_;
|
||||
}
|
||||
|
||||
private:
|
||||
void initDemangledName() {
|
||||
if (demangled_name_.empty()) {
|
||||
amd::Os::CxaDemangle(name(), &demangled_name_);
|
||||
}
|
||||
}
|
||||
|
||||
std::string demangled_name_; //!< Cache demangled name
|
||||
std::once_flag demangle_once_;
|
||||
};
|
||||
|
||||
} // namespace amd::roc
|
||||
|
||||
@@ -66,9 +66,8 @@ Event::~Event() {
|
||||
delete callback;
|
||||
callback = next;
|
||||
}
|
||||
// Release the notify event
|
||||
if (notify_event_ != nullptr) {
|
||||
notify_event_->release();
|
||||
if (auto* notifyEvent = notify_event_.load(std::memory_order_acquire)) {
|
||||
notifyEvent->release();
|
||||
}
|
||||
// Destroy global HW event if available
|
||||
if ((hw_event_ != nullptr) && (device_ != nullptr)) {
|
||||
@@ -269,11 +268,10 @@ bool Event::notifyCmdQueue(bool cpu_wait) {
|
||||
// If HW event was assigned, then notification can be ignored, since a barrier was issued
|
||||
// @note: Force the marker always in OCL for now, since OCL events require precise
|
||||
// sequence of the status update
|
||||
((HwEvent() == nullptr) || !amd::IS_HIP) && !notified_.test_and_set()) {
|
||||
((HwEvent() == nullptr) || !amd::IS_HIP) && (notify_event_ == nullptr)) {
|
||||
// Make sure the queue is draining the enqueued commands.
|
||||
amd::Command* command = new amd::Marker(*queue, false, nullWaitList, this, cpu_wait);
|
||||
if (command == NULL) {
|
||||
notified_.clear();
|
||||
return false;
|
||||
}
|
||||
command->enqueue();
|
||||
|
||||
@@ -90,7 +90,7 @@ class Event : public RuntimeObject {
|
||||
std::atomic_flag notified_; //!< Command queue was notified
|
||||
|
||||
void* hw_event_; //!< HW event ID associated with SW event
|
||||
Event* notify_event_; //!< Notify event, which should contain HW signal
|
||||
std::atomic<Event*> notify_event_; //!< Notify event, which should contain HW signal
|
||||
const Device* device_; //!< Device, this event associated with
|
||||
|
||||
std::atomic<int32_t> event_entry_scope_; //!< Command entry scope
|
||||
@@ -219,7 +219,7 @@ class Event : public RuntimeObject {
|
||||
void* HwEvent() const { return hw_event_; }
|
||||
|
||||
//! Returns notify even associated with the current command
|
||||
Event* NotifyEvent() const {ScopedLock l(notify_lock_); return notify_event_; }
|
||||
Event* NotifyEvent() const { return notify_event_; }
|
||||
|
||||
//! Get entry scope of the event
|
||||
int32_t getCommandEntryScope() const {
|
||||
|
||||
Reference in New Issue
Block a user