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