2004-01-19 20:43:50 +03:00
|
|
|
//
|
2004-11-22 04:38:40 +03:00
|
|
|
// Copyright (c) 2004-2005 The Trustees of Indiana University.
|
|
|
|
// All rights reserved.
|
|
|
|
// Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
|
|
|
|
// All rights reserved.
|
2004-11-28 23:09:25 +03:00
|
|
|
// Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
// University of Stuttgart. All rights reserved.
|
2005-03-24 15:43:37 +03:00
|
|
|
// Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
// All rights reserved.
|
2004-11-22 04:38:40 +03:00
|
|
|
// $COPYRIGHT$
|
|
|
|
//
|
|
|
|
// Additional copyrights may follow
|
|
|
|
//
|
2004-01-19 20:43:50 +03:00
|
|
|
// $HEADER$
|
|
|
|
//
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
#include "ompi_config.h"
|
2004-01-19 20:43:50 +03:00
|
|
|
|
2004-01-29 05:51:20 +03:00
|
|
|
#include <iostream>
|
2004-01-19 20:43:50 +03:00
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2004-03-17 21:45:16 +03:00
|
|
|
#include "mca/base/base.h"
|
2004-06-07 19:33:53 +04:00
|
|
|
#include "tools/ompi_info/ompi_info.h"
|
2004-10-26 19:47:15 +04:00
|
|
|
#include "util/printf.h"
|
2004-01-19 20:43:50 +03:00
|
|
|
|
|
|
|
using namespace std;
|
2004-06-07 19:33:53 +04:00
|
|
|
using namespace ompi_info;
|
2004-01-19 20:43:50 +03:00
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Public variables
|
|
|
|
//
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
const string ompi_info::ver_full = "full";
|
|
|
|
const string ompi_info::ver_major = "major";
|
|
|
|
const string ompi_info::ver_minor = "minor";
|
|
|
|
const string ompi_info::ver_release = "release";
|
|
|
|
const string ompi_info::ver_alpha = "alpha";
|
|
|
|
const string ompi_info::ver_beta = "beta";
|
|
|
|
const string ompi_info::ver_svn = "svn";
|
2004-01-19 20:43:50 +03:00
|
|
|
|
|
|
|
//
|
|
|
|
// Private variables
|
|
|
|
//
|
|
|
|
|
|
|
|
static const string ver_all = "all";
|
|
|
|
static const string ver_mca = "mca";
|
|
|
|
static const string ver_type = "type";
|
2004-07-14 00:25:12 +04:00
|
|
|
static const string ver_component = "component";
|
2004-01-19 20:43:50 +03:00
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Private functions
|
|
|
|
//
|
|
|
|
|
2004-08-02 04:24:22 +04:00
|
|
|
static void show_mca_version(const mca_base_component_t *component,
|
2004-01-19 20:43:50 +03:00
|
|
|
const string& scope, const string& ver_type);
|
|
|
|
static string make_version_str(const string& scope,
|
|
|
|
int major, int minor, int release, int alpha,
|
2004-07-07 16:45:36 +04:00
|
|
|
int beta, const string& svn);
|
2004-01-19 20:43:50 +03:00
|
|
|
|
|
|
|
//
|
|
|
|
// do_version
|
|
|
|
//
|
2004-07-14 00:25:12 +04:00
|
|
|
// Determines the version information related to the ompi components
|
2004-01-19 20:43:50 +03:00
|
|
|
// being used.
|
|
|
|
// Accepts:
|
2004-07-14 00:25:12 +04:00
|
|
|
// - want_all: True if all components' info is required.
|
2004-01-19 20:43:50 +03:00
|
|
|
// - cmd_line: The constructed command line argument
|
|
|
|
//
|
2004-06-07 19:33:53 +04:00
|
|
|
void ompi_info::do_version(bool want_all, ompi_cmd_line_t *cmd_line)
|
2004-01-19 20:43:50 +03:00
|
|
|
{
|
|
|
|
unsigned int count;
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_info::type_vector_t::size_type i;
|
2004-07-14 00:25:12 +04:00
|
|
|
string arg1, scope, type, component;
|
2004-01-19 20:43:50 +03:00
|
|
|
string::size_type pos;
|
|
|
|
|
2004-07-14 00:25:12 +04:00
|
|
|
open_components();
|
2004-01-19 20:43:50 +03:00
|
|
|
|
|
|
|
if (want_all) {
|
2004-06-07 19:33:53 +04:00
|
|
|
show_ompi_version(ver_full);
|
2004-01-30 06:59:17 +03:00
|
|
|
for (i = 0; i < mca_types.size(); ++i) {
|
2004-07-14 00:25:12 +04:00
|
|
|
show_component_version(mca_types[i], component_all, ver_full, type_all);
|
2004-01-30 06:59:17 +03:00
|
|
|
}
|
2004-01-19 20:43:50 +03:00
|
|
|
} else {
|
2004-06-07 19:33:53 +04:00
|
|
|
count = ompi_cmd_line_get_ninsts(cmd_line, "version");
|
2004-01-19 20:43:50 +03:00
|
|
|
for (i = 0; i < count; ++i) {
|
2004-06-07 19:33:53 +04:00
|
|
|
arg1 = ompi_cmd_line_get_param(cmd_line, "version", i, 0);
|
|
|
|
scope = ompi_cmd_line_get_param(cmd_line, "version", i, 1);
|
2004-01-19 20:43:50 +03:00
|
|
|
|
2004-08-06 18:30:18 +04:00
|
|
|
// Version of Open MPI
|
2004-01-19 20:43:50 +03:00
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
if (type_ompi == arg1) {
|
|
|
|
show_ompi_version(scope);
|
2004-01-19 20:43:50 +03:00
|
|
|
}
|
|
|
|
|
2004-07-14 00:25:12 +04:00
|
|
|
// Specific type and component
|
2004-01-19 20:43:50 +03:00
|
|
|
|
|
|
|
else if (string::npos != (pos = arg1.find(':'))) {
|
|
|
|
type = arg1.substr(0, pos - 1);
|
2004-07-14 00:25:12 +04:00
|
|
|
component = arg1.substr(pos);
|
2004-01-19 20:43:50 +03:00
|
|
|
|
2004-07-14 00:25:12 +04:00
|
|
|
show_component_version(type, component, scope, ver_all);
|
2004-01-19 20:43:50 +03:00
|
|
|
}
|
|
|
|
|
2004-07-14 00:25:12 +04:00
|
|
|
// All components of a specific type
|
2004-01-19 20:43:50 +03:00
|
|
|
|
|
|
|
else {
|
2004-07-14 00:25:12 +04:00
|
|
|
show_component_version(arg1, component_all, scope, ver_all);
|
2004-01-19 20:43:50 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
2004-08-06 18:30:18 +04:00
|
|
|
// Show the version of Open MPI
|
2004-01-19 20:43:50 +03:00
|
|
|
//
|
2004-06-07 19:33:53 +04:00
|
|
|
void ompi_info::show_ompi_version(const string& scope)
|
2004-01-19 20:43:50 +03:00
|
|
|
{
|
2004-08-06 18:30:18 +04:00
|
|
|
out("Open MPI", "version:" + type_ompi,
|
2004-01-19 20:43:50 +03:00
|
|
|
make_version_str(scope,
|
2004-06-07 19:33:53 +04:00
|
|
|
OMPI_MAJOR_VERSION, OMPI_MINOR_VERSION,
|
|
|
|
OMPI_RELEASE_VERSION,
|
2004-07-07 16:45:36 +04:00
|
|
|
OMPI_ALPHA_VERSION, OMPI_BETA_VERSION,
|
|
|
|
OMPI_SVN_VERSION));
|
2004-01-19 20:43:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
2004-07-14 00:25:12 +04:00
|
|
|
// Show all the components of a specific type/component combo (component may be
|
2004-01-19 20:43:50 +03:00
|
|
|
// a wildcard)
|
|
|
|
//
|
2004-07-14 00:25:12 +04:00
|
|
|
void ompi_info::show_component_version(const string& type_name,
|
|
|
|
const string& component_name,
|
2004-01-29 05:51:20 +03:00
|
|
|
const string& scope, const string& ver_type)
|
2004-01-19 20:43:50 +03:00
|
|
|
{
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_info::type_vector_t::size_type i;
|
2004-07-14 00:25:12 +04:00
|
|
|
bool want_all_components = (type_all == component_name);
|
2004-01-19 20:43:50 +03:00
|
|
|
bool found;
|
2004-08-11 20:18:52 +04:00
|
|
|
ompi_list_item_t *item;
|
2004-08-02 04:24:22 +04:00
|
|
|
mca_base_component_list_item_t *cli;
|
|
|
|
const mca_base_component_t *component;
|
2004-07-14 00:25:12 +04:00
|
|
|
ompi_list_t *components;
|
2004-01-19 20:43:50 +03:00
|
|
|
|
|
|
|
// Check to see if the type is valid
|
|
|
|
|
|
|
|
for (found = false, i = 0; i < mca_types.size(); ++i) {
|
|
|
|
if (mca_types[i] == type_name) {
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!found) {
|
|
|
|
#if 0
|
2004-06-07 19:33:53 +04:00
|
|
|
show_help("ompi_info", "usage");
|
2004-01-19 20:43:50 +03:00
|
|
|
#endif
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2004-07-14 00:25:12 +04:00
|
|
|
// Now that we have a valid type, find the right component list
|
2004-01-19 20:43:50 +03:00
|
|
|
|
2004-07-14 00:25:12 +04:00
|
|
|
components = component_map[type_name];
|
|
|
|
if (NULL != components) {
|
|
|
|
for (item = ompi_list_get_first(components);
|
|
|
|
ompi_list_get_end(components) != item;
|
2004-06-07 19:33:53 +04:00
|
|
|
item = ompi_list_get_next(item)) {
|
2004-08-02 04:24:22 +04:00
|
|
|
cli = (mca_base_component_list_item_t *) item;
|
|
|
|
component = cli->cli_component;
|
2004-07-14 00:25:12 +04:00
|
|
|
if (want_all_components ||
|
2004-08-02 04:24:22 +04:00
|
|
|
component->mca_component_name == component_name) {
|
2004-07-14 00:25:12 +04:00
|
|
|
show_mca_version(component, scope, ver_type);
|
2004-02-14 01:17:42 +03:00
|
|
|
}
|
2004-01-19 20:43:50 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
2004-07-14 00:25:12 +04:00
|
|
|
// Given a component, display its relevant version(s)
|
2004-01-19 20:43:50 +03:00
|
|
|
//
|
2004-08-02 04:24:22 +04:00
|
|
|
static void show_mca_version(const mca_base_component_t* component,
|
2004-01-19 20:43:50 +03:00
|
|
|
const string& scope, const string& ver_type)
|
|
|
|
{
|
|
|
|
bool printed;
|
|
|
|
bool want_mca = (ver_all == ver_type || ver_type == ver_mca);
|
|
|
|
bool want_type = (ver_all == ver_type || ver_type == ver_type);
|
2004-07-14 00:25:12 +04:00
|
|
|
bool want_component = (ver_all == ver_type || ver_type == ver_component);
|
2004-01-19 20:43:50 +03:00
|
|
|
string message, content;
|
|
|
|
string mca_version;
|
|
|
|
string api_version;
|
2004-07-14 00:25:12 +04:00
|
|
|
string component_version;
|
2004-01-19 20:43:50 +03:00
|
|
|
string empty;
|
|
|
|
|
2004-07-14 00:25:12 +04:00
|
|
|
mca_version = make_version_str(scope, component->mca_major_version,
|
|
|
|
component->mca_minor_version,
|
|
|
|
component->mca_release_version, 0, 0, "");
|
|
|
|
api_version = make_version_str(scope, component->mca_type_major_version,
|
|
|
|
component->mca_type_minor_version,
|
|
|
|
component->mca_type_release_version, 0, 0, "");
|
2004-08-02 04:24:22 +04:00
|
|
|
component_version = make_version_str(scope, component->mca_component_major_version,
|
|
|
|
component->mca_component_minor_version,
|
|
|
|
component->mca_component_release_version,
|
2004-07-07 16:45:36 +04:00
|
|
|
0, 0, "");
|
2004-01-19 20:43:50 +03:00
|
|
|
|
|
|
|
if (pretty) {
|
|
|
|
message = "MCA ";
|
2004-07-14 00:25:12 +04:00
|
|
|
message += component->mca_type_name;
|
2004-01-19 20:43:50 +03:00
|
|
|
printed = false;
|
|
|
|
|
2004-08-02 04:24:22 +04:00
|
|
|
content = component->mca_component_name + string(" (");
|
2004-01-19 20:43:50 +03:00
|
|
|
if (want_mca) {
|
|
|
|
content += "MCA v" + mca_version;
|
|
|
|
printed = true;
|
|
|
|
}
|
|
|
|
if (want_type) {
|
|
|
|
if (printed)
|
|
|
|
content += ", ";
|
|
|
|
content += "API v" + api_version;
|
|
|
|
printed = true;
|
|
|
|
}
|
2004-07-14 00:25:12 +04:00
|
|
|
if (want_component) {
|
2004-01-19 20:43:50 +03:00
|
|
|
if (printed)
|
|
|
|
content += ", ";
|
2004-07-14 00:25:12 +04:00
|
|
|
content += "Component v" + component_version;
|
2004-01-19 20:43:50 +03:00
|
|
|
printed = true;
|
|
|
|
}
|
|
|
|
out(message, empty, content + ")");
|
|
|
|
} else {
|
|
|
|
message = "mca:";
|
2004-07-14 00:25:12 +04:00
|
|
|
message += component->mca_type_name;
|
2004-01-19 20:43:50 +03:00
|
|
|
message += ":";
|
2004-08-02 04:24:22 +04:00
|
|
|
message += component->mca_component_name;
|
2004-01-19 20:43:50 +03:00
|
|
|
message += ":version";
|
|
|
|
if (want_mca)
|
|
|
|
out(empty, message, "mca:" + mca_version);
|
|
|
|
if (want_type)
|
|
|
|
out(empty, message, "api:" + api_version);
|
2004-07-14 00:25:12 +04:00
|
|
|
if (want_component)
|
|
|
|
out(empty, message, "component:" + component_version);
|
2004-01-19 20:43:50 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static string make_version_str(const string& scope,
|
|
|
|
int major, int minor, int release, int alpha,
|
2004-07-07 16:45:36 +04:00
|
|
|
int beta, const string& svn)
|
2004-01-19 20:43:50 +03:00
|
|
|
{
|
|
|
|
string str;
|
|
|
|
char temp[BUFSIZ];
|
|
|
|
|
|
|
|
temp[BUFSIZ - 1] = '\0';
|
|
|
|
if (scope == ver_full) {
|
|
|
|
snprintf(temp, BUFSIZ - 1, "%d.%d", major, minor);
|
|
|
|
str = temp;
|
|
|
|
if (release > 0) {
|
|
|
|
snprintf(temp, BUFSIZ - 1, ".%d", release);
|
|
|
|
str += temp;
|
|
|
|
}
|
|
|
|
if (alpha > 0) {
|
|
|
|
snprintf(temp, BUFSIZ - 1, "a%d", alpha);
|
|
|
|
str += temp;
|
|
|
|
}
|
|
|
|
else if (beta > 0) {
|
|
|
|
snprintf(temp, BUFSIZ - 1, "b%d", beta);
|
|
|
|
str += temp;
|
|
|
|
}
|
2004-07-07 16:45:36 +04:00
|
|
|
if (!svn.empty()) {
|
|
|
|
str += svn;
|
2004-01-19 20:43:50 +03:00
|
|
|
}
|
|
|
|
} else if (scope == ver_major)
|
|
|
|
snprintf(temp, BUFSIZ - 1, "%d", major);
|
|
|
|
else if (scope == ver_minor)
|
|
|
|
snprintf(temp, BUFSIZ - 1, "%d", minor);
|
|
|
|
else if (scope == ver_release)
|
|
|
|
snprintf(temp, BUFSIZ - 1, "%d", release);
|
|
|
|
else if (scope == ver_alpha)
|
|
|
|
snprintf(temp, BUFSIZ - 1, "%d", alpha);
|
|
|
|
else if (scope == ver_beta)
|
|
|
|
snprintf(temp, BUFSIZ - 1, "%d", beta);
|
2004-03-19 09:05:27 +03:00
|
|
|
else if (scope == ver_svn)
|
2004-07-07 16:45:36 +04:00
|
|
|
str = svn;
|
2004-01-19 20:43:50 +03:00
|
|
|
else {
|
|
|
|
#if 0
|
2004-06-07 19:33:53 +04:00
|
|
|
show_help("ompi_info", "usage");
|
2004-01-19 20:43:50 +03:00
|
|
|
#endif
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (str.empty())
|
|
|
|
str = temp;
|
|
|
|
|
|
|
|
return str;
|
|
|
|
}
|