Skip to content

Commit

Permalink
Merge pull request #869 from jkottiku/master
Browse files Browse the repository at this point in the history
Add gpu index in json log
  • Loading branch information
jkottiku authored Dec 20, 2024
2 parents a74ec5a + 71bcfe4 commit d9d7201
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 12 deletions.
8 changes: 7 additions & 1 deletion gpup.so/src/action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -488,9 +488,15 @@ int gpup_action::run(void) {
if (bjson){
json_root_node = json_node_create(std::string(module_name),
action_name.c_str(), rvs::logresults);
if(json_root_node)
if(json_root_node) {
rvs::lp::AddString(json_root_node, RVS_JSON_LOG_GPU_ID_KEY, std::to_string(gpu_id[i]));

uint16_t gpu_index = 0;
rvs::gpulist::gpu2gpuindex(gpu_id[i], &gpu_index);
rvs::lp::AddString(json_root_node, RVS_JSON_LOG_GPU_IDX_KEY, std::to_string(gpu_index));
}
}

// properties values
sts = property_get_value(gpu_id[i]);
sts = property_io_links_get_value(gpu_id[i]);
Expand Down
1 change: 1 addition & 0 deletions include/rvs_key_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,6 @@
#define YAML_DEVICE_PROP_DELIMITER " "

#define RVS_JSON_LOG_GPU_ID_KEY "gpu_id"
#define RVS_JSON_LOG_GPU_IDX_KEY "gpu_index"

#endif // INCLUDE_RVS_KEY_DEF_H_
10 changes: 8 additions & 2 deletions include/rvs_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ bool fetch_gpu_list(int hip_num_gpu_devices, map<int, uint16_t>& gpus_device_ind
void getBDF(int idx ,unsigned int& domain,unsigned int& bus,unsigned int& device,unsigned int& function);
int display_gpu_info(void);
void *json_list_create(std::string lname, int log_level);

template <typename... KVPairs>
void log_to_json(action_descriptor desc, int log_level, KVPairs... key_values ) {
std::vector<std::string> kvlist{key_values...};
Expand All @@ -146,8 +147,13 @@ void log_to_json(action_descriptor desc, int log_level, KVPairs... key_values )
void *json_node = json_node_create(desc.module_name,
desc.action_name.c_str(), log_level);
if (json_node) {
rvs::lp::AddString(json_node, "gpu_id",
std::to_string(desc.gpu_id));

rvs::lp::AddString(json_node, "gpu_id", std::to_string(desc.gpu_id));

uint16_t gpu_index = 0;
rvs::gpulist::gpu2gpuindex(desc.gpu_id, &gpu_index);
rvs::lp::AddString(json_node, "gpu_index", std::to_string(gpu_index));

for (int i =0; i< kvlist.size()-1; i +=2){
rvs::lp::AddString(json_node, kvlist[i], kvlist[i+1]);
}
Expand Down
16 changes: 12 additions & 4 deletions mem.so/src/rvs_memworker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,12 @@ void MemWorker::run() {
void *json_node = json_node_create(std::string(MODULE_NAME),
action_name.c_str(), rvs::loginfo);
if (json_node){
rvs::lp::AddString(json_node, "gpu_id",
std::to_string(gpu_id));
rvs::lp::AddString(json_node, "gpu_id", std::to_string(gpu_id));

uint16_t gpu_index = 0;
rvs::gpulist::gpu2gpuindex(gpu_id, &gpu_index);
rvs::lp::AddString(json_node, "gpu_index", std::to_string(gpu_index));

rvs::lp::AddString(json_node,"Total Memory", std::to_string(total));
rvs::lp::AddString(json_node,"Free Memory", std::to_string(free));
rvs::lp::LogRecordFlush(json_node, rvs::logresults);
Expand Down Expand Up @@ -289,8 +293,12 @@ void MemWorker::log_to_json(int log_level, KVPairs... key_values ) {
void *json_node = json_node_create(std::string(MODULE_NAME),
action_name.c_str(), log_level);
if (json_node) {
rvs::lp::AddString(json_node, "gpu_id",
std::to_string(gpu_id));
rvs::lp::AddString(json_node, "gpu_id", std::to_string(gpu_id));

uint16_t gpu_index = 0;
rvs::gpulist::gpu2gpuindex(gpu_id, &gpu_index);
rvs::lp::AddString(json_node, "gpu_index", std::to_string(gpu_index));

for (int i =0; i< kvlist.size()-1; i +=2){
rvs::lp::AddString(json_node, kvlist[i], kvlist[i+1]);
}
Expand Down
7 changes: 5 additions & 2 deletions peqt.so/src/action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,11 @@ bool peqt_action::get_gpu_all_pcie_capabilities(struct pci_dev *dev,
action_name.c_str(), rvs::logresults);

if (json_pcaps_node != NULL) {
rvs::lp::AddString(json_pcaps_node, RVS_JSON_LOG_GPU_ID_KEY,
std::to_string(gpu_id));
rvs::lp::AddString(json_pcaps_node, RVS_JSON_LOG_GPU_ID_KEY, std::to_string(gpu_id));

uint16_t gpu_index = 0;
rvs::gpulist::gpu2gpuindex(gpu_id, &gpu_index);
rvs::lp::AddString(json_pcaps_node, RVS_JSON_LOG_GPU_IDX_KEY, std::to_string(gpu_index));
}
}
for (it = property.begin(); it != property.end(); ++it) {
Expand Down
10 changes: 7 additions & 3 deletions perf.so/src/perf_worker.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/********************************************************************************
*
* Copyright (c) 2018-2022 Advanced Micro Devices, Inc. All rights reserved.
* Copyright (c) 2018-2024 Advanced Micro Devices, Inc. All rights reserved.
*
* MIT LICENSE:
* Permission is hereby granted, free of charge, to any person obtaining a copy of
Expand Down Expand Up @@ -277,8 +277,12 @@ void PERFWorker::log_to_json(const std::string &key, const std::string &value,
void *json_node = rvs::lp::LogRecordCreate(MODULE_NAME,
action_name.c_str(), log_level, sec, usec);
if (json_node) {
rvs::lp::AddString(json_node, PERF_JSON_LOG_GPU_ID_KEY,
std::to_string(gpu_id));
rvs::lp::AddString(json_node, PERF_JSON_LOG_GPU_ID_KEY, std::to_string(gpu_id));

uint16_t gpu_index = 0;
rvs::gpulist::gpu2gpuindex(gpu_id, &gpu_index);
rvs::lp::AddString(json_node, "gpu_index", std::to_string(gpu_index));

rvs::lp::AddString(json_node, key, value);
rvs::lp::LogRecordFlush(json_node);
}
Expand Down
10 changes: 10 additions & 0 deletions pesm.so/src/worker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,11 @@ void Worker::run() {
r = json_node_create("PESM",
stop_action_name.c_str(), rvs::logresults);
rvs::lp::AddString(r, "gpu_id", std::to_string(i.first));

uint16_t gpu_index = 0;
rvs::gpulist::gpu2gpuindex(i.first, &gpu_index);
rvs::lp::AddString(r, "gpu_index", std::to_string(gpu_index));

rvs::lp::AddString(r, "pcie speed change",i.second);
rvs::lp::LogRecordFlush(r);
r = nullptr;
Expand All @@ -278,6 +283,11 @@ void Worker::run() {
r = json_node_create("PESM",
stop_action_name.c_str(), rvs::logresults);
rvs::lp::AddString(r, "gpu_id", std::to_string(i.first));

uint16_t gpu_index = 0;
rvs::gpulist::gpu2gpuindex(i.first, &gpu_index);
rvs::lp::AddString(r, "gpu_index", std::to_string(gpu_index));

rvs::lp::AddString(r, "power_change", i.second);
rvs::lp::AddString(r, "msg", "stopped");
rvs::lp::LogRecordFlush(r);
Expand Down
3 changes: 3 additions & 0 deletions tst.so/src/tst_worker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
#define TST_PASS_KEY "pass"

#define TST_JSON_LOG_GPU_ID_KEY "gpu_id"
#define TST_JSON_LOG_GPU_IDX_KEY "gpu_index"
#define TST_MEM_ALLOC_ERROR 1
#define TST_BLAS_ERROR 2
#define TST_BLAS_MEMCPY_ERROR 3
Expand Down Expand Up @@ -95,6 +96,8 @@ void TSTWorker::log_to_json(const std::string &key, const std::string &value,
if (json_node) {
rvs::lp::AddString(json_node, TST_JSON_LOG_GPU_ID_KEY,
std::to_string(gpu_id));
rvs::lp::AddString(json_node, TST_JSON_LOG_GPU_IDX_KEY,
std::to_string(smi_device_index));
rvs::lp::AddString(json_node, key, value);
rvs::lp::LogRecordFlush(json_node);
}
Expand Down

0 comments on commit d9d7201

Please sign in to comment.