From 01cb5a2b6155e857cfd42207a57ecbbfbd59db6c Mon Sep 17 00:00:00 2001 From: Sreekant Somasekharan Date: Mon, 4 Oct 2021 16:39:13 -0400 Subject: [PATCH] Add test case for rsmi_is_P2P_accessible API. Change-Id: Iccfede42925c98d96454b5f25cc0ed6fc9258911 [ROCm/rocm_smi_lib commit: ce46fd237a352b46dbb3a146c9fa646b72f63328] --- .../functional/hw_topology_read.cc | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/projects/rocm-smi-lib/tests/rocm_smi_test/functional/hw_topology_read.cc b/projects/rocm-smi-lib/tests/rocm_smi_test/functional/hw_topology_read.cc index 433304f21b..7ee37561c0 100755 --- a/projects/rocm-smi-lib/tests/rocm_smi_test/functional/hw_topology_read.cc +++ b/projects/rocm-smi-lib/tests/rocm_smi_test/functional/hw_topology_read.cc @@ -59,6 +59,7 @@ typedef struct { std::string type; uint64_t hops; uint64_t weight; + bool accessible; } gpu_link_t; TestHWTopologyRead::TestHWTopologyRead() : TestBase() { @@ -135,6 +136,7 @@ void TestHWTopologyRead::Run(void) { gpu_links[dv_ind_src][dv_ind_dst].type = "X"; gpu_links[dv_ind_src][dv_ind_dst].hops = 0; gpu_links[dv_ind_src][dv_ind_dst].weight = 0; + gpu_links[dv_ind_src][dv_ind_dst].accessible = false; } else { RSMI_IO_LINK_TYPE type; err = rsmi_topo_get_link_type(dv_ind_src, dv_ind_dst, @@ -182,6 +184,20 @@ void TestHWTopologyRead::Run(void) { CHK_ERR_ASRT(err) } } + err = rsmi_is_P2P_accessible(dv_ind_src, dv_ind_dst, + &gpu_links[dv_ind_src][dv_ind_dst].accessible); + if (err != RSMI_STATUS_SUCCESS) { + if (err == RSMI_STATUS_NOT_SUPPORTED) { + IF_VERB(STANDARD) { + std::cout << + "\t**P2P Access. check: Not supported on this machine" + << std::endl; + return; + } + } else { + CHK_ERR_ASRT(err) + } + } } } } @@ -268,4 +284,21 @@ void TestHWTopologyRead::Run(void) { std::cout << std::endl; } std::cout << std::endl; + std::cout << "**Access between two GPUs**" << std::endl; + std::cout << " "; + for (i = 0; i < num_devices; ++i) { + tmp = "GPU" + std::to_string(i); + std::cout << std::setw(12) << std::left << tmp; + } + std::cout << std::endl; + for (i = 0; i < num_devices; i++) { + tmp = "GPU" + std::to_string(i); + std::cout << std::setw(6) << std::left << tmp; + for (j = 0; j < num_devices; j++) { + std::cout << std::boolalpha; + std::cout << std::setw(12) << std::left << gpu_links[i][j].accessible; + } + std::cout << std::endl; + } + std::cout << std::endl; }