rocr: Move OpenSMI call to Driver

This commit is contained in:
Tony Gutierrez
2025-06-17 12:25:21 -07:00
committed by Gutierrez, Tony
parent 2ca4d8f6d4
commit 1a339feb1f
4 changed files with 23 additions and 7 deletions
@@ -484,6 +484,13 @@ hsa_status_t KfdDriver::SPMSetDestBuffer(uint32_t preferred_node_id, uint32_t si
return HSA_STATUS_SUCCESS;
}
hsa_status_t KfdDriver::OpenSMI(uint32_t node_id, int* fd) const {
if (HSAKMT_CALL(hsaKmtOpenSMI(node_id, fd)) != HSAKMT_STATUS_SUCCESS) {
return HSA_STATUS_ERROR;
}
return HSA_STATUS_SUCCESS;
}
void *KfdDriver::AllocateKfdMemory(const HsaMemFlags &flags, uint32_t node_id,
size_t size) {
void *mem = nullptr;
@@ -123,6 +123,8 @@ public:
uint32_t* size_copied, void* dest_mem_addr,
bool* is_spm_data_loss) const override;
hsa_status_t OpenSMI(uint32_t node_id, int* fd) const override;
hsa_status_t IsModelEnabled(bool* enable) const override;
private:
+9
View File
@@ -249,6 +249,15 @@ public:
uint32_t* timeout, uint32_t* size_copied,
void* dest_mem_addr, bool* is_spm_data_loss) const = 0;
/// @brief Open anonymous file descriptor to enable events and read SMI events.
/// @param[in] node_id Node ID to receive the SMI event from.
/// @param[out] fd Anonymous file descriptor.
/// @retval HSA_STATUS_ERROR_INVALID_AGENT if the agent's driver doesn't support
/// SMI events.
virtual hsa_status_t OpenSMI(uint32_t node_id, int* fd) const {
return HSA_STATUS_ERROR_INVALID_AGENT;
}
/// @brief Check if the HSA KMT Model is enabled
/// @param[out] enable True if the model is enabled, false otherwise
virtual hsa_status_t IsModelEnabled(bool* enable) const = 0;
@@ -3,7 +3,7 @@
// The University of Illinois/NCSA
// Open Source License (NCSA)
//
// Copyright (c) 2022-2022, Advanced Micro Devices, Inc. All rights reserved.
// Copyright (c) 2022-2025, Advanced Micro Devices, Inc. All rights reserved.
//
// Developed by:
//
@@ -47,8 +47,6 @@
#include <sys/eventfd.h>
#include <poll.h>
#include "hsakmt/hsakmt.h"
#include "core/util/utils.h"
#include "core/inc/runtime.h"
#include "core/inc/agent.h"
@@ -143,9 +141,9 @@ void SvmProfileControl::PollSmi() {
HSA_SMI_EVENT_MASK_FROM_INDEX(HSA_SMI_EVENT_UNMAP_FROM_GPU);
for (int i = 0; i < core::Runtime::runtime_singleton_->gpu_agents().size(); i++) {
auto err = HSAKMT_CALL(hsaKmtOpenSMI(core::Runtime::runtime_singleton_->gpu_agents()[i]->node_id(),
&files[i + 1].fd));
assert(err == HSAKMT_STATUS_SUCCESS);
auto gpu_agent = core::Runtime::runtime_singleton_->gpu_agents()[i];
auto err = gpu_agent->driver().OpenSMI(gpu_agent->node_id(), &files[i + 1].fd);
assert(err == HSA_STATUS_SUCCESS);
files[i + 1].events = POLLIN;
files[i + 1].revents = 0;
// Enable collecting masked events.
@@ -377,6 +375,6 @@ std::string SvmProfileControl::format(const char* format, Args... args) {
}
return std::string(&format_buffer[0]);
}
} // namespace AMD
} // namespace rocr