Add rsmi_dev_pci_throughput_get()

[ROCm/rocm_smi_lib commit: 18ce553dce]
Bu işleme şunda yer alıyor:
Chris Freehill
2019-02-27 15:10:26 -06:00
ebeveyn 89b3cb5030
işleme 9fa25de22a
7 değiştirilmiş dosya ile 128 ekleme ve 31 silme
+26
Dosyayı Görüntüle
@@ -468,6 +468,32 @@ rsmi_status_t rsmi_dev_pci_bandwidth_set(uint32_t dv_ind, uint64_t bw_bitmask);
*/
rsmi_status_t rsmi_dev_pci_id_get(uint32_t dv_ind, uint64_t *bdfid);
/**
* @brief Get PCIe traffic information
*
* @details Give a device index @p dv_ind and pointers to a uint64_t's, @p
* sent, @p received and @p max_pkt_sz, this function will write the number
* of bytes sent and received in 1 second to @p sent and @p received,
* respectively. The maximum possible packet size will be written to
* @max_pkt_size.
*
* @param[in] dv_ind a device index
*
* @param[inout] sent a pointer to uint64_t to which the number of bytes sent
* will be written in 1 second. If pointer is NULL, it will be ignored.
*
* @param[inout] received a pointer to uint64_t to which the number of bytes
* received will be written. If pointer is NULL, it will be ignored.
*
* @param[inout] max_pkt_sz a pointer to uint64_t to which the maximum packet
* size will be written. If pointer is NULL, it will be ignored.
*
* @retval ::RSMI_STATUS_SUCCESS is returned upon successful call.
*/
rsmi_status_t rsmi_dev_pci_throughput_get(uint32_t dv_ind, uint64_t *sent,
uint64_t *received, uint64_t *max_pkt_sz);
/**
* @brief Get the device id associated with the device with provided device
* index.
+3 -2
Dosyayı Görüntüle
@@ -64,11 +64,12 @@ enum DevInfoTypes {
kDevDevID,
kDevGPUMClk,
kDevGPUSClk,
kDevPCIEBW,
kDevPCIEClk,
kDevPowerProfileMode,
kDevUsage,
kDevPowerODVoltage,
kDevVBiosVer,
kDevPCIEThruPut,
};
class Device {
@@ -85,7 +86,7 @@ class Device {
#if 0 // This is not being used right now.
int readDevInfo(DevInfoTypes type, uint32_t *val);
#endif
int readDevInfoLine(DevInfoTypes type, std::string *line);
int readDevInfo(DevInfoTypes type, std::string *val);
int readDevInfo(DevInfoTypes type, std::vector<std::string> *retVec);
int writeDevInfo(DevInfoTypes type, uint64_t val);
+39 -2
Dosyayı Görüntüle
@@ -290,6 +290,14 @@ static rsmi_status_t get_dev_value_str(amd::smi::DevInfoTypes type,
return errno_to_rsmi_status(ret);
}
static rsmi_status_t get_dev_value_line(amd::smi::DevInfoTypes type,
uint32_t dv_ind, std::string *val_str) {
GET_DEV_FROM_INDX
int ret = dev->readDevInfoLine(type, val_str);
return errno_to_rsmi_status(ret);
}
static rsmi_status_t set_dev_value(amd::smi::DevInfoTypes type,
uint32_t dv_ind, uint64_t val) {
GET_DEV_FROM_INDX
@@ -911,7 +919,7 @@ rsmi_dev_pci_bandwidth_get(uint32_t dv_ind, rsmi_pcie_bandwidth *b) {
return RSMI_STATUS_INVALID_ARGS;
}
return get_frequencies(amd::smi::kDevPCIEBW, dv_ind,
return get_frequencies(amd::smi::kDevPCIEClk, dv_ind,
&b->transfer_rate, b->lanes);
CATCH
@@ -949,13 +957,42 @@ rsmi_dev_pci_bandwidth_set(uint32_t dv_ind, uint64_t bw_bitmask) {
}
uint32_t ret_i;
ret_i = dev->writeDevInfo(amd::smi::kDevPCIEBW, freq_enable_str);
ret_i = dev->writeDevInfo(amd::smi::kDevPCIEClk, freq_enable_str);
return errno_to_rsmi_status(ret_i);
CATCH
}
rsmi_status_t
rsmi_dev_pci_throughput_get(uint32_t dv_ind, uint64_t *sent,
uint64_t *received, uint64_t *max_pkt_sz) {
TRY
rsmi_status_t ret;
std::string val_str;
ret = get_dev_value_line(amd::smi::kDevPCIEThruPut, dv_ind, &val_str);
if (ret != RSMI_STATUS_SUCCESS) {
return ret;
}
std::istringstream fs_rng(val_str);
if (sent) {
fs_rng >> *sent;
}
if (received) {
fs_rng >> *received;
}
if (max_pkt_sz) {
fs_rng >> *max_pkt_sz;
}
return RSMI_STATUS_SUCCESS;
CATCH
}
rsmi_status_t
rsmi_dev_temp_metric_get(uint32_t dv_ind, uint32_t sensor_ind,
rsmi_temperature_metric metric, int64_t *temperature) {
+23 -6
Dosyayı Görüntüle
@@ -69,7 +69,7 @@ static const char *kDevPowerProfileModeFName = "pp_power_profile_mode";
static const char *kDevPowerODVoltageFName = "pp_od_clk_voltage";
static const char *kDevUsageFName = "gpu_busy_percent";
static const char *kDevVBiosVerFName = "vbios_version";
static const char *kDevPCIEThruPutFName = "pcie_bw";
static const char *kDevPerfLevelAutoStr = "auto";
static const char *kDevPerfLevelLowStr = "low";
static const char *kDevPerfLevelHighStr = "high";
@@ -86,11 +86,12 @@ static const std::map<DevInfoTypes, const char *> kDevAttribNameMap = {
{kDevDevID, kDevDevIDFName},
{kDevGPUMClk, kDevGPUMClkFName},
{kDevGPUSClk, kDevGPUSClkFName},
{kDevPCIEBW, kDevGPUPCIEClkFname},
{kDevPCIEClk, kDevGPUPCIEClkFname},
{kDevPowerProfileMode, kDevPowerProfileModeFName},
{kDevUsage, kDevUsageFName},
{kDevPowerODVoltage, kDevPowerODVoltageFName},
{kDevVBiosVer, kDevVBiosVerFName},
{kDevPCIEThruPut, kDevPCIEThruPutFName},
};
static const std::map<rsmi_dev_perf_level, const char *> kDevPerfLvlMap = {
@@ -216,7 +217,7 @@ int Device::writeDevInfo(DevInfoTypes type, uint64_t val) {
case kDevGPUMClk: // integer (index within num-freq range)
case kDevGPUSClk: // integer (index within num-freq range)
case kDevPCIEBW: // integer (index within num-freq range)
case kDevPCIEClk: // integer (index within num-freq range)
case kDevDevID: // string (read-only)
default:
break;
@@ -229,7 +230,7 @@ int Device::writeDevInfo(DevInfoTypes type, std::string val) {
switch (type) {
case kDevGPUMClk:
case kDevGPUSClk:
case kDevPCIEBW:
case kDevPCIEClk:
case kDevPowerODVoltage:
return writeDevInfoStr(type, val);
@@ -243,9 +244,24 @@ int Device::writeDevInfo(DevInfoTypes type, std::string val) {
return -1;
}
int Device::readDevInfoLine(DevInfoTypes type, std::string *line) {
int ret;
std::ifstream fs;
assert(line != nullptr);
ret = openSysfsFileStream(type, &fs);
if (ret != 0) {
return ret;
}
std::getline(fs, *line);
return 0;
}
int Device::readDevInfoMultiLineStr(DevInfoTypes type,
std::vector<std::string> *retVec) {
auto tempPath = path_;
std::string line;
int ret;
std::ifstream fs;
@@ -303,7 +319,7 @@ int Device::readDevInfo(DevInfoTypes type, std::vector<std::string> *val) {
switch (type) {
case kDevGPUMClk:
case kDevGPUSClk:
case kDevPCIEBW:
case kDevPCIEClk:
case kDevPowerProfileMode:
case kDevPowerODVoltage:
return readDevInfoMultiLineStr(type, val);
@@ -325,6 +341,7 @@ int Device::readDevInfo(DevInfoTypes type, std::string *val) {
case kDevOverDriveLevel:
case kDevDevID:
case kDevVBiosVer:
case kDevPCIEThruPut:
return readDevInfoStr(type, val);
break;
@@ -1,7 +1,4 @@
/*
* =============================================================================
* ROC Runtime Conformance Release License
* =============================================================================
* The University of Illinois/NCSA
* Open Source License (NCSA)
*
@@ -53,51 +50,70 @@
#include "gtest/gtest.h"
#include "rocm_smi/rocm_smi.h"
#include "rocm_smi_test/functional/pci_bw_read_write.h"
#include "rocm_smi_test/functional/pci_read_write.h"
#include "rocm_smi_test/test_common.h"
TestPciBWReadWrite::TestPciBWReadWrite() : TestBase() {
TestPciReadWrite::TestPciReadWrite() : TestBase() {
set_title("RSMI PCIe Bandwidth Read/Write Test");
set_description("The PCIe Bandwidth tests verify that the PCIe bandwidth "
"settings can be read and controlled properly.");
}
TestPciBWReadWrite::~TestPciBWReadWrite(void) {
TestPciReadWrite::~TestPciReadWrite(void) {
}
void TestPciBWReadWrite::SetUp(void) {
void TestPciReadWrite::SetUp(void) {
TestBase::SetUp();
return;
}
void TestPciBWReadWrite::DisplayTestInfo(void) {
void TestPciReadWrite::DisplayTestInfo(void) {
TestBase::DisplayTestInfo();
}
void TestPciBWReadWrite::DisplayResults(void) const {
void TestPciReadWrite::DisplayResults(void) const {
TestBase::DisplayResults();
return;
}
void TestPciBWReadWrite::Close() {
void TestPciReadWrite::Close() {
// This will close handles opened within rsmitst utility calls and call
// rsmi_shut_down(), so it should be done after other hsa cleanup
TestBase::Close();
}
void TestPciBWReadWrite::Run(void) {
void TestPciReadWrite::Run(void) {
rsmi_status_t ret;
rsmi_pcie_bandwidth bw;
uint32_t freq_bitmask;
uint64_t sent, received, max_pkt_sz;
TestBase::Run();
for (uint32_t dv_ind = 0; dv_ind < num_monitor_devs(); ++dv_ind) {
PrintDeviceHeader(dv_ind);
ret = rsmi_dev_pci_throughput_get(dv_ind, &sent, &received, &max_pkt_sz);
if (ret == RSMI_STATUS_NOT_SUPPORTED) {
std::cout << "TEST FAILURE: Current PCIe throughput is not detected. "
"This is likely because it is not indicated in the pcie_bw sysfs "
"file. Aborting test." << std::endl;
return;
}
CHK_ERR_ASRT(ret)
IF_VERB(STANDARD) {
std::cout << "PCIe Throughput (1 sec.): " << std::endl;
std::cout << "\t\tSent: " << sent << " bytes" << std::endl;
std::cout << "\t\tReceived: " << received << " bytes" << std::endl;
std::cout << "\t\tMax Packet Size: " << max_pkt_sz << " bytes" <<
std::endl;
std::cout << std::endl;
}
ret = rsmi_dev_pci_bandwidth_get(dv_ind, &bw);
if (ret == RSMI_STATUS_NOT_SUPPORTED) {
@@ -42,17 +42,17 @@
* DEALINGS WITH THE SOFTWARE.
*
*/
#ifndef TESTS_ROCM_SMI_TEST_FUNCTIONAL_PCI_BW_READ_WRITE_H_
#define TESTS_ROCM_SMI_TEST_FUNCTIONAL_PCI_BW_READ_WRITE_H_
#ifndef TESTS_ROCM_SMI_TEST_FUNCTIONAL_PCI_READ_WRITE_H_
#define TESTS_ROCM_SMI_TEST_FUNCTIONAL_PCI_READ_WRITE_H_
#include "rocm_smi_test/test_base.h"
class TestPciBWReadWrite : public TestBase {
class TestPciReadWrite : public TestBase {
public:
TestPciBWReadWrite();
TestPciReadWrite();
// @Brief: Destructor for test case of TestPciBWReadWrite
virtual ~TestPciBWReadWrite();
// @Brief: Destructor for test case of TestPciReadWrite
virtual ~TestPciReadWrite();
// @Brief: Setup the environment for measurement
virtual void SetUp();
@@ -70,4 +70,4 @@ class TestPciBWReadWrite : public TestBase {
virtual void DisplayTestInfo(void);
};
#endif // TESTS_ROCM_SMI_TEST_FUNCTIONAL_PCI_BW_READ_WRITE_H_
#endif // TESTS_ROCM_SMI_TEST_FUNCTIONAL_PCI_READ_WRITE_H_
+3 -3
Dosyayı Görüntüle
@@ -64,7 +64,7 @@
#include "functional/overdrive_read_write.h"
#include "functional/perf_level_read_write.h"
#include "functional/frequencies_read_write.h"
#include "functional/pci_bw_read_write.h"
#include "functional/pci_read_write.h"
#include "functional/power_read_write.h"
#include "functional/power_cap_read_write.h"
#include "functional/version_read.h"
@@ -157,8 +157,8 @@ TEST(rsmitstReadWrite, TestFrequenciesReadWrite) {
TestFrequenciesReadWrite tst;
RunGenericTest(&tst);
}
TEST(rsmitstReadWrite, TestPciBWReadWrite) {
TestPciBWReadWrite tst;
TEST(rsmitstReadWrite, TestPciReadWrite) {
TestPciReadWrite tst;
RunGenericTest(&tst);
}
TEST(rsmitstReadOnly, TestSysInfoRead) {