Change variable name from device to processor
device_count to processor_count
devices to processor
device to processor
also handle_to_device is renamed to handle_to_processor
Change-Id: Ie9c7e01bc1b83058eeaae80934526d06468f4f5c
[ROCm/amdsmi commit: 6e6176b04a]
Этот коммит содержится в:
коммит произвёл
Naveen Krishna Chatradhi
родитель
dd840db708
Коммит
320b708b6e
@@ -69,7 +69,7 @@ class AMDSmiSystem {
|
||||
amdsmi_status_t handle_to_socket(amdsmi_socket_handle socket_handle,
|
||||
AMDSmiSocket** socket);
|
||||
|
||||
amdsmi_status_t handle_to_device(amdsmi_processor_handle processor_handle,
|
||||
amdsmi_status_t handle_to_processor(amdsmi_processor_handle processor_handle,
|
||||
AMDSmiProcessor** device);
|
||||
|
||||
amdsmi_status_t gpu_index_to_handle(uint32_t gpu_index,
|
||||
@@ -82,7 +82,7 @@ class AMDSmiSystem {
|
||||
uint64_t init_flag_;
|
||||
AMDSmiDrm drm_;
|
||||
std::vector<AMDSmiSocket*> sockets_;
|
||||
std::set<AMDSmiProcessor*> devices_; // Track valid devices
|
||||
std::set<AMDSmiProcessor*> processors_; // Track valid processors
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ static amdsmi_status_t get_gpu_device_from_handle(amdsmi_processor_handle proces
|
||||
|
||||
amd::smi::AMDSmiProcessor* device = nullptr;
|
||||
amdsmi_status_t r = amd::smi::AMDSmiSystem::getInstance()
|
||||
.handle_to_device(processor_handle, &device);
|
||||
.handle_to_processor(processor_handle, &device);
|
||||
if (r != AMDSMI_STATUS_SUCCESS) return r;
|
||||
|
||||
if (device->get_processor_type() == AMD_GPU) {
|
||||
@@ -215,11 +215,11 @@ amdsmi_status_t amdsmi_get_socket_info(
|
||||
}
|
||||
|
||||
amdsmi_status_t amdsmi_get_processor_handles(amdsmi_socket_handle socket_handle,
|
||||
uint32_t* device_count,
|
||||
uint32_t* processor_count,
|
||||
amdsmi_processor_handle* processor_handles) {
|
||||
AMDSMI_CHECK_INIT();
|
||||
|
||||
if (device_count == nullptr) {
|
||||
if (processor_count == nullptr) {
|
||||
return AMDSMI_STATUS_INVAL;
|
||||
}
|
||||
|
||||
@@ -230,20 +230,20 @@ amdsmi_status_t amdsmi_get_processor_handles(amdsmi_socket_handle socket_handle,
|
||||
if (r != AMDSMI_STATUS_SUCCESS) return r;
|
||||
|
||||
|
||||
std::vector<amd::smi::AMDSmiProcessor*>& devices = socket->get_processors();
|
||||
uint32_t device_size = static_cast<uint32_t>(devices.size());
|
||||
// Get the device count only
|
||||
std::vector<amd::smi::AMDSmiProcessor*>& processors = socket->get_processors();
|
||||
uint32_t processor_size = static_cast<uint32_t>(processors.size());
|
||||
// Get the processor count only
|
||||
if (processor_handles == nullptr) {
|
||||
*device_count = device_size;
|
||||
*processor_count = processor_size;
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
// If the processor_handles can hold all devices, return all of them.
|
||||
*device_count = *device_count >= device_size ? device_size : *device_count;
|
||||
// If the processor_handles can hold all processors, return all of them.
|
||||
*processor_count = *processor_count >= processor_size ? processor_size : *processor_count;
|
||||
|
||||
// Copy the device handles
|
||||
for (uint32_t i = 0; i < *device_count; i++) {
|
||||
processor_handles[i] = reinterpret_cast<amdsmi_processor_handle>(devices[i]);
|
||||
// Copy the processor handles
|
||||
for (uint32_t i = 0; i < *processor_count; i++) {
|
||||
processor_handles[i] = reinterpret_cast<amdsmi_processor_handle>(processors[i]);
|
||||
}
|
||||
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
@@ -257,11 +257,11 @@ amdsmi_status_t amdsmi_get_processor_type(amdsmi_processor_handle processor_hand
|
||||
if (processor_type == nullptr) {
|
||||
return AMDSMI_STATUS_INVAL;
|
||||
}
|
||||
amd::smi::AMDSmiProcessor* device = nullptr;
|
||||
amd::smi::AMDSmiProcessor* processor = nullptr;
|
||||
amdsmi_status_t r = amd::smi::AMDSmiSystem::getInstance()
|
||||
.handle_to_device(processor_handle, &device);
|
||||
.handle_to_processor(processor_handle, &processor);
|
||||
if (r != AMDSMI_STATUS_SUCCESS) return r;
|
||||
*processor_type = device->get_processor_type();
|
||||
*processor_type = processor->get_processor_type();
|
||||
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
}
|
||||
@@ -357,7 +357,7 @@ amdsmi_status_t amdsmi_get_vram_usage(amdsmi_processor_handle processor_handle,
|
||||
|
||||
amd::smi::AMDSmiProcessor* device = nullptr;
|
||||
amdsmi_status_t ret = amd::smi::AMDSmiSystem::getInstance()
|
||||
.handle_to_device(processor_handle, &device);
|
||||
.handle_to_processor(processor_handle, &device);
|
||||
if (ret != AMDSMI_STATUS_SUCCESS) return ret;
|
||||
|
||||
if (device->get_processor_type() != AMD_GPU) {
|
||||
@@ -399,7 +399,7 @@ amdsmi_status_t amdsmi_get_caps_info(amdsmi_processor_handle processor_handle,
|
||||
|
||||
amd::smi::AMDSmiProcessor* amd_device = nullptr;
|
||||
amdsmi_status_t ret = amd::smi::AMDSmiSystem::getInstance()
|
||||
.handle_to_device(processor_handle, &amd_device);
|
||||
.handle_to_processor(processor_handle, &amd_device);
|
||||
if (ret != AMDSMI_STATUS_SUCCESS) return ret;
|
||||
|
||||
if (amd_device->get_processor_type() != AMD_GPU) {
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace smi {
|
||||
amdsmi_status_t AMDSmiSystem::init(uint64_t flags) {
|
||||
init_flag_ = flags;
|
||||
amdsmi_status_t amd_smi_status;
|
||||
// populate sockets and devices
|
||||
// populate sockets and processors
|
||||
if (flags & AMDSMI_INIT_AMD_GPUS) {
|
||||
amd_smi_status = populate_amd_gpu_devices();
|
||||
if (amd_smi_status != AMDSMI_STATUS_SUCCESS)
|
||||
@@ -106,7 +106,7 @@ amdsmi_status_t AMDSmiSystem::populate_amd_gpu_devices() {
|
||||
|
||||
AMDSmiProcessor* device = new AMDSmiGPUDevice(i, drm_);
|
||||
socket->add_processor(device);
|
||||
devices_.insert(device);
|
||||
processors_.insert(device);
|
||||
}
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
}
|
||||
@@ -136,7 +136,7 @@ amdsmi_status_t AMDSmiSystem::cleanup() {
|
||||
for (uint32_t i = 0; i < sockets_.size(); i++) {
|
||||
delete sockets_[i];
|
||||
}
|
||||
devices_.clear();
|
||||
processors_.clear();
|
||||
sockets_.clear();
|
||||
init_flag_ = AMDSMI_INIT_ALL_DEVICES;
|
||||
rsmi_status_t ret = rsmi_shut_down();
|
||||
@@ -164,17 +164,17 @@ amdsmi_status_t AMDSmiSystem::handle_to_socket(
|
||||
return AMDSMI_STATUS_INVAL;
|
||||
}
|
||||
|
||||
amdsmi_status_t AMDSmiSystem::handle_to_device(
|
||||
amdsmi_status_t AMDSmiSystem::handle_to_processor(
|
||||
amdsmi_processor_handle processor_handle,
|
||||
AMDSmiProcessor** device) {
|
||||
if (processor_handle == nullptr || device == nullptr) {
|
||||
AMDSmiProcessor** processor) {
|
||||
if (processor_handle == nullptr || processor == nullptr) {
|
||||
return AMDSMI_STATUS_INVAL;
|
||||
}
|
||||
*device = static_cast<AMDSmiProcessor*>(processor_handle);
|
||||
*processor = static_cast<AMDSmiProcessor*>(processor_handle);
|
||||
|
||||
// double check handlers is here
|
||||
if (std::find(devices_.begin(), devices_.end(), *device)
|
||||
!= devices_.end()) {
|
||||
if (std::find(processors_.begin(), processors_.end(), *processor)
|
||||
!= processors_.end()) {
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
}
|
||||
return AMDSMI_STATUS_NOT_FOUND;
|
||||
@@ -185,8 +185,8 @@ amdsmi_status_t AMDSmiSystem::gpu_index_to_handle(uint32_t gpu_index,
|
||||
if (processor_handle == nullptr)
|
||||
return AMDSMI_STATUS_INVAL;
|
||||
|
||||
auto iter = devices_.begin();
|
||||
for (; iter != devices_.end(); iter++) {
|
||||
auto iter = processors_.begin();
|
||||
for (; iter != processors_.end(); iter++) {
|
||||
auto cur_device = (*iter);
|
||||
if (cur_device->get_processor_type() != AMD_GPU)
|
||||
continue;
|
||||
|
||||
Ссылка в новой задаче
Block a user