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-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";
|
|
|
|
static const string ver_module = "module";
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Private functions
|
|
|
|
//
|
|
|
|
|
|
|
|
static void show_mca_version(const mca_base_module_t *module,
|
|
|
|
const string& scope, const string& ver_type);
|
|
|
|
static string make_version_str(const string& scope,
|
|
|
|
int major, int minor, int release, int alpha,
|
2004-03-19 09:05:27 +03:00
|
|
|
int beta, int svn);
|
2004-01-19 20:43:50 +03:00
|
|
|
|
|
|
|
//
|
|
|
|
// do_version
|
|
|
|
//
|
2004-06-07 19:33:53 +04:00
|
|
|
// Determines the version information related to the ompi modules
|
2004-01-19 20:43:50 +03:00
|
|
|
// being used.
|
|
|
|
// Accepts:
|
|
|
|
// - want_all: True if all modules' info is required.
|
|
|
|
// - 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-01-19 20:43:50 +03:00
|
|
|
string arg1, scope, type, module;
|
|
|
|
string::size_type pos;
|
|
|
|
|
|
|
|
open_modules();
|
|
|
|
|
|
|
|
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-01-19 20:43:50 +03:00
|
|
|
show_module_version(mca_types[i], module_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-06-07 19:33:53 +04:00
|
|
|
// Version of OMPI/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
|
|
|
}
|
|
|
|
|
|
|
|
// Specific type and module
|
|
|
|
|
|
|
|
else if (string::npos != (pos = arg1.find(':'))) {
|
|
|
|
type = arg1.substr(0, pos - 1);
|
|
|
|
module = arg1.substr(pos);
|
|
|
|
|
|
|
|
show_module_version(type, module, scope, ver_all);
|
|
|
|
}
|
|
|
|
|
|
|
|
// All modules of a specific type
|
|
|
|
|
|
|
|
else {
|
|
|
|
show_module_version(arg1, module_all, scope, ver_all);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
2004-06-07 19:33:53 +04:00
|
|
|
// Show the version of OMPI/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-06-07 19:33:53 +04:00
|
|
|
out("OMPI/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,
|
|
|
|
OMPI_ALPHA_VERSION, OMPI_BETA_VERSION, OMPI_SVN_VERSION));
|
2004-01-19 20:43:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Show all the modules of a specific type/module combo (module may be
|
|
|
|
// a wildcard)
|
|
|
|
//
|
2004-06-07 19:33:53 +04:00
|
|
|
void ompi_info::show_module_version(const string& type_name,
|
2004-01-29 05:51:20 +03:00
|
|
|
const string& module_name,
|
|
|
|
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-01-19 20:43:50 +03:00
|
|
|
bool want_all_modules = (type_all == module_name);
|
|
|
|
bool found;
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_list_item *item;
|
2004-01-29 05:51:20 +03:00
|
|
|
mca_base_module_list_item_t *mli;
|
|
|
|
const mca_base_module_t *module;
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_list_t *modules;
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now that we have a valid type, find the right module list
|
|
|
|
|
|
|
|
modules = module_map[type_name];
|
2004-02-14 01:17:42 +03:00
|
|
|
if (NULL != modules) {
|
2004-06-07 19:33:53 +04:00
|
|
|
for (item = ompi_list_get_first(modules);
|
|
|
|
ompi_list_get_end(modules) != item;
|
|
|
|
item = ompi_list_get_next(item)) {
|
2004-02-14 01:17:42 +03:00
|
|
|
mli = (mca_base_module_list_item_t *) item;
|
|
|
|
module = mli->mli_module;
|
|
|
|
if (want_all_modules || module->mca_module_name == module_name) {
|
|
|
|
show_mca_version(module, scope, ver_type);
|
|
|
|
}
|
2004-01-19 20:43:50 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Given a module, display its relevant version(s)
|
|
|
|
//
|
|
|
|
static void show_mca_version(const mca_base_module_t* module,
|
|
|
|
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);
|
|
|
|
bool want_module = (ver_all == ver_type || ver_type == ver_module);
|
|
|
|
string message, content;
|
|
|
|
string mca_version;
|
|
|
|
string api_version;
|
|
|
|
string module_version;
|
|
|
|
string empty;
|
|
|
|
|
|
|
|
mca_version = make_version_str(scope, module->mca_major_version,
|
|
|
|
module->mca_minor_version,
|
|
|
|
module->mca_release_version, 0, 0, 0);
|
|
|
|
api_version = make_version_str(scope, module->mca_type_major_version,
|
|
|
|
module->mca_type_minor_version,
|
|
|
|
module->mca_type_release_version, 0, 0, 0);
|
|
|
|
module_version = make_version_str(scope, module->mca_module_major_version,
|
|
|
|
module->mca_module_minor_version,
|
|
|
|
module->mca_module_release_version,
|
|
|
|
0, 0, 0);
|
|
|
|
|
|
|
|
if (pretty) {
|
|
|
|
message = "MCA ";
|
|
|
|
message += module->mca_type_name;
|
|
|
|
printed = false;
|
|
|
|
|
|
|
|
content = module->mca_module_name + string(" (");
|
|
|
|
if (want_mca) {
|
|
|
|
content += "MCA v" + mca_version;
|
|
|
|
printed = true;
|
|
|
|
}
|
|
|
|
if (want_type) {
|
|
|
|
if (printed)
|
|
|
|
content += ", ";
|
|
|
|
content += "API v" + api_version;
|
|
|
|
printed = true;
|
|
|
|
}
|
|
|
|
if (want_module) {
|
|
|
|
if (printed)
|
|
|
|
content += ", ";
|
|
|
|
content += "Module v" + module_version;
|
|
|
|
printed = true;
|
|
|
|
}
|
|
|
|
out(message, empty, content + ")");
|
|
|
|
} else {
|
|
|
|
message = "mca:";
|
|
|
|
message += module->mca_type_name;
|
|
|
|
message += ":";
|
|
|
|
message += module->mca_module_name;
|
|
|
|
message += ":version";
|
|
|
|
if (want_mca)
|
|
|
|
out(empty, message, "mca:" + mca_version);
|
|
|
|
if (want_type)
|
|
|
|
out(empty, message, "api:" + api_version);
|
|
|
|
if (want_module)
|
|
|
|
out(empty, message, "module:" + module_version);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static string make_version_str(const string& scope,
|
|
|
|
int major, int minor, int release, int alpha,
|
2004-03-19 09:05:27 +03:00
|
|
|
int beta, int 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-03-19 09:05:27 +03:00
|
|
|
if (svn > 0) {
|
|
|
|
str += "svn";
|
|
|
|
if (svn > 1) {
|
|
|
|
snprintf(temp, BUFSIZ - 1, "%d", svn);
|
2004-01-19 20:43:50 +03:00
|
|
|
str += temp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} 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)
|
|
|
|
snprintf(temp, BUFSIZ - 1, "%d", 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;
|
|
|
|
}
|