Support standard deviation and json output for job stats
In the job stats, in addition to the max, min and average, it will also display the standard deviation. A new option --json is added to the rdci to output the results in json format. In the job stats, using the GMT time instead of timestamp for start and end time. Change-Id: If245c4fc4854a1dc867f97ff5aa9112af7962eca
Этот коммит содержится в:
коммит произвёл
Chris Freehill
родитель
9efb55b06f
Коммит
e6d910f67a
@@ -37,6 +37,7 @@ RdciGroupSubSystem::RdciGroupSubSystem():
|
||||
|
||||
void RdciGroupSubSystem::parse_cmd_opts(int argc, char ** argv) {
|
||||
const int HOST_OPTIONS = 1000;
|
||||
const int JSON_OPTIONS = 1001;
|
||||
const struct option long_options[] = {
|
||||
{"host", required_argument, nullptr, HOST_OPTIONS },
|
||||
{"help", optional_argument, nullptr, 'h' },
|
||||
@@ -47,6 +48,7 @@ void RdciGroupSubSystem::parse_cmd_opts(int argc, char ** argv) {
|
||||
{"add", required_argument, nullptr, 'a' },
|
||||
{"info", optional_argument, nullptr, 'i' },
|
||||
{"delete", required_argument, nullptr, 'd' },
|
||||
{"json", optional_argument, nullptr, JSON_OPTIONS },
|
||||
{ nullptr, 0 , nullptr, 0 }
|
||||
};
|
||||
|
||||
@@ -59,6 +61,9 @@ void RdciGroupSubSystem::parse_cmd_opts(int argc, char ** argv) {
|
||||
case HOST_OPTIONS:
|
||||
ip_port_ = optarg;
|
||||
break;
|
||||
case JSON_OPTIONS:
|
||||
set_json_output(true);
|
||||
break;
|
||||
case 'h':
|
||||
group_ops_ = GROUP_HELP;
|
||||
return;
|
||||
@@ -116,18 +121,22 @@ void RdciGroupSubSystem::parse_cmd_opts(int argc, char ** argv) {
|
||||
}
|
||||
|
||||
void RdciGroupSubSystem::show_help() const {
|
||||
if (is_json_output()) return;
|
||||
std::cout << " group -- Used to create and maintain groups of GPUs.\n\n";
|
||||
std::cout << "Usage\n";
|
||||
std::cout << " rdci group [--host <IP/FQDN>:port] [-u] -l\n";
|
||||
std::cout << " rdci group [--host <IP/FQDN>:port] [-u] -c <groupName> "
|
||||
<< "[-a <entityId>]\n";
|
||||
std::cout << " rdci group [--host <IP/FQDN>:port] [-u] -g <groupId> "
|
||||
<< "[-a <entityId>]\n";
|
||||
std::cout << " rdci group [--host <IP/FQDN>:port] [-u] "
|
||||
std::cout << " rdci group [--host <IP/FQDN>:port] [--json] [-u] -l\n";
|
||||
std::cout << " rdci group [--host <IP/FQDN>:port] [--json] [-u]"
|
||||
<< " -c <groupName> [-a <entityId>]\n";
|
||||
std::cout << " rdci group [--host <IP/FQDN>:port] [--json] [-u]"
|
||||
<< " -g <groupId> [-a <entityId>]\n";
|
||||
std::cout << " rdci group [--host <IP/FQDN>:port] [--json] [-u] "
|
||||
<< "-g <groupId> [-i]\n";
|
||||
std::cout << " rdci group [--host <IP/FQDN>:port] [-u] -d <groupId>\n";
|
||||
std::cout << " rdci group [--host <IP/FQDN>:port] [--json] [-u] "
|
||||
<< "-d <groupId>\n";
|
||||
std::cout << "\nFlags:\n";
|
||||
show_common_usage();
|
||||
std::cout << " --json "
|
||||
<< "Output using json.\n";
|
||||
std::cout << " -l --list "
|
||||
<< "List the groups that currently exist for a host.\n";
|
||||
std::cout << " -g --group groupId "
|
||||
@@ -148,6 +157,7 @@ void RdciGroupSubSystem::process() {
|
||||
std::vector<std::string> gpu_ids;
|
||||
rdc_group_info_t group_info;
|
||||
uint32_t count = 0;
|
||||
std::string json_group_ids = "\"gpu_groups\": [";
|
||||
switch (group_ops_) {
|
||||
case GROUP_HELP:
|
||||
show_help();
|
||||
@@ -181,8 +191,13 @@ void RdciGroupSubSystem::process() {
|
||||
}
|
||||
|
||||
if (result == RDC_ST_OK) {
|
||||
std::cout << "Successfully created group with a group ID "
|
||||
<< group_id << std::endl;
|
||||
if (is_json_output()) {
|
||||
std::cout << "\"group_id\": \"" << group_id
|
||||
<<"\", \"status\": \"ok\"";
|
||||
} else {
|
||||
std::cout << "Successfully created group with a group ID "
|
||||
<< group_id << std::endl;
|
||||
}
|
||||
return;
|
||||
}
|
||||
break;
|
||||
@@ -194,8 +209,13 @@ void RdciGroupSubSystem::process() {
|
||||
}
|
||||
result = rdc_group_gpu_destroy(rdc_handle_, group_id_);
|
||||
if (result == RDC_ST_OK) {
|
||||
std::cout << "Successfully deleted the group "
|
||||
<< group_id_ << std::endl;
|
||||
if (is_json_output()) {
|
||||
std::cout << "\"group_id\": \"" << group_id_
|
||||
<<"\", \"status\": \"ok\"";
|
||||
} else {
|
||||
std::cout << "Successfully deleted the group "
|
||||
<< group_id_ << std::endl;
|
||||
}
|
||||
return;
|
||||
}
|
||||
break;
|
||||
@@ -204,8 +224,10 @@ void RdciGroupSubSystem::process() {
|
||||
result = rdc_group_get_all_ids(rdc_handle_, group_id_list, &count);
|
||||
if ( result != RDC_ST_OK) break;
|
||||
|
||||
std::cout << count << " group found.\n";
|
||||
std::cout << "GroupID\t" << "GroupName\t" << "GPUIndex\n";
|
||||
if (!is_json_output()) {
|
||||
std::cout << count << " group found.\n";
|
||||
std::cout << "GroupID\t" << "GroupName\t" << "GPUIndex\n";
|
||||
}
|
||||
for (uint32_t i = 0; i < count; i++) {
|
||||
result = rdc_group_gpu_get_info(rdc_handle_,
|
||||
group_id_list[i], &group_info);
|
||||
@@ -215,15 +237,43 @@ void RdciGroupSubSystem::process() {
|
||||
+ std::to_string(group_id_list[i]));
|
||||
}
|
||||
|
||||
std::cout << group_id_list[i] << "\t"
|
||||
<< group_info.group_name << "\t\t";
|
||||
if (!is_json_output()) {
|
||||
std::cout << group_id_list[i] << "\t"
|
||||
<< group_info.group_name << "\t\t";
|
||||
} else {
|
||||
json_group_ids += "{\"group_id\": \"";
|
||||
json_group_ids += std::to_string(group_id_list[i]);
|
||||
json_group_ids += "\", \"group_name\": \"";
|
||||
json_group_ids += group_info.group_name;
|
||||
json_group_ids += "\", \"gpu_indexes\": [";
|
||||
}
|
||||
for (uint32_t j = 0; j < group_info.count; j++) {
|
||||
std::cout << group_info.entity_ids[j];
|
||||
if (!is_json_output()) {
|
||||
std::cout << group_info.entity_ids[j];
|
||||
} else {
|
||||
json_group_ids +=
|
||||
std::to_string(group_info.entity_ids[j]);
|
||||
}
|
||||
if (j < group_info.count -1) {
|
||||
std::cout << ",";
|
||||
if (!is_json_output()) {
|
||||
std::cout << ",";
|
||||
} else {
|
||||
json_group_ids += ",";
|
||||
}
|
||||
}
|
||||
}
|
||||
std::cout << std::endl;
|
||||
if (!is_json_output()) {
|
||||
std::cout << std::endl;
|
||||
} else {
|
||||
json_group_ids += "]}";
|
||||
if (i != count -1) {
|
||||
json_group_ids += ",";
|
||||
}
|
||||
}
|
||||
}
|
||||
if (is_json_output()) {
|
||||
json_group_ids += "], \"status\": \"ok\"";
|
||||
std::cout << json_group_ids;
|
||||
}
|
||||
break;
|
||||
case GROUP_ADD_GPUS:
|
||||
@@ -247,8 +297,13 @@ void RdciGroupSubSystem::process() {
|
||||
}
|
||||
}
|
||||
if (result == RDC_ST_OK) {
|
||||
std::cout << "Successfully added the GPU " << gpu_ids_
|
||||
<< " to group "<< group_id_ << std::endl;
|
||||
if (is_json_output()) {
|
||||
std::cout << "\"group_id\": \"" << group_id_
|
||||
<<"\", \"status\": \"ok\"";
|
||||
} else {
|
||||
std::cout << "Successfully added the GPU " << gpu_ids_
|
||||
<< " to group "<< group_id_ << std::endl;
|
||||
}
|
||||
return;
|
||||
}
|
||||
break;
|
||||
@@ -261,13 +316,29 @@ void RdciGroupSubSystem::process() {
|
||||
result = rdc_group_gpu_get_info(rdc_handle_,
|
||||
group_id_, &group_info);
|
||||
if (result == RDC_ST_OK) {
|
||||
std::cout << "Group name: "
|
||||
<< group_info.group_name << std::endl;
|
||||
std::cout << "Gpu indexes: ";
|
||||
for (uint32_t i = 0; i < group_info.count; i++) {
|
||||
std::cout << group_info.entity_ids[i] << " ";
|
||||
if (is_json_output()) {
|
||||
std::cout << "\"group_name\": \"" << group_info.group_name
|
||||
<< "\", \"gpu_indexes\": [";
|
||||
} else {
|
||||
std::cout << "Group name: "
|
||||
<< group_info.group_name << std::endl;
|
||||
std::cout << "Gpu indexes: ";
|
||||
}
|
||||
for (uint32_t i = 0; i < group_info.count; i++) {
|
||||
if (is_json_output()) {
|
||||
std::cout << group_info.entity_ids[i];
|
||||
if ( i != group_info.count-1 ) {
|
||||
std::cout << ",";
|
||||
}
|
||||
} else {
|
||||
std::cout << group_info.entity_ids[i] << " ";
|
||||
}
|
||||
}
|
||||
if (is_json_output()) {
|
||||
std::cout << "], \"status\": \"ok\"";
|
||||
} else {
|
||||
std::cout << std::endl;
|
||||
}
|
||||
std::cout << std::endl;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
Ссылка в новой задаче
Block a user