Users/dayatsin/swdev 519413 hsa amd pointer info return err shutdown (#1509)

* rocr: hsa_amd_pointer_info return err on shutdown

Decrement ref count before starting to unload to make sure API
calls during shutdown return error.

Delete blit objects during agent destructor.

* Add support for HSA_AMD_SYSTEM_SHUTDOWN_EVENT

Add support for new event to indicate shut down within the
hsa_amd_register_system_event_handler API.
Αυτή η υποβολή περιλαμβάνεται σε:
David Yat Sin
2025-10-27 09:32:52 -04:00
υποβλήθηκε από GitHub
γονέας 45d6598724
υποβολή db01d95ebc
3 αρχεία άλλαξαν με 21 προσθήκες και 4 διαγραφές
@@ -244,6 +244,8 @@ GpuAgent::GpuAgent(HSAuint32 node, const HsaNodeProperties& node_props, bool xna
}
GpuAgent::~GpuAgent() {
for (auto& blit : blits_) blit.reset();
std::for_each(regions_.begin(), regions_.end(), DeleteObject());
regions_.clear();
}
@@ -150,13 +150,22 @@ hsa_status_t Runtime::Release() {
if (runtime_singleton_ == nullptr) return HSA_STATUS_ERROR_NOT_INITIALIZED;
if (runtime_singleton_->ref_count_ == 1) {
if (runtime_singleton_->ref_count_-- == 1) {
auto system_event_handlers = runtime_singleton_->GetSystemEventHandlers();
if (!system_event_handlers.empty()) {
hsa_amd_event_t system_shutdown_event = {} ;
system_shutdown_event.event_type = HSA_AMD_SYSTEM_SHUTDOWN_EVENT;
/* Remaining fields hsa_amd_event_t are empty */
for (auto& callback : system_event_handlers) {
callback.first(&system_shutdown_event, callback.second);
}
}
// Release all registered memory, then unload backends
runtime_singleton_->Unload();
}
runtime_singleton_->ref_count_--;
if (runtime_singleton_->ref_count_ == 0) {
delete runtime_singleton_;
runtime_singleton_ = nullptr;