[SWDEV-528647/SWDEV-528450] Reduce API load times and libdrm/libdrm_amdgpu dynamic loading (#333)
Changes:
- Removed libdrm/libdrm_amdgpu dependencies
- Added/updated new internal libdrm/libdrm_amdgpu/xf86drm APIs
to allow our APIs to reference before dynamic loading
the libdrm/libdrm_amdgpu libraries:
1. amdgpu_drm.h to what's seen in mainline
2. Added xf86drm.h to whats seen in mainline
- Modified internal DRM capabilities:
1. Require each API to independently connect to libdrm/libdrm_amdgpu
+ validate API handles reponses accordingly
2. Initialization of AMD SMI no longer has as strong of a tie to
libdrm
- Updated internal implementations of several APIs which have
connections to libdrm/libdrm_amdgpu or APIs which have conflicts
with open libdrm/libdrm_amdgpu connections:
1. amdsmi_init()
2. amdsmi_get_gpu_vram_usage()
3. amdsmi_get_gpu_asic_info()
4. amdsmi_get_gpu_vram_info()
5. amdsmi_get_gpu_vbios_info()
6. amdsmi_get_gpu_driver_info()
7. amdsmi_get_gpu_virtualization_mode()
8. amdsmi_set_gpu_memory_partition()
9. amdsmi_set_gpu_memory_partition_mode()
- Cleaned up effected tests/APIs
Change-Id: I96e2cf1b06b0cfee1b01a5e991ccc6116c4245a8
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
757aa016f4
Коммит
b5a43b7744
@@ -1,3 +1,4 @@
|
||||
set(CMAKE_VERBOSE_MAKEFILE on)
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
|
||||
option(ENABLE_ESMI_LIB "Build ESMI Library" ON)
|
||||
|
||||
@@ -255,6 +255,26 @@ mapStringToSMIMemoryPartitionTypes {
|
||||
{"N/A", AMDSMI_MEMORY_PARTITION_UNKNOWN}
|
||||
};
|
||||
|
||||
static const std::map<amdsmi_virtualization_mode_t, std::string>
|
||||
virtualization_mode_map = {
|
||||
{AMDSMI_VIRTUALIZATION_MODE_UNKNOWN, "UNKNOWN"},
|
||||
{AMDSMI_VIRTUALIZATION_MODE_BAREMETAL, "BAREMETAL"},
|
||||
{ AMDSMI_VIRTUALIZATION_MODE_HOST, "HOST"},
|
||||
{ AMDSMI_VIRTUALIZATION_MODE_GUEST, "GUEST"},
|
||||
{AMDSMI_VIRTUALIZATION_MODE_PASSTHROUGH, "PASSTHROUGH"}
|
||||
};
|
||||
|
||||
static const std::map<processor_type_t, std::string>
|
||||
processor_type_map = {
|
||||
{AMDSMI_PROCESSOR_TYPE_UNKNOWN, "UNKNOWN"},
|
||||
{AMDSMI_PROCESSOR_TYPE_AMD_GPU, "AMD_GPU"},
|
||||
{AMDSMI_PROCESSOR_TYPE_AMD_CPU, "AMD_CPU"},
|
||||
{AMDSMI_PROCESSOR_TYPE_NON_AMD_GPU, "NON_AMD_GPU"},
|
||||
{AMDSMI_PROCESSOR_TYPE_NON_AMD_CPU, "NON_AMD_CPU"},
|
||||
{AMDSMI_PROCESSOR_TYPE_AMD_CPU_CORE, "AMD_CPU_CORE"},
|
||||
{AMDSMI_PROCESSOR_TYPE_AMD_APU, "AMD_APU"}
|
||||
};
|
||||
|
||||
int main() {
|
||||
amdsmi_status_t ret, ret_set;
|
||||
const char *err_str;
|
||||
@@ -304,7 +324,10 @@ int main() {
|
||||
// For each device of the socket, get name and temperature.
|
||||
for (uint32_t device_index = 0; device_index < device_count; device_index++) {
|
||||
std::cout << "Device Index: " << device_index << std::endl;
|
||||
#ifdef ENABLE_ESMI_LIB
|
||||
|
||||
// Commenting out the code to get CPU socket count and GPU count
|
||||
// Doesn't work on system with no supported CPU sockets
|
||||
#if 0
|
||||
uint32_t cpu_sockets = 0;
|
||||
uint32_t gpus = 0;
|
||||
ret = amdsmi_get_processor_count_from_handles(&processor_handles[device_index], &device_count, &cpu_sockets, nullptr, &gpus);
|
||||
@@ -318,6 +341,13 @@ int main() {
|
||||
processor_type_t processor_type = {};
|
||||
ret = amdsmi_get_processor_type(processor_handles[device_index], &processor_type);
|
||||
CHK_AMDSMI_RET(ret)
|
||||
|
||||
auto it = processor_type_map.find(processor_type);
|
||||
if (it != processor_type_map.end()) {
|
||||
std::cout << "\t**Processor Type: " << it->second << std::endl;
|
||||
} else {
|
||||
std::cout << "\t**Processor Type: MAP TYPE UNKNOWN?" << std::endl;
|
||||
}
|
||||
if (processor_type != AMDSMI_PROCESSOR_TYPE_AMD_GPU) {
|
||||
std::cout << "Expect AMDSMI_PROCESSOR_TYPE_AMD_GPU device type!\n";
|
||||
return AMDSMI_STATUS_NOT_SUPPORTED;
|
||||
@@ -359,6 +389,19 @@ int main() {
|
||||
printf("\tPower Management Enabled: %s\n\n",
|
||||
(is_power_management_enabled ? "TRUE" : "FALSE"));
|
||||
|
||||
amdsmi_virtualization_mode_t vmode;
|
||||
ret = amdsmi_get_gpu_virtualization_mode(processor_handles[device_index], &vmode);
|
||||
if (ret != AMDSMI_STATUS_NOT_SUPPORTED) {
|
||||
CHK_AMDSMI_RET(ret)
|
||||
}
|
||||
|
||||
auto it2 = virtualization_mode_map.find(vmode);
|
||||
if (it2 != virtualization_mode_map.end()) {
|
||||
std::cout << "\t**Virtualization Mode: " << it2->second << std::endl;
|
||||
} else {
|
||||
std::cout << "\t**Virtualization Mode: MAP TYPE UNKNOWN?" << std::endl;
|
||||
}
|
||||
|
||||
std::cout << " **Version 1: Accelerator/Compute Partition API Examples**\n";
|
||||
char original_compute_partition[AMDSMI_MAX_STRING_LENGTH];
|
||||
ret = amdsmi_get_gpu_compute_partition(processor_handles[device_index], original_compute_partition,
|
||||
@@ -1376,7 +1419,9 @@ int main() {
|
||||
for (uint32_t k = 0; k < topology_nearest_info.count; k++) {
|
||||
amdsmi_bdf_t bdf = {};
|
||||
ret = amdsmi_get_gpu_device_bdf(topology_nearest_info.processor_list[k], &bdf);
|
||||
CHK_AMDSMI_RET(ret)
|
||||
if (ret != AMDSMI_STATUS_INVAL) {
|
||||
CHK_AMDSMI_RET(ret);
|
||||
}
|
||||
printf("\t\tGPU BDF %04" PRIx64 ":%02" PRIx32 ":%02" PRIx32 ".%" PRIu32 "\n",
|
||||
static_cast<uint64_t>(bdf.domain_number),
|
||||
static_cast<uint32_t>(bdf.bus_number),
|
||||
|
||||
Ссылка в новой задаче
Block a user