Unverified Commit 6c478599 authored by Ramesh Errabolu's avatar Ramesh Errabolu Committed by GitHub
Browse files

Merge pull request #24 from RadeonOpenCompute/addBusDevFunc

Print Bus-Device-Func Ids of a Gpu device
parents d95be1a8 07a95fd2
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
#include "base_test.hpp" #include "base_test.hpp"
#include "hsatimer.hpp" #include "hsatimer.hpp"
#include "common.hpp" #include "common.hpp"
#include <vector> #include <vector>
using namespace std; using namespace std;
...@@ -66,7 +67,8 @@ typedef struct agent_info { ...@@ -66,7 +67,8 @@ typedef struct agent_info {
uint32_t index_; uint32_t index_;
hsa_agent_t agent_; hsa_agent_t agent_;
hsa_device_type_t device_type_; hsa_device_type_t device_type_;
char name_[64]; // Size specified in public header file char name_[64]; // Size specified in public header file
char bdf_id_[16]; // Bus (8-bits), Device (5-bits), Function (3-bits)
} agent_info_t; } agent_info_t;
...@@ -323,6 +325,9 @@ class RocmBandwidthTest : public BaseTest { ...@@ -323,6 +325,9 @@ class RocmBandwidthTest : public BaseTest {
// relevant data structures used to maintain system topology // relevant data structures used to maintain system topology
friend hsa_status_t AgentInfo(hsa_agent_t agent, void* data); friend hsa_status_t AgentInfo(hsa_agent_t agent, void* data);
friend hsa_status_t MemPoolInfo(hsa_amd_memory_pool_t pool, void* data); friend hsa_status_t MemPoolInfo(hsa_amd_memory_pool_t pool, void* data);
// Populate the Bus Device Function of Gpu device
friend void PopulateBDF(uint32_t bdf_id, agent_info_t *agent_info);
// Structure of Version used to identify an instance of RocmBandwidthTest // Structure of Version used to identify an instance of RocmBandwidthTest
struct RocmBandwidthVersion { struct RocmBandwidthVersion {
......
...@@ -99,10 +99,15 @@ void RocmBandwidthTest::PrintTopology() { ...@@ -99,10 +99,15 @@ void RocmBandwidthTest::PrintTopology() {
std::cout << ""; std::cout << "";
std::cout.width(format); std::cout.width(format);
if (HSA_DEVICE_TYPE_CPU == node.agent.device_type_) if (HSA_DEVICE_TYPE_CPU == node.agent.device_type_) {
std::cout << " Device Type: CPU" << std::endl; std::cout << " Device Type: CPU" << std::endl;
else if (HSA_DEVICE_TYPE_GPU == node.agent.device_type_) } else if (HSA_DEVICE_TYPE_GPU == node.agent.device_type_) {
std::cout << " Device Type: GPU" << std::endl; std::cout << " Device Type: GPU" << std::endl;
std::cout.width(format);
std::cout << "";
std::cout.width(format);
std::cout << " Device BDF: " << node.agent.bdf_id_ << std::endl;
}
// Print pool info // Print pool info
size_t pool_count = node.pool_list.size(); size_t pool_count = node.pool_list.size();
...@@ -222,10 +227,12 @@ void RocmBandwidthTest::PrintAgentsList() { ...@@ -222,10 +227,12 @@ void RocmBandwidthTest::PrintAgentsList() {
agent_pool_info_t node = agent_pool_list_.at(idx); agent_pool_info_t node = agent_pool_list_.at(idx);
std::cout << "Device Index: " std::cout << "Device Index: "
<< node.agent.index_ << std::endl; << node.agent.index_ << std::endl;
if (HSA_DEVICE_TYPE_CPU == node.agent.device_type_) if (HSA_DEVICE_TYPE_CPU == node.agent.device_type_) {
std::cout << " Device Type: CPU" << std::endl; std::cout << " Device Type: CPU" << std::endl;
else if (HSA_DEVICE_TYPE_GPU == node.agent.device_type_) } else if (HSA_DEVICE_TYPE_GPU == node.agent.device_type_) {
std::cout << " Device Type: GPU" << std::endl; std::cout << " Device Type: GPU" << std::endl;
std::cout << " Device BDF: " << node.agent.bdf_id_ << std::endl;
}
} }
std::cout << std::endl; std::cout << std::endl;
} }
......
...@@ -237,19 +237,19 @@ void RocmBandwidthTest::DisplayCopyTimeMatrix(bool peak) const { ...@@ -237,19 +237,19 @@ void RocmBandwidthTest::DisplayCopyTimeMatrix(bool peak) const {
std::cout.width(format); std::cout.width(format);
if ((peak) && (req_copy_all_unidir_ == REQ_COPY_ALL_UNIDIR)) { if ((peak) && (req_copy_all_unidir_ == REQ_COPY_ALL_UNIDIR)) {
std::cout << "Unidirectional peak bandwidth GB/s"; std::cout << "Unidirectional copy peak bandwidth GB/s";
} }
if ((peak == false) && (req_copy_all_unidir_ == REQ_COPY_ALL_UNIDIR)) { if ((peak == false) && (req_copy_all_unidir_ == REQ_COPY_ALL_UNIDIR)) {
std::cout << "Unidirectional average bandwidth GB/s"; std::cout << "Unidirectional copy average bandwidth GB/s";
} }
if ((peak) && (req_copy_all_bidir_ == REQ_COPY_ALL_BIDIR)) { if ((peak) && (req_copy_all_bidir_ == REQ_COPY_ALL_BIDIR)) {
std::cout << "Bdirectional peak bandwidth GB/s"; std::cout << "Bdirectional copy peak bandwidth GB/s";
} }
if ((peak == false) && (req_copy_all_bidir_ == REQ_COPY_ALL_BIDIR)) { if ((peak == false) && (req_copy_all_bidir_ == REQ_COPY_ALL_BIDIR)) {
std::cout << "Bidirectional average bandwidth GB/s"; std::cout << "Bidirectional copy average bandwidth GB/s";
} }
std::cout << std::endl; std::cout << std::endl;
...@@ -372,7 +372,12 @@ void RocmBandwidthTest::DisplayDevInfo() const { ...@@ -372,7 +372,12 @@ void RocmBandwidthTest::DisplayDevInfo() const {
std::cout.width(format); std::cout.width(format);
std::cout << ""; std::cout << "";
std::cout << "Device: " << idx; std::cout << "Device: " << idx;
std::cout << ", " << agent_list_[idx].name_ << std::endl; std::cout << ", " << agent_list_[idx].name_;
bool gpuDevice = (agent_list_[idx].device_type_ == HSA_DEVICE_TYPE_GPU);
if (gpuDevice) {
std::cout << ", " << agent_list_[idx].bdf_id_;
}
std::cout << std::endl;
} }
} }
std::cout << std::endl; std::cout << std::endl;
......
...@@ -43,6 +43,10 @@ ...@@ -43,6 +43,10 @@
#include "common.hpp" #include "common.hpp"
#include "rocm_bandwidth_test.hpp" #include "rocm_bandwidth_test.hpp"
#include <iomanip>
#include <sstream>
#include <string>
// @brief: Helper method to iterate throught the memory pools of // @brief: Helper method to iterate throught the memory pools of
// an agent and discover its properties // an agent and discover its properties
hsa_status_t MemPoolInfo(hsa_amd_memory_pool_t pool, void* data) { hsa_status_t MemPoolInfo(hsa_amd_memory_pool_t pool, void* data) {
...@@ -133,6 +137,17 @@ hsa_status_t MemPoolInfo(hsa_amd_memory_pool_t pool, void* data) { ...@@ -133,6 +137,17 @@ hsa_status_t MemPoolInfo(hsa_amd_memory_pool_t pool, void* data) {
return HSA_STATUS_SUCCESS; return HSA_STATUS_SUCCESS;
} }
void PopulateBDF(uint32_t bdf_id, agent_info_t *agent_info) {
uint8_t func_id = (bdf_id & 0x00000003);
uint8_t dev_id = ((bdf_id & 0x000000F8) >> 3);
uint8_t bus_id = ((bdf_id & 0x0000FF00) >> 8);
std::stringstream stream;
stream << std::setfill('0') << std::setw(sizeof(uint8_t) * 2);
stream << std::hex << +bus_id << ":" << +dev_id << "." << +func_id;
strcpy(agent_info->bdf_id_, (stream.str()).c_str());
}
// @brief: Helper method to iterate throught the agents of // @brief: Helper method to iterate throught the agents of
// a system and discover its properties // a system and discover its properties
hsa_status_t AgentInfo(hsa_agent_t agent, void* data) { hsa_status_t AgentInfo(hsa_agent_t agent, void* data) {
...@@ -157,11 +172,18 @@ hsa_status_t AgentInfo(hsa_agent_t agent, void* data) { ...@@ -157,11 +172,18 @@ hsa_status_t AgentInfo(hsa_agent_t agent, void* data) {
} }
// Instantiate an instance of agent_info_t and populate its name // Instantiate an instance of agent_info_t and populate its name
// field before adding it to the list of agent_info_t objects // and BDF fields before adding it to the list of agent_info_t objects
agent_info_t agent_info(agent, asyncDrvr->agent_index_, device_type); agent_info_t agent_info(agent, asyncDrvr->agent_index_, device_type);
status = hsa_agent_get_info(agent, status = hsa_agent_get_info(agent,
(hsa_agent_info_t)HSA_AMD_AGENT_INFO_PRODUCT_NAME, (hsa_agent_info_t)HSA_AMD_AGENT_INFO_PRODUCT_NAME,
(void *)&agent_info.name_[0]); (void *)&agent_info.name_[0]);
if (device_type == HSA_DEVICE_TYPE_GPU) {
uint32_t bdf_id = 0;
status = hsa_agent_get_info(agent,
(hsa_agent_info_t)HSA_AMD_AGENT_INFO_BDFID,
(void *)&bdf_id);
PopulateBDF(bdf_id, &agent_info);
}
asyncDrvr->agent_list_.push_back(agent_info); asyncDrvr->agent_list_.push_back(agent_info);
// Contruct an new agent_pool_info structure and add it to the list // Contruct an new agent_pool_info structure and add it to the list
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment