LINT: Add cpplint, clang-format and pre-commit support
Change-Id: I3cbb787ef27d90486b212dfb1a8c77c460acc2ac
Signed-off-by: Galantsev, Dmitrii <dmitrii.galantsev@amd.com>
[ROCm/rdc commit: 434e40305d]
This commit is contained in:
Executable → Regular
+20
-24
@@ -21,26 +21,27 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include "rdc/rdc_client.h"
|
||||
|
||||
#include <grpcpp/grpcpp.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "rdc/rdc_client.h"
|
||||
#include "rocm_smi/rocm_smi.h"
|
||||
|
||||
#define CHK_RET_STATUS(RET) \
|
||||
if ((RET) != RDC_STATUS_SUCCESS) { \
|
||||
const char *err_msg_str; \
|
||||
(void)rdc_status_string((RET), &err_msg_str); \
|
||||
std::cout << "rdc call returned error: " << (RET) << ":\"" << \
|
||||
err_msg_str << "\"" << std::endl; \
|
||||
#define CHK_RET_STATUS(RET) \
|
||||
if ((RET) != RDC_STATUS_SUCCESS) { \
|
||||
const char* err_msg_str; \
|
||||
(void)rdc_status_string((RET), &err_msg_str); \
|
||||
std::cout << "rdc call returned error: " << (RET) << ":\"" << err_msg_str << "\"" \
|
||||
<< std::endl; \
|
||||
}
|
||||
|
||||
#define CHK_RET_STATUS_CONT(RET) \
|
||||
if ((RET) != RDC_STATUS_SUCCESS) { \
|
||||
std::cout << "rdc call returned error: " << (RET) << std::endl; \
|
||||
continue; \
|
||||
#define CHK_RET_STATUS_CONT(RET) \
|
||||
if ((RET) != RDC_STATUS_SUCCESS) { \
|
||||
std::cout << "rdc call returned error: " << (RET) << std::endl; \
|
||||
continue; \
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
@@ -58,11 +59,9 @@ int main(int argc, char** argv) {
|
||||
serv_port = argv[2];
|
||||
}
|
||||
|
||||
std::cout << "Attempting to create channel to " << serv_host << ":" <<
|
||||
serv_port << std::endl;
|
||||
std::cout << "Attempting to create channel to " << serv_host << ":" << serv_port << std::endl;
|
||||
|
||||
ret = rdc_channel_create(&server_ch, serv_host.c_str(), serv_port.c_str(),
|
||||
false);
|
||||
ret = rdc_channel_create(&server_ch, serv_host.c_str(), serv_port.c_str(), false);
|
||||
CHK_RET_STATUS(ret)
|
||||
std::cout << "Successfully created channel" << std::endl;
|
||||
|
||||
@@ -80,23 +79,20 @@ int main(int argc, char** argv) {
|
||||
std::cout << "Getting number of gpus at server..." << std::endl;
|
||||
ret = rdc_num_gpus_get(server_ch, &num_gpu);
|
||||
CHK_RET_STATUS(ret)
|
||||
std::cout << "Number of GPUs at server is " << server_ch <<
|
||||
num_gpu << std::endl;
|
||||
std::cout << "Number of GPUs at server is " << server_ch << num_gpu << std::endl;
|
||||
|
||||
for (uint32_t dv_ind = 0; dv_ind < num_gpu; ++dv_ind) {
|
||||
std::cout << "Info for Device " << dv_ind << ":" << std::endl;
|
||||
std::cout << "\tGetting temperature..." << std::endl;
|
||||
ret = rdc_dev_temp_metric_get(server_ch, dv_ind, RSMI_TEMP_TYPE_JUNCTION,
|
||||
RSMI_TEMP_CURRENT, &temperature);
|
||||
ret = rdc_dev_temp_metric_get(server_ch, dv_ind, RSMI_TEMP_TYPE_JUNCTION, RSMI_TEMP_CURRENT,
|
||||
&temperature);
|
||||
CHK_RET_STATUS_CONT(ret)
|
||||
std::cout << "\t GPU " << dv_ind << " has a temperature of " <<
|
||||
temperature << std::endl;
|
||||
std::cout << "\t GPU " << dv_ind << " has a temperature of " << temperature << std::endl;
|
||||
}
|
||||
|
||||
ret = rdc_channel_destroy(server_ch);
|
||||
CHK_RET_STATUS(ret)
|
||||
std::cout << "Successfully destroyed channel to " << serv_host << ":" <<
|
||||
serv_port << std::endl;
|
||||
std::cout << "Successfully destroyed channel to " << serv_host << ":" << serv_port << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -20,26 +20,25 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "rdc_tests/functional/rdci_discovery.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "rdc_tests/functional/rdci_discovery.h"
|
||||
#include "rdc_tests/test_common.h"
|
||||
#include "rdc/rdc.h"
|
||||
|
||||
#include "rdc_tests/test_common.h"
|
||||
|
||||
TestRdciDiscovery::TestRdciDiscovery() : TestBase() {
|
||||
set_title("\tRDC Discovery Test");
|
||||
set_description("\tThe Discovery tests verifies that the GPUs are "
|
||||
"discovered and identified .");
|
||||
set_description(
|
||||
"\tThe Discovery tests verifies that the GPUs are "
|
||||
"discovered and identified .");
|
||||
}
|
||||
|
||||
TestRdciDiscovery::~TestRdciDiscovery(void) {
|
||||
}
|
||||
TestRdciDiscovery::~TestRdciDiscovery(void) {}
|
||||
|
||||
void TestRdciDiscovery::SetUp(void) {
|
||||
TestBase::SetUp();
|
||||
@@ -48,9 +47,7 @@ void TestRdciDiscovery::SetUp(void) {
|
||||
return;
|
||||
}
|
||||
|
||||
void TestRdciDiscovery::DisplayTestInfo(void) {
|
||||
TestBase::DisplayTestInfo();
|
||||
}
|
||||
void TestRdciDiscovery::DisplayTestInfo(void) { TestBase::DisplayTestInfo(); }
|
||||
|
||||
void TestRdciDiscovery::DisplayResults(void) const {
|
||||
TestBase::DisplayResults();
|
||||
@@ -61,15 +58,11 @@ void TestRdciDiscovery::Close() {
|
||||
TestBase::Close();
|
||||
rdc_status_t result;
|
||||
if (standalone_) {
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "\t**Disconnecting from host....\n" << std::endl;
|
||||
}
|
||||
IF_VERB(STANDARD) { std::cout << "\t**Disconnecting from host....\n" << std::endl; }
|
||||
result = rdc_disconnect(rdc_handle);
|
||||
ASSERT_EQ(result, RDC_ST_OK);
|
||||
} else {
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "\t**Stopping Embedded RDC Engine....\n" << std::endl;
|
||||
}
|
||||
IF_VERB(STANDARD) { std::cout << "\t**Stopping Embedded RDC Engine....\n" << std::endl; }
|
||||
result = rdc_stop_embedded(rdc_handle);
|
||||
ASSERT_EQ(result, RDC_ST_OK);
|
||||
}
|
||||
@@ -82,54 +75,44 @@ void TestRdciDiscovery::Run(void) {
|
||||
TestBase::Run();
|
||||
rdc_status_t result;
|
||||
if (standalone_) {
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "\t**Connecting to host....\n" << std::endl;
|
||||
}
|
||||
IF_VERB(STANDARD) { std::cout << "\t**Connecting to host....\n" << std::endl; }
|
||||
char hostIpAddress[] = {"localhost:50051"};
|
||||
result = rdc_connect(hostIpAddress, &rdc_handle, nullptr, nullptr, nullptr);
|
||||
ASSERT_EQ(result, RDC_ST_OK);
|
||||
} else {
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "\t**Starting embedded RDC engine....\n" << std::endl;
|
||||
}
|
||||
IF_VERB(STANDARD) { std::cout << "\t**Starting embedded RDC engine....\n" << std::endl; }
|
||||
result = rdc_start_embedded(RDC_OPERATION_MODE_AUTO, &rdc_handle);
|
||||
ASSERT_EQ(result, RDC_ST_OK);
|
||||
}
|
||||
|
||||
uint32_t gpu_index_list[RDC_MAX_NUM_DEVICES];
|
||||
uint32_t gpu_index_list[RDC_MAX_NUM_DEVICES];
|
||||
uint32_t count = 0;
|
||||
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "\t**Getting the devices in the system\n" << std::endl;
|
||||
}
|
||||
result = rdc_device_get_all(0, gpu_index_list, &count);
|
||||
IF_VERB(STANDARD) { std::cout << "\t**Getting the devices in the system\n" << std::endl; }
|
||||
result = rdc_device_get_all(0, gpu_index_list, &count);
|
||||
ASSERT_EQ(result, RDC_ST_INVALID_HANDLER);
|
||||
|
||||
result = rdc_device_get_all(rdc_handle, gpu_index_list, 0);
|
||||
result = rdc_device_get_all(rdc_handle, gpu_index_list, 0);
|
||||
ASSERT_EQ(result, RDC_ST_INVALID_HANDLER);
|
||||
|
||||
result = rdc_device_get_all(rdc_handle, gpu_index_list, &count);
|
||||
result = rdc_device_get_all(rdc_handle, gpu_index_list, &count);
|
||||
ASSERT_EQ(result, RDC_ST_OK);
|
||||
|
||||
ASSERT_GT(count, 0);
|
||||
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "\t**Fetching attributes of every device\n" << std::endl;
|
||||
}
|
||||
IF_VERB(STANDARD) { std::cout << "\t**Fetching attributes of every device\n" << std::endl; }
|
||||
|
||||
rdc_device_attributes_t attribute;
|
||||
for (uint32_t i = 0; i < count; i++) {
|
||||
result = rdc_device_get_attributes(0, gpu_index_list[i], &attribute);
|
||||
ASSERT_EQ(result, RDC_ST_INVALID_HANDLER);
|
||||
result = rdc_device_get_attributes(0, gpu_index_list[i], &attribute);
|
||||
ASSERT_EQ(result, RDC_ST_INVALID_HANDLER);
|
||||
|
||||
result = rdc_device_get_attributes(rdc_handle, gpu_index_list[i], 0);
|
||||
ASSERT_EQ(result, RDC_ST_INVALID_HANDLER);
|
||||
result = rdc_device_get_attributes(rdc_handle, gpu_index_list[i], 0);
|
||||
ASSERT_EQ(result, RDC_ST_INVALID_HANDLER);
|
||||
|
||||
result = rdc_device_get_attributes(rdc_handle, gpu_index_list[i],
|
||||
&attribute);
|
||||
ASSERT_EQ(result, RDC_ST_OK);
|
||||
result = rdc_device_get_attributes(rdc_handle, gpu_index_list[i], &attribute);
|
||||
ASSERT_EQ(result, RDC_ST_OK);
|
||||
|
||||
std::cout << "\tGPU ID "<< i << " || " <<
|
||||
attribute.device_name <<std::endl;
|
||||
std::cout << "\tGPU ID " << i << " || " << attribute.device_name << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ THE SOFTWARE.
|
||||
|
||||
class TestRdciDiscovery : public TestBase {
|
||||
public:
|
||||
TestRdciDiscovery();
|
||||
TestRdciDiscovery();
|
||||
|
||||
// @Brief: Destructor for test case of TestRdciDiscovery
|
||||
virtual ~TestRdciDiscovery();
|
||||
|
||||
@@ -20,26 +20,23 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "rdc_tests/functional/rdci_dmon.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "rdc_tests/functional/rdci_dmon.h"
|
||||
#include "rdc_tests/test_common.h"
|
||||
#include "rdc/rdc.h"
|
||||
|
||||
#include "rdc_tests/test_common.h"
|
||||
|
||||
TestRdciDmon::TestRdciDmon() : TestBase() {
|
||||
set_title("\tRDC Dmon Test");
|
||||
set_description(
|
||||
"\tThe Dmon tests verifies that the GPUs metrics are being monitored. ");
|
||||
set_description("\tThe Dmon tests verifies that the GPUs metrics are being monitored. ");
|
||||
}
|
||||
|
||||
TestRdciDmon::~TestRdciDmon(void) {
|
||||
}
|
||||
TestRdciDmon::~TestRdciDmon(void) {}
|
||||
|
||||
void TestRdciDmon::SetUp(void) {
|
||||
TestBase::SetUp();
|
||||
@@ -48,9 +45,7 @@ void TestRdciDmon::SetUp(void) {
|
||||
return;
|
||||
}
|
||||
|
||||
void TestRdciDmon::DisplayTestInfo(void) {
|
||||
TestBase::DisplayTestInfo();
|
||||
}
|
||||
void TestRdciDmon::DisplayTestInfo(void) { TestBase::DisplayTestInfo(); }
|
||||
|
||||
void TestRdciDmon::DisplayResults(void) const {
|
||||
TestBase::DisplayResults();
|
||||
@@ -61,15 +56,11 @@ void TestRdciDmon::Close() {
|
||||
TestBase::Close();
|
||||
rdc_status_t result;
|
||||
if (standalone_) {
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "\t**Disconnecting from host....\n" << std::endl;
|
||||
}
|
||||
IF_VERB(STANDARD) { std::cout << "\t**Disconnecting from host....\n" << std::endl; }
|
||||
result = rdc_disconnect(rdc_handle);
|
||||
ASSERT_EQ(result, RDC_ST_OK);
|
||||
} else {
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "\t**Stopping Embedded RDC Engine....\n" << std::endl;
|
||||
}
|
||||
IF_VERB(STANDARD) { std::cout << "\t**Stopping Embedded RDC Engine....\n" << std::endl; }
|
||||
result = rdc_stop_embedded(rdc_handle);
|
||||
ASSERT_EQ(result, RDC_ST_OK);
|
||||
}
|
||||
@@ -82,16 +73,12 @@ void TestRdciDmon::Run(void) {
|
||||
TestBase::Run();
|
||||
rdc_status_t result;
|
||||
if (standalone_) {
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "\t**Connecting to host....\n" << std::endl;
|
||||
}
|
||||
IF_VERB(STANDARD) { std::cout << "\t**Connecting to host....\n" << std::endl; }
|
||||
char hostIpAddress[] = {"localhost:50051"};
|
||||
result = rdc_connect(hostIpAddress, &rdc_handle, nullptr, nullptr, nullptr);
|
||||
ASSERT_EQ(result, RDC_ST_OK);
|
||||
} else {
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "\t**Starting embedded RDC engine....\n" << std::endl;
|
||||
}
|
||||
IF_VERB(STANDARD) { std::cout << "\t**Starting embedded RDC engine....\n" << std::endl; }
|
||||
result = rdc_start_embedded(RDC_OPERATION_MODE_AUTO, &rdc_handle);
|
||||
ASSERT_EQ(result, RDC_ST_OK);
|
||||
}
|
||||
@@ -99,8 +86,7 @@ void TestRdciDmon::Run(void) {
|
||||
rdc_group_info_t group_info;
|
||||
rdc_gpu_group_t group_id;
|
||||
rdc_field_grp_t field_group_id;
|
||||
result = rdc_group_gpu_create(rdc_handle, RDC_GROUP_EMPTY,
|
||||
"GRP_DMON", &group_id);
|
||||
result = rdc_group_gpu_create(rdc_handle, RDC_GROUP_EMPTY, "GRP_DMON", &group_id);
|
||||
ASSERT_EQ(result, RDC_ST_OK);
|
||||
|
||||
result = rdc_group_gpu_add(rdc_handle, group_id, 0);
|
||||
@@ -116,11 +102,9 @@ void TestRdciDmon::Run(void) {
|
||||
ASSERT_EQ(result, RDC_ST_OK);
|
||||
ASSERT_GT(group_info.count, 0);
|
||||
|
||||
rdc_field_t field_ids[]= {RDC_FI_GPU_TEMP, RDC_FI_POWER_USAGE,
|
||||
RDC_FI_GPU_UTIL};
|
||||
uint32_t fsize = sizeof(field_ids)/sizeof(field_ids[0]);
|
||||
result = rdc_group_field_create(rdc_handle, fsize , &field_ids[0],
|
||||
"FIELD_GRP", &field_group_id);
|
||||
rdc_field_t field_ids[] = {RDC_FI_GPU_TEMP, RDC_FI_POWER_USAGE, RDC_FI_GPU_UTIL};
|
||||
uint32_t fsize = sizeof(field_ids) / sizeof(field_ids[0]);
|
||||
result = rdc_group_field_create(rdc_handle, fsize, &field_ids[0], "FIELD_GRP", &field_group_id);
|
||||
ASSERT_EQ(result, RDC_ST_OK);
|
||||
|
||||
result = rdc_field_watch(rdc_handle, -1, field_group_id, 0, 60, 10);
|
||||
|
||||
@@ -26,7 +26,7 @@ THE SOFTWARE.
|
||||
|
||||
class TestRdciDmon : public TestBase {
|
||||
public:
|
||||
TestRdciDmon();
|
||||
TestRdciDmon();
|
||||
|
||||
// @Brief: Destructor for test case of TestRdciDmon
|
||||
virtual ~TestRdciDmon();
|
||||
|
||||
@@ -20,25 +20,23 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "rdc_tests/functional/rdci_fieldgroup.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "rdc_tests/functional/rdci_fieldgroup.h"
|
||||
#include "rdc_tests/test_common.h"
|
||||
#include "rdc/rdc.h"
|
||||
#include "rdc_tests/test_common.h"
|
||||
|
||||
TestRdciFieldgroup::TestRdciFieldgroup() : TestBase() {
|
||||
set_title("\tRDC Fieldgroup Test");
|
||||
set_description(
|
||||
"\tThe Fieldgroup tests verifies the creation/deletion of fieldgroups.");
|
||||
set_description("\tThe Fieldgroup tests verifies the creation/deletion of fieldgroups.");
|
||||
}
|
||||
|
||||
TestRdciFieldgroup::~TestRdciFieldgroup(void) {
|
||||
}
|
||||
TestRdciFieldgroup::~TestRdciFieldgroup(void) {}
|
||||
|
||||
void TestRdciFieldgroup::SetUp(void) {
|
||||
TestBase::SetUp();
|
||||
@@ -47,9 +45,7 @@ void TestRdciFieldgroup::SetUp(void) {
|
||||
return;
|
||||
}
|
||||
|
||||
void TestRdciFieldgroup::DisplayTestInfo(void) {
|
||||
TestBase::DisplayTestInfo();
|
||||
}
|
||||
void TestRdciFieldgroup::DisplayTestInfo(void) { TestBase::DisplayTestInfo(); }
|
||||
|
||||
void TestRdciFieldgroup::DisplayResults(void) const {
|
||||
TestBase::DisplayResults();
|
||||
@@ -60,15 +56,11 @@ void TestRdciFieldgroup::Close() {
|
||||
TestBase::Close();
|
||||
rdc_status_t result;
|
||||
if (standalone_) {
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "\t**Disconnecting from host....\n" << std::endl;
|
||||
}
|
||||
IF_VERB(STANDARD) { std::cout << "\t**Disconnecting from host....\n" << std::endl; }
|
||||
result = rdc_disconnect(rdc_handle);
|
||||
ASSERT_EQ(result, RDC_ST_OK);
|
||||
} else {
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "\t**Stopping Embedded RDC Engine....\n" << std::endl;
|
||||
}
|
||||
IF_VERB(STANDARD) { std::cout << "\t**Stopping Embedded RDC Engine....\n" << std::endl; }
|
||||
result = rdc_stop_embedded(rdc_handle);
|
||||
ASSERT_EQ(result, RDC_ST_OK);
|
||||
}
|
||||
@@ -81,45 +73,38 @@ void TestRdciFieldgroup::Run(void) {
|
||||
TestBase::Run();
|
||||
rdc_status_t result;
|
||||
if (standalone_) {
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "\t**Connecting to host....\n" << std::endl;
|
||||
}
|
||||
IF_VERB(STANDARD) { std::cout << "\t**Connecting to host....\n" << std::endl; }
|
||||
char hostIpAddress[] = {"localhost:50051"};
|
||||
result = rdc_connect(hostIpAddress, &rdc_handle, nullptr, nullptr, nullptr);
|
||||
ASSERT_EQ(result, RDC_ST_OK);
|
||||
} else {
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "\t**Starting embedded RDC engine....\n" << std::endl;
|
||||
}
|
||||
IF_VERB(STANDARD) { std::cout << "\t**Starting embedded RDC engine....\n" << std::endl; }
|
||||
result = rdc_start_embedded(RDC_OPERATION_MODE_AUTO, &rdc_handle);
|
||||
ASSERT_EQ(result, RDC_ST_OK);
|
||||
}
|
||||
|
||||
rdc_field_grp_t field_group_id;
|
||||
rdc_field_t field_ids[]= {RDC_FI_GPU_TEMP, RDC_FI_POWER_USAGE};
|
||||
rdc_field_t invalid_field_ids[]= {RDC_FI_INVALID, RDC_FI_INVALID};
|
||||
uint32_t fsize = sizeof(field_ids)/sizeof(field_ids[0]);
|
||||
rdc_field_t field_ids[] = {RDC_FI_GPU_TEMP, RDC_FI_POWER_USAGE};
|
||||
rdc_field_t invalid_field_ids[] = {RDC_FI_INVALID, RDC_FI_INVALID};
|
||||
uint32_t fsize = sizeof(field_ids) / sizeof(field_ids[0]);
|
||||
uint32_t count = 0;
|
||||
rdc_field_group_info_t group_info;
|
||||
|
||||
result = rdc_group_field_create(rdc_handle, fsize, &invalid_field_ids[0],
|
||||
"FIELD_GRP", &field_group_id);
|
||||
result = rdc_group_field_create(rdc_handle, fsize, &invalid_field_ids[0], "FIELD_GRP",
|
||||
&field_group_id);
|
||||
ASSERT_EQ(result, RDC_ST_NOT_SUPPORTED);
|
||||
|
||||
result = rdc_group_field_create(NULL, fsize, &field_ids[0],
|
||||
"FIELD_GRP", &field_group_id);
|
||||
result = rdc_group_field_create(NULL, fsize, &field_ids[0], "FIELD_GRP", &field_group_id);
|
||||
ASSERT_EQ(result, RDC_ST_INVALID_HANDLER);
|
||||
|
||||
result = rdc_group_field_create(rdc_handle, fsize, &field_ids[0],
|
||||
NULL, NULL);
|
||||
result = rdc_group_field_create(rdc_handle, fsize, &field_ids[0], NULL, NULL);
|
||||
ASSERT_EQ(result, RDC_ST_INVALID_HANDLER);
|
||||
|
||||
result = rdc_group_field_create(rdc_handle,
|
||||
(RDC_MAX_FIELD_IDS_PER_FIELD_GROUP+1), &field_ids[0], "FIELD_GRP", NULL);
|
||||
result = rdc_group_field_create(rdc_handle, (RDC_MAX_FIELD_IDS_PER_FIELD_GROUP + 1),
|
||||
&field_ids[0], "FIELD_GRP", NULL);
|
||||
ASSERT_EQ(result, RDC_ST_INVALID_HANDLER);
|
||||
|
||||
result = rdc_group_field_create(rdc_handle, fsize, &field_ids[0],
|
||||
"FIELD_GRP", &field_group_id);
|
||||
result = rdc_group_field_create(rdc_handle, fsize, &field_ids[0], "FIELD_GRP", &field_group_id);
|
||||
ASSERT_EQ(result, RDC_ST_OK);
|
||||
|
||||
rdc_field_grp_t group_id_list[RDC_MAX_NUM_FIELD_GROUPS];
|
||||
@@ -131,14 +116,15 @@ void TestRdciFieldgroup::Run(void) {
|
||||
|
||||
ASSERT_GT(count, 0);
|
||||
|
||||
std::cout << "\tGroupID\t" << "GroupName\t" << "FieldIds\n";
|
||||
std::cout << "\tGroupID\t"
|
||||
<< "GroupName\t"
|
||||
<< "FieldIds\n";
|
||||
for (uint32_t i = 0; i < count; i++) {
|
||||
result = rdc_group_field_get_info(rdc_handle, group_id_list[i], 0);
|
||||
ASSERT_EQ(result, RDC_ST_BAD_PARAMETER);
|
||||
result = rdc_group_field_get_info(rdc_handle, group_id_list[i], 0);
|
||||
ASSERT_EQ(result, RDC_ST_BAD_PARAMETER);
|
||||
|
||||
result = rdc_group_field_get_info(rdc_handle, group_id_list[i],
|
||||
&group_info);
|
||||
ASSERT_EQ(result, RDC_ST_OK);
|
||||
result = rdc_group_field_get_info(rdc_handle, group_id_list[i], &group_info);
|
||||
ASSERT_EQ(result, RDC_ST_OK);
|
||||
}
|
||||
|
||||
result = rdc_group_field_destroy(NULL, field_group_id);
|
||||
|
||||
@@ -26,7 +26,7 @@ THE SOFTWARE.
|
||||
|
||||
class TestRdciFieldgroup : public TestBase {
|
||||
public:
|
||||
TestRdciFieldgroup();
|
||||
TestRdciFieldgroup();
|
||||
|
||||
// @Brief: Destructor for test case of TestRdciFieldgroup
|
||||
virtual ~TestRdciFieldgroup();
|
||||
|
||||
@@ -20,24 +20,23 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "rdc_tests/functional/rdci_group.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "rdc_tests/functional/rdci_group.h"
|
||||
#include "rdc_tests/test_common.h"
|
||||
#include "rdc/rdc.h"
|
||||
#include "rdc_tests/test_common.h"
|
||||
|
||||
TestRdciGroup::TestRdciGroup() : TestBase() {
|
||||
set_title("\tRDC Group Test");
|
||||
set_description("\tThe Group tests verifies creation/deletion of GPU groups");
|
||||
}
|
||||
|
||||
TestRdciGroup::~TestRdciGroup(void) {
|
||||
}
|
||||
TestRdciGroup::~TestRdciGroup(void) {}
|
||||
|
||||
void TestRdciGroup::SetUp(void) {
|
||||
TestBase::SetUp();
|
||||
@@ -46,9 +45,7 @@ void TestRdciGroup::SetUp(void) {
|
||||
return;
|
||||
}
|
||||
|
||||
void TestRdciGroup::DisplayTestInfo(void) {
|
||||
TestBase::DisplayTestInfo();
|
||||
}
|
||||
void TestRdciGroup::DisplayTestInfo(void) { TestBase::DisplayTestInfo(); }
|
||||
|
||||
void TestRdciGroup::DisplayResults(void) const {
|
||||
TestBase::DisplayResults();
|
||||
@@ -59,15 +56,11 @@ void TestRdciGroup::Close() {
|
||||
TestBase::Close();
|
||||
rdc_status_t result;
|
||||
if (standalone_) {
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "\t**Disconnecting from host....\n" << std::endl;
|
||||
}
|
||||
IF_VERB(STANDARD) { std::cout << "\t**Disconnecting from host....\n" << std::endl; }
|
||||
result = rdc_disconnect(rdc_handle);
|
||||
ASSERT_EQ(result, RDC_ST_OK);
|
||||
} else {
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "\t**Stopping Embedded RDC Engine....\n" << std::endl;
|
||||
}
|
||||
IF_VERB(STANDARD) { std::cout << "\t**Stopping Embedded RDC Engine....\n" << std::endl; }
|
||||
result = rdc_stop_embedded(rdc_handle);
|
||||
ASSERT_EQ(result, RDC_ST_OK);
|
||||
}
|
||||
@@ -80,16 +73,12 @@ void TestRdciGroup::Run(void) {
|
||||
TestBase::Run();
|
||||
rdc_status_t result;
|
||||
if (standalone_) {
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "\t**Connecting to host....\n" << std::endl;
|
||||
}
|
||||
IF_VERB(STANDARD) { std::cout << "\t**Connecting to host....\n" << std::endl; }
|
||||
char hostIpAddress[] = {"localhost:50051"};
|
||||
result = rdc_connect(hostIpAddress, &rdc_handle, nullptr, nullptr, nullptr);
|
||||
ASSERT_EQ(result, RDC_ST_OK);
|
||||
} else {
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "\t**Starting embedded RDC engine....\n" << std::endl;
|
||||
}
|
||||
IF_VERB(STANDARD) { std::cout << "\t**Starting embedded RDC engine....\n" << std::endl; }
|
||||
result = rdc_start_embedded(RDC_OPERATION_MODE_AUTO, &rdc_handle);
|
||||
ASSERT_EQ(result, RDC_ST_OK);
|
||||
}
|
||||
@@ -107,8 +96,7 @@ void TestRdciGroup::Run(void) {
|
||||
result = rdc_group_gpu_create(rdc_handle, RDC_GROUP_EMPTY, "GRP_NAME", NULL);
|
||||
ASSERT_EQ(result, RDC_ST_BAD_PARAMETER);
|
||||
|
||||
result = rdc_group_gpu_create(rdc_handle, RDC_GROUP_EMPTY,
|
||||
"GRP_NAME", &group_id);
|
||||
result = rdc_group_gpu_create(rdc_handle, RDC_GROUP_EMPTY, "GRP_NAME", &group_id);
|
||||
ASSERT_EQ(result, RDC_ST_OK);
|
||||
|
||||
result = rdc_group_gpu_add(rdc_handle, group_id, -1);
|
||||
@@ -116,9 +104,9 @@ void TestRdciGroup::Run(void) {
|
||||
|
||||
result = rdc_device_get_all(rdc_handle, gpu_index_list, &count);
|
||||
ASSERT_EQ(result, RDC_ST_OK);
|
||||
for (uint32_t i=0; i < count; i++) {
|
||||
result = rdc_group_gpu_add(rdc_handle, group_id, gpu_index_list[i]);
|
||||
ASSERT_EQ(result, RDC_ST_OK);
|
||||
for (uint32_t i = 0; i < count; i++) {
|
||||
result = rdc_group_gpu_add(rdc_handle, group_id, gpu_index_list[i]);
|
||||
ASSERT_EQ(result, RDC_ST_OK);
|
||||
}
|
||||
|
||||
rdc_gpu_group_t group_id_list[RDC_MAX_NUM_GROUPS];
|
||||
@@ -128,23 +116,22 @@ void TestRdciGroup::Run(void) {
|
||||
result = rdc_group_get_all_ids(rdc_handle, group_id_list, &count);
|
||||
ASSERT_EQ(result, RDC_ST_OK);
|
||||
for (uint32_t i = 0; i < count; i++) {
|
||||
result = rdc_group_gpu_get_info(rdc_handle,
|
||||
group_id_list[i], NULL);
|
||||
ASSERT_EQ(result, RDC_ST_INVALID_HANDLER);
|
||||
result = rdc_group_gpu_get_info(rdc_handle,
|
||||
group_id_list[i], &group_info);
|
||||
ASSERT_EQ(result, RDC_ST_OK);
|
||||
std::cout << "\tGroupID\t" << "GroupName\t" << "GPUIndex\n";
|
||||
std::cout << "\t" << group_id_list[i] << "\t"
|
||||
<< group_info.group_name << "\t\t";
|
||||
for (uint32_t j = 0; j < group_info.count; j++) {
|
||||
std::cout << group_info.entity_ids[j];
|
||||
if (j < group_info.count -1) {
|
||||
std::cout << ",";
|
||||
}
|
||||
}
|
||||
std::cout << std::endl;
|
||||
result = rdc_group_gpu_get_info(rdc_handle, group_id_list[i], NULL);
|
||||
ASSERT_EQ(result, RDC_ST_INVALID_HANDLER);
|
||||
result = rdc_group_gpu_get_info(rdc_handle, group_id_list[i], &group_info);
|
||||
ASSERT_EQ(result, RDC_ST_OK);
|
||||
std::cout << "\tGroupID\t"
|
||||
<< "GroupName\t"
|
||||
<< "GPUIndex\n";
|
||||
std::cout << "\t" << group_id_list[i] << "\t" << group_info.group_name << "\t\t";
|
||||
for (uint32_t j = 0; j < group_info.count; j++) {
|
||||
std::cout << group_info.entity_ids[j];
|
||||
if (j < group_info.count - 1) {
|
||||
std::cout << ",";
|
||||
}
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
result = rdc_group_gpu_destroy(0, group_id);
|
||||
ASSERT_EQ(result, RDC_ST_INVALID_HANDLER);
|
||||
|
||||
@@ -26,7 +26,7 @@ THE SOFTWARE.
|
||||
|
||||
class TestRdciGroup : public TestBase {
|
||||
public:
|
||||
TestRdciGroup();
|
||||
TestRdciGroup();
|
||||
|
||||
// @Brief: Destructor for test case of TestRdciGroup
|
||||
virtual ~TestRdciGroup();
|
||||
|
||||
@@ -20,26 +20,25 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "rdc_tests/functional/rdci_stats.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "rdc_tests/functional/rdci_stats.h"
|
||||
#include "rdc_tests/test_common.h"
|
||||
#include "rdc/rdc.h"
|
||||
|
||||
#include "rdc_tests/test_common.h"
|
||||
|
||||
TestRdciStats::TestRdciStats() : TestBase() {
|
||||
set_title("\tRDC Stats Test");
|
||||
set_description("\tThe Stats tests collects and verifies job "
|
||||
"statistics running on gpu groups.");
|
||||
set_description(
|
||||
"\tThe Stats tests collects and verifies job "
|
||||
"statistics running on gpu groups.");
|
||||
}
|
||||
|
||||
TestRdciStats::~TestRdciStats(void) {
|
||||
}
|
||||
TestRdciStats::~TestRdciStats(void) {}
|
||||
|
||||
void TestRdciStats::SetUp(void) {
|
||||
TestBase::SetUp();
|
||||
@@ -48,9 +47,7 @@ void TestRdciStats::SetUp(void) {
|
||||
return;
|
||||
}
|
||||
|
||||
void TestRdciStats::DisplayTestInfo(void) {
|
||||
TestBase::DisplayTestInfo();
|
||||
}
|
||||
void TestRdciStats::DisplayTestInfo(void) { TestBase::DisplayTestInfo(); }
|
||||
|
||||
void TestRdciStats::DisplayResults(void) const {
|
||||
TestBase::DisplayResults();
|
||||
@@ -61,15 +58,11 @@ void TestRdciStats::Close() {
|
||||
TestBase::Close();
|
||||
rdc_status_t result;
|
||||
if (standalone_) {
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "\t**Disconnecting from host....\n" << std::endl;
|
||||
}
|
||||
IF_VERB(STANDARD) { std::cout << "\t**Disconnecting from host....\n" << std::endl; }
|
||||
result = rdc_disconnect(rdc_handle);
|
||||
ASSERT_EQ(result, RDC_ST_OK);
|
||||
} else {
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "\t**Stopping Embedded RDC Engine....\n" << std::endl;
|
||||
}
|
||||
IF_VERB(STANDARD) { std::cout << "\t**Stopping Embedded RDC Engine....\n" << std::endl; }
|
||||
result = rdc_stop_embedded(rdc_handle);
|
||||
ASSERT_EQ(result, RDC_ST_OK);
|
||||
}
|
||||
@@ -82,24 +75,18 @@ void TestRdciStats::Run(void) {
|
||||
TestBase::Run();
|
||||
rdc_status_t result;
|
||||
if (standalone_) {
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "\t**Connecting to host....\n" << std::endl;
|
||||
}
|
||||
IF_VERB(STANDARD) { std::cout << "\t**Connecting to host....\n" << std::endl; }
|
||||
char hostIpAddress[] = {"localhost:50051"};
|
||||
result = rdc_connect(hostIpAddress, &rdc_handle, nullptr,
|
||||
nullptr, nullptr);
|
||||
result = rdc_connect(hostIpAddress, &rdc_handle, nullptr, nullptr, nullptr);
|
||||
ASSERT_EQ(result, RDC_ST_OK);
|
||||
} else {
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "\t**Starting embedded RDC engine....\n" << std::endl;
|
||||
}
|
||||
IF_VERB(STANDARD) { std::cout << "\t**Starting embedded RDC engine....\n" << std::endl; }
|
||||
result = rdc_start_embedded(RDC_OPERATION_MODE_AUTO, &rdc_handle);
|
||||
ASSERT_EQ(result, RDC_ST_OK);
|
||||
}
|
||||
|
||||
rdc_gpu_group_t group_id;
|
||||
result = rdc_group_gpu_create(rdc_handle, RDC_GROUP_EMPTY,
|
||||
"GRP_NAME", &group_id);
|
||||
result = rdc_group_gpu_create(rdc_handle, RDC_GROUP_EMPTY, "GRP_NAME", &group_id);
|
||||
ASSERT_EQ(result, RDC_ST_OK);
|
||||
|
||||
result = rdc_group_gpu_add(rdc_handle, group_id, 0);
|
||||
@@ -107,10 +94,10 @@ void TestRdciStats::Run(void) {
|
||||
|
||||
result = rdc_job_start_stats(rdc_handle, group_id, "0", 1000000);
|
||||
if (result == RDC_ST_NOT_SUPPORTED) {
|
||||
std::cout <<
|
||||
"\t** GPU Metric is not supported"
|
||||
" on this machine" << std::endl;
|
||||
return;
|
||||
std::cout << "\t** GPU Metric is not supported"
|
||||
" on this machine"
|
||||
<< std::endl;
|
||||
return;
|
||||
}
|
||||
ASSERT_EQ(result, RDC_ST_OK);
|
||||
|
||||
@@ -121,7 +108,8 @@ void TestRdciStats::Run(void) {
|
||||
result = rdc_job_get_stats(rdc_handle, "0", &job_info);
|
||||
if (result == RDC_ST_NOT_SUPPORTED) {
|
||||
std::cout << "\t** GPU Metric is not supported"
|
||||
" on this machine" << std::endl;
|
||||
" on this machine"
|
||||
<< std::endl;
|
||||
return;
|
||||
}
|
||||
ASSERT_EQ(result, RDC_ST_OK);
|
||||
|
||||
@@ -26,7 +26,7 @@ THE SOFTWARE.
|
||||
|
||||
class TestRdciStats : public TestBase {
|
||||
public:
|
||||
TestRdciStats();
|
||||
TestRdciStats();
|
||||
|
||||
// @Brief: Destructor for test case of TestRdciStats
|
||||
virtual ~TestRdciStats();
|
||||
|
||||
Executable → Regular
+30
-32
@@ -21,29 +21,27 @@ THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <dirent.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "rdc/rdc.h"
|
||||
#include "rocm_smi/rocm_smi.h"
|
||||
#include "rdc_tests/test_common.h"
|
||||
#include "rdc_tests/test_base.h"
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "functional/rdci_discovery.h"
|
||||
#include "functional/rdci_group.h"
|
||||
#include "functional/rdci_dmon.h"
|
||||
#include "functional/rdci_fieldgroup.h"
|
||||
#include "functional/rdci_group.h"
|
||||
#include "functional/rdci_stats.h"
|
||||
#include "rdc/rdc.h"
|
||||
#include "rdc_tests/test_base.h"
|
||||
#include "rdc_tests/test_common.h"
|
||||
#include "rocm_smi/rocm_smi.h"
|
||||
|
||||
static RDCTstGlobals *sRDCGlvalues = nullptr;
|
||||
static RDCTstGlobals* sRDCGlvalues = nullptr;
|
||||
|
||||
static void SetFlags(TestBase *test) {
|
||||
static void SetFlags(TestBase* test) {
|
||||
assert(sRDCGlvalues != nullptr);
|
||||
|
||||
test->set_verbosity(sRDCGlvalues->verbosity);
|
||||
@@ -54,7 +52,7 @@ static void SetFlags(TestBase *test) {
|
||||
test->set_mode(sRDCGlvalues->standalone);
|
||||
}
|
||||
|
||||
static void RunCustomTestProlog(TestBase *test) {
|
||||
static void RunCustomTestProlog(TestBase* test) {
|
||||
SetFlags(test);
|
||||
|
||||
test->DisplayTestInfo();
|
||||
@@ -62,7 +60,7 @@ static void RunCustomTestProlog(TestBase *test) {
|
||||
test->Run();
|
||||
return;
|
||||
}
|
||||
static void RunCustomTestEpilog(TestBase *test) {
|
||||
static void RunCustomTestEpilog(TestBase* test) {
|
||||
test->DisplayResults();
|
||||
test->Close();
|
||||
return;
|
||||
@@ -74,7 +72,7 @@ static void RunCustomTestEpilog(TestBase *test) {
|
||||
// * RunCustomTestProlog(test) // Run() should contain minimal code
|
||||
// * <insert call to actual test function within test case>
|
||||
// * RunCustomTestEpilog(test)
|
||||
static void RunGenericTest(TestBase *test) {
|
||||
static void RunGenericTest(TestBase* test) {
|
||||
RunCustomTestProlog(test);
|
||||
RunCustomTestEpilog(test);
|
||||
return;
|
||||
@@ -108,14 +106,13 @@ TEST(rdctstReadOnly, TestRdciStats) {
|
||||
static int getPIDFromName(std::string name) {
|
||||
int pid = -1;
|
||||
|
||||
DIR *dir_ptr = opendir("/proc");
|
||||
DIR* dir_ptr = opendir("/proc");
|
||||
if (dir_ptr != NULL) {
|
||||
struct dirent *dentry;
|
||||
struct dirent* dentry;
|
||||
while (pid < 0 && (dentry = readdir(dir_ptr))) {
|
||||
int id = atoi(dentry->d_name);
|
||||
if (id > 0) {
|
||||
std::string commPath = std::string("/proc/") +
|
||||
dentry->d_name + "/comm";
|
||||
std::string commPath = std::string("/proc/") + dentry->d_name + "/comm";
|
||||
std::ifstream cmdFile(commPath.c_str());
|
||||
std::string cmdLine;
|
||||
getline(cmdFile, cmdLine);
|
||||
@@ -172,13 +169,13 @@ static int killRDCD(int pid = 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int startRDCD(std::string *rdcd_path, char *envp[]) {
|
||||
static int startRDCD(std::string* rdcd_path, char* envp[]) {
|
||||
assert(rdcd_path != nullptr);
|
||||
const char *rdcd_cl[128] = {rdcd_path->c_str(), "-u", NULL};
|
||||
const char* rdcd_cl[128] = {rdcd_path->c_str(), "-u", NULL};
|
||||
int pid = fork();
|
||||
|
||||
if (pid == 0) {
|
||||
if (-1 == execve(rdcd_cl[0], (char **)rdcd_cl , envp)) { // NOLINT
|
||||
if (-1 == execve(rdcd_cl[0], (char**)rdcd_cl, envp)) { // NOLINT
|
||||
std::string err_msg = "ERROR: Child process failed to start ";
|
||||
err_msg += *rdcd_path;
|
||||
perror(err_msg.c_str());
|
||||
@@ -220,13 +217,13 @@ int main(int argc, char** argv, char* envp[]) {
|
||||
std::cout << "0 - Embedded mode \n";
|
||||
std::cout << "1 - Standalone mode \n";
|
||||
while (!(std::cin >> settings.standalone)) {
|
||||
std::cout << "Invalid input.\n";
|
||||
std::cin.clear();
|
||||
std::cin.ignore();
|
||||
std::cout << "Invalid input.\n";
|
||||
std::cin.clear();
|
||||
std::cin.ignore();
|
||||
}
|
||||
std::cout << std::endl;
|
||||
std::cout << (settings.standalone?
|
||||
"Standalone mode selected.\n":"Embedded mode selected.\n");
|
||||
std::cout << (settings.standalone ? "Standalone mode selected.\n"
|
||||
: "Embedded mode selected.\n");
|
||||
}
|
||||
sRDCGlvalues = &settings;
|
||||
|
||||
@@ -271,9 +268,10 @@ int main(int argc, char** argv, char* envp[]) {
|
||||
}
|
||||
} else {
|
||||
if (getPIDFromName("rdcd") == -1) {
|
||||
std::cout <<
|
||||
"rdcd is not running. Use -d (--start_rdcd) to have rdcd started."
|
||||
" Exiting test." << std::endl;
|
||||
std::cout << "rdcd is not running. Use -d (--start_rdcd) to have "
|
||||
"rdcd started."
|
||||
" Exiting test."
|
||||
<< std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
Executable → Regular
+15
-24
@@ -19,13 +19,13 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "rdc_tests/test_base.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "rocm_smi/rocm_smi.h"
|
||||
#include "rdc_tests/test_base.h"
|
||||
#include "rdc_tests/test_common.h"
|
||||
#include "rocm_smi/rocm_smi.h"
|
||||
|
||||
static const int kOutputLineLength = 80;
|
||||
static const char kLabelDelimiter[] = "####";
|
||||
@@ -39,12 +39,10 @@ rdc_status_t result;
|
||||
|
||||
/*TestBase::TestBase() : description_(""), rdc_channel_(0) {
|
||||
}*/
|
||||
TestBase::TestBase() : description_("") {
|
||||
}
|
||||
TestBase::~TestBase() {
|
||||
}
|
||||
TestBase::TestBase() : description_("") {}
|
||||
TestBase::~TestBase() {}
|
||||
|
||||
static void MakeHeaderStr(const char *inStr, std::string *outStr) {
|
||||
static void MakeHeaderStr(const char* inStr, std::string* outStr) {
|
||||
assert(outStr != nullptr);
|
||||
assert(inStr != nullptr);
|
||||
|
||||
@@ -65,25 +63,18 @@ void TestBase::SetUp(void) {
|
||||
}
|
||||
|
||||
void TestBase::PrintDeviceHeader(uint32_t dv_ind) {
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "\t**Device index: " << dv_ind << std::endl;
|
||||
}
|
||||
IF_VERB(STANDARD) { std::cout << "\t**Device index: " << dv_ind << std::endl; }
|
||||
|
||||
std::cout << std::setbase(10);
|
||||
}
|
||||
|
||||
rdc_status_t
|
||||
TestBase::AllocateRDCChannel(void) {
|
||||
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "\t**Initializing RDC" << std::endl;
|
||||
}
|
||||
rdc_status_t TestBase::AllocateRDCChannel(void) {
|
||||
IF_VERB(STANDARD) { std::cout << "\t**Initializing RDC" << std::endl; }
|
||||
rdc_status_t result = rdc_init(0);
|
||||
if (result != RDC_ST_OK) {
|
||||
std::cout << "Error initializing RDC.... " <<
|
||||
rdc_status_string(result) << std::endl;
|
||||
return result;
|
||||
}
|
||||
std::cout << "Error initializing RDC.... " << rdc_status_string(result) << std::endl;
|
||||
return result;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -109,8 +100,9 @@ void TestBase::DisplayResults(void) const {
|
||||
}
|
||||
|
||||
void TestBase::DisplayTestInfo(void) {
|
||||
printf("#########################################"
|
||||
"######################################\n");
|
||||
printf(
|
||||
"#########################################"
|
||||
"######################################\n");
|
||||
|
||||
std::string label;
|
||||
MakeHeaderStr(kTitleLabel, &label);
|
||||
@@ -134,4 +126,3 @@ void TestBase::set_description(std::string d) {
|
||||
i = endlptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Executable → Regular
+34
-63
@@ -23,6 +23,7 @@ THE SOFTWARE.
|
||||
#define TESTS_RDC_TESTS_TEST_BASE_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "rdc/rdc.h"
|
||||
|
||||
class TestBase {
|
||||
@@ -31,7 +32,7 @@ class TestBase {
|
||||
|
||||
virtual ~TestBase(void);
|
||||
|
||||
enum VerboseLevel {VERBOSE_MIN = 0, VERBOSE_STANDARD, VERBOSE_PROGRESS};
|
||||
enum VerboseLevel { VERBOSE_MIN = 0, VERBOSE_STANDARD, VERBOSE_PROGRESS };
|
||||
|
||||
// @Brief: Before run the core measure codes, do something to set up
|
||||
// i.e. init runtime, prepare packet...
|
||||
@@ -49,88 +50,58 @@ class TestBase {
|
||||
// @Brief: Display information about the test
|
||||
virtual void DisplayTestInfo(void);
|
||||
|
||||
const std::string & description(void) const {return description_;}
|
||||
const std::string& description(void) const { return description_; }
|
||||
|
||||
void set_description(std::string d);
|
||||
|
||||
void set_title(std::string name) {
|
||||
title_ = name;
|
||||
}
|
||||
std::string title(void) const {
|
||||
return title_;
|
||||
}
|
||||
void set_verbosity(uint32_t v) {
|
||||
verbosity_ = v;
|
||||
}
|
||||
uint32_t verbosity(void) const {
|
||||
return verbosity_;
|
||||
}
|
||||
void set_dont_fail(bool f) {
|
||||
dont_fail_ = f;
|
||||
}
|
||||
bool dont_fail(void) const {
|
||||
return dont_fail_;
|
||||
}
|
||||
void set_num_monitor_devs(uint32_t i) {
|
||||
num_monitor_devs_ = i;
|
||||
}
|
||||
uint32_t num_monitor_devs(void) const {
|
||||
return num_monitor_devs_;
|
||||
}
|
||||
void set_monitor_server_ip(std::string ip) {
|
||||
monitor_server_ip_ = ip;
|
||||
}
|
||||
std::string monitor_server_ip(void) const {
|
||||
return monitor_server_ip_;
|
||||
}
|
||||
void set_monitor_server_port(std::string port) {
|
||||
monitor_server_port_ = port;
|
||||
}
|
||||
std::string monitor_server_port(void) const {
|
||||
return monitor_server_port_;
|
||||
}
|
||||
void set_secure(bool sec) {
|
||||
secure_ = sec;
|
||||
}
|
||||
bool secure(void) const {
|
||||
return secure_;
|
||||
}
|
||||
void set_mode(bool standalone) {
|
||||
standalone_ = standalone;
|
||||
}
|
||||
void set_title(std::string name) { title_ = name; }
|
||||
std::string title(void) const { return title_; }
|
||||
void set_verbosity(uint32_t v) { verbosity_ = v; }
|
||||
uint32_t verbosity(void) const { return verbosity_; }
|
||||
void set_dont_fail(bool f) { dont_fail_ = f; }
|
||||
bool dont_fail(void) const { return dont_fail_; }
|
||||
void set_num_monitor_devs(uint32_t i) { num_monitor_devs_ = i; }
|
||||
uint32_t num_monitor_devs(void) const { return num_monitor_devs_; }
|
||||
void set_monitor_server_ip(std::string ip) { monitor_server_ip_ = ip; }
|
||||
std::string monitor_server_ip(void) const { return monitor_server_ip_; }
|
||||
void set_monitor_server_port(std::string port) { monitor_server_port_ = port; }
|
||||
std::string monitor_server_port(void) const { return monitor_server_port_; }
|
||||
void set_secure(bool sec) { secure_ = sec; }
|
||||
bool secure(void) const { return secure_; }
|
||||
void set_mode(bool standalone) { standalone_ = standalone; }
|
||||
rdc_handle_t rdc_handle;
|
||||
|
||||
protected:
|
||||
void PrintDeviceHeader(uint32_t dv_ind);
|
||||
rdc_status_t AllocateRDCChannel(void);
|
||||
bool standalone_;
|
||||
bool standalone_;
|
||||
|
||||
private:
|
||||
uint64_t num_monitor_devs_; ///< Number of monitor devices found
|
||||
std::string description_;
|
||||
std::string title_; ///< Displayed title of test
|
||||
uint32_t verbosity_; ///< How much additional output to produce
|
||||
bool dont_fail_; ///< Don't quit test on individual failure if true
|
||||
uint32_t verbosity_; ///< How much additional output to produce
|
||||
bool dont_fail_; ///< Don't quit test on individual failure if true
|
||||
std::string monitor_server_ip_;
|
||||
std::string monitor_server_port_;
|
||||
bool secure_; // Use authenticated comms. (SSL/TSL)
|
||||
|
||||
};
|
||||
|
||||
#define IF_VERB(VB) if (verbosity() && verbosity() >= (TestBase::VERBOSE_##VB))
|
||||
|
||||
// Macros to be used within TestBase classes
|
||||
#define CHK_ERR_ASRT(RET) { \
|
||||
if (dont_fail() && ((RET) != RDC_STATUS_SUCCESS)) { \
|
||||
std::cout << std::endl << "\t===> TEST FAILURE." << std::endl; \
|
||||
DISPLAY_RDC_ERR(RET); \
|
||||
std::cout << \
|
||||
"\t===> Abort is over-ridden due to dont_fail command line option." \
|
||||
<< std::endl; \
|
||||
return; \
|
||||
} else { \
|
||||
ASSERT_EQ(RDC_STATUS_SUCCESS, (RET)); \
|
||||
} \
|
||||
}
|
||||
#define CHK_ERR_ASRT(RET) \
|
||||
{ \
|
||||
if (dont_fail() && ((RET) != RDC_STATUS_SUCCESS)) { \
|
||||
std::cout << std::endl << "\t===> TEST FAILURE." << std::endl; \
|
||||
DISPLAY_RDC_ERR(RET); \
|
||||
std::cout << "\t===> Abort is over-ridden due to dont_fail command " \
|
||||
"line option." \
|
||||
<< std::endl; \
|
||||
return; \
|
||||
} else { \
|
||||
ASSERT_EQ(RDC_STATUS_SUCCESS, (RET)); \
|
||||
} \
|
||||
}
|
||||
|
||||
#endif // TESTS_RDC_TESTS_TEST_BASE_H_
|
||||
|
||||
Executable → Regular
+107
-132
@@ -20,19 +20,21 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "rdc_tests/test_common.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
#include <getopt.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include "rdc_tests/test_base.h"
|
||||
#include "rdc_tests/test_common.h"
|
||||
#include "rocm_smi/rocm_smi.h"
|
||||
|
||||
/*static const std::map<grpc_connectivity_state, const char *> kGRPCChanState = {
|
||||
/*static const std::map<grpc_connectivity_state, const char *> kGRPCChanState =
|
||||
{
|
||||
{
|
||||
{GRPC_CHANNEL_IDLE, "GRPC_CHANNEL_IDLE: Channel is idle"},
|
||||
{GRPC_CHANNEL_CONNECTING,
|
||||
@@ -45,110 +47,89 @@ THE SOFTWARE.
|
||||
},
|
||||
};
|
||||
*/
|
||||
static const std::map<rsmi_gpu_block_t, const char *> kBlockNameMap = {
|
||||
{RSMI_GPU_BLOCK_UMC, "UMC"},
|
||||
{RSMI_GPU_BLOCK_SDMA, "SDMA"},
|
||||
{RSMI_GPU_BLOCK_GFX, "GFX"},
|
||||
{RSMI_GPU_BLOCK_MMHUB, "MMHUB"},
|
||||
{RSMI_GPU_BLOCK_ATHUB, "ATHUB"},
|
||||
{RSMI_GPU_BLOCK_PCIE_BIF, "PCIE_BIF"},
|
||||
{RSMI_GPU_BLOCK_HDP, "HDP"},
|
||||
{RSMI_GPU_BLOCK_XGMI_WAFL, "XGMI_WAFL"},
|
||||
{RSMI_GPU_BLOCK_DF, "DF"},
|
||||
{RSMI_GPU_BLOCK_SMN, "SMN"},
|
||||
{RSMI_GPU_BLOCK_SEM, "SEM"},
|
||||
{RSMI_GPU_BLOCK_MP0, "MP0"},
|
||||
{RSMI_GPU_BLOCK_MP1, "MP1"},
|
||||
{RSMI_GPU_BLOCK_FUSE, "FUSE"},
|
||||
static const std::map<rsmi_gpu_block_t, const char*> kBlockNameMap = {
|
||||
{RSMI_GPU_BLOCK_UMC, "UMC"}, {RSMI_GPU_BLOCK_SDMA, "SDMA"},
|
||||
{RSMI_GPU_BLOCK_GFX, "GFX"}, {RSMI_GPU_BLOCK_MMHUB, "MMHUB"},
|
||||
{RSMI_GPU_BLOCK_ATHUB, "ATHUB"}, {RSMI_GPU_BLOCK_PCIE_BIF, "PCIE_BIF"},
|
||||
{RSMI_GPU_BLOCK_HDP, "HDP"}, {RSMI_GPU_BLOCK_XGMI_WAFL, "XGMI_WAFL"},
|
||||
{RSMI_GPU_BLOCK_DF, "DF"}, {RSMI_GPU_BLOCK_SMN, "SMN"},
|
||||
{RSMI_GPU_BLOCK_SEM, "SEM"}, {RSMI_GPU_BLOCK_MP0, "MP0"},
|
||||
{RSMI_GPU_BLOCK_MP1, "MP1"}, {RSMI_GPU_BLOCK_FUSE, "FUSE"},
|
||||
};
|
||||
static_assert(RSMI_GPU_BLOCK_LAST == RSMI_GPU_BLOCK_FUSE,
|
||||
"kBlockNameMap needs to be updated");
|
||||
static_assert(RSMI_GPU_BLOCK_LAST == RSMI_GPU_BLOCK_FUSE, "kBlockNameMap needs to be updated");
|
||||
|
||||
static const char * kRasErrStateStrings[] = {
|
||||
"None", // RSMI_RAS_ERR_STATE_NONE
|
||||
"Disabled", // RSMI_RAS_ERR_STATE_DISABLED
|
||||
"Error Unknown", // RSMI_RAS_ERR_STATE_PARITY
|
||||
"Single, Correctable", // RSMI_RAS_ERR_STATE_SING_C
|
||||
"Multiple, Uncorrectable", // RSMI_RAS_ERR_STATE_MULT_UC
|
||||
"Poison" // RSMI_RAS_ERR_STATE_POISON
|
||||
"Off", // RSMI_RAS_ERR_STATE_DISABLED
|
||||
"On", // RSMI_RAS_ERR_STATE_ENABLED
|
||||
static const char* kRasErrStateStrings[] = {
|
||||
"None", // RSMI_RAS_ERR_STATE_NONE
|
||||
"Disabled", // RSMI_RAS_ERR_STATE_DISABLED
|
||||
"Error Unknown", // RSMI_RAS_ERR_STATE_PARITY
|
||||
"Single, Correctable", // RSMI_RAS_ERR_STATE_SING_C
|
||||
"Multiple, Uncorrectable", // RSMI_RAS_ERR_STATE_MULT_UC
|
||||
"Poison" // RSMI_RAS_ERR_STATE_POISON
|
||||
"Off", // RSMI_RAS_ERR_STATE_DISABLED
|
||||
"On", // RSMI_RAS_ERR_STATE_ENABLED
|
||||
};
|
||||
static_assert(
|
||||
sizeof(kRasErrStateStrings)/sizeof(char *) == (RSMI_RAS_ERR_STATE_LAST + 1),
|
||||
"kErrStateNameMap needs to be updated");
|
||||
static_assert(sizeof(kRasErrStateStrings) / sizeof(char*) == (RSMI_RAS_ERR_STATE_LAST + 1),
|
||||
"kErrStateNameMap needs to be updated");
|
||||
|
||||
|
||||
static const std::map<rsmi_ras_err_state_t, const char *> kErrStateNameMap = {
|
||||
{RSMI_RAS_ERR_STATE_NONE,
|
||||
kRasErrStateStrings[RSMI_RAS_ERR_STATE_NONE]},
|
||||
{RSMI_RAS_ERR_STATE_DISABLED,
|
||||
kRasErrStateStrings[RSMI_RAS_ERR_STATE_DISABLED]},
|
||||
{RSMI_RAS_ERR_STATE_PARITY,
|
||||
kRasErrStateStrings[RSMI_RAS_ERR_STATE_PARITY]},
|
||||
{RSMI_RAS_ERR_STATE_SING_C,
|
||||
kRasErrStateStrings[RSMI_RAS_ERR_STATE_SING_C]},
|
||||
{RSMI_RAS_ERR_STATE_MULT_UC,
|
||||
kRasErrStateStrings[RSMI_RAS_ERR_STATE_MULT_UC]},
|
||||
{RSMI_RAS_ERR_STATE_POISON,
|
||||
kRasErrStateStrings[RSMI_RAS_ERR_STATE_POISON]},
|
||||
{RSMI_RAS_ERR_STATE_ENABLED,
|
||||
kRasErrStateStrings[RSMI_RAS_ERR_STATE_ENABLED]},
|
||||
static const std::map<rsmi_ras_err_state_t, const char*> kErrStateNameMap = {
|
||||
{RSMI_RAS_ERR_STATE_NONE, kRasErrStateStrings[RSMI_RAS_ERR_STATE_NONE]},
|
||||
{RSMI_RAS_ERR_STATE_DISABLED, kRasErrStateStrings[RSMI_RAS_ERR_STATE_DISABLED]},
|
||||
{RSMI_RAS_ERR_STATE_PARITY, kRasErrStateStrings[RSMI_RAS_ERR_STATE_PARITY]},
|
||||
{RSMI_RAS_ERR_STATE_SING_C, kRasErrStateStrings[RSMI_RAS_ERR_STATE_SING_C]},
|
||||
{RSMI_RAS_ERR_STATE_MULT_UC, kRasErrStateStrings[RSMI_RAS_ERR_STATE_MULT_UC]},
|
||||
{RSMI_RAS_ERR_STATE_POISON, kRasErrStateStrings[RSMI_RAS_ERR_STATE_POISON]},
|
||||
{RSMI_RAS_ERR_STATE_ENABLED, kRasErrStateStrings[RSMI_RAS_ERR_STATE_ENABLED]},
|
||||
};
|
||||
static_assert(RSMI_RAS_ERR_STATE_LAST == RSMI_RAS_ERR_STATE_ENABLED,
|
||||
"kErrStateNameMap needs to be updated");
|
||||
"kErrStateNameMap needs to be updated");
|
||||
|
||||
static const struct option long_options[] = {
|
||||
{"iterations", required_argument, nullptr, 'i'},
|
||||
{"verbose", required_argument, nullptr, 'v'},
|
||||
{"monitor_verbose", required_argument, nullptr, 'm'},
|
||||
{"remote_server_ip", required_argument, nullptr, 's'},
|
||||
{"remote_server_port", required_argument, nullptr, 'p'},
|
||||
{"start_rdcd", optional_argument, nullptr, 'd'},
|
||||
{"batch_mode", no_argument, nullptr, 'b'},
|
||||
{"dont_fail", no_argument, nullptr, 'f'},
|
||||
{"unauth_comm", no_argument, nullptr, 'u'},
|
||||
{"rdctst_help", no_argument, nullptr, 'r'},
|
||||
{"iterations", required_argument, nullptr, 'i'},
|
||||
{"verbose", required_argument, nullptr, 'v'},
|
||||
{"monitor_verbose", required_argument, nullptr, 'm'},
|
||||
{"remote_server_ip", required_argument, nullptr, 's'},
|
||||
{"remote_server_port", required_argument, nullptr, 'p'},
|
||||
{"start_rdcd", optional_argument, nullptr, 'd'},
|
||||
{"batch_mode", no_argument, nullptr, 'b'},
|
||||
{"dont_fail", no_argument, nullptr, 'f'},
|
||||
{"unauth_comm", no_argument, nullptr, 'u'},
|
||||
{"rdctst_help", no_argument, nullptr, 'r'},
|
||||
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
{nullptr, 0, nullptr, 0}};
|
||||
static const char* short_options = "i:v:m:s:p:d:bfur";
|
||||
|
||||
static void PrintHelp(void) {
|
||||
std::cout <<
|
||||
"Optional rdctst Arguments:\n"
|
||||
"--batch_mode, -b run in embedded mode with no interactive prompts\n"
|
||||
"--dont_fail, -f if set, don't fail test when individual test fails; "
|
||||
"default is to fail when an individual test fails\n"
|
||||
"--rdctst_help, -r print this help message\n"
|
||||
"--verbosity, -v <verbosity level>\n"
|
||||
" Verbosity levels:\n"
|
||||
" 0 -- minimal; just summary information\n"
|
||||
" 1 -- intermediate; show intermediate values such as intermediate "
|
||||
"perf. data\n"
|
||||
" 2 -- progress; show progress displays\n"
|
||||
" >= 3 -- more debug output\n"
|
||||
"--start_rdcd <optional path>; start default version of rdcd, or "
|
||||
"optionally specified rdcd\n"
|
||||
"--remote_server_ip <ip address>; connect to already running "
|
||||
"rdcd on specified IP\n"
|
||||
"--remote_server_port <remote port>; connect to already running "
|
||||
"rdcd on specified IP at this port\n"
|
||||
"--unauth_comm; don't use TSL/SSL authentication; "
|
||||
"default is with authentication\n";
|
||||
std::cout << "Optional rdctst Arguments:\n"
|
||||
"--batch_mode, -b run in embedded mode with no interactive prompts\n"
|
||||
"--dont_fail, -f if set, don't fail test when individual test fails; "
|
||||
"default is to fail when an individual test fails\n"
|
||||
"--rdctst_help, -r print this help message\n"
|
||||
"--verbosity, -v <verbosity level>\n"
|
||||
" Verbosity levels:\n"
|
||||
" 0 -- minimal; just summary information\n"
|
||||
" 1 -- intermediate; show intermediate values such as "
|
||||
"intermediate "
|
||||
"perf. data\n"
|
||||
" 2 -- progress; show progress displays\n"
|
||||
" >= 3 -- more debug output\n"
|
||||
"--start_rdcd <optional path>; start default version of rdcd, or "
|
||||
"optionally specified rdcd\n"
|
||||
"--remote_server_ip <ip address>; connect to already running "
|
||||
"rdcd on specified IP\n"
|
||||
"--remote_server_port <remote port>; connect to already running "
|
||||
"rdcd on specified IP at this port\n"
|
||||
"--unauth_comm; don't use TSL/SSL authentication; "
|
||||
"default is with authentication\n";
|
||||
}
|
||||
|
||||
static bool CheckArgs(RDCTstGlobals *test) {
|
||||
static bool CheckArgs(RDCTstGlobals* test) {
|
||||
if (test->batch_mode) {
|
||||
if (
|
||||
(test->monitor_server_ip != "") ||
|
||||
(test->monitor_server_port != "") ||
|
||||
test->secure) {
|
||||
if ((test->monitor_server_ip != "") || (test->monitor_server_port != "") || test->secure) {
|
||||
std::cout << "--batch_mode option is incompatible with "
|
||||
"--remote_server_ip, --remote_server_port and --unauth_comm" <<
|
||||
std::endl;
|
||||
"--remote_server_ip, --remote_server_port and --unauth_comm"
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -193,7 +174,7 @@ uint32_t ProcessCmdline(RDCTstGlobals* test, int arg_cnt, char** arg_list) {
|
||||
|
||||
case 'p':
|
||||
test->monitor_server_port = optarg;
|
||||
break;
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
PrintHelp();
|
||||
@@ -213,8 +194,7 @@ uint32_t ProcessCmdline(RDCTstGlobals* test, int arg_cnt, char** arg_list) {
|
||||
break;
|
||||
|
||||
default:
|
||||
std::cout << "Unknown command line option: \"" <<
|
||||
arg_list[arg_ind] << "\"" << std::endl;
|
||||
std::cout << "Unknown command line option: \"" << arg_list[arg_ind] << "\"" << std::endl;
|
||||
PrintHelp();
|
||||
return 1;
|
||||
}
|
||||
@@ -227,31 +207,32 @@ uint32_t ProcessCmdline(RDCTstGlobals* test, int arg_cnt, char** arg_list) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char *GetBlockNameStr(rsmi_gpu_block_t id) {
|
||||
return kBlockNameMap.at(id);
|
||||
}
|
||||
const char *GetErrStateNameStr(rsmi_ras_err_state_t st) {
|
||||
return kErrStateNameMap.at(st);
|
||||
}
|
||||
const char* GetBlockNameStr(rsmi_gpu_block_t id) { return kBlockNameMap.at(id); }
|
||||
const char* GetErrStateNameStr(rsmi_ras_err_state_t st) { return kErrStateNameMap.at(st); }
|
||||
/*const char *GetGRPCChanStateStr(grpc_connectivity_state st) {
|
||||
return kGRPCChanState.at(st);
|
||||
}*/
|
||||
|
||||
const char *FreqEnumToStr(rsmi_clk_type rsmi_clk) {
|
||||
static_assert(RSMI_CLK_TYPE_LAST == RSMI_CLK_TYPE_MEM,
|
||||
"FreqEnumToStr() needs to be updated");
|
||||
const char* FreqEnumToStr(rsmi_clk_type rsmi_clk) {
|
||||
static_assert(RSMI_CLK_TYPE_LAST == RSMI_CLK_TYPE_MEM, "FreqEnumToStr() needs to be updated");
|
||||
switch (rsmi_clk) {
|
||||
case RSMI_CLK_TYPE_SYS: return "System clock";
|
||||
case RSMI_CLK_TYPE_DF: return "Data Fabric clock";
|
||||
case RSMI_CLK_TYPE_DCEF: return "Display Controller Engine clock";
|
||||
case RSMI_CLK_TYPE_SOC: return "SOC clock";
|
||||
case RSMI_CLK_TYPE_MEM: return "Memory clock";
|
||||
default: return "Invalid Clock ID";
|
||||
case RSMI_CLK_TYPE_SYS:
|
||||
return "System clock";
|
||||
case RSMI_CLK_TYPE_DF:
|
||||
return "Data Fabric clock";
|
||||
case RSMI_CLK_TYPE_DCEF:
|
||||
return "Display Controller Engine clock";
|
||||
case RSMI_CLK_TYPE_SOC:
|
||||
return "SOC clock";
|
||||
case RSMI_CLK_TYPE_MEM:
|
||||
return "Memory clock";
|
||||
default:
|
||||
return "Invalid Clock ID";
|
||||
}
|
||||
}
|
||||
|
||||
#if ENABLE_SMI
|
||||
void DumpMonitorInfo(const TestBase *test) {
|
||||
void DumpMonitorInfo(const TestBase* test) {
|
||||
int ret = 0;
|
||||
uint32_t value;
|
||||
uint32_t value2;
|
||||
@@ -259,16 +240,14 @@ void DumpMonitorInfo(const TestBase *test) {
|
||||
std::vector<std::string> val_vec;
|
||||
|
||||
assert(test != nullptr);
|
||||
assert(test->monitor_devices() != nullptr &&
|
||||
"Make sure to call test->set_monitor_devices()");
|
||||
auto print_attr_label =
|
||||
[&](std::string attrib) -> bool {
|
||||
std::cout << "\t** " << attrib;
|
||||
if (ret == -1) {
|
||||
std::cout << "not available" << std::endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
assert(test->monitor_devices() != nullptr && "Make sure to call test->set_monitor_devices()");
|
||||
auto print_attr_label = [&](std::string attrib) -> bool {
|
||||
std::cout << "\t** " << attrib;
|
||||
if (ret == -1) {
|
||||
std::cout << "not available" << std::endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
auto delim = "\t***********************************";
|
||||
@@ -277,8 +256,7 @@ void DumpMonitorInfo(const TestBase *test) {
|
||||
std::cout << delim << std::endl;
|
||||
std::cout.setf(std::ios::dec, std::ios::basefield);
|
||||
for (auto dev : *test->monitor_devices()) {
|
||||
auto print_vector =
|
||||
[&](amd::smi::DevInfoTypes type, std::string label) {
|
||||
auto print_vector = [&](amd::smi::DevInfoTypes type, std::string label) {
|
||||
ret = dev->readDevInfo(type, &val_vec);
|
||||
if (print_attr_label(label)) {
|
||||
for (auto vs : val_vec) {
|
||||
@@ -287,8 +265,7 @@ void DumpMonitorInfo(const TestBase *test) {
|
||||
val_vec.clear();
|
||||
}
|
||||
};
|
||||
auto print_val_str =
|
||||
[&](amd::smi::DevInfoTypes type, std::string label) {
|
||||
auto print_val_str = [&](amd::smi::DevInfoTypes type, std::string label) {
|
||||
ret = dev->readDevInfo(type, &val_str);
|
||||
|
||||
std::cout << "\t** " << label;
|
||||
@@ -297,16 +274,14 @@ void DumpMonitorInfo(const TestBase *test) {
|
||||
} else {
|
||||
std::cout << val_str;
|
||||
}
|
||||
std::cout << std:: endl;
|
||||
std::cout << std::endl;
|
||||
};
|
||||
|
||||
print_val_str(amd::smi::kDevDevID, "Device ID: ");
|
||||
print_val_str(amd::smi::kDevPerfLevel, "Performance Level: ");
|
||||
print_val_str(amd::smi::kDevOverDriveLevel, "OverDrive Level: ");
|
||||
print_vector(amd::smi::kDevGPUMClk,
|
||||
"Supported GPU Memory clock frequencies:\n");
|
||||
print_vector(amd::smi::kDevGPUSClk,
|
||||
"Supported GPU clock frequencies:\n");
|
||||
print_vector(amd::smi::kDevGPUMClk, "Supported GPU Memory clock frequencies:\n");
|
||||
print_vector(amd::smi::kDevGPUSClk, "Supported GPU clock frequencies:\n");
|
||||
|
||||
if (dev->monitor() != nullptr) {
|
||||
ret = dev->monitor()->readMonitor(amd::smi::kMonName, &val_str);
|
||||
@@ -316,7 +291,7 @@ void DumpMonitorInfo(const TestBase *test) {
|
||||
|
||||
ret = dev->monitor()->readMonitor(amd::smi::kMonTemp, &value);
|
||||
if (print_attr_label("Temperature: ")) {
|
||||
std::cout << static_cast<float>(value)/1000.0 << "C" << std::endl;
|
||||
std::cout << static_cast<float>(value) / 1000.0 << "C" << std::endl;
|
||||
}
|
||||
|
||||
std::cout.setf(std::ios::dec, std::ios::basefield);
|
||||
@@ -326,8 +301,8 @@ void DumpMonitorInfo(const TestBase *test) {
|
||||
ret = dev->monitor()->readMonitor(amd::smi::kMonFanSpeed, &value2);
|
||||
}
|
||||
if (print_attr_label("Current Fan Speed: ")) {
|
||||
std::cout << value2/static_cast<float>(value) * 100 << "% (" <<
|
||||
value2 << "/" << value << ")" << std::endl;
|
||||
std::cout << value2 / static_cast<float>(value) * 100 << "% (" << value2 << "/" << value
|
||||
<< ")" << std::endl;
|
||||
}
|
||||
}
|
||||
std::cout << "\t=======" << std::endl;
|
||||
|
||||
Executable → Regular
+30
-28
@@ -24,8 +24,8 @@ THE SOFTWARE.
|
||||
#define TESTS_RDC_TESTS_TEST_COMMON_H_
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "rocm_smi/rocm_smi.h"
|
||||
|
||||
@@ -45,38 +45,40 @@ struct RDCTstGlobals {
|
||||
uint32_t ProcessCmdline(RDCTstGlobals* test, int arg_cnt, char** arg_list);
|
||||
|
||||
void PrintTestHeader(uint32_t dv_ind);
|
||||
const char *GetBlockNameStr(rsmi_gpu_block_t id);
|
||||
const char *GetErrStateNameStr(rsmi_ras_err_state_t st);
|
||||
//const char *GetGRPCChanStateStr(grpc_connectivity_state st);
|
||||
const char *FreqEnumToStr(rsmi_clk_type rsmi_clk);
|
||||
const char* GetBlockNameStr(rsmi_gpu_block_t id);
|
||||
const char* GetErrStateNameStr(rsmi_ras_err_state_t st);
|
||||
// const char *GetGRPCChanStateStr(grpc_connectivity_state st);
|
||||
const char* FreqEnumToStr(rsmi_clk_type rsmi_clk);
|
||||
|
||||
#if ENABLE_SMI
|
||||
void DumpMonitorInfo(const TestBase *test);
|
||||
void DumpMonitorInfo(const TestBase* test);
|
||||
#endif
|
||||
|
||||
#define DISPLAY_RDC_ERR(RET) { \
|
||||
if (RET != RDC_STATUS_SUCCESS) { \
|
||||
const char *err_str; \
|
||||
std::cout << "\t===> ERROR: RDC call returned " << (RET) << std::endl; \
|
||||
rdc_status_string((RET), &err_str); \
|
||||
std::cout << "\t===> (" << err_str << ")" << std::endl; \
|
||||
std::cout << "\t===> at " << __FILE__ << ":" << std::dec << __LINE__ << \
|
||||
std::endl; \
|
||||
} \
|
||||
}
|
||||
#define DISPLAY_RDC_ERR(RET) \
|
||||
{ \
|
||||
if (RET != RDC_STATUS_SUCCESS) { \
|
||||
const char* err_str; \
|
||||
std::cout << "\t===> ERROR: RDC call returned " << (RET) << std::endl; \
|
||||
rdc_status_string((RET), &err_str); \
|
||||
std::cout << "\t===> (" << err_str << ")" << std::endl; \
|
||||
std::cout << "\t===> at " << __FILE__ << ":" << std::dec << __LINE__ << std::endl; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define CHK_ERR_RET(RET) { \
|
||||
DISPLAY_RDC_ERR(RET) \
|
||||
if ((RET) != RDC_STATUS_SUCCESS) { \
|
||||
return (RET); \
|
||||
} \
|
||||
}
|
||||
#define CHK_RDC_PERM_ERR(RET) { \
|
||||
if (RET == RDC_STATUS_PERMISSION) { \
|
||||
#define CHK_ERR_RET(RET) \
|
||||
{ \
|
||||
DISPLAY_RDC_ERR(RET) \
|
||||
if ((RET) != RDC_STATUS_SUCCESS) { \
|
||||
return (RET); \
|
||||
} \
|
||||
}
|
||||
#define CHK_RDC_PERM_ERR(RET) \
|
||||
{ \
|
||||
if (RET == RDC_STATUS_PERMISSION) { \
|
||||
std::cout << "This command requires root access." << std::endl; \
|
||||
} else { \
|
||||
DISPLAY_RDC_ERR(RET) \
|
||||
} \
|
||||
}
|
||||
} else { \
|
||||
DISPLAY_RDC_ERR(RET) \
|
||||
} \
|
||||
}
|
||||
|
||||
#endif // TESTS_RDC_TESTS_TEST_COMMON_H_
|
||||
|
||||
Executable → Regular
+4
-7
@@ -43,12 +43,13 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "rdc_tests/test_utils.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "rocm_smi/rocm_smi.h"
|
||||
#include "rdc_tests/test_utils.h"
|
||||
|
||||
static const std::map<rsmi_fw_block_t, const char *> kDevFWNameMap = {
|
||||
static const std::map<rsmi_fw_block_t, const char*> kDevFWNameMap = {
|
||||
{RSMI_FW_BLOCK_ASD, "asd"},
|
||||
{RSMI_FW_BLOCK_CE, "ce"},
|
||||
{RSMI_FW_BLOCK_DMCU, "dmcu"},
|
||||
@@ -72,8 +73,4 @@ static const std::map<rsmi_fw_block_t, const char *> kDevFWNameMap = {
|
||||
{RSMI_FW_BLOCK_VCN, "vcn"},
|
||||
};
|
||||
|
||||
|
||||
const char *
|
||||
NameFromFWEnum(rsmi_fw_block_t blk) {
|
||||
return kDevFWNameMap.at(blk);
|
||||
}
|
||||
const char* NameFromFWEnum(rsmi_fw_block_t blk) { return kDevFWNameMap.at(blk); }
|
||||
|
||||
Executable → Regular
+1
-2
@@ -48,7 +48,6 @@
|
||||
|
||||
#include "rocm_smi/rocm_smi.h"
|
||||
|
||||
const char *
|
||||
NameFromFWEnum(rsmi_fw_block_t blk);
|
||||
const char* NameFromFWEnum(rsmi_fw_block_t blk);
|
||||
|
||||
#endif // TESTS_RDC_TESTS_TEST_UTILS_H_
|
||||
|
||||
Fai riferimento in un nuovo problema
Block a user