2004-08-15 07:33:13 +04: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-08-15 07:33:13 +04:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
2005-03-14 23:57:21 +03:00
|
|
|
#include "orte_config.h"
|
|
|
|
#include "include/orte_constants.h"
|
|
|
|
#include "include/constants.h"
|
|
|
|
|
|
|
|
#include "util/output.h"
|
2004-08-15 07:33:13 +04:00
|
|
|
|
|
|
|
#include "mca/gpr/base/base.h"
|
|
|
|
|
|
|
|
|
2004-09-11 16:56:52 +04:00
|
|
|
|
2004-08-15 07:33:13 +04:00
|
|
|
/*
|
|
|
|
* The following file was created by configure. It contains extern
|
|
|
|
* statements and the definition of an array of pointers to each
|
|
|
|
* component's public mca_base_module_t struct.
|
|
|
|
*/
|
|
|
|
|
2004-08-15 09:49:55 +04:00
|
|
|
#include "mca/gpr/base/static-components.h"
|
2004-08-15 07:33:13 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* globals
|
|
|
|
*/
|
|
|
|
|
2005-03-14 23:57:21 +03:00
|
|
|
/** KEYVAL **/
|
|
|
|
/* constructor - used to initialize state of keyval instance */
|
|
|
|
static void orte_gpr_keyval_construct(orte_gpr_keyval_t* keyval)
|
2004-08-15 07:33:13 +04:00
|
|
|
{
|
2005-03-14 23:57:21 +03:00
|
|
|
keyval->key = NULL;
|
|
|
|
keyval->type = 0;
|
|
|
|
keyval->value.i32 = 0;
|
2004-08-15 07:33:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* destructor - used to free any resources held by instance */
|
2005-03-14 23:57:21 +03:00
|
|
|
static void orte_gpr_keyval_destructor(orte_gpr_keyval_t* keyval)
|
2004-08-15 07:33:13 +04:00
|
|
|
{
|
2005-03-14 23:57:21 +03:00
|
|
|
orte_byte_object_t *byteptr;
|
|
|
|
|
|
|
|
if (NULL != keyval->key) {
|
|
|
|
free(keyval->key);
|
|
|
|
}
|
|
|
|
if (ORTE_BYTE_OBJECT == keyval->type) {
|
|
|
|
byteptr = &(keyval->value.byteobject);
|
|
|
|
if (NULL != byteptr->bytes) {
|
|
|
|
free(byteptr->bytes);
|
|
|
|
}
|
2005-03-22 03:31:17 +03:00
|
|
|
} else if (ORTE_STRING == keyval->type) {
|
|
|
|
if (NULL != keyval->value.strptr)
|
|
|
|
free(keyval->value.strptr);
|
|
|
|
} else if (ORTE_APP_CONTEXT == keyval->type) {
|
|
|
|
if (NULL != keyval->value.app_context)
|
|
|
|
OBJ_RELEASE(keyval->value.app_context);
|
2004-08-15 07:33:13 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* define instance of ompi_class_t */
|
|
|
|
OBJ_CLASS_INSTANCE(
|
2005-03-14 23:57:21 +03:00
|
|
|
orte_gpr_keyval_t, /* type name */
|
|
|
|
ompi_object_t, /* parent "class" name */
|
|
|
|
orte_gpr_keyval_construct, /* constructor */
|
|
|
|
orte_gpr_keyval_destructor); /* destructor */
|
2004-08-17 19:04:56 +04:00
|
|
|
|
|
|
|
|
2005-03-14 23:57:21 +03:00
|
|
|
|
|
|
|
/** VALUE **/
|
|
|
|
/* constructor - used to initialize state of registry value instance */
|
|
|
|
static void orte_gpr_value_construct(orte_gpr_value_t* reg_val)
|
2004-11-20 22:12:43 +03:00
|
|
|
{
|
2005-03-14 23:57:21 +03:00
|
|
|
reg_val->addr_mode = 0;
|
|
|
|
reg_val->segment = NULL;
|
|
|
|
reg_val->cnt = 0;
|
|
|
|
reg_val->keyvals = NULL;
|
|
|
|
reg_val->num_tokens = 0;
|
|
|
|
reg_val->tokens = 0;
|
2004-11-20 22:12:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* destructor - used to free any resources held by instance */
|
2005-03-14 23:57:21 +03:00
|
|
|
static void orte_gpr_value_destructor(orte_gpr_value_t* reg_val)
|
2004-11-20 22:12:43 +03:00
|
|
|
{
|
2005-03-14 23:57:21 +03:00
|
|
|
char **tokens;
|
|
|
|
int32_t i;
|
|
|
|
|
|
|
|
if (NULL != reg_val->segment) free(reg_val->segment);
|
|
|
|
|
|
|
|
if (0 < reg_val->cnt && NULL != reg_val->keyvals) {
|
|
|
|
for (i=0; i < reg_val->cnt; i++) {
|
2005-03-19 02:58:36 +03:00
|
|
|
if (NULL != reg_val->keyvals[i])
|
2005-03-14 23:57:21 +03:00
|
|
|
OBJ_RELEASE(reg_val->keyvals[i]);
|
|
|
|
}
|
|
|
|
free(reg_val->keyvals);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (0 < reg_val->num_tokens && NULL != reg_val->tokens) {
|
|
|
|
tokens = reg_val->tokens;
|
|
|
|
for (i=0; i < reg_val->num_tokens; i++) {
|
|
|
|
if(NULL != tokens[i])
|
|
|
|
free(tokens[i]);
|
|
|
|
}
|
|
|
|
free(tokens);
|
|
|
|
}
|
2004-11-20 22:12:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* define instance of ompi_class_t */
|
|
|
|
OBJ_CLASS_INSTANCE(
|
2005-03-14 23:57:21 +03:00
|
|
|
orte_gpr_value_t, /* type name */
|
|
|
|
ompi_object_t, /* parent "class" name */
|
|
|
|
orte_gpr_value_construct, /* constructor */
|
|
|
|
orte_gpr_value_destructor); /* destructor */
|
2004-11-20 22:12:43 +03:00
|
|
|
|
|
|
|
|
2005-03-14 23:57:21 +03:00
|
|
|
/** NOTIFY DATA **/
|
|
|
|
/* constructor - used to initialize state of registry value instance */
|
|
|
|
static void orte_gpr_notify_data_construct(orte_gpr_notify_data_t* ptr)
|
2004-08-17 19:04:56 +04:00
|
|
|
{
|
2005-03-14 23:57:21 +03:00
|
|
|
ptr->cb_num = 0;
|
|
|
|
ptr->addr_mode = 0;
|
|
|
|
ptr->segment = NULL;
|
|
|
|
ptr->cnt = 0;
|
|
|
|
ptr->values = NULL;
|
2004-08-17 19:04:56 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* destructor - used to free any resources held by instance */
|
2005-03-14 23:57:21 +03:00
|
|
|
static void orte_gpr_notify_data_destructor(orte_gpr_notify_data_t* ptr)
|
2004-08-17 19:04:56 +04:00
|
|
|
{
|
2005-03-14 23:57:21 +03:00
|
|
|
int32_t i;
|
|
|
|
|
|
|
|
if (NULL != ptr->segment) free(ptr->segment);
|
|
|
|
|
|
|
|
if (0 < ptr->cnt && NULL != ptr->values) {
|
|
|
|
for (i=0; i < ptr->cnt; i++) {
|
2005-03-19 02:58:36 +03:00
|
|
|
if (NULL != ptr->values[i])
|
2005-03-14 23:57:21 +03:00
|
|
|
OBJ_RELEASE(ptr->values[i]);
|
|
|
|
}
|
|
|
|
free(ptr->values);
|
2004-08-17 19:04:56 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* define instance of ompi_class_t */
|
|
|
|
OBJ_CLASS_INSTANCE(
|
2005-03-14 23:57:21 +03:00
|
|
|
orte_gpr_notify_data_t, /* type name */
|
|
|
|
ompi_object_t, /* parent "class" name */
|
|
|
|
orte_gpr_notify_data_construct, /* constructor */
|
|
|
|
orte_gpr_notify_data_destructor); /* destructor */
|
2004-08-17 19:04:56 +04:00
|
|
|
|
|
|
|
|
2005-03-14 23:57:21 +03:00
|
|
|
/** SUBSCRIPTION **/
|
|
|
|
/* constructor - used to initialize state of registry subscription instance */
|
|
|
|
static void orte_gpr_subscription_construct(orte_gpr_subscription_t* sub)
|
2004-08-17 19:04:56 +04:00
|
|
|
{
|
2005-03-14 23:57:21 +03:00
|
|
|
sub->addr_mode = 0;
|
|
|
|
sub->segment = NULL;
|
|
|
|
sub->num_tokens = 0;
|
|
|
|
sub->tokens = NULL;
|
|
|
|
sub->num_keys = 0;
|
|
|
|
sub->keys = NULL;
|
|
|
|
sub->cbfunc = NULL;
|
|
|
|
sub->user_tag = NULL;
|
2004-08-17 19:04:56 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* destructor - used to free any resources held by instance */
|
2005-03-14 23:57:21 +03:00
|
|
|
static void orte_gpr_subscription_destructor(orte_gpr_subscription_t* sub)
|
2004-08-17 19:04:56 +04:00
|
|
|
{
|
2005-03-14 23:57:21 +03:00
|
|
|
char **tokens;
|
|
|
|
int32_t i;
|
|
|
|
|
|
|
|
if (NULL != sub->segment) free(sub->segment);
|
|
|
|
|
|
|
|
if (0 < sub->num_tokens && NULL != sub->tokens) {
|
|
|
|
tokens = sub->tokens;
|
|
|
|
for (i=0; i < sub->num_tokens; i++) {
|
|
|
|
if(NULL != tokens[i])
|
|
|
|
free(tokens[i]);
|
|
|
|
}
|
|
|
|
free(sub->tokens);
|
2004-08-17 19:04:56 +04:00
|
|
|
}
|
2005-03-14 23:57:21 +03:00
|
|
|
|
|
|
|
if (0 < sub->num_keys && NULL != sub->keys) {
|
|
|
|
tokens = sub->keys;
|
|
|
|
for (i=0; i < sub->num_keys; i++) {
|
|
|
|
if(NULL != tokens[i])
|
|
|
|
free(tokens[i]);
|
|
|
|
}
|
|
|
|
free(sub->keys);
|
2004-08-17 19:04:56 +04:00
|
|
|
}
|
2005-03-14 23:57:21 +03:00
|
|
|
|
2004-08-17 19:04:56 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* define instance of ompi_class_t */
|
|
|
|
OBJ_CLASS_INSTANCE(
|
2005-03-14 23:57:21 +03:00
|
|
|
orte_gpr_subscription_t, /* type name */
|
|
|
|
ompi_object_t, /* parent "class" name */
|
|
|
|
orte_gpr_subscription_construct, /* constructor */
|
|
|
|
orte_gpr_subscription_destructor); /* destructor */
|
2004-08-15 07:33:13 +04:00
|
|
|
|
|
|
|
|
2005-03-14 23:57:21 +03:00
|
|
|
/** NOTIFY MESSAGE */
|
|
|
|
/* constructor - used to initialize notify message instance */
|
|
|
|
static void orte_gpr_notify_message_construct(orte_gpr_notify_message_t* msg)
|
2004-08-27 09:23:04 +04:00
|
|
|
{
|
2005-03-14 23:57:21 +03:00
|
|
|
msg->idtag = 0;
|
|
|
|
msg->cnt = 0;
|
|
|
|
msg->data = NULL;
|
2004-08-27 09:23:04 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* destructor - used to free any resources held by instance */
|
2005-03-14 23:57:21 +03:00
|
|
|
static void orte_gpr_notify_message_destructor(orte_gpr_notify_message_t* msg)
|
2004-08-27 09:23:04 +04:00
|
|
|
{
|
2005-03-14 23:57:21 +03:00
|
|
|
int i;
|
|
|
|
|
|
|
|
if (0 < msg->cnt && NULL != msg->data) {
|
|
|
|
for (i=0; i < msg->cnt; i++) {
|
2005-03-19 02:58:36 +03:00
|
|
|
if (NULL != msg->data[i]) OBJ_RELEASE(msg->data[i]);
|
2005-03-14 23:57:21 +03:00
|
|
|
}
|
|
|
|
free(msg->data);
|
|
|
|
}
|
|
|
|
|
2004-08-27 09:23:04 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* define instance of ompi_class_t */
|
|
|
|
OBJ_CLASS_INSTANCE(
|
2005-03-14 23:57:21 +03:00
|
|
|
orte_gpr_notify_message_t, /* type name */
|
|
|
|
ompi_object_t, /* parent "class" name */
|
|
|
|
orte_gpr_notify_message_construct, /* constructor */
|
|
|
|
orte_gpr_notify_message_destructor); /* destructor */
|
2004-08-27 09:23:04 +04:00
|
|
|
|
|
|
|
|
2005-03-14 23:57:21 +03:00
|
|
|
/** TEST RESULTS */
|
|
|
|
/* constructor - used to initialize state of test results instance */
|
|
|
|
static void orte_gpr_internal_test_results_construct(orte_gpr_internal_test_results_t* results)
|
2004-08-27 09:23:04 +04:00
|
|
|
{
|
2005-03-14 23:57:21 +03:00
|
|
|
results->test = NULL;
|
|
|
|
results->message = NULL;
|
2004-08-27 09:23:04 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* destructor - used to free any resources held by instance */
|
2005-03-14 23:57:21 +03:00
|
|
|
static void orte_gpr_internal_test_results_destructor(orte_gpr_internal_test_results_t* results)
|
2004-08-27 09:23:04 +04:00
|
|
|
{
|
2005-03-14 23:57:21 +03:00
|
|
|
if (NULL != results->test) {
|
|
|
|
free(results->test);
|
2004-08-27 09:23:04 +04:00
|
|
|
}
|
2005-03-14 23:57:21 +03:00
|
|
|
if (NULL != results->message) {
|
|
|
|
free(results->message);
|
2004-08-27 09:23:04 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* define instance of ompi_class_t */
|
|
|
|
OBJ_CLASS_INSTANCE(
|
2005-03-14 23:57:21 +03:00
|
|
|
orte_gpr_internal_test_results_t, /* type name */
|
|
|
|
ompi_list_item_t, /* parent "class" name */
|
|
|
|
orte_gpr_internal_test_results_construct, /* constructor */
|
|
|
|
orte_gpr_internal_test_results_destructor); /* destructor */
|
2004-08-27 09:23:04 +04:00
|
|
|
|
2004-08-15 07:33:13 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Global variables
|
|
|
|
*/
|
2005-03-14 23:57:21 +03:00
|
|
|
int orte_gpr_base_output = -1;
|
|
|
|
orte_gpr_base_module_t orte_gpr;
|
|
|
|
bool orte_gpr_base_selected = false;
|
|
|
|
ompi_list_t orte_gpr_base_components_available;
|
|
|
|
mca_gpr_base_component_t orte_gpr_base_selected_component;
|
|
|
|
ompi_mutex_t orte_gpr_mutex;
|
2004-08-15 07:33:13 +04:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function for finding and opening either all MCA components, or the one
|
|
|
|
* that was specifically requested via a MCA parameter.
|
|
|
|
*/
|
2005-03-14 23:57:21 +03:00
|
|
|
int orte_gpr_base_open(void)
|
2004-08-15 07:33:13 +04:00
|
|
|
{
|
2005-03-24 23:23:15 +03:00
|
|
|
int param, value;
|
2004-11-20 22:12:43 +03:00
|
|
|
|
2005-03-24 23:23:15 +03:00
|
|
|
/* Debugging / verbose output */
|
|
|
|
|
|
|
|
param = mca_base_param_register_int("gpr", "base", "verbose",
|
|
|
|
NULL, 0);
|
|
|
|
mca_base_param_lookup_int(param, &value);
|
|
|
|
if (value != 0) {
|
|
|
|
orte_gpr_base_output = ompi_output_open(NULL);
|
|
|
|
} else {
|
|
|
|
orte_gpr_base_output = -1;
|
|
|
|
}
|
2004-08-15 07:33:13 +04:00
|
|
|
|
2005-03-24 23:23:15 +03:00
|
|
|
/* Open up all available components */
|
2004-08-15 07:33:13 +04:00
|
|
|
|
2005-03-24 23:23:15 +03:00
|
|
|
if (OMPI_SUCCESS !=
|
|
|
|
mca_base_components_open("gpr", 0, mca_gpr_base_static_components,
|
2005-04-13 07:19:48 +04:00
|
|
|
&orte_gpr_base_components_available, true)) {
|
2005-03-24 23:23:15 +03:00
|
|
|
return ORTE_ERROR;
|
|
|
|
}
|
2004-08-15 07:33:13 +04:00
|
|
|
|
2005-03-24 23:23:15 +03:00
|
|
|
/* All done */
|
|
|
|
|
|
|
|
return ORTE_SUCCESS;
|
2004-08-15 07:33:13 +04:00
|
|
|
}
|