1
1

Added new solaris sysinfo module. Also added code to assign

orte_local_chip_type and orte_local_chip_model in MPI processes it the
appropriate sysinfo module found the values on the machine.

This commit was SVN r23581.
Этот коммит содержится в:
Terry Dontje 2010-08-09 19:28:56 +00:00
родитель 16bf3c2f30
Коммит b74ef351b7
17 изменённых файлов: 848 добавлений и 16 удалений

38
opal/mca/sysinfo/solaris/Makefile.am Обычный файл
Просмотреть файл

@ -0,0 +1,38 @@
#
# Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
sources = \
sysinfo_solaris.h \
chiptype.h \
chiptype.c \
sysinfo_solaris_component.c \
sysinfo_solaris_module.c
# Make the output library in this directory, and name it either
# mca_<type>_<name>.la (for DSO builds) or libmca_<type>_<name>.la
# (for static builds).
if OMPI_BUILD_sysinfo_solaris_DSO
component_noinst =
component_install = mca_sysinfo_solaris.la
else
component_noinst = libmca_sysinfo_solaris.la
component_install =
endif
mcacomponentdir = $(pkglibdir)
mcacomponent_LTLIBRARIES = $(component_install)
mca_sysinfo_solaris_la_SOURCES = $(sources)
mca_sysinfo_solaris_la_LIBADD = $(sysinfo_solaris_LIBS)
mca_sysinfo_solaris_la_LDFLAGS = -module -avoid-version $(sysinfo_solaris_LDFLAGS)
noinst_LTLIBRARIES = $(component_noinst)
libmca_sysinfo_solaris_la_SOURCES =$(sources)
libmca_sysinfo_solaris_la_LIBADD = $(sysinfo_solaris_LIBS)
libmca_sysinfo_solaris_la_LDFLAGS = -module -avoid-version $(sysinfo_solaris_LDFLAGS)

309
opal/mca/sysinfo/solaris/chiptype.c Обычный файл
Просмотреть файл

@ -0,0 +1,309 @@
/*
* Copyright (c) 2009-2010 Oracle and/or its affiliates. All rights reserved.
*
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include <stdlib.h>
#include <strings.h>
#include <sys/systeminfo.h>
#include <picl.h>
#include "chiptype.h"
/*****************************************************************************
Order of this list is important for the assign_value and
assign_string_value routines
*****************************************************************************/
static const char* items[] = {
"clock-frequency",
"cpu-mhz",
"ecache-size",
"l2-cache-size",
"sectored-l2-cache-size",
"implementation#",
"manufacturer#",
"compatible"
};
#define NUM_ITEMS (sizeof(items) / sizeof(items[0]))
/*****************************************************************************
SPARC strings for chip modes and implementation
*****************************************************************************/
static const char* sparc_modes[] = {
"UNKNOWN",
"SPITFIRE",
"BLACKBIRD",
"CHEETAH",
"SPARC64_VI",
"T1",
"T2",
"SPARC64_VII",
"ROCK"
};
/*****************************************************************************
SPARC strings for chip manufacturers
*****************************************************************************/
static const char* sparc_mfg[] = {
"SPARC"
};
/*****************************************************************************
Default values are for Spitfire, 2MB E$, TI, and Spitfire clock
*****************************************************************************/
static long dss_chip_mode = 1;
static long dss_chip_impl = IMPL_SPITFIRE;
static long dss_chip_cache = TWO_MEG_CACHE;
static long dss_chip_manufacturer = TI_MANUFACTURER;
static long long dss_chip_speed = SPITFIRE_SPEED;
static int called_cpu_probe = 0;
/*****************************************************************************
Assigns values based on the value of index. For this reason, the order of
the items array is important.
*****************************************************************************/
static void assign_value(int index, long long val) {
if (index == 0) { /* clock-frequency */
dss_chip_speed = val;
}
if (index == 1) { /* cpu-mhz */
dss_chip_speed = val * 1000000; /* Scale since value was in MHz */
}
else if ((index >= 2) && (index <= 4)) {
/* ecache-size, l2-cache-size, sectored-l2-cache-size */
dss_chip_cache = val;
}
else if (index == 5) {
/* implementation# T1, T2, and Rock do not have this, see RFE 6615268 */
dss_chip_impl = val;
if (dss_chip_impl == IMPL_SPITFIRE) {
dss_chip_mode = 1;
}
else if ((dss_chip_impl >= IMPL_BLACKBIRD) &&
(dss_chip_impl <= IMPL_HUMMINGBIRD)) {
dss_chip_mode = 2;
}
else if ((dss_chip_impl >= IMPL_CHEETAH) &&
(dss_chip_impl <= IMPL_PANTHER)) {
dss_chip_mode = 3;
}
else if (dss_chip_impl == IMPL_SPARC64_VI) {
dss_chip_mode = 4;
}
else if (dss_chip_impl == IMPL_NIAGARA) {
dss_chip_mode = 5;
}
else if (dss_chip_impl == IMPL_NIAGARA_2) {
dss_chip_mode = 6;
}
else if (dss_chip_impl == IMPL_SPARC64_VII) {
dss_chip_mode = 7;
}
else if (dss_chip_impl == IMPL_ROCK) {
dss_chip_mode = 8;
}
}
else if (index == 6) { /* manufacturer# */
dss_chip_manufacturer = val;
}
}
/*****************************************************************************
Assigns values based on the value of index. For this reason, the order of
the items array is important.
*****************************************************************************/
static void assign_string_value(int index, char* string_val) {
if (index == 7) { /* compatible */
if (strncasecmp(string_val, "FJSV,SPARC64-VI",
PICL_PROPNAMELEN_MAX) == 0) {
dss_chip_mode = 4;
}
else if (strncasecmp(string_val, "SUNW,UltraSPARC-T1",
PICL_PROPNAMELEN_MAX) == 0) {
dss_chip_mode = 5;
}
else if (strncasecmp(string_val, "SUNW,UltraSPARC-T2",
PICL_PROPNAMELEN_MAX) == 0) {
dss_chip_mode = 6;
}
else if (strncasecmp(string_val, "FJSV,SPARC64-VII",
PICL_PROPNAMELEN_MAX) == 0) {
dss_chip_mode = 7;
}
else if (strncasecmp(string_val, "SUNW,Rock",
PICL_PROPNAMELEN_MAX) == 0) {
dss_chip_mode = 8;
}
}
}
/*****************************************************************************
Gets called by probe_cpu. Cycles through the table values until we find
what we are looking for.
*****************************************************************************/
static int search_table(int index, picl_prophdl_t table_hdl) {
picl_prophdl_t col_hdl;
picl_prophdl_t row_hdl;
picl_propinfo_t p_info;
int val;
char string_val[PICL_PROPNAMELEN_MAX];
for (val = picl_get_next_by_col(table_hdl, &row_hdl); val != PICL_ENDOFLIST;
val = picl_get_next_by_col(row_hdl, &row_hdl)) {
if (val == PICL_SUCCESS) {
for (col_hdl = row_hdl; val != PICL_ENDOFLIST;
val = picl_get_next_by_row(col_hdl, &col_hdl)) {
if (val == PICL_SUCCESS) {
val = picl_get_propinfo(col_hdl, &p_info);
if (val == PICL_SUCCESS) {
if (p_info.type == PICL_PTYPE_CHARSTRING) {
val = picl_get_propval(col_hdl, &string_val, sizeof(string_val));
if (val == PICL_SUCCESS) {
assign_string_value(index, string_val);
}
}
}
}
}
}
}
}
/*****************************************************************************
Gets called by picl_walk_tree_by_class. Then it cycles through the properties
until we find what we are looking for. Once we are done, we return
PICL_WALK_TERMINATE to stop picl_walk_tree_by_class from traversing the tree.
Note that PICL_PTYPE_UNSIGNED_INT and PICL_PTYPE_INT can either be 4-bytes
or 8-bytes.
*****************************************************************************/
static int probe_cpu(picl_nodehdl_t node_hdl, void* dummy_arg) {
picl_prophdl_t p_hdl;
picl_prophdl_t table_hdl;
picl_propinfo_t p_info;
long long long_long_val;
unsigned int uint_val;
int index;
int int_val;
int val;
char string_val[PICL_PROPNAMELEN_MAX];
val = picl_get_first_prop(node_hdl, &p_hdl);
while (val == PICL_SUCCESS) {
called_cpu_probe = 1;
val = picl_get_propinfo(p_hdl, &p_info);
if (val == PICL_SUCCESS) {
for (index = 0; index < NUM_ITEMS; index++) {
if (strcasecmp(p_info.name, items[index]) == 0) {
if (p_info.type == PICL_PTYPE_UNSIGNED_INT) {
if (p_info.size == sizeof(uint_val)) {
val = picl_get_propval(p_hdl, &uint_val, sizeof(uint_val));
if (val == PICL_SUCCESS) {
long_long_val = uint_val;
assign_value(index, long_long_val);
}
}
else if (p_info.size == sizeof(long_long_val)) {
val = picl_get_propval(p_hdl, &long_long_val,
sizeof(long_long_val));
if (val == PICL_SUCCESS) {
assign_value(index, long_long_val);
}
}
}
else if (p_info.type == PICL_PTYPE_INT) {
if (p_info.size == sizeof(int_val)) {
val = picl_get_propval(p_hdl, &int_val, sizeof(int_val));
if (val == PICL_SUCCESS) {
long_long_val = int_val;
assign_value(index, long_long_val);
}
}
else if (p_info.size == sizeof(long_long_val)) {
val = picl_get_propval(p_hdl, &long_long_val,
sizeof(long_long_val));
if (val == PICL_SUCCESS) {
assign_value(index, long_long_val);
}
}
}
else if (p_info.type == PICL_PTYPE_CHARSTRING) {
val = picl_get_propval(p_hdl, &string_val, sizeof(string_val));
if (val == PICL_SUCCESS) {
assign_string_value(index, string_val);
}
}
else if (p_info.type == PICL_PTYPE_TABLE) {
val = picl_get_propval(p_hdl, &table_hdl, p_info.size);
if (val == PICL_SUCCESS) {
search_table(index, table_hdl);
}
}
break;
}
}
}
val = picl_get_next_prop(p_hdl, &p_hdl);
}
return PICL_WALK_TERMINATE;
}
/*****************************************************************************
Initializes, gets the root, then walks the picl tree looking for information
Currently, the "core" class is only needed for OPL systems
*****************************************************************************/
char* get_sparc_chip_manufacturer(void) {
picl_nodehdl_t root;
int val;
static char chip_mfg[128];
val = picl_initialize();
if (val != PICL_SUCCESS) { /* Can't initialize session with PICL daemon */
return(NULL);
}
val = picl_get_root(&root);
if (val != PICL_SUCCESS) { /* Failed to get root node of the PICL tree */
return(NULL);
}
val = picl_walk_tree_by_class(root, "cpu", (void *)NULL, probe_cpu);
val = picl_walk_tree_by_class(root, "core", (void *)NULL, probe_cpu);
picl_shutdown();
if (called_cpu_probe) {
memcpy(chip_mfg, sparc_mfg[0], strlen(sparc_mfg[0]));
} else {
/* no picl information on machine available */
sysinfo(SI_HW_PROVIDER, chip_mfg, 128);
}
return(chip_mfg);
}
/*****************************************************************************
Initializes, gets the root, then walks the picl tree looking for information
Currently, the "core" class is only needed for OPL systems
*****************************************************************************/
char *get_sparc_chip_mode(void) {
static char chip_mode[128];
if (called_cpu_probe) {
} else {
/* no picl information on machine available */
sysinfo(SI_PLATFORM, chip_mode, 128);
}
return((char*)(sparc_modes[dss_chip_mode]));
}

45
opal/mca/sysinfo/solaris/chiptype.h Обычный файл
Просмотреть файл

@ -0,0 +1,45 @@
/*
* Copyright (c) 2009-2010 Oracle and/or its affiliates. All rights reserved.
*
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/* SPARC Chip Modes. */
#define MODE_SPITFIRE 1
#define MODE_BLACKBIRD 2
#define MODE_CHEETAH 3
#define MODE_SPARC64_VI 4
#define MODE_T1 5
#define MODE_T2 6
#define MODE_SPARC64_VII 7
#define MODE_ROCK 8
/* SPARC Chip Implementations. */
#define IMPL_SPARC64_VI 0x6
#define IMPL_SPARC64_VII 0x7
#define IMPL_SPITFIRE 0x10
#define IMPL_BLACKBIRD 0x11
#define IMPL_SABRE 0x12
#define IMPL_HUMMINGBIRD 0x13
#define IMPL_CHEETAH 0x14
#define IMPL_CHEETAHPLUS 0x15
#define IMPL_JALAPENO 0x16
#define IMPL_JAGUAR 0x18
#define IMPL_PANTHER 0x19
#define IMPL_NIAGARA 0x23
#define IMPL_NIAGARA_2 0x24
#define IMPL_ROCK 0x25
/* Default Mfg, Cache, Speed settings */
#define TI_MANUFACTURER 0x17
#define TWO_MEG_CACHE 2097152
#define SPITFIRE_SPEED 142943750
char* get_sparc_chip_manufacturer(void);
char* get_sparc_chip_mode(void);

47
opal/mca/sysinfo/solaris/configure.m4 Обычный файл
Просмотреть файл

@ -0,0 +1,47 @@
# -*- shell-script -*-
#
# Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved.
#
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
# MCA_sysinfo_solaris_CONFIG(action-if-can-compile,
# [action-if-cant-compile])
# ------------------------------------------------
AC_DEFUN([MCA_sysinfo_solaris_CONFIG],[
# check to see if we are on a solaris machine
case $host in
*solaris*)
if test "x$ompi_cv_c_compiler_vendor" = "xsun"; then
sysinfo_solaris_happy=yes
AC_MSG_NOTICE([*** Open MPI supports solaris sysinfo on this platform])
else
sysinfo_solaris_happy=no
fi
;;
*)
sysinfo_solaris_happy=no
AC_MSG_NOTICE([*** Open MPI does not support solaris sysinfo on this platform])
;;
esac
AS_IF([test "$sysinfo_solaris_happy" = "yes"],
[OPAL_SETUP_COMPONENT_PACKAGE([sysinfo],
[solaris],
[libpicl],
[include/picl.h],
[lib/libpicl*],
[picl.h],
[picl],
[picl_initialize],
[],
[AC_CHECK_DECLS([MPOL_MF_MOVE])
$1],
[$2])],
[$2])
])

18
opal/mca/sysinfo/solaris/configure.params Обычный файл
Просмотреть файл

@ -0,0 +1,18 @@
# -*- shell-script -*-
#
# Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved.
#
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
PARAM_CONFIG_FILES="Makefile"
#
# Set the config priority so that, if we can build,
# only this component will build
PARAM_CONFIG_PRIORITY=60

38
opal/mca/sysinfo/solaris/sysinfo_solaris.h Обычный файл
Просмотреть файл

@ -0,0 +1,38 @@
/*
* Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved.
*
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/**
* @file
*
* System resource info for Solaris systems.
*
*/
#ifndef MCA_SYSINFO_SOLARIS_H
#define MCA_SYSINFO_SOLARIS_H
#include "opal_config.h"
#include "opal/mca/mca.h"
#include "opal/mca/sysinfo/sysinfo.h"
BEGIN_C_DECLS
/**
* Globally exported variable
*/
OPAL_DECLSPEC extern const opal_sysinfo_base_component_t mca_sysinfo_solaris_component;
OPAL_DECLSPEC extern const opal_sysinfo_base_module_t opal_sysinfo_solaris_module;
END_C_DECLS
#endif /* MCA_SYSINFO_LINUX_H */

Просмотреть файл

@ -0,0 +1,73 @@
/*
* Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved.
*
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*
* These symbols are in a file by themselves to provide nice linker
* semantics. Since linkers generally pull in symbols by object
* files, keeping these symbols as the only symbols in this file
* prevents utility programs such as "ompi_info" from having to import
* entire components just to query their version and parameters.
*/
#include "opal_config.h"
#include "opal/constants.h"
#include "opal/mca/sysinfo/sysinfo.h"
#include "sysinfo_solaris.h"
/*
* Public string showing the sysinfo ompi_linux component version number
*/
const char *opal_sysinfo_solaris_component_version_string =
"OPAL solaris sysinfo MCA component version " OPAL_VERSION;
/*
* Local function
*/
static int sysinfo_solaris_component_query(mca_base_module_t **module, int *priority);
/*
* Instantiate the public struct with all of our public information
* and pointers to our public functions in it
*/
const opal_sysinfo_base_component_t mca_sysinfo_solaris_component = {
/* First, the mca_component_t struct containing meta information
about the component itself */
{
OPAL_SYSINFO_BASE_VERSION_2_0_0,
/* Component name and version */
"solaris",
OPAL_MAJOR_VERSION,
OPAL_MINOR_VERSION,
OPAL_RELEASE_VERSION,
/* Component open and close functions */
NULL,
NULL,
sysinfo_solaris_component_query,
NULL,
},
{
/* The component is checkpoint ready */
MCA_BASE_METADATA_PARAM_CHECKPOINT
}
};
static int sysinfo_solaris_component_query(mca_base_module_t **module, int *priority)
{
*priority = 20;
*module = (mca_base_module_t *)&opal_sysinfo_solaris_module;
return OPAL_SUCCESS;
}

Просмотреть файл

@ -0,0 +1,127 @@
/*
* Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved.
*
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "opal_config.h"
#include "opal/constants.h"
/* This component will only be compiled on Linux, where we are
guaranteed to have <unistd.h> and friends */
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>
#include <sys/param.h> /* for HZ to convert jiffies to actual time */
#include "opal/mca/base/mca_base_param.h"
#include "opal/dss/dss_types.h"
#include "opal/util/printf.h"
#include "sysinfo_solaris.h"
#include "chiptype.h"
/*
* Module functions
*/
static int solaris_module_init(void);
static int query(char **keys, opal_list_t *values);
static int solaris_module_fini(void);
/*
* Solaris sysinfo module
*/
const opal_sysinfo_base_module_t opal_sysinfo_solaris_module = {
solaris_module_init,
query,
solaris_module_fini
};
/* Local data */
static int int_cpu_type=0;
static int int_cpu_model=0;
static char *cpu_type=NULL;
static char *cpu_model=NULL;
static int num_cpus=0;
static int64_t mem_size=0;
static char input[256];
static int solaris_module_init(void)
{
FILE *fp;
char *data, *value, *ptr;
/* Get CPU Type */
cpu_type = get_sparc_chip_manufacturer();
/* Get CPU Model */
cpu_model = get_sparc_chip_mode();
/* Get number of cores */
/* get memory size */
return OPAL_SUCCESS;
}
static int solaris_module_fini(void)
{
return OPAL_SUCCESS;
}
static int query(char **keys, opal_list_t *values)
{
int i;
opal_sysinfo_value_t *data;
/* cycle through the requested keys */
for (i=0; NULL != keys[i]; i++) {
if (0 == strcmp(keys[i], OPAL_SYSINFO_CPU_TYPE) &&
NULL != cpu_type) {
data = OBJ_NEW(opal_sysinfo_value_t);
data->key = strdup(OPAL_SYSINFO_CPU_TYPE);
data->type = OPAL_STRING;
data->data.str = strdup(cpu_type);
opal_list_append(values, &data->super);
continue;
}
if (0 == strcmp(keys[i], OPAL_SYSINFO_CPU_MODEL) &&
NULL != cpu_model) {
data = OBJ_NEW(opal_sysinfo_value_t);
data->key = strdup(OPAL_SYSINFO_CPU_MODEL);
data->type = OPAL_STRING;
data->data.str = strdup(cpu_model);
opal_list_append(values, &data->super);
continue;
}
if (0 == strcmp(keys[i], OPAL_SYSINFO_NUM_CPUS) &&
num_cpus > 0) {
data = OBJ_NEW(opal_sysinfo_value_t);
data->key = strdup(OPAL_SYSINFO_NUM_CPUS);
data->type = OPAL_INT64;
data->data.i64 = (int64_t)num_cpus;
opal_list_append(values, &data->super);
continue;
}
if (0 == strcmp(keys[i], OPAL_SYSINFO_MEM_SIZE) &&
mem_size > 0) {
data = OBJ_NEW(opal_sysinfo_value_t);
data->key = strdup(OPAL_SYSINFO_MEM_SIZE);
data->type = OPAL_INT64;
data->data.i64 = mem_size;
opal_list_append(values, &data->super);
continue;
}
}
return OPAL_SUCCESS;
}

Просмотреть файл

@ -9,6 +9,7 @@
* University of Stuttgart. All rights reserved. * University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California. * Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved. * All rights reserved.
* Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved.
* $COPYRIGHT$ * $COPYRIGHT$
* *
* Additional copyrights may follow * Additional copyrights may follow
@ -37,6 +38,7 @@
#include "opal/util/path.h" #include "opal/util/path.h"
#include "opal/util/opal_sos.h" #include "opal/util/opal_sos.h"
#include "opal/mca/base/mca_base_param.h" #include "opal/mca/base/mca_base_param.h"
#include "opal/mca/sysinfo/sysinfo.h"
#include "opal/mca/installdirs/installdirs.h" #include "opal/mca/installdirs/installdirs.h"
#include "opal/mca/paffinity/paffinity.h" #include "opal/mca/paffinity/paffinity.h"
@ -432,13 +434,29 @@ static int fork_hnp(void)
return ORTE_ERR_HNP_COULD_NOT_START; return ORTE_ERR_HNP_COULD_NOT_START;
} }
/* parse the name from the returned info */
if (']' != orted_uri[strlen(orted_uri)-1]) { if (']' != orted_uri[strlen(orted_uri)-1]) {
ORTE_ERROR_LOG(ORTE_ERR_COMM_FAILURE); ORTE_ERROR_LOG(ORTE_ERR_COMM_FAILURE);
free(orted_uri); free(orted_uri);
return ORTE_ERR_COMM_FAILURE; return ORTE_ERR_COMM_FAILURE;
} }
orted_uri[strlen(orted_uri)-1] = '\0'; orted_uri[strlen(orted_uri)-1] = '\0';
/* parse the sysinfo from the returned info */
if (NULL == (param = strrchr(orted_uri, '['))) {
ORTE_ERROR_LOG(ORTE_ERR_COMM_FAILURE);
free(orted_uri);
return ORTE_ERR_COMM_FAILURE;
}
param[-1] = '\0'; /* terminate the string */
if (ORTE_SUCCESS != (rc = orte_util_convert_string_to_sysinfo(&orte_local_cpu_type,
&orte_local_cpu_model, ++param))) {
ORTE_ERROR_LOG(rc);
free(orted_uri);
return rc;
}
/* parse the name from the returned info */
if (NULL == (param = strrchr(orted_uri, '['))) { if (NULL == (param = strrchr(orted_uri, '['))) {
ORTE_ERROR_LOG(ORTE_ERR_COMM_FAILURE); ORTE_ERROR_LOG(ORTE_ERR_COMM_FAILURE);
free(orted_uri); free(orted_uri);
@ -446,11 +464,13 @@ static int fork_hnp(void)
} }
*param = '\0'; /* terminate the string */ *param = '\0'; /* terminate the string */
param++; param++;
if (ORTE_SUCCESS != (rc = orte_util_convert_string_to_process_name(ORTE_PROC_MY_NAME, param))) { if (ORTE_SUCCESS != (rc = orte_util_convert_string_to_process_name(ORTE_PROC_MY_NAME, param))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
free(orted_uri); free(orted_uri);
return rc; return rc;
} }
/* save the daemon uri - we will process it later */ /* save the daemon uri - we will process it later */
orte_process_info.my_daemon_uri = strdup(orted_uri); orte_process_info.my_daemon_uri = strdup(orted_uri);
@ -459,6 +479,7 @@ static int fork_hnp(void)
/* indicate we are a singleton so orte_init knows what to do */ /* indicate we are a singleton so orte_init knows what to do */
orte_process_info.proc_type |= ORTE_PROC_SINGLETON; orte_process_info.proc_type |= ORTE_PROC_SINGLETON;
/* all done - report success */ /* all done - report success */
free(orted_uri); free(orted_uri);
return ORTE_SUCCESS; return ORTE_SUCCESS;
@ -561,13 +582,30 @@ static int fork_hnp(void)
return ORTE_ERR_HNP_COULD_NOT_START; return ORTE_ERR_HNP_COULD_NOT_START;
} }
/* parse the name from the returned info */
if (']' != orted_uri[strlen(orted_uri)-1]) { if (']' != orted_uri[strlen(orted_uri)-1]) {
ORTE_ERROR_LOG(ORTE_ERR_COMM_FAILURE); ORTE_ERROR_LOG(ORTE_ERR_COMM_FAILURE);
free(orted_uri); free(orted_uri);
return ORTE_ERR_COMM_FAILURE; return ORTE_ERR_COMM_FAILURE;
} }
orted_uri[strlen(orted_uri)-1] = '\0'; orted_uri[strlen(orted_uri)-1] = '\0';
/* parse the sysinfo from the returned info */
if (NULL == (param = strrchr(orted_uri, '['))) {
ORTE_ERROR_LOG(ORTE_ERR_COMM_FAILURE);
free(orted_uri);
return ORTE_ERR_COMM_FAILURE;
}
param[-1] = '\0'; /* terminate the string */
/* save the cpu model */
if (ORTE_SUCCESS != (rc = orte_util_convert_string_to_sysinfo(&orte_local_cpu_type,
&orte_local_cpu_model, ++param))) {
ORTE_ERROR_LOG(rc);
free(orted_uri);
return rc;
}
/* parse the name from the returned info */
if (NULL == (param = strrchr(orted_uri, '['))) { if (NULL == (param = strrchr(orted_uri, '['))) {
ORTE_ERROR_LOG(ORTE_ERR_COMM_FAILURE); ORTE_ERROR_LOG(ORTE_ERR_COMM_FAILURE);
free(orted_uri); free(orted_uri);

Просмотреть файл

@ -9,7 +9,7 @@
* University of Stuttgart. All rights reserved. * University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California. * Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved. * All rights reserved.
* Copyright (c) 2007-2009 Sun Microsystems, Inc. All rights reserved. * Copyright (c) 2007-2010 Oracle and/or its affiliates. All rights reserved.
* $COPYRIGHT$ * $COPYRIGHT$
* *
* Additional copyrights may follow * Additional copyrights may follow
@ -1165,13 +1165,17 @@ static int odls_base_default_setup_fork(orte_app_context_t *context,
free(param); free(param);
free(param2); free(param2);
/* pass a param telling the child what model of cpu we are on, /* pass a param telling the child what type and model of cpu we are on,
* if we know it * if we know it
*/ */
if (NULL != orte_local_cpu_type) {
param = mca_base_param_environ_variable("orte","cpu","type");
opal_setenv(param, orte_local_cpu_type, true, environ_copy);
free(param);
}
if (NULL != orte_local_cpu_model) { if (NULL != orte_local_cpu_model) {
param = mca_base_param_environ_variable("cpu", NULL,"model"); param = mca_base_param_environ_variable("orte","cpu","model");
/* do not overwrite what the user may have provided */ opal_setenv(param, orte_local_cpu_model, true, environ_copy);
opal_setenv(param, orte_local_cpu_model, false, environ_copy);
free(param); free(param);
} }

Просмотреть файл

@ -9,6 +9,7 @@
* University of Stuttgart. All rights reserved. * University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California. * Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved. * All rights reserved.
* Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved.
* $COPYRIGHT$ * $COPYRIGHT$
* *
* Additional copyrights may follow * Additional copyrights may follow
@ -220,15 +221,18 @@ int orte_odls_base_open(void)
if (NULL != opal_sysinfo.query) { if (NULL != opal_sysinfo.query) {
/* get and store our local resources */ /* get and store our local resources */
opal_sysinfo.query(keys, &orte_odls_globals.sysinfo); opal_sysinfo.query(keys, &orte_odls_globals.sysinfo);
/* find our cpu model and save it for later */ /* find our cpu model and type, save it for later */
for (item = opal_list_get_first(&orte_odls_globals.sysinfo); for (item = opal_list_get_first(&orte_odls_globals.sysinfo);
item != opal_list_get_end(&orte_odls_globals.sysinfo); item != opal_list_get_end(&orte_odls_globals.sysinfo) &&
(NULL == orte_local_cpu_model || NULL == orte_local_cpu_model);
item = opal_list_get_next(item)) { item = opal_list_get_next(item)) {
info = (opal_sysinfo_value_t*)item; info = (opal_sysinfo_value_t*)item;
if (0 == strcmp(info->key, OPAL_SYSINFO_CPU_TYPE)) {
orte_local_cpu_type = strdup(info->data.str);
}
if (0 == strcmp(info->key, OPAL_SYSINFO_CPU_MODEL)) { if (0 == strcmp(info->key, OPAL_SYSINFO_CPU_MODEL)) {
orte_local_cpu_model = strdup(info->data.str); orte_local_cpu_model = strdup(info->data.str);
break;
} }
} }
} }

Просмотреть файл

@ -14,6 +14,7 @@
* reserved. * reserved.
* Copyright (c) 2009 Institut National de Recherche en Informatique * Copyright (c) 2009 Institut National de Recherche en Informatique
* et Automatique. All rights reserved. * et Automatique. All rights reserved.
* Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved.
* $COPYRIGHT$ * $COPYRIGHT$
* *
* Additional copyrights may follow * Additional copyrights may follow
@ -453,7 +454,7 @@ int orte_daemon(int argc, char *argv[])
orte_proc_t *proc; orte_proc_t *proc;
orte_node_t **nodes; orte_node_t **nodes;
orte_app_context_t *app; orte_app_context_t *app;
char *tmp, *nptr; char *tmp, *nptr, *sysinfo;
int rc; int rc;
int32_t ljob; int32_t ljob;
@ -504,10 +505,12 @@ int orte_daemon(int argc, char *argv[])
opal_pointer_array_add(jdata->procs, proc); opal_pointer_array_add(jdata->procs, proc);
jdata->num_procs = 1; jdata->num_procs = 1;
/* create a string that contains our uri + the singleton's name */ /* create a string that contains our uri + the singleton's name + sysinfo */
orte_util_convert_process_name_to_string(&nptr, &proc->name); orte_util_convert_process_name_to_string(&nptr, &proc->name);
asprintf(&tmp, "%s[%s]", orte_process_info.my_daemon_uri, nptr); orte_util_convert_sysinfo_to_string(&sysinfo, orte_local_cpu_type, orte_local_cpu_model);
asprintf(&tmp, "%s[%s][%s]", orte_process_info.my_daemon_uri, nptr, sysinfo);
free(nptr); free(nptr);
free(sysinfo);
/* pass that info to the singleton */ /* pass that info to the singleton */
#ifndef __WINDOWS__ #ifndef __WINDOWS__

Просмотреть файл

@ -10,7 +10,7 @@
* Copyright (c) 2004-2005 The Regents of the University of California. * Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved. * All rights reserved.
* Copyright (c) 2007-2009 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2007-2009 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2009 Sun Microsystems, Inc. All rights reserved. * Copyright (c) 2009-2010 Oracle and/or its affiliates. All rights reserved.
* $COPYRIGHT$ * $COPYRIGHT$
* *
* Additional copyrights may follow * Additional copyrights may follow
@ -59,6 +59,7 @@ bool orte_leave_session_attached;
bool orte_do_not_launch = false; bool orte_do_not_launch = false;
bool orted_spin_flag = false; bool orted_spin_flag = false;
bool orte_daemon_bootstrap = false; bool orte_daemon_bootstrap = false;
char *orte_local_cpu_type = NULL;
char *orte_local_cpu_model = NULL; char *orte_local_cpu_model = NULL;
char *orte_basename = NULL; char *orte_basename = NULL;

Просмотреть файл

@ -9,7 +9,7 @@
* University of Stuttgart. All rights reserved. * University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California. * Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved. * All rights reserved.
* Copyright (c) 2007-2009 Sun Microsystems, Inc. All rights reserved. * Copyright (c) 2007-2010 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007-2010 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2007-2010 Cisco Systems, Inc. All rights reserved.
* $COPYRIGHT$ * $COPYRIGHT$
* *
@ -572,6 +572,7 @@ ORTE_DECLSPEC extern bool orte_leave_session_attached;
ORTE_DECLSPEC extern bool orte_do_not_launch; ORTE_DECLSPEC extern bool orte_do_not_launch;
ORTE_DECLSPEC extern bool orted_spin_flag; ORTE_DECLSPEC extern bool orted_spin_flag;
ORTE_DECLSPEC extern bool orte_daemon_bootstrap; ORTE_DECLSPEC extern bool orte_daemon_bootstrap;
ORTE_DECLSPEC extern char *orte_local_cpu_type;
ORTE_DECLSPEC extern char *orte_local_cpu_model; ORTE_DECLSPEC extern char *orte_local_cpu_model;
ORTE_DECLSPEC extern char *orte_basename; ORTE_DECLSPEC extern char *orte_basename;

Просмотреть файл

@ -10,7 +10,7 @@
* Copyright (c) 2004-2005 The Regents of the University of California. * Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved. * All rights reserved.
* Copyright (c) 2007 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2009 Sun Microsystems, Inc. All rights reserved. * Copyright (c) 2009-2010 Oracle and/or its affiliates. All rights reserved.
* $COPYRIGHT$ * $COPYRIGHT$
* *
* Additional copyrights may follow * Additional copyrights may follow
@ -375,6 +375,15 @@ int orte_register_params(void)
} }
} }
/* cluster hardware info detected by orte only */
mca_base_param_reg_string_name("orte", "cpu_type",
"cpu model detected in node",
true, false, NULL, &orte_local_cpu_type);
mca_base_param_reg_string_name("orte", "cpu_model",
"cpu model detected in node",
true, false, NULL, &orte_local_cpu_model);
/* cluster hardware info */ /* cluster hardware info */
mca_base_param_reg_int_name("orte", "num_boards", mca_base_param_reg_int_name("orte", "num_boards",
"Number of processor boards/node (1-256) [default: 1]", "Number of processor boards/node (1-256) [default: 1]",

Просмотреть файл

@ -9,6 +9,7 @@
* University of Stuttgart. All rights reserved. * University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California. * Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved. * All rights reserved.
* Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved.
* $COPYRIGHT$ * $COPYRIGHT$
* *
* Additional copyrights may follow * Additional copyrights may follow
@ -552,6 +553,77 @@ uint64_t orte_util_hash_name(const orte_process_name_t * name) {
return hash; return hash;
} }
/* sysinfo conversion to and from string */
int orte_util_convert_string_to_sysinfo(char **cpu_type, char **cpu_model,
const char* sysinfo_string)
{
char *temp, *token;
int return_code=ORTE_SUCCESS;
/* check for NULL string - error */
if (NULL == sysinfo_string) {
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
return ORTE_ERR_BAD_PARAM;
}
temp = strdup(sysinfo_string); /** copy input string as the strtok process is destructive */
token = strtok(temp, ORTE_SCHEMA_DELIMITER_STRING); /** get first field -> cpu_type */
/* check for error */
if (NULL == token) {
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
return ORTE_ERR_BAD_PARAM;
}
/* If type is a valid string get the value otherwise leave cpu_type untouched.
*/
if (0 != strcmp(token, ORTE_SCHEMA_INVALID_STRING)) {
*cpu_type = strdup(token);
}
token = strtok(NULL, ORTE_SCHEMA_DELIMITER_STRING); /** get next field -> cpu_model */
/* check for error */
if (NULL == token) {
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
return ORTE_ERR_BAD_PARAM;
}
/* If type is a valid string get the value otherwise leave cpu_type untouched.
*/
if (0 != strcmp(token, ORTE_SCHEMA_INVALID_STRING)) {
*cpu_model = strdup(token);
}
free(temp);
return return_code;
}
int orte_util_convert_sysinfo_to_string(char **sysinfo_string,
const char *cpu_type, const char *cpu_model)
{
char *tmp;
/* check for no sysinfo values (like empty cpu_type) - where encountered, insert the
* invalid string so we can correctly parse the name string when
* it is passed back to us later
*/
if (NULL == cpu_type) {
asprintf(&tmp, "%s", ORTE_SCHEMA_INVALID_STRING);
} else {
asprintf(&tmp, "%s", cpu_type);
}
if (NULL == cpu_model) {
asprintf(sysinfo_string, "%s%c%s", tmp, ORTE_SCHEMA_DELIMITER_CHAR, ORTE_SCHEMA_INVALID_STRING);
} else {
asprintf(sysinfo_string, "%s%c%s", tmp, ORTE_SCHEMA_DELIMITER_CHAR, cpu_model);
}
free(tmp);
return ORTE_SUCCESS;
}
char *orte_pretty_print_timing(int64_t secs, int64_t usecs) char *orte_pretty_print_timing(int64_t secs, int64_t usecs)
{ {
unsigned long minutes, seconds; unsigned long minutes, seconds;

Просмотреть файл

@ -9,6 +9,7 @@
* University of Stuttgart. All rights reserved. * University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California. * Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved. * All rights reserved.
* Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved.
* $COPYRIGHT$ * $COPYRIGHT$
* *
* Additional copyrights may follow * Additional copyrights may follow
@ -122,6 +123,10 @@ ORTE_DECLSPEC int orte_util_compare_name_fields(orte_ns_cmp_bitmask_t fields,
const orte_process_name_t* name2); const orte_process_name_t* name2);
/** This funtion returns a guaranteed unique hash value for the passed process name */ /** This funtion returns a guaranteed unique hash value for the passed process name */
ORTE_DECLSPEC uint64_t orte_util_hash_name(const orte_process_name_t * name); ORTE_DECLSPEC uint64_t orte_util_hash_name(const orte_process_name_t * name);
ORTE_DECLSPEC int orte_util_convert_string_to_sysinfo(char **cpu_type, char **cpu_model,
const char* sysinfo_string);
ORTE_DECLSPEC int orte_util_convert_sysinfo_to_string(char** sysinfo_string,
const char *cpu_model, const char *cpu_type);
END_C_DECLS END_C_DECLS
#endif #endif