1
1

Hey, sports fans!! Guess what??

Here's the huge registry check-in you've all been waiting for with baited breath. The revised version sends a single message to all processes at the various stage gates, thus making the startup much more scalable. I could provide you with all the tawdry details, but won't for now - you are welcome to ask, though, and I'll merrily bore your ears to tears.

In addition, the commit contains the following:

1. set the ignore properties on ompi/debuggers and orte/mca/pls/poe

2. Added simplified subscribe and put functions to the registry's API. I have also converted all of the ompi functions that registered subscriptions to the new API, and caught their associated put's as well.

In a follow-on commit, I'll be adding support for George's hetero arch registry subscription (wanted to get this one in first).

This commit was SVN r7118.
Этот коммит содержится в:
Ralph Castain 2005-09-01 01:07:30 +00:00
родитель 4ac2445c61
Коммит 96f4bb7a63
51 изменённых файлов: 3040 добавлений и 2494 удалений

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

@ -3,14 +3,14 @@
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
*
* Additional copyrights may follow
*
*
* $HEADER$
*/
@ -26,7 +26,7 @@
* Predefined attributes are integer-valued or address-valued (per
* MPI-2; see section 4.12.7, keeping in mind that Example 4.13 is
* totally wrong -- see src/attribute/attribute.h for a lengthy
* explanation of this).
* explanation of this).
*
* The only address-valued attribute is MPI_WIN_BASE. We treat it as
* if it were set from C. All other attributes are integer-valued.
@ -104,17 +104,16 @@ static int set_f(int keyval, MPI_Fint value);
int ompi_attr_create_predefined(void)
{
int rc, ret;
orte_gpr_trigger_t trig, *trig1;
orte_gpr_value_t value, *values;
orte_gpr_subscription_t sub, *sub1;
orte_gpr_subscription_id_t id;
char *sub_name, *trig_name;
orte_jobid_t job;
/* Create all the keyvals */
/* DO NOT CHANGE THE ORDER OF CREATING THESE KEYVALS! This order
strictly adheres to the order in mpi.h. If you change the
order here, you must change the order in mpi.h as well! */
if (OMPI_SUCCESS != (ret = create_comm(MPI_TAG_UB, true)) ||
OMPI_SUCCESS != (ret = create_comm(MPI_HOST, true)) ||
OMPI_SUCCESS != (ret = create_comm(MPI_IO, true)) ||
@ -149,7 +148,7 @@ int ompi_attr_create_predefined(void)
OMPI_SUCCESS != (ret = set_f(MPI_HOST, MPI_PROC_NULL)) ||
OMPI_SUCCESS != (ret = set_f(MPI_IO, MPI_ANY_SOURCE)) ||
OMPI_SUCCESS != (ret = set_f(MPI_WTIME_IS_GLOBAL, 0)) ||
OMPI_SUCCESS != (ret = set_f(MPI_LASTUSEDCODE,
OMPI_SUCCESS != (ret = set_f(MPI_LASTUSEDCODE,
ompi_errclass_lastused)) ||
OMPI_SUCCESS != (ret = set_f(MPI_UNIVERSE_SIZE,
ompi_comm_size(MPI_COMM_WORLD))) ||
@ -157,11 +156,11 @@ int ompi_attr_create_predefined(void)
/* JMS For when we implement IMPI */
OMPI_SUCCESS != (ret = set(MPI_IMPI_CLIENT_SIZE,
&attr_impi_client_size)) ||
OMPI_SUCCESS != (ret = set(MPI_IMPI_CLIENT_COLOR,
OMPI_SUCCESS != (ret = set(MPI_IMPI_CLIENT_COLOR,
&attr_impi_client_color)) ||
OMPI_SUCCESS != (ret = set(MPI_IMPI_HOST_SIZE,
&attr_impi_host_size)) ||
OMPI_SUCCESS != (ret = set(MPI_IMPI_HOST_COLOR,
OMPI_SUCCESS != (ret = set(MPI_IMPI_HOST_COLOR,
&attr_impi_host_color)) ||
#endif
0) {
@ -176,100 +175,41 @@ int ompi_attr_create_predefined(void)
ORTE_ERROR_LOG(rc);
return rc;
}
OBJ_CONSTRUCT(&sub, orte_gpr_subscription_t);
/* indicate that this is a standard subscription. This indicates that the
* subscription will be common to all processes. Thus, the resulting data
* can be consolidated into a process-independent message and broadcast
* to all processes
*/
if (ORTE_SUCCESS != (rc = orte_schema.get_std_subscription_name(&(sub.name),
OMPI_ATTRIBUTE_SUBSCRIPTION, job))) {
/* indicate that this is a standard subscription. This indicates
that the subscription will be common to all processes. Thus,
the resulting data can be consolidated into a
process-independent message and broadcast to all processes */
if (ORTE_SUCCESS !=
(rc = orte_schema.get_std_subscription_name(&sub_name,
OMPI_ATTRIBUTE_SUBSCRIPTION, job))) {
ORTE_ERROR_LOG(rc);
return rc;
}
/* send data when trigger fires, then delete -
* no need for further notifications
*/
sub.action = ORTE_GPR_NOTIFY_DELETE_AFTER_TRIG;
OBJ_CONSTRUCT(&value, orte_gpr_value_t);
values = &value;
sub.values = &values;
sub.cnt = 1;
value.addr_mode = ORTE_GPR_TOKENS_OR | ORTE_GPR_KEYS_OR;
value.segment = strdup(ORTE_NODE_SEGMENT);
if (NULL == value.segment) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_DESTRUCT(&value);
sub.values = NULL;
OBJ_DESTRUCT(&sub);
return ORTE_ERR_OUT_OF_RESOURCE;
}
value.tokens = NULL; /* wildcard - look at all containers */
value.num_tokens = 0;
value.cnt = 1;
value.keyvals = (orte_gpr_keyval_t**)malloc(sizeof(orte_gpr_keyval_t*));
if (NULL == value.keyvals) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_DESTRUCT(&value);
sub.values = NULL;
OBJ_DESTRUCT(&sub);
return ORTE_ERR_OUT_OF_RESOURCE;
}
value.keyvals[0] = OBJ_NEW(orte_gpr_keyval_t);
if (NULL == value.keyvals[0]) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_DESTRUCT(&value);
sub.values = NULL;
OBJ_DESTRUCT(&sub);
return ORTE_ERR_OUT_OF_RESOURCE;
}
value.keyvals[0]->key = strdup(ORTE_NODE_SLOTS_KEY);
if (NULL == value.keyvals[0]->key) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_DESTRUCT(&value);
sub.values = NULL;
OBJ_DESTRUCT(&sub);
return ORTE_ERR_OUT_OF_RESOURCE;
}
sub.cbfunc = ompi_attr_create_predefined_callback;
sub.user_tag = NULL;
/* setup the trigger information */
OBJ_CONSTRUCT(&trig, orte_gpr_trigger_t);
if (ORTE_SUCCESS != (rc = orte_schema.get_std_trigger_name(&(trig.name),
ORTE_STG1_TRIGGER, job))) {
ORTE_ERROR_LOG(rc);
OBJ_DESTRUCT(&value);
sub.values = NULL;
OBJ_DESTRUCT(&sub);
return rc;
}
/* this is an ORTE-standard trigger that is defined by the ORTE resource manager
* when the job was launched - therefore, we don't need to provide any additional
* info
*/
/* do the subscription */
sub1 = ⊂
trig1 = &trig;
rc = orte_gpr.subscribe(1, &sub1, 1, &trig1);
if(ORTE_SUCCESS != rc) {
opal_output(0, "ompi_attr_create_predefined: subscribe failed");
OBJ_DESTRUCT(&value);
sub.values = NULL;
OBJ_DESTRUCT(&sub);
OBJ_DESTRUCT(&trig);
return OMPI_ERROR;
/* attach ourselves to the standard stage-1 trigger */
if (ORTE_SUCCESS !=
(rc = orte_schema.get_std_trigger_name(&trig_name,
ORTE_STG1_TRIGGER, job))) {
ORTE_ERROR_LOG(rc);
free(sub_name);
return rc;
}
OBJ_DESTRUCT(&value);
sub.values = NULL;
OBJ_DESTRUCT(&sub);
OBJ_DESTRUCT(&trig);
return OMPI_SUCCESS;
if (ORTE_SUCCESS != (rc = orte_gpr.subscribe_1(&id, trig_name, sub_name,
ORTE_GPR_NOTIFY_DELETE_AFTER_TRIG,
ORTE_GPR_TOKENS_OR | ORTE_GPR_KEYS_OR,
ORTE_NODE_SEGMENT,
NULL, /* wildcard - look at all containers */
ORTE_NODE_SLOTS_KEY,
ompi_attr_create_predefined_callback, NULL))) {
ORTE_ERROR_LOG(rc);
}
free(trig_name);
free(sub_name);
return rc;
}
@ -299,7 +239,7 @@ void ompi_attr_create_predefined_callback(
/* Query the gpr to find out how many CPUs there will be.
This will only return a non-empty list in a persistent
universe. If we don't have a persistent universe, then just
default to the size of MPI_COMM_WORLD.
default to the size of MPI_COMM_WORLD.
JMS: I think we need more here -- there are cases where you
wouldn't have a persistent universe but still may have a
@ -357,7 +297,7 @@ static int create_comm(int target_keyval, bool want_inherit)
ompi_attribute_fn_ptr_union_t del;
keyval = -1;
copy.attr_communicator_copy_fn =
copy.attr_communicator_copy_fn =
want_inherit ? MPI_COMM_DUP_FN : MPI_COMM_NULL_COPY_FN;
del.attr_communicator_delete_fn = MPI_COMM_NULL_DELETE_FN;
err = ompi_attr_create_keyval(COMM_ATTR, copy, del,
@ -400,7 +340,7 @@ static int create_win(int target_keyval)
static int set_f(int keyval, MPI_Fint value)
{
return ompi_attr_set_fortran_mpi1(COMM_ATTR, MPI_COMM_WORLD,
&MPI_COMM_WORLD->c_keyhash,
keyval, value,
&MPI_COMM_WORLD->c_keyhash,
keyval, value,
true, true);
}

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

@ -3,14 +3,14 @@
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
*
* Additional copyrights may follow
*
*
* $HEADER$
*/
@ -69,16 +69,16 @@ static void mca_pml_base_modex_module_destruct(mca_pml_base_modex_module_t *modu
}
OBJ_CLASS_INSTANCE(
mca_pml_base_modex_module_t,
opal_list_item_t,
mca_pml_base_modex_module_construct,
mca_pml_base_modex_module_t,
opal_list_item_t,
mca_pml_base_modex_module_construct,
mca_pml_base_modex_module_destruct
);
/**
* mca_pml_base_modex_t
*
* List of modules (mca_pml_base_modex_module_t) for which data has been
* List of modules (mca_pml_base_modex_module_t) for which data has been
* received from peers.
*/
struct mca_pml_base_modex_t {
@ -98,9 +98,9 @@ static void mca_pml_base_modex_destruct(mca_pml_base_modex_t* modex)
}
OBJ_CLASS_INSTANCE(
mca_pml_base_modex_t,
opal_object_t,
mca_pml_base_modex_construct,
mca_pml_base_modex_t,
opal_object_t,
mca_pml_base_modex_construct,
mca_pml_base_modex_destruct
);
@ -216,7 +216,7 @@ static void mca_pml_base_modex_registry_callback(
int rc;
#if 0
opal_output(0, "[%lu,%lu,%lu] mca_pml_base_modex_registry_callback\n",
opal_output(0, "[%lu,%lu,%lu] mca_pml_base_modex_registry_callback\n",
ORTE_NAME_ARGS(orte_process_info.my_name));
orte_gpr_base_dump_notify_data(data,0);
#endif
@ -225,7 +225,7 @@ orte_gpr_base_dump_notify_data(data,0);
new_procs = (ompi_proc_t**)malloc(sizeof(ompi_proc_t*) * data->cnt);
if(NULL == new_procs) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return;
return;
}
}
@ -245,16 +245,16 @@ orte_gpr_base_dump_notify_data(data,0);
proc = ompi_proc_find_and_add(proc_name, &isnew);
if(NULL == proc)
continue;
if(isnew) {
new_procs[new_proc_count] = proc;
new_proc_count++;
}
/*
* Lookup the modex data structure.
*/
OPAL_THREAD_LOCK(&proc->proc_lock);
if(NULL == (modex = (mca_pml_base_modex_t*)proc->proc_modex)) {
modex = OBJ_NEW(mca_pml_base_modex_t);
@ -265,7 +265,7 @@ orte_gpr_base_dump_notify_data(data,0);
}
proc->proc_modex = &modex->super;
}
/*
* Extract the component name and version from the keyval object's key
* Could be multiple keyvals returned since there is one for each
@ -280,10 +280,10 @@ orte_gpr_base_dump_notify_data(data,0);
size_t num_bytes;
if(strcmp(keyval[j]->key,"modex") != 0)
continue;
OBJ_CONSTRUCT(&buffer, orte_buffer_t);
if (ORTE_SUCCESS != (rc = orte_dps.load(&buffer,
keyval[j]->value.byteobject.bytes,
if (ORTE_SUCCESS != (rc = orte_dps.load(&buffer,
keyval[j]->value.byteobject.bytes,
keyval[j]->value.byteobject.size))) {
ORTE_ERROR_LOG(rc);
continue;
@ -295,7 +295,7 @@ orte_gpr_base_dump_notify_data(data,0);
}
strcpy(component.mca_type_name,ptr);
free(ptr);
cnt = 1;
if (ORTE_SUCCESS != (rc = orte_dps.unpack(&buffer, &ptr, &cnt, ORTE_STRING))) {
ORTE_ERROR_LOG(rc);
@ -303,21 +303,21 @@ orte_gpr_base_dump_notify_data(data,0);
}
strcpy(component.mca_component_name,ptr);
free(ptr);
cnt = 1;
if (ORTE_SUCCESS != (rc = orte_dps.unpack(&buffer,
if (ORTE_SUCCESS != (rc = orte_dps.unpack(&buffer,
&component.mca_component_major_version, &cnt, ORTE_INT32))) {
ORTE_ERROR_LOG(rc);
continue;
}
cnt = 1;
if (ORTE_SUCCESS != (rc = orte_dps.unpack(&buffer,
if (ORTE_SUCCESS != (rc = orte_dps.unpack(&buffer,
&component.mca_component_minor_version, &cnt, ORTE_INT32))) {
ORTE_ERROR_LOG(rc);
continue;
}
cnt = 1;
if (ORTE_SUCCESS != (rc = orte_dps.unpack(&buffer,
if (ORTE_SUCCESS != (rc = orte_dps.unpack(&buffer,
&num_bytes, &cnt, ORTE_SIZE))) {
ORTE_ERROR_LOG(rc);
continue;
@ -333,7 +333,7 @@ orte_gpr_base_dump_notify_data(data,0);
ORTE_ERROR_LOG(rc);
continue;
}
/*
* Lookup the corresponding modex structure
*/
@ -343,7 +343,7 @@ orte_gpr_base_dump_notify_data(data,0);
OPAL_THREAD_UNLOCK(&proc->proc_lock);
return;
}
modex_module->module_data = bytes;
modex_module->module_data_size = num_bytes;
modex_module->module_data_avail = true;
@ -360,7 +360,7 @@ opal_output(0, "[%lu,%lu,%lu] mca_pml_base_modex_registry_callback: %s-%s-%d-%d
}
OPAL_THREAD_UNLOCK(&proc->proc_lock);
} /* convert string to process name */
} /* if value[i]->cnt > 0 */
}
}
@ -380,8 +380,8 @@ opal_output(0, "[%lu,%lu,%lu] mca_pml_base_modex_registry_callback: %s-%s-%d-%d
static int mca_pml_base_modex_subscribe(orte_process_name_t* name)
{
orte_gpr_trigger_t trig, *trigs;
orte_gpr_subscription_t sub, *subs;
char *segment, *sub_name, *trig_name;
orte_gpr_subscription_id_t sub_id;
orte_jobid_t jobid;
opal_list_item_t* item;
mca_pml_base_modex_subscription_t* subscription;
@ -407,112 +407,56 @@ static int mca_pml_base_modex_subscribe(orte_process_name_t* name)
ORTE_ERROR_LOG(rc);
return rc;
}
/* setup the subscription definition */
OBJ_CONSTRUCT(&sub, orte_gpr_subscription_t);
/* indicate that this is a standard subscription. This indicates that the
* subscription will be common to all processes. Thus, the resulting data
* can be consolidated into a process-independent message and broadcast
* to all processes
*/
if (ORTE_SUCCESS != (rc = orte_schema.get_std_subscription_name(&(sub.name),
if (ORTE_SUCCESS != (rc = orte_schema.get_std_subscription_name(&sub_name,
OMPI_MODEX_SUBSCRIPTION, jobid))) {
ORTE_ERROR_LOG(rc);
return rc;
}
/* send data when trigger fires, continue to monitor. The default
* action for any subscription that includes a trigger condition is
* to send the specified data when the trigger fires. This set of flags
* indicates that - AFTER the trigger fires - the subscription should
* continue to send data any time an entry is added or changed.
*/
sub.action = ORTE_GPR_NOTIFY_ADD_ENTRY |
ORTE_GPR_NOTIFY_VALUE_CHG |
ORTE_GPR_NOTIFY_STARTS_AFTER_TRIG;
/* setup the value structures that describe the data to
* be monitored and returned by this subscription
*/
sub.cnt = 1;
sub.values = (orte_gpr_value_t**)malloc(sizeof(orte_gpr_value_t*));
if (NULL == sub.values) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
sub.values[0] = OBJ_NEW(orte_gpr_value_t);
if (NULL == sub.values[0]) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
sub.cnt = 1;
/* define the segment */
if (ORTE_SUCCESS != (rc = orte_schema.get_job_segment_name(
&(sub.values[0]->segment), jobid))) {
ORTE_ERROR_LOG(rc);
OBJ_DESTRUCT(&sub);
return rc;
}
sub.values[0]->addr_mode = ORTE_GPR_KEYS_OR | ORTE_GPR_TOKENS_OR;
/* look at all containers on this segment */
sub.values[0]->tokens = NULL;
sub.values[0]->num_tokens = 0;
/* look for any keyval with "modex" key */
sub.values[0]->cnt = 1;
sub.values[0]->keyvals = (orte_gpr_keyval_t**)malloc(sizeof(orte_gpr_keyval_t*));
if (NULL == sub.values[0]->keyvals) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_DESTRUCT(&sub);
return ORTE_ERR_OUT_OF_RESOURCE;
}
sub.values[0]->keyvals[0] = OBJ_NEW(orte_gpr_keyval_t);
if (NULL == sub.values[0]->keyvals[0]) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_DESTRUCT(&sub);
return ORTE_ERR_OUT_OF_RESOURCE;
}
sub.values[0]->keyvals[0]->key = strdup("modex");
if (NULL == sub.values[0]->keyvals[0]->key) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_DESTRUCT(&sub);
return ORTE_ERR_OUT_OF_RESOURCE;
}
/* define the callback function */
sub.cbfunc = mca_pml_base_modex_registry_callback;
sub.user_tag = NULL;
/* setup the trigger definition */
OBJ_CONSTRUCT(&trig, orte_gpr_trigger_t);
if (ORTE_SUCCESS != (rc = orte_schema.get_std_trigger_name(&(trig.name),
/* attach to the stage-1 standard trigger */
if (ORTE_SUCCESS != (rc = orte_schema.get_std_trigger_name(&trig_name,
ORTE_STG1_TRIGGER, jobid))) {
ORTE_ERROR_LOG(rc);
free(sub_name);
return rc;
}
/* this is an ORTE-standard trigger that is defined by the ORTE resource manager
* when the job was launched - therefore, we don't need to provide any additional
* info
*/
/* register the subscription */
subs = ⊂
trigs = &trig;
rc = orte_gpr.subscribe(1, &subs, 1, &trigs);
if(ORTE_SUCCESS != rc) {
opal_output(0, "mca_pml_base_modex_exchange: "
"orte_gpr.subscribe failed with return code %d\n", rc);
OBJ_DESTRUCT(&sub);
OBJ_DESTRUCT(&trig);
return OMPI_ERROR;
/* define the segment */
if (ORTE_SUCCESS != (rc = orte_schema.get_job_segment_name(&segment, jobid))) {
ORTE_ERROR_LOG(rc);
free(sub_name);
free(trig_name);
return rc;
}
if (ORTE_SUCCESS != (rc = orte_gpr.subscribe_1(&sub_id, trig_name, sub_name,
ORTE_GPR_NOTIFY_ADD_ENTRY |
ORTE_GPR_NOTIFY_VALUE_CHG |
ORTE_GPR_NOTIFY_STARTS_AFTER_TRIG,
ORTE_GPR_KEYS_OR | ORTE_GPR_TOKENS_OR,
segment,
NULL, /* look at all containers on this segment */
"modex",
mca_pml_base_modex_registry_callback, NULL))) {
ORTE_ERROR_LOG(rc);
opal_output(0, "mca_pml_base_modex_exchange: "
"orte_gpr.subscribe failed with return code %d\n", rc);
free(sub_name);
free(trig_name);
free(segment);
return rc;
}
free(sub_name);
free(trig_name);
free(segment);
/* add this jobid to our list of subscriptions */
OPAL_LOCK(&mca_pml_base_modex_lock);
subscription = OBJ_NEW(mca_pml_base_modex_subscription_t);
subscription->jobid = name->jobid;
opal_list_append(&mca_pml_base_modex_subscriptions, &subscription->item);
OPAL_UNLOCK(&mca_pml_base_modex_lock);
OBJ_DESTRUCT(&sub);
OBJ_DESTRUCT(&trig);
return OMPI_SUCCESS;
}
@ -525,8 +469,8 @@ static int mca_pml_base_modex_subscribe(orte_process_name_t* name)
*/
int mca_pml_base_modex_send(
mca_base_component_t *source_component,
const void *data,
mca_base_component_t *source_component,
const void *data,
size_t size)
{
orte_jobid_t jobid;
@ -575,7 +519,7 @@ int mca_pml_base_modex_send(
}
memcpy((value->keyvals[0])->value.byteobject.bytes, data, size);
asprintf(&((value->keyvals[0])->key), "modex-%s-%s-%d-%d",
asprintf(&((value->keyvals[0])->key), "modex-%s-%s-%d-%d",
source_component->mca_type_name,
source_component->mca_component_name,
source_component->mca_component_major_version,
@ -602,7 +546,7 @@ int mca_pml_base_modex_send(
if (ORTE_SUCCESS != (rc = orte_dps.pack(&buffer, (void*)data, size, ORTE_BYTE))) {
goto cleanup;
}
if (ORTE_SUCCESS != (rc = orte_dps.unload(&buffer,
if (ORTE_SUCCESS != (rc = orte_dps.unload(&buffer,
(void**)&(value->keyvals[0])->value.byteobject.bytes,
(size_t*)&(value->keyvals[0])->value.byteobject.size))) {
goto cleanup;
@ -625,8 +569,8 @@ cleanup:
int mca_pml_base_modex_recv(
mca_base_component_t *component,
ompi_proc_t *proc,
void **buffer,
ompi_proc_t *proc,
void **buffer,
size_t *size)
{
mca_pml_base_modex_t* modex;

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

@ -3,14 +3,14 @@
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
*
* Additional copyrights may follow
*
*
* $HEADER$
*/
@ -25,6 +25,7 @@
#include "orte/mca/oob/oob.h"
#include "orte/mca/ns/ns.h"
#include "orte/mca/gpr/gpr.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/util/proc_info.h"
#include "ompi/proc/proc.h"
#include "ompi/mca/pml/pml.h"
@ -41,9 +42,9 @@ static int setup_registry_callback(void);
static void callback(orte_gpr_notify_data_t *data, void *cbdata);
OBJ_CLASS_INSTANCE(
ompi_proc_t,
ompi_proc_t,
opal_list_item_t,
ompi_proc_construct,
ompi_proc_construct,
ompi_proc_destruct
);
@ -166,7 +167,7 @@ ompi_proc_t** ompi_proc_world(size_t *size)
/* First count how many match this jobid */
OPAL_THREAD_LOCK(&ompi_proc_lock);
for (proc = (ompi_proc_t*)opal_list_get_first(&ompi_proc_list);
for (proc = (ompi_proc_t*)opal_list_get_first(&ompi_proc_list);
proc != (ompi_proc_t*)opal_list_get_end(&ompi_proc_list);
proc = (ompi_proc_t*)opal_list_get_next(proc)) {
if (0 == orte_ns.compare(mask, &proc->proc_name, &my_name)) {
@ -182,7 +183,7 @@ ompi_proc_t** ompi_proc_world(size_t *size)
/* now save only the procs that match this jobid */
count = 0;
for (proc = (ompi_proc_t*)opal_list_get_first(&ompi_proc_list);
for (proc = (ompi_proc_t*)opal_list_get_first(&ompi_proc_list);
proc != (ompi_proc_t*)opal_list_get_end(&ompi_proc_list);
proc = (ompi_proc_t*)opal_list_get_next(proc)) {
if (0 == orte_ns.compare(mask, &proc->proc_name, &my_name)) {
@ -198,7 +199,7 @@ ompi_proc_t** ompi_proc_world(size_t *size)
ompi_proc_t** ompi_proc_all(size_t* size)
{
ompi_proc_t **procs =
ompi_proc_t **procs =
(ompi_proc_t**) malloc(opal_list_get_size(&ompi_proc_list) * sizeof(ompi_proc_t*));
ompi_proc_t *proc;
size_t count = 0;
@ -208,7 +209,7 @@ ompi_proc_t** ompi_proc_all(size_t* size)
}
OPAL_THREAD_LOCK(&ompi_proc_lock);
for(proc = (ompi_proc_t*)opal_list_get_first(&ompi_proc_list);
for(proc = (ompi_proc_t*)opal_list_get_first(&ompi_proc_list);
proc != (ompi_proc_t*)opal_list_get_end(&ompi_proc_list);
proc = (ompi_proc_t*)opal_list_get_next(proc)) {
OBJ_RETAIN(proc);
@ -241,7 +242,7 @@ ompi_proc_t * ompi_proc_find ( const orte_process_name_t * name )
mask = ORTE_NS_CMP_CELLID | ORTE_NS_CMP_JOBID | ORTE_NS_CMP_VPID;
OPAL_THREAD_LOCK(&ompi_proc_lock);
for(proc = (ompi_proc_t*)opal_list_get_first(&ompi_proc_list);
for(proc = (ompi_proc_t*)opal_list_get_first(&ompi_proc_list);
proc != (ompi_proc_t*)opal_list_get_end(&ompi_proc_list);
proc = (ompi_proc_t*)opal_list_get_next(proc)) {
if (0 == orte_ns.compare(mask, &proc->proc_name, name)) {
@ -262,7 +263,7 @@ ompi_proc_t * ompi_proc_find_and_add ( const orte_process_name_t * name, bool* i
/* return the proc-struct which matches this jobid+process id */
mask = ORTE_NS_CMP_CELLID | ORTE_NS_CMP_JOBID | ORTE_NS_CMP_VPID;
OPAL_THREAD_LOCK(&ompi_proc_lock);
for(proc = (ompi_proc_t*)opal_list_get_first(&ompi_proc_list);
for(proc = (ompi_proc_t*)opal_list_get_first(&ompi_proc_list);
proc != (ompi_proc_t*)opal_list_get_end(&ompi_proc_list);
proc = (ompi_proc_t*)opal_list_get_next(proc)) {
if (0 == orte_ns.compare(mask, &proc->proc_name, name)) {
@ -336,105 +337,68 @@ int ompi_proc_get_proclist (orte_buffer_t* buf, int proclistsize, ompi_proc_t **
static int setup_registry_callback(void)
{
int rc;
char *segment;
char *segment, *sub_name, *trig_name, *keys[2];
ompi_proc_t *local = ompi_proc_local();
orte_gpr_subscription_id_t id;
orte_jobid_t jobid;
orte_gpr_trigger_t trig, *trig1;
orte_gpr_value_t value, *values;
orte_gpr_subscription_t sub, *sub1;
if (ORTE_SUCCESS != orte_ns.get_jobid(&jobid, &local->proc_name)) {
printf("Badness!\n");
if (ORTE_SUCCESS != (rc = orte_ns.get_jobid(&jobid, &local->proc_name))) {
ORTE_ERROR_LOG(rc);
return rc;
}
/* find the job segment on the registry */
if (ORTE_SUCCESS !=
if (ORTE_SUCCESS !=
(rc = orte_schema.get_job_segment_name(&segment, jobid))) {
return rc;
}
OBJ_CONSTRUCT(&sub, orte_gpr_subscription_t);
/* indicate that this is a standard subscription. This indicates
that the subscription will be common to all processes. Thus,
the resulting data can be consolidated into a
process-independent message and broadcast to all processes */
if (ORTE_SUCCESS !=
(rc = orte_schema.get_std_subscription_name(&(sub.name),
if (ORTE_SUCCESS !=
(rc = orte_schema.get_std_subscription_name(&sub_name,
OMPI_PROC_SUBSCRIPTION, jobid))) {
ORTE_ERROR_LOG(rc);
free(segment);
return rc;
}
/* send data when trigger fires, then delete - no need for further
notifications */
sub.action = ORTE_GPR_NOTIFY_DELETE_AFTER_TRIG;
OBJ_CONSTRUCT(&value, orte_gpr_value_t);
values = &value;
sub.values = &values;
sub.cnt = 1;
value.addr_mode = ORTE_GPR_TOKENS_OR | ORTE_GPR_KEYS_OR;
value.segment = segment;
value.tokens = NULL; /* wildcard - look at all containers */
value.num_tokens = 0;
value.cnt = 2;
value.keyvals =
(orte_gpr_keyval_t**)malloc(sizeof(orte_gpr_keyval_t*) * 2);
if (NULL == value.keyvals) {
rc = ORTE_ERR_OUT_OF_RESOURCE;
goto cleanup;
}
value.keyvals[0] = NULL;
value.keyvals[1] = NULL;
value.keyvals[0] = OBJ_NEW(orte_gpr_keyval_t);
if (NULL == value.keyvals[0]) {
rc = ORTE_ERR_OUT_OF_RESOURCE;
goto cleanup;
}
value.keyvals[0]->key = strdup(ORTE_PROC_NAME_KEY);
if (NULL == value.keyvals[0]->key) {
rc = ORTE_ERR_OUT_OF_RESOURCE;
goto cleanup;
}
value.keyvals[1] = OBJ_NEW(orte_gpr_keyval_t);
if (NULL == value.keyvals[0]) {
rc = ORTE_ERR_OUT_OF_RESOURCE;
goto cleanup;
}
value.keyvals[1]->key = strdup(ORTE_NODE_NAME_KEY);
if (NULL == value.keyvals[0]->key) {
rc = ORTE_ERR_OUT_OF_RESOURCE;
goto cleanup;
}
/* define the keys to be returned */
keys[0] = strdup(ORTE_PROC_NAME_KEY);
keys[1] = strdup(ORTE_NODE_NAME_KEY);
/* Here we have to add another key to the registry to be able to get the information
* about the remote architectures.
* TODO: George.
*/
sub.cbfunc = callback;
sub.user_tag = NULL;
/* setup the trigger information */
OBJ_CONSTRUCT(&trig, orte_gpr_trigger_t);
if (ORTE_SUCCESS !=
(rc = orte_schema.get_std_trigger_name(&(trig.name),
/* attach ourselves to the standard stage-1 trigger */
if (ORTE_SUCCESS !=
(rc = orte_schema.get_std_trigger_name(&trig_name,
ORTE_STG1_TRIGGER, jobid))) {
goto cleanup;
ORTE_ERROR_LOG(rc);
goto CLEANUP;
}
/* do the subscription */
sub1 = ⊂
trig1 = &trig;
rc = orte_gpr.subscribe(1, &sub1, 1, &trig1);
if (ORTE_SUCCESS != (rc = orte_gpr.subscribe_N(&id, trig_name, sub_name,
ORTE_GPR_NOTIFY_DELETE_AFTER_TRIG,
ORTE_GPR_TOKENS_OR | ORTE_GPR_KEYS_OR,
segment,
NULL, /* wildcard - look at all containers */
2, keys,
callback, NULL))) {
ORTE_ERROR_LOG(rc);
}
free(trig_name);
CLEANUP:
free(segment);
free(sub_name);
free(keys[0]);
free(keys[1]);
cleanup:
OBJ_DESTRUCT(&value);
sub.values = NULL;
OBJ_DESTRUCT(&sub);
OBJ_DESTRUCT(&trig);
return rc;
}
@ -445,7 +409,7 @@ static int setup_registry_callback(void)
* figure out which procs are on the same host as the local proc. For
* each proc that is on the same host as the local proc, we set that
* proc's OMPI_PROC_FLAG_LOCAL flag.
*/
*/
static void callback(orte_gpr_notify_data_t *data, void *cbdata)
{
size_t i, j, k;
@ -475,7 +439,7 @@ static void callback(orte_gpr_notify_data_t *data, void *cbdata)
str = NULL;
found_name = false;
keyval = value[i]->keyvals;
/* find the 2 keys that we're looking for */
for (j = 0; j < value[i]->cnt; ++j) {
if (strcmp(keyval[j]->key, ORTE_PROC_NAME_KEY) == 0) {
@ -489,15 +453,15 @@ static void callback(orte_gpr_notify_data_t *data, void *cbdata)
str = strdup(keyval[j]->value.strptr);
}
}
/* if we found both keys and the proc is on my local host,
find it in the master proc list and set the "local" flag */
if (NULL != str && found_name &&
0 == strcmp(str, orte_system_info.nodename)) {
for (proc = (ompi_proc_t*)opal_list_get_first(&ompi_proc_list);
for (proc = (ompi_proc_t*)opal_list_get_first(&ompi_proc_list);
proc != (ompi_proc_t*)opal_list_get_end(&ompi_proc_list);
proc = (ompi_proc_t*)opal_list_get_next(proc)) {
if (0 == orte_ns.compare(mask, &name,
if (0 == orte_ns.compare(mask, &name,
&proc->proc_name)) {
proc->proc_flags |= OMPI_PROC_FLAG_LOCAL;
}

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

@ -93,7 +93,8 @@ int ompi_mpi_finalize(void)
/*
* Wait for everyone to get here
*/
if (ORTE_SUCCESS != (ret = orte_rml.xcast(NULL, NULL, 0, NULL, NULL))) {
if (ORTE_SUCCESS != (ret = orte_rml.xcast(NULL, NULL, 0, NULL,
orte_gpr.deliver_notify_msg, NULL))) {
ORTE_ERROR_LOG(ret);
return ret;
}
@ -219,7 +220,8 @@ int ompi_mpi_finalize(void)
* the RTE while the soh is trying to do the update - which causes
* an ugly race condition
*/
if (ORTE_SUCCESS != (ret = orte_rml.xcast(NULL, NULL, 0, NULL, NULL))) {
if (ORTE_SUCCESS != (ret = orte_rml.xcast(NULL, NULL, 0, NULL,
orte_gpr.deliver_notify_msg, NULL))) {
ORTE_ERROR_LOG(ret);
return ret;
}

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

@ -179,7 +179,7 @@ int ompi_mpi_init(int argc, char **argv, int requested, int *provided)
}
}
#ifndef WIN32
#if 0
if (OMPI_SUCCESS != (ret = opal_util_register_stackhandlers ())) {
error = "util_register_stackhandlers() failed";
goto error;
@ -363,7 +363,8 @@ int ompi_mpi_init(int argc, char **argv, int requested, int *provided)
}
/* FIRST BARRIER - WAIT FOR MSG FROM RMGR_PROC_STAGE_GATE_MGR TO ARRIVE */
if (ORTE_SUCCESS != (ret = orte_rml.xcast(NULL, NULL, 0, NULL, NULL))) {
if (ORTE_SUCCESS != (ret = orte_rml.xcast(NULL, NULL, 0, NULL,
orte_gpr.deliver_notify_msg, NULL))) {
ORTE_ERROR_LOG(ret);
error = "ompi_mpi_init: failed to see all procs register\n";
goto error;
@ -469,7 +470,8 @@ int ompi_mpi_init(int argc, char **argv, int requested, int *provided)
/* Second barrier -- wait for message from
RMGR_PROC_STAGE_GATE_MGR to arrive */
if (ORTE_SUCCESS != (ret = orte_rml.xcast(NULL, NULL, 0, NULL, NULL))) {
if (ORTE_SUCCESS != (ret = orte_rml.xcast(NULL, NULL, 0, NULL,
orte_gpr.deliver_notify_msg, NULL))) {
ORTE_ERROR_LOG(ret);
error = "ompi_mpi_init: failed to see all procs register\n";
goto error;

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

@ -3,14 +3,14 @@
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
*
* Additional copyrights may follow
*
*
* $HEADER$
*/
/** @file */
@ -26,7 +26,7 @@
/**
* Supported datatypes for messaging and storage operations.
*
*
* ANY CHANGES TO THESE DEFINITIONS MUST BE REFLECTED IN THE TEXT ARRAY
* orte_data_strings DEFINED IN src/runtime/orte_init.c.
*
@ -90,12 +90,13 @@ typedef uint8_t orte_data_type_t ;
#define ORTE_GPR_TRIGGER (orte_data_type_t) 44 /**< describes trigger conditions */
#define ORTE_GPR_NOTIFY_DATA (orte_data_type_t) 45 /**< data returned from a subscription */
#define ORTE_GPR_NOTIFY_MSG (orte_data_type_t) 46 /**< notify message containing notify_data objects */
#define ORTE_GPR_NOTIFY_MSG_TYPE (orte_data_type_t) 47 /**< notify message type (subscription or trigger) */
/* Resource Manager types */
#define ORTE_APP_CONTEXT (orte_data_type_t) 47 /**< argv and enviro arrays */
#define ORTE_APP_CONTEXT_MAP (orte_data_type_t) 48 /**< application context mapping array */
#define ORTE_APP_CONTEXT (orte_data_type_t) 48 /**< argv and enviro arrays */
#define ORTE_APP_CONTEXT_MAP (orte_data_type_t) 49 /**< application context mapping array */
/* define the starting point for dynamically assigning data types */
#define ORTE_DPS_ID_DYNAMIC 50
#define ORTE_DPS_ID_DYNAMIC 60
/* define a structure to hold generic byte objects */
typedef struct {
@ -103,12 +104,4 @@ typedef struct {
uint8_t *bytes;
} orte_byte_object_t;
/* define a print format to handle the variations in pid_t */
#if SIZEOF_PID_T == SIZEOF_INT
#define ORTE_PID_T_PRINTF "%u"
#elif SIZEOF_PID_T == SIZEOF_LONG
#define ORTE_PID_T_PRINTF "%lu"
#endif
#endif

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

@ -3,14 +3,14 @@
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
*
* Additional copyrights may follow
*
*
* $HEADER$
*/
/** @file:
@ -48,7 +48,7 @@
* the addition of another subscriber, and deletion. Notifications are sent via
* the OOB communication channel.
*
*
*
*/
#ifndef ORTE_GPR_BASE_H_
@ -85,27 +85,29 @@ extern "C" {
/*
* Define flag values for remote commands
*/
#define ORTE_GPR_DELETE_SEGMENT_CMD (uint8_t) 1
#define ORTE_GPR_PUT_CMD (uint8_t) 2
#define ORTE_GPR_DELETE_ENTRIES_CMD (uint8_t) 3
#define ORTE_GPR_INDEX_CMD (uint8_t) 4
#define ORTE_GPR_SUBSCRIBE_CMD (uint8_t) 5
#define ORTE_GPR_UNSUBSCRIBE_CMD (uint8_t) 6
#define ORTE_GPR_CANCEL_TRIGGER_CMD (uint8_t) 7
#define ORTE_GPR_GET_CMD (uint8_t) 8
#define ORTE_GPR_TEST_INTERNALS_CMD (uint8_t) 9
#define ORTE_GPR_NOTIFY_CMD (uint8_t) 10
#define ORTE_GPR_DUMP_ALL_CMD (uint8_t) 11
#define ORTE_GPR_DUMP_SEGMENTS_CMD (uint8_t) 12
#define ORTE_GPR_DUMP_TRIGGERS_CMD (uint8_t) 13
#define ORTE_GPR_DUMP_SUBSCRIPTIONS_CMD (uint8_t) 14
#define ORTE_GPR_DUMP_CALLBACKS_CMD (uint8_t) 15
#define ORTE_GPR_INCREMENT_VALUE_CMD (uint8_t) 16
#define ORTE_GPR_DECREMENT_VALUE_CMD (uint8_t) 17
#define ORTE_GPR_COMPOUND_CMD (uint8_t) 18
#define ORTE_GPR_CLEANUP_JOB_CMD (uint8_t) 19
#define ORTE_GPR_CLEANUP_PROC_CMD (uint8_t) 20
#define ORTE_GPR_ERROR (uint8_t)0xff
#define ORTE_GPR_DELETE_SEGMENT_CMD (uint8_t) 1
#define ORTE_GPR_PUT_CMD (uint8_t) 2
#define ORTE_GPR_DELETE_ENTRIES_CMD (uint8_t) 3
#define ORTE_GPR_INDEX_CMD (uint8_t) 4
#define ORTE_GPR_SUBSCRIBE_CMD (uint8_t) 5
#define ORTE_GPR_UNSUBSCRIBE_CMD (uint8_t) 6
#define ORTE_GPR_CANCEL_TRIGGER_CMD (uint8_t) 7
#define ORTE_GPR_GET_CMD (uint8_t) 8
#define ORTE_GPR_TEST_INTERNALS_CMD (uint8_t) 9
#define ORTE_GPR_NOTIFY_CMD (uint8_t) 10
#define ORTE_GPR_DUMP_ALL_CMD (uint8_t) 11
#define ORTE_GPR_DUMP_SEGMENTS_CMD (uint8_t) 12
#define ORTE_GPR_DUMP_TRIGGERS_CMD (uint8_t) 13
#define ORTE_GPR_DUMP_SUBSCRIPTIONS_CMD (uint8_t) 14
#define ORTE_GPR_DUMP_CALLBACKS_CMD (uint8_t) 15
#define ORTE_GPR_INCREMENT_VALUE_CMD (uint8_t) 16
#define ORTE_GPR_DECREMENT_VALUE_CMD (uint8_t) 17
#define ORTE_GPR_COMPOUND_CMD (uint8_t) 18
#define ORTE_GPR_CLEANUP_JOB_CMD (uint8_t) 19
#define ORTE_GPR_CLEANUP_PROC_CMD (uint8_t) 20
#define ORTE_GPR_DUMP_A_TRIGGER_CMD (uint8_t) 21
#define ORTE_GPR_DUMP_A_SUBSCRIPTION_CMD (uint8_t) 22
#define ORTE_GPR_ERROR (uint8_t)0xff
typedef uint8_t orte_gpr_cmd_flag_t;
#define ORTE_GPR_CMD_T ORTE_UINT8
@ -125,7 +127,7 @@ typedef uint8_t orte_gpr_cmd_flag_t;
size_t n, char **keys,
orte_data_type_t *types,
orte_gpr_value_union_t *data_values);
OMPI_DECLSPEC int orte_gpr_base_subscribe_1(orte_gpr_subscription_id_t *id,
char *trig_name,
char *sub_name,
@ -162,14 +164,26 @@ typedef uint8_t orte_gpr_cmd_flag_t;
orte_gpr_trigger_cb_fn_t cbfunc,
void *user_tag);
OMPI_DECLSPEC int orte_gpr_base_define_trigger_level(orte_gpr_trigger_id_t *id,
char *trig_name,
orte_gpr_trigger_action_t action,
orte_gpr_addr_mode_t addr_mode,
char *segment,
char **tokens,
size_t n,
char **keys,
size_t *levels,
orte_gpr_trigger_cb_fn_t cbfunc,
void *user_tag);
/* general usage functions */
OMPI_DECLSPEC int orte_gpr_base_pack_delete_segment(orte_buffer_t *cmd,
char *segment);
OMPI_DECLSPEC int orte_gpr_base_unpack_delete_segment(orte_buffer_t *buffer, int *ret);
OMPI_DECLSPEC int orte_gpr_base_pack_delete_entries(orte_buffer_t *buffer,
orte_gpr_addr_mode_t mode,
char *segment, char **tokens, char **keys);
orte_gpr_addr_mode_t mode,
char *segment, char **tokens, char **keys);
OMPI_DECLSPEC int orte_gpr_base_unpack_delete_entries(orte_buffer_t *buffer, int *ret);
OMPI_DECLSPEC int orte_gpr_base_pack_index(orte_buffer_t *cmd, char *segment);
@ -183,7 +197,7 @@ typedef uint8_t orte_gpr_cmd_flag_t;
OMPI_DECLSPEC int orte_gpr_base_unpack_subscribe(orte_buffer_t *buffer, int *ret);
OMPI_DECLSPEC int orte_gpr_base_pack_unsubscribe(orte_buffer_t *cmd,
orte_gpr_subscription_id_t id);
orte_gpr_subscription_id_t id);
OMPI_DECLSPEC int orte_gpr_base_unpack_unsubscribe(orte_buffer_t *buffer, int *ret);
OMPI_DECLSPEC int orte_gpr_base_pack_cancel_trigger(orte_buffer_t *cmd,
@ -191,19 +205,26 @@ typedef uint8_t orte_gpr_cmd_flag_t;
OMPI_DECLSPEC int orte_gpr_base_unpack_cancel_trigger(orte_buffer_t *buffer, int *ret);
OMPI_DECLSPEC int orte_gpr_base_pack_put(orte_buffer_t *cmd,
size_t cnt, orte_gpr_value_t **values);
size_t cnt, orte_gpr_value_t **values);
OMPI_DECLSPEC int orte_gpr_base_unpack_put(orte_buffer_t *buffer, int *ret);
OMPI_DECLSPEC int orte_gpr_base_pack_get(orte_buffer_t *cmd,
orte_gpr_addr_mode_t mode,
char *segment, char **tokens, char **keys);
orte_gpr_addr_mode_t mode,
char *segment, char **tokens, char **keys);
OMPI_DECLSPEC int orte_gpr_base_unpack_get(orte_buffer_t *buffer, int *ret,
size_t *cnt, orte_gpr_value_t ***values);
OMPI_DECLSPEC int orte_gpr_base_pack_dump_all(orte_buffer_t *cmd);
OMPI_DECLSPEC int orte_gpr_base_pack_dump_segments(orte_buffer_t *cmd, char *segment);
OMPI_DECLSPEC int orte_gpr_base_pack_dump_triggers(orte_buffer_t *cmd);
OMPI_DECLSPEC int orte_gpr_base_pack_dump_subscriptions(orte_buffer_t *cmd);
OMPI_DECLSPEC int orte_gpr_base_pack_dump_triggers(orte_buffer_t *cmd,
orte_gpr_trigger_id_t start);
OMPI_DECLSPEC int orte_gpr_base_pack_dump_subscriptions(orte_buffer_t *cmd,
orte_gpr_subscription_id_t start);
OMPI_DECLSPEC int orte_gpr_base_pack_dump_a_trigger(orte_buffer_t *cmd,
char *name, orte_gpr_trigger_id_t id);
OMPI_DECLSPEC int orte_gpr_base_pack_dump_a_subscription(orte_buffer_t *cmd,
char *name,
orte_gpr_subscription_id_t id);
OMPI_DECLSPEC int orte_gpr_base_pack_dump_callbacks(orte_buffer_t *cmd);
OMPI_DECLSPEC int orte_gpr_base_print_dump(orte_buffer_t *buffer, int output_id);
OMPI_DECLSPEC void orte_gpr_base_dump_keyval_value(orte_buffer_t *buffer,
@ -219,11 +240,11 @@ typedef uint8_t orte_gpr_cmd_flag_t;
OMPI_DECLSPEC int orte_gpr_base_pack_cleanup_job(orte_buffer_t *buffer,
orte_jobid_t jobid);
OMPI_DECLSPEC int orte_gpr_base_unpack_cleanup_job(orte_buffer_t *buffer, int *ret);
OMPI_DECLSPEC int orte_gpr_base_pack_cleanup_proc(orte_buffer_t *buffer,
orte_process_name_t *proc);
OMPI_DECLSPEC int orte_gpr_base_unpack_cleanup_proc(orte_buffer_t *buffer, int *ret);
OMPI_DECLSPEC int orte_gpr_base_pack_increment_value(orte_buffer_t *cmd, orte_gpr_value_t *value);
OMPI_DECLSPEC int orte_gpr_base_unpack_increment_value(orte_buffer_t *buffer, int *ret);
@ -246,6 +267,9 @@ int orte_gpr_base_pack_notify_action(orte_buffer_t *buffer, void *src,
int orte_gpr_base_pack_trigger_action(orte_buffer_t *buffer, void *src,
size_t num_vals, orte_data_type_t type);
int orte_gpr_base_pack_notify_msg_type(orte_buffer_t *buffer, void *src,
size_t num_vals, orte_data_type_t type);
int orte_gpr_base_pack_addr_mode(orte_buffer_t *buffer, void *src,
size_t num_vals, orte_data_type_t type);
@ -286,6 +310,9 @@ int orte_gpr_base_unpack_trigger_action(orte_buffer_t *buffer, void *dest,
int orte_gpr_base_unpack_addr_mode(orte_buffer_t *buffer, void *dest,
size_t *num_vals, orte_data_type_t type);
int orte_gpr_base_unpack_notify_msg_type(orte_buffer_t *buffer, void *dest,
size_t *num_vals, orte_data_type_t type);
int orte_gpr_base_unpack_keyval(orte_buffer_t *buffer, void *dest,
size_t *num_vals, orte_data_type_t type);

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

@ -3,17 +3,17 @@
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
*
* Additional copyrights may follow
*
*
* $HEADER$
*/
#include "orte_config.h"
#include <sys/types.h>
@ -37,7 +37,7 @@ int orte_gpr_base_pack_cmd(orte_buffer_t *buffer, void *src,
if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer, src, num_vals, ORTE_GPR_CMD_T))) {
ORTE_ERROR_LOG(rc);
}
return rc;
}
@ -52,7 +52,7 @@ int orte_gpr_base_pack_subscription_id(orte_buffer_t *buffer, void *src,
if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer, src, num_vals, ORTE_GPR_SUBSCRIPTION_ID_T))) {
ORTE_ERROR_LOG(rc);
}
return rc;
}
@ -67,7 +67,7 @@ int orte_gpr_base_pack_trigger_id(orte_buffer_t *buffer, void *src,
if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer, src, num_vals, ORTE_GPR_TRIGGER_ID_T))) {
ORTE_ERROR_LOG(rc);
}
return rc;
}
@ -82,7 +82,7 @@ int orte_gpr_base_pack_notify_action(orte_buffer_t *buffer, void *src,
if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer, src, num_vals, ORTE_GPR_NOTIFY_ACTION_T))) {
ORTE_ERROR_LOG(rc);
}
return rc;
}
@ -97,7 +97,7 @@ int orte_gpr_base_pack_trigger_action(orte_buffer_t *buffer, void *src,
if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer, src, num_vals, ORTE_GPR_TRIGGER_ACTION_T))) {
ORTE_ERROR_LOG(rc);
}
return rc;
}
@ -112,10 +112,26 @@ int orte_gpr_base_pack_addr_mode(orte_buffer_t *buffer, void *src,
if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer, src, num_vals, ORTE_GPR_ADDR_MODE_T))) {
ORTE_ERROR_LOG(rc);
}
return rc;
}
/*
* NOTIFY MSG TYPE
*/
int orte_gpr_base_pack_notify_msg_type(orte_buffer_t *buffer, void *src,
size_t num_vals, orte_data_type_t type)
{
int rc;
if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer, src, num_vals, ORTE_GPR_NOTIFY_MSG_TYPE_T))) {
ORTE_ERROR_LOG(rc);
}
return rc;
}
/*
* KEYVAL
*/
@ -152,7 +168,7 @@ int orte_gpr_base_pack_keyval(orte_buffer_t *buffer, void *src,
return rc;
}
}
return ORTE_SUCCESS;
}
@ -175,7 +191,7 @@ int orte_gpr_base_pack_value(orte_buffer_t *buffer, void *src,
ORTE_ERROR_LOG(rc);
return ORTE_ERROR;
}
/* pack the segment name */
if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer,
(void*)(&(values[i]->segment)), 1, ORTE_STRING))) {
@ -198,7 +214,7 @@ int orte_gpr_base_pack_value(orte_buffer_t *buffer, void *src,
return ORTE_ERROR;
}
}
/* pack the number of keyval pairs so we can read it for unpacking */
if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer,
(void*)(&(values[i]->cnt)), 1, DPS_TYPE_SIZE_T))) {
@ -215,7 +231,7 @@ int orte_gpr_base_pack_value(orte_buffer_t *buffer, void *src,
}
}
}
return ORTE_SUCCESS;
}
@ -347,7 +363,7 @@ int orte_gpr_base_pack_notify_data(orte_buffer_t *buffer, void *src,
/* pack the subscription name */
if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer,
(void*)(&(data[i]->name)), 1, ORTE_STRING))) {
(void*)(&(data[i]->target)), 1, ORTE_STRING))) {
ORTE_ERROR_LOG(rc);
return rc;
}
@ -407,12 +423,19 @@ int orte_gpr_base_pack_notify_msg(orte_buffer_t *buffer, void *src,
/* array of messages */
msg = (orte_gpr_notify_message_t**) src;
for (i=0; i<num_vals; i++) {
/* pack the message type */
if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer,
(void*)(&(msg[i]->msg_type)), 1, ORTE_GPR_NOTIFY_MSG_TYPE))) {
ORTE_ERROR_LOG(rc);
return rc;
}
/* pack the trigger name */
if (ORTE_SUCCESS != (rc = orte_dps_pack_buffer(buffer,
(void*)(&(msg[i]->name)), 1, ORTE_STRING))) {
(void*)(&(msg[i]->target)), 1, ORTE_STRING))) {
ORTE_ERROR_LOG(rc);
return rc;
}

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

@ -3,17 +3,17 @@
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
*
* Additional copyrights may follow
*
*
* $HEADER$
*/
#include "orte_config.h"
#include <sys/types.h>
@ -37,7 +37,7 @@ int orte_gpr_base_unpack_cmd(orte_buffer_t *buffer, void *dest,
if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, dest, num_vals, ORTE_GPR_CMD_T))) {
ORTE_ERROR_LOG(rc);
}
return rc;
}
@ -52,7 +52,7 @@ int orte_gpr_base_unpack_subscription_id(orte_buffer_t *buffer, void *dest,
if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, dest, num_vals, ORTE_GPR_SUBSCRIPTION_ID_T))) {
ORTE_ERROR_LOG(rc);
}
return rc;
}
@ -67,7 +67,7 @@ int orte_gpr_base_unpack_trigger_id(orte_buffer_t *buffer, void *dest,
if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, dest, num_vals, ORTE_GPR_TRIGGER_ID_T))) {
ORTE_ERROR_LOG(rc);
}
return rc;
}
@ -82,7 +82,7 @@ int orte_gpr_base_unpack_notify_action(orte_buffer_t *buffer, void *dest,
if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, dest, num_vals, ORTE_GPR_NOTIFY_ACTION_T))) {
ORTE_ERROR_LOG(rc);
}
return rc;
}
@ -97,7 +97,22 @@ int orte_gpr_base_unpack_trigger_action(orte_buffer_t *buffer, void *dest,
if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, dest, num_vals, ORTE_GPR_TRIGGER_ACTION_T))) {
ORTE_ERROR_LOG(rc);
}
return rc;
}
/*
* NOTIFY MSG TYPE
*/
int orte_gpr_base_unpack_notify_msg_type(orte_buffer_t *buffer, void *dest,
size_t *num_vals, orte_data_type_t type)
{
int rc;
if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, dest, num_vals, ORTE_GPR_NOTIFY_MSG_TYPE_T))) {
ORTE_ERROR_LOG(rc);
}
return rc;
}
@ -112,7 +127,7 @@ int orte_gpr_base_unpack_addr_mode(orte_buffer_t *buffer, void *dest,
if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, dest, num_vals, ORTE_GPR_ADDR_MODE_T))) {
ORTE_ERROR_LOG(rc);
}
return rc;
}
@ -187,7 +202,7 @@ int orte_gpr_base_unpack_value(orte_buffer_t *buffer, void *dest,
ORTE_ERROR_LOG(rc);
return rc;
}
/* unpack the segment name */
if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, &(values[i]->segment),
&max_n, ORTE_STRING))) {
@ -217,7 +232,7 @@ int orte_gpr_base_unpack_value(orte_buffer_t *buffer, void *dest,
return rc;
}
}
/* get the number of keyval pairs */
if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, &(values[i]->cnt),
&max_n, DPS_TYPE_SIZE_T))) {
@ -239,9 +254,9 @@ int orte_gpr_base_unpack_value(orte_buffer_t *buffer, void *dest,
ORTE_ERROR_LOG(rc);
return rc;
}
}
}
}
return ORTE_SUCCESS;
}
@ -308,7 +323,7 @@ int orte_gpr_base_unpack_subscription(orte_buffer_t *buffer, void *dest,
return rc;
}
}
/* the pointer fields for cb_func and user_tag were NOT packed
* so ignore them here as well
*/
@ -408,7 +423,7 @@ int orte_gpr_base_unpack_notify_data(orte_buffer_t *buffer, void *dest,
}
/* unpack the subscription name */
if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, &(data[i]->name),
if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, &(data[i]->target),
&max_n, ORTE_STRING))) {
ORTE_ERROR_LOG(rc);
return rc;
@ -434,7 +449,7 @@ int orte_gpr_base_unpack_notify_data(orte_buffer_t *buffer, void *dest,
ORTE_ERROR_LOG(rc);
return rc;
}
/* if there are values, unpack them to the value array */
if (0 < data[i]->cnt) {
if (ORTE_SUCCESS != (rc = orte_pointer_array_set_size(data[i]->values, data[i]->cnt))) {
@ -479,8 +494,15 @@ int orte_gpr_base_unpack_notify_msg(orte_buffer_t *buffer, void *dest,
return ORTE_ERR_OUT_OF_RESOURCE;
}
/* unpack the message type */
if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, &(msg[i]->msg_type),
&max_n, ORTE_GPR_NOTIFY_MSG_TYPE))) {
ORTE_ERROR_LOG(rc);
return rc;
}
/* unpack the trigger name */
if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, &(msg[i]->name),
if (ORTE_SUCCESS != (rc = orte_dps_unpack_buffer(buffer, &(msg[i]->target),
&max_n, ORTE_STRING))) {
ORTE_ERROR_LOG(rc);
return rc;
@ -506,7 +528,7 @@ int orte_gpr_base_unpack_notify_msg(orte_buffer_t *buffer, void *dest,
ORTE_ERROR_LOG(rc);
return rc;
}
/* if there are datagrams, unpack them to the data array */
if (0 < msg[i]->cnt) {
if (ORTE_SUCCESS != (rc = orte_pointer_array_set_size(msg[i]->data, msg[i]->cnt))) {

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

@ -3,14 +3,14 @@
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
*
* Additional copyrights may follow
*
*
* $HEADER$
*/
@ -60,7 +60,7 @@ static void orte_gpr_keyval_construct(orte_gpr_keyval_t* keyval)
static void orte_gpr_keyval_destructor(orte_gpr_keyval_t* keyval)
{
orte_byte_object_t *byteptr;
if (NULL != keyval->key) {
free(keyval->key);
}
@ -106,15 +106,15 @@ static void orte_gpr_value_destructor(orte_gpr_value_t* reg_val)
size_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++) {
if (NULL != reg_val->keyvals[i])
OBJ_RELEASE(reg_val->keyvals[i]);
}
free(reg_val->keyvals);
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++) {
@ -127,17 +127,17 @@ static void orte_gpr_value_destructor(orte_gpr_value_t* reg_val)
/* define instance of opal_class_t */
OBJ_CLASS_INSTANCE(
orte_gpr_value_t, /* type name */
opal_object_t, /* parent "class" name */
orte_gpr_value_construct, /* constructor */
orte_gpr_value_destructor); /* destructor */
orte_gpr_value_t, /* type name */
opal_object_t, /* parent "class" name */
orte_gpr_value_construct, /* constructor */
orte_gpr_value_destructor); /* destructor */
/** NOTIFY DATA **/
/* constructor - used to initialize state of registry value instance */
static void orte_gpr_notify_data_construct(orte_gpr_notify_data_t* ptr)
{
ptr->name = NULL;
ptr->target = NULL;
ptr->id = ORTE_GPR_SUBSCRIPTION_ID_MAX;
ptr->remove = false;
ptr->cnt = 0;
@ -153,8 +153,8 @@ static void orte_gpr_notify_data_destructor(orte_gpr_notify_data_t* ptr)
size_t i, j;
orte_gpr_value_t **values;
if (NULL != ptr->name) free(ptr->name);
if (NULL != ptr->target) free(ptr->target);
if (NULL != ptr->values) {
values = (orte_gpr_value_t**)(ptr->values)->addr;
for (i=0, j=0; j < ptr->cnt &&
@ -195,7 +195,7 @@ static void orte_gpr_subscription_destructor(orte_gpr_subscription_t* sub)
size_t i;
if (NULL != sub->name) free(sub->name);
if (0 < sub->cnt && NULL != sub->values) {
for (i=0; i < sub->cnt; i++) {
OBJ_RELEASE(sub->values[i]);
@ -236,7 +236,7 @@ static void orte_gpr_trigger_destructor(orte_gpr_trigger_t* trig)
for (i=0; i < trig->cnt; i++) OBJ_RELEASE(trig->values[i]);
free(trig->values);
}
}
/* define instance of opal_class_t */
@ -251,7 +251,8 @@ OBJ_CLASS_INSTANCE(
/* constructor - used to initialize notify message instance */
static void orte_gpr_notify_message_construct(orte_gpr_notify_message_t* msg)
{
msg->name = NULL;
msg->msg_type = 0;
msg->target = NULL;
msg->id = ORTE_GPR_TRIGGER_ID_MAX;
msg->remove = false;
msg->cnt = 0;
@ -265,9 +266,9 @@ static void orte_gpr_notify_message_destructor(orte_gpr_notify_message_t* msg)
{
size_t i, j;
orte_gpr_notify_data_t **data;
if (NULL != msg->name) free(msg->name);
if (NULL != msg->target) free(msg->target);
if (NULL != msg->data) {
data = (orte_gpr_notify_data_t**)(msg->data)->addr;
for (i=0, j=0; j < msg->cnt &&
@ -279,7 +280,7 @@ static void orte_gpr_notify_message_destructor(orte_gpr_notify_message_t* msg)
}
OBJ_RELEASE(msg->data);
}
}
/* define instance of opal_class_t */
@ -312,7 +313,7 @@ int orte_gpr_base_open(void)
orte_data_type_t tmp;
/* Debugging / verbose output */
param = mca_base_param_reg_int_name("gpr_base", "verbose",
"Verbosity level for the gpr framework",
false, false, 0, &value);
@ -326,12 +327,12 @@ int orte_gpr_base_open(void)
ORTE_GPR_ARRAY_MAX_SIZE);
mca_base_param_lookup_int(id, &param);
orte_gpr_array_max_size = (size_t)param;
id = mca_base_param_register_int("gpr", "base", "blocksize", NULL,
ORTE_GPR_ARRAY_BLOCK_SIZE);
mca_base_param_lookup_int(id, &param);
orte_gpr_array_block_size = (size_t)param;
/* register the base data types with the DPS */
tmp = ORTE_GPR_CMD;
if (ORTE_SUCCESS != (rc = orte_dps.register_type(orte_gpr_base_pack_cmd,
@ -340,7 +341,7 @@ int orte_gpr_base_open(void)
ORTE_ERROR_LOG(rc);
return rc;
}
tmp = ORTE_GPR_SUBSCRIPTION_ID;
if (ORTE_SUCCESS != (rc = orte_dps.register_type(orte_gpr_base_pack_subscription_id,
orte_gpr_base_unpack_subscription_id,
@ -373,6 +374,14 @@ int orte_gpr_base_open(void)
return rc;
}
tmp = ORTE_GPR_NOTIFY_MSG_TYPE;
if (ORTE_SUCCESS != (rc = orte_dps.register_type(orte_gpr_base_pack_notify_msg_type,
orte_gpr_base_unpack_notify_msg_type,
"ORTE_GPR_NOTIFY_MSG_TYPE", &tmp))) {
ORTE_ERROR_LOG(rc);
return rc;
}
tmp = ORTE_GPR_ADDR_MODE;
if (ORTE_SUCCESS != (rc = orte_dps.register_type(orte_gpr_base_pack_addr_mode,
orte_gpr_base_unpack_addr_mode,
@ -431,15 +440,15 @@ int orte_gpr_base_open(void)
/* Open up all available components */
if (OMPI_SUCCESS !=
mca_base_components_open("gpr",
if (OMPI_SUCCESS !=
mca_base_components_open("gpr",
orte_gpr_base_output,
mca_gpr_base_static_components,
mca_gpr_base_static_components,
&orte_gpr_base_components_available, true)) {
return ORTE_ERROR;
}
/* All done */
return ORTE_SUCCESS;
}

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

@ -4,17 +4,17 @@
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
*
* Additional copyrights may follow
*
*
* $HEADER$
*/
/** @file
/** @file
*
*/
@ -54,16 +54,17 @@ int orte_gpr_base_subscribe_1(orte_gpr_subscription_id_t *id,
NULL, 0, 0, 0, NULL, 0, NULL };
size_t i;
int rc;
/* assemble the subscription object */
subs = &sub;
sub.name = sub_name;
sub.action = action;
sub.cnt = 1;
values = &value;
sub.values = &values;
sub.cbfunc = cbfunc;
sub.user_tag = user_tag;
value.addr_mode = addr_mode;
value.segment = segment;
value.cnt = 1;
@ -87,21 +88,21 @@ int orte_gpr_base_subscribe_1(orte_gpr_subscription_id_t *id,
if (ORTE_SUCCESS != (rc = orte_gpr.subscribe(1, &subs, 0, NULL))) {
ORTE_ERROR_LOG(rc);
}
} else {
trigs = &trig;
trig.name = trig_name;
if (ORTE_SUCCESS != (rc = orte_gpr.subscribe(1, &subs, 1, &trigs))) {
ORTE_ERROR_LOG(rc);
}
}
/* no memory to cleanup since we didn't allocate anything */
/* return the subscription id */
*id = sub.id;
return rc;
}
@ -130,7 +131,7 @@ int orte_gpr_base_subscribe_N(orte_gpr_subscription_id_t *id,
NULL, 0, 0, 0, NULL, 0, NULL };
size_t i, j;
int rc;
/* assemble the subscription object */
subs = &sub;
sub.name = sub_name;
@ -140,7 +141,7 @@ int orte_gpr_base_subscribe_N(orte_gpr_subscription_id_t *id,
sub.values = &values;
sub.cbfunc = cbfunc;
sub.user_tag = user_tag;
value.addr_mode = addr_mode;
value.segment = segment;
value.cnt = n;
@ -176,16 +177,16 @@ int orte_gpr_base_subscribe_N(orte_gpr_subscription_id_t *id,
if (ORTE_SUCCESS != (rc = orte_gpr.subscribe(1, &subs, 0, NULL))) {
ORTE_ERROR_LOG(rc);
}
} else {
trigs = &trig;
trig.name = trig_name;
if (ORTE_SUCCESS != (rc = orte_gpr.subscribe(1, &subs, 1, &trigs))) {
ORTE_ERROR_LOG(rc);
}
}
/* clean up memory - very carefully!
* We can't use the object destructors because we didn't
* copy input data fields into the objects. Thus, only
@ -196,7 +197,7 @@ int orte_gpr_base_subscribe_N(orte_gpr_subscription_id_t *id,
/* return the subscription id */
*id = sub.id;
return rc;
}
@ -221,7 +222,17 @@ int orte_gpr_base_define_trigger(orte_gpr_trigger_id_t *id,
NULL, 0, 0, 0, NULL, 0, NULL };
size_t i, j;
int rc;
/* check for error - this function can only be used to define triggers
* that compare their values to each other. It cannot be used to define
* triggers that fire when reaching a specified value as there is no
* way to specify a trigger level within this API
*/
if (ORTE_GPR_TRIG_AT_LEVEL & action) {
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
return ORTE_ERR_BAD_PARAM;
}
/* assemble the trigger object */
trigs = &trig;
trig.name = trig_name;
@ -231,7 +242,7 @@ int orte_gpr_base_define_trigger(orte_gpr_trigger_id_t *id,
trig.values = &values;
trig.cbfunc = cbfunc;
trig.user_tag = user_tag;
value.addr_mode = addr_mode;
value.segment = segment;
value.cnt = n;
@ -266,7 +277,7 @@ int orte_gpr_base_define_trigger(orte_gpr_trigger_id_t *id,
if (ORTE_SUCCESS != (rc = orte_gpr.subscribe(0, NULL, 1, &trigs))) {
ORTE_ERROR_LOG(rc);
}
/* clean up memory - very carefully!
* We can't use the object destructors because we didn't
* copy input data fields into the objects. Thus, only
@ -277,7 +288,99 @@ int orte_gpr_base_define_trigger(orte_gpr_trigger_id_t *id,
/* return the subscription id */
*id = trig.id;
return rc;
}
int orte_gpr_base_define_trigger_level(orte_gpr_trigger_id_t *id,
char *trig_name,
orte_gpr_trigger_action_t action,
orte_gpr_addr_mode_t addr_mode,
char *segment,
char **tokens,
size_t n,
char **keys,
size_t *levels,
orte_gpr_trigger_cb_fn_t cbfunc,
void *user_tag)
{
orte_gpr_value_t *values;
orte_gpr_value_t value = { {OBJ_CLASS(opal_object_t),0},
ORTE_GPR_TOKENS_AND,
NULL, 0, NULL, 0, NULL };
orte_gpr_trigger_t *trigs;
orte_gpr_trigger_t trig = { {OBJ_CLASS(opal_object_t),0},
NULL, 0, 0, 0, NULL, 0, NULL };
size_t i, j;
int rc;
/* check for error - this function can only be used to define triggers
* that fire at a specified level. It cannot be used to define
* triggers that compare their values to each other
*/
if (ORTE_GPR_TRIG_CMP_LEVELS & action) {
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
return ORTE_ERR_BAD_PARAM;
}
/* assemble the trigger object */
trigs = &trig;
trig.name = trig_name;
trig.action = action;
trig.cnt = 1;
values = &value;
trig.values = &values;
trig.cbfunc = cbfunc;
trig.user_tag = user_tag;
value.addr_mode = addr_mode;
value.segment = segment;
value.cnt = n;
value.keyvals = (orte_gpr_keyval_t**)malloc(n * sizeof(orte_gpr_keyval_t*));
if (NULL == value.keyvals) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
for (i=0; i < n; i++) {
value.keyvals[i] = OBJ_NEW(orte_gpr_keyval_t);
if (NULL == value.keyvals[i]) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
for (j=0; j < i; j++) OBJ_RELEASE(value.keyvals[j]);
free(value.keyvals);
return ORTE_ERR_OUT_OF_RESOURCE;
}
value.keyvals[i]->key = keys[i];
value.keyvals[i]->type = ORTE_SIZE;
value.keyvals[i]->value.intval = levels[i];
}
value.tokens = tokens;
/* must count the number of tokens */
if (NULL == tokens) {
value.num_tokens = 0;
} else {
for (i=0; NULL != tokens[i]; i++) {
(value.num_tokens)++;
}
}
/* send the subscription */
if (ORTE_SUCCESS != (rc = orte_gpr.subscribe(0, NULL, 1, &trigs))) {
ORTE_ERROR_LOG(rc);
}
/* clean up memory - very carefully!
* We can't use the object destructors because we didn't
* copy input data fields into the objects. Thus, only
* release the data that we explicitly allocated
*/
for (i=0; i < n; i++) free(value.keyvals[i]);
free(value.keyvals);
/* return the subscription id */
*id = trig.id;
return rc;
}

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

@ -3,14 +3,14 @@
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
*
* Additional copyrights may follow
*
*
* $HEADER$
*/
@ -41,31 +41,35 @@ int orte_gpr_base_xfer_payload(orte_gpr_value_union_t *dest,
return ORTE_ERR_OUT_OF_RESOURCE;
}
break;
case ORTE_SIZE:
dest->size = src->size;
break;
case ORTE_BOOL:
dest->tf_flag = src->tf_flag;
break;
case ORTE_PID:
dest->pid = src->pid;
break;
case ORTE_INT:
dest->intval = src->intval;
break;
case ORTE_UINT8:
dest->ui8 = src->ui8;
break;
case ORTE_UINT16:
dest->ui16 = src->ui16;
break;
case ORTE_UINT32:
dest->ui32 = src->ui32;
break;
#ifdef HAVE_INT64_T
case ORTE_UINT64:
dest->ui64 = src->ui64;
@ -75,15 +79,15 @@ int orte_gpr_base_xfer_payload(orte_gpr_value_union_t *dest,
case ORTE_INT8:
dest->i8 = src->i8;
break;
case ORTE_INT16:
dest->i16 = src->i16;
break;
case ORTE_INT32:
dest->i32 = src->i32;
break;
#ifdef HAVE_INT64_T
case ORTE_INT64:
dest->i64 = src->i64;
@ -103,35 +107,35 @@ int orte_gpr_base_xfer_payload(orte_gpr_value_union_t *dest,
case ORTE_NAME:
dest->proc = src->proc;;
break;
case ORTE_VPID:
dest->vpid = src->vpid;
break;
case ORTE_JOBID:
dest->jobid = src->jobid;
break;
case ORTE_CELLID:
dest->cellid = src->cellid;
break;
case ORTE_NODE_STATE:
dest->node_state = src->node_state;
break;
case ORTE_PROC_STATE:
dest->proc_state = src->proc_state;
break;
case ORTE_JOB_STATE:
dest->job_state = src->job_state;
break;
case ORTE_EXIT_CODE:
dest->exit_code = src->exit_code;
break;
case ORTE_APP_CONTEXT:
if(NULL == src->app_context) {
dest->app_context = NULL;
@ -158,7 +162,7 @@ int orte_gpr_base_xfer_payload(orte_gpr_value_union_t *dest,
if (NULL != src->app_context->map_data) {
dest->app_context->map_data = (orte_app_context_map_t **) malloc(sizeof(orte_app_context_map_t *) * src->app_context->num_map);
for (i = 0; i < src->app_context->num_map; ++i) {
dest->app_context->map_data[i] =
dest->app_context->map_data[i] =
OBJ_NEW(orte_app_context_map_t);
dest->app_context->map_data[i]->map_type =
src->app_context->map_data[i]->map_type;
@ -172,7 +176,7 @@ int orte_gpr_base_xfer_payload(orte_gpr_value_union_t *dest,
case ORTE_NULL:
break;
default:
return ORTE_ERR_BAD_PARAM;
break;

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

@ -60,22 +60,92 @@ int orte_gpr_base_pack_dump_segments(orte_buffer_t *cmd, char *segment)
return ORTE_SUCCESS;
}
int orte_gpr_base_pack_dump_triggers(orte_buffer_t *cmd)
int orte_gpr_base_pack_dump_triggers(orte_buffer_t *cmd, orte_gpr_trigger_id_t start)
{
orte_gpr_cmd_flag_t command;
int rc;
command = ORTE_GPR_DUMP_TRIGGERS_CMD;
return orte_dps.pack(cmd, &command, 1, ORTE_GPR_CMD);
if (ORTE_SUCCESS != (rc = orte_dps.pack(cmd, &command, 1, ORTE_GPR_CMD))) {
ORTE_ERROR_LOG(rc);
return rc;
}
if (ORTE_SUCCESS != (rc = orte_dps.pack(cmd, &start, 1, ORTE_GPR_TRIGGER_ID))) {
ORTE_ERROR_LOG(rc);
return rc;
}
return ORTE_SUCCESS;
}
int orte_gpr_base_pack_dump_subscriptions(orte_buffer_t *cmd)
int orte_gpr_base_pack_dump_subscriptions(orte_buffer_t *cmd, orte_gpr_subscription_id_t start)
{
orte_gpr_cmd_flag_t command;
int rc;
command = ORTE_GPR_DUMP_SUBSCRIPTIONS_CMD;
return orte_dps.pack(cmd, &command, 1, ORTE_GPR_CMD);
if (ORTE_SUCCESS != (rc = orte_dps.pack(cmd, &command, 1, ORTE_GPR_CMD))) {
ORTE_ERROR_LOG(rc);
return rc;
}
if (ORTE_SUCCESS != (rc = orte_dps.pack(cmd, &start, 1, ORTE_GPR_SUBSCRIPTION_ID))) {
ORTE_ERROR_LOG(rc);
return rc;
}
return ORTE_SUCCESS;
}
int orte_gpr_base_pack_dump_a_trigger(orte_buffer_t *cmd, char *name, orte_gpr_trigger_id_t id)
{
orte_gpr_cmd_flag_t command;
int rc;
command = ORTE_GPR_DUMP_A_TRIGGER_CMD;
if (ORTE_SUCCESS != (rc = orte_dps.pack(cmd, &command, 1, ORTE_GPR_CMD))) {
ORTE_ERROR_LOG(rc);
return rc;
}
if (ORTE_SUCCESS != (rc = orte_dps.pack(cmd, &name, 1, ORTE_STRING))) {
ORTE_ERROR_LOG(rc);
return rc;
}
if (ORTE_SUCCESS != (rc = orte_dps.pack(cmd, &id, 1, ORTE_GPR_TRIGGER_ID))) {
ORTE_ERROR_LOG(rc);
return rc;
}
return ORTE_SUCCESS;
}
int orte_gpr_base_pack_dump_a_subscription(orte_buffer_t *cmd, char *name,
orte_gpr_subscription_id_t id)
{
orte_gpr_cmd_flag_t command;
int rc;
command = ORTE_GPR_DUMP_A_SUBSCRIPTION_CMD;
if (ORTE_SUCCESS != (rc = orte_dps.pack(cmd, &command, 1, ORTE_GPR_CMD))) {
ORTE_ERROR_LOG(rc);
return rc;
}
if (ORTE_SUCCESS != (rc = orte_dps.pack(cmd, &name, 1, ORTE_STRING))) {
ORTE_ERROR_LOG(rc);
return rc;
}
if (ORTE_SUCCESS != (rc = orte_dps.pack(cmd, &id, 1, ORTE_GPR_SUBSCRIPTION_ID))) {
ORTE_ERROR_LOG(rc);
return rc;
}
return ORTE_SUCCESS;
}
int orte_gpr_base_pack_dump_callbacks(orte_buffer_t *cmd)

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

@ -3,14 +3,14 @@
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
*
* Additional copyrights may follow
*
*
* $HEADER$
*/
/** @file:
@ -33,7 +33,7 @@
#include "mca/gpr/base/base.h"
int orte_gpr_base_pack_subscribe(orte_buffer_t *cmd,
size_t num_subs,
size_t num_subs,
orte_gpr_subscription_t **subscriptions,
size_t num_trigs,
orte_gpr_trigger_t **trigs)
@ -49,17 +49,17 @@ int orte_gpr_base_pack_subscribe(orte_buffer_t *cmd,
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
return ORTE_ERR_BAD_PARAM;
}
if (ORTE_SUCCESS != (rc = orte_dps.pack(cmd, &command, 1, ORTE_GPR_CMD))) {
ORTE_ERROR_LOG(rc);
return rc;
return rc;
}
/* see if there are subscriptions - if so, pack them */
if (NULL != subscriptions) {
if (ORTE_SUCCESS != (rc = orte_dps.pack(cmd, subscriptions, num_subs, ORTE_GPR_SUBSCRIPTION))) {
ORTE_ERROR_LOG(rc);
return rc;
return rc;
}
} else {
if (ORTE_SUCCESS != (rc = orte_dps.pack(cmd, &zero, 1, ORTE_SIZE))) {
@ -89,7 +89,7 @@ int orte_gpr_base_pack_subscribe(orte_buffer_t *cmd,
int orte_gpr_base_pack_unsubscribe(orte_buffer_t *cmd,
orte_gpr_subscription_id_t id)
orte_gpr_subscription_id_t id)
{
orte_gpr_cmd_flag_t command;
int rc;
@ -97,11 +97,11 @@ int orte_gpr_base_pack_unsubscribe(orte_buffer_t *cmd,
command = ORTE_GPR_UNSUBSCRIBE_CMD;
if (ORTE_SUCCESS != (rc = orte_dps.pack(cmd, &command, 1, ORTE_GPR_CMD))) {
return rc;
return rc;
}
if (ORTE_SUCCESS != (rc = orte_dps.pack(cmd, &id, 1, ORTE_GPR_SUBSCRIPTION_ID))) {
return rc;
return rc;
}
return ORTE_SUCCESS;

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

@ -3,14 +3,14 @@
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
*
* Additional copyrights may follow
*
*
* $HEADER$
*/
/** @file:
@ -42,7 +42,7 @@ int orte_gpr_base_dump_notify_msg(orte_buffer_t *buffer,
char *tmp_out;
orte_gpr_notify_data_t **data;
size_t i, j;
asprintf(&tmp_out, "\nDUMP OF NOTIFY MESSAGE STRUCTURE");
orte_gpr_base_dump_load_string(buffer, &tmp_out);
@ -51,27 +51,34 @@ int orte_gpr_base_dump_notify_msg(orte_buffer_t *buffer,
orte_gpr_base_dump_load_string(buffer, &tmp_out);
return ORTE_SUCCESS;
}
if (NULL == msg->name) {
asprintf(&tmp_out, "\tTrigger name: NULL");
} else {
asprintf(&tmp_out, "\tTrigger name: %s", msg->name);
if (ORTE_GPR_TRIGGER_MSG == msg->msg_type) {
asprintf(&tmp_out, "TRIGGER message");
} else if (ORTE_GPR_SUBSCRIPTION_MSG == msg->msg_type) {
asprintf(&tmp_out, "SUBSCRIPTION message");
}
orte_gpr_base_dump_load_string(buffer, &tmp_out);
if (NULL == msg->target) {
asprintf(&tmp_out, "\tTrigger target: NULL");
} else {
asprintf(&tmp_out, "\tTrigger target: %s", msg->target);
}
orte_gpr_base_dump_load_string(buffer, &tmp_out);
asprintf(&tmp_out, "\tTrigger id: %ld", (long)msg->id);
orte_gpr_base_dump_load_string(buffer, &tmp_out);
asprintf(&tmp_out, "\t%lu Notify data structures in message",
(unsigned long) msg->cnt);
orte_gpr_base_dump_load_string(buffer, &tmp_out);
if (0 < msg->cnt) {
data = (orte_gpr_notify_data_t**)(msg->data)->addr;
for (i=0, j=0; j < msg->cnt &&
i < (msg->data)->size; i++) {
if (NULL != data[i]) {
asprintf(&tmp_out, "\nDump of notify data structure number %lu",
asprintf(&tmp_out, "\nDump of notify data structure number %lu",
(unsigned long) j);
orte_gpr_base_dump_load_string(buffer, &tmp_out);
orte_gpr_base_dump_data(buffer, data[i]);
@ -96,7 +103,7 @@ int orte_gpr_base_dump_notify_data(orte_buffer_t *buffer,
orte_gpr_base_dump_load_string(buffer, &tmp_out);
return ORTE_SUCCESS;
}
orte_gpr_base_dump_data(buffer, data);
return ORTE_SUCCESS;
}
@ -108,15 +115,15 @@ static void orte_gpr_base_dump_data(orte_buffer_t *buffer,
orte_gpr_value_t **values;
size_t i, j;
if (NULL != data->name) {
asprintf(&tmp_out, "%lu values going to subscription name %s",
(unsigned long) data->cnt, data->name);
if (NULL != data->target) {
asprintf(&tmp_out, "%lu values going to subscription target %s",
(unsigned long) data->cnt, data->target);
} else {
asprintf(&tmp_out, "%lu values going to subscription num %lu",
asprintf(&tmp_out, "%lu values going to subscription num %lu",
(unsigned long) data->cnt, (unsigned long) data->id);
}
orte_gpr_base_dump_load_string(buffer, &tmp_out);
values = (orte_gpr_value_t**)(data->values)->addr;
if (0 < data->cnt) {
for (i=0, j=0; j < data->cnt &&
@ -145,13 +152,13 @@ int orte_gpr_base_dump_value(orte_buffer_t *buffer, orte_gpr_value_t *value)
value->segment, (unsigned long) value->cnt);
}
orte_gpr_base_dump_load_string(buffer, &tmp_out);
addr = value->addr_mode;
if (NULL == value->tokens) {
asprintf(&tmp_out, "\tNULL tokens (wildcard)");
orte_gpr_base_dump_load_string(buffer, &tmp_out);
} else {
asprintf(&tmp_out, "\t%lu Tokens returned",
asprintf(&tmp_out, "\t%lu Tokens returned",
(unsigned long) value->num_tokens);
orte_gpr_base_dump_load_string(buffer, &tmp_out);
for (j=0; j < value->num_tokens; j++) {
@ -159,7 +166,7 @@ int orte_gpr_base_dump_value(orte_buffer_t *buffer, orte_gpr_value_t *value)
asprintf(&tmp_out, "\tToken %lu: NULL token pointer",
(unsigned long) j);
} else {
asprintf(&tmp_out, "\tToken %lu: %s", (unsigned long) j,
asprintf(&tmp_out, "\tToken %lu: %s", (unsigned long) j,
value->tokens[j]);
}
orte_gpr_base_dump_load_string(buffer, &tmp_out);
@ -214,19 +221,19 @@ int orte_gpr_base_dump_value(orte_buffer_t *buffer, orte_gpr_value_t *value)
asprintf(&tmp_out, "\t\tORTE_GPR_KEYS_NOT");
orte_gpr_base_dump_load_string(buffer, &tmp_out);
}
for (j=0; j < value->cnt; j++) {
if (NULL == (value->keyvals[j])->key) {
asprintf(&tmp_out, "\t\tData for keyval %lu: NULL key",
asprintf(&tmp_out, "\t\tData for keyval %lu: NULL key",
(unsigned long) j);
} else {
asprintf(&tmp_out, "\t\tData for keyval %lu: Key: %s",
asprintf(&tmp_out, "\t\tData for keyval %lu: Key: %s",
(unsigned long) j, (value->keyvals[j])->key);
}
orte_gpr_base_dump_load_string(buffer, &tmp_out);
orte_gpr_base_dump_keyval_value(buffer, value->keyvals[j]);
}
return ORTE_SUCCESS;
}
@ -234,55 +241,55 @@ int orte_gpr_base_dump_value(orte_buffer_t *buffer, orte_gpr_value_t *value)
void orte_gpr_base_dump_keyval_value(orte_buffer_t *buffer, orte_gpr_keyval_t *iptr)
{
char *tmp_out;
switch(iptr->type) {
case ORTE_BYTE:
asprintf(&tmp_out, "\t\t\tData type: ORTE_BYTE: no value field");
orte_gpr_base_dump_load_string(buffer, &tmp_out);
break;
case ORTE_BOOL:
asprintf(&tmp_out, "\t\t\tData type: ORTE_BOOL: no value field");
orte_gpr_base_dump_load_string(buffer, &tmp_out);
break;
case ORTE_STRING:
asprintf(&tmp_out, "\t\t\tData type: ORTE_STRING\tValue: %s", iptr->value.strptr);
orte_gpr_base_dump_load_string(buffer, &tmp_out);
break;
case ORTE_SIZE:
asprintf(&tmp_out, "\t\t\tData type: ORTE_SIZE:\tValue: %lu",
(unsigned long) iptr->value.size);
orte_gpr_base_dump_load_string(buffer, &tmp_out);
break;
case ORTE_PID:
asprintf(&tmp_out, "\t\t\tData type: ORTE_PID:\tValue: " ORTE_PID_T_PRINTF, iptr->value.pid);
asprintf(&tmp_out, "\t\t\tData type: ORTE_PID:\tValue: %lu", (unsigned long)iptr->value.pid);
orte_gpr_base_dump_load_string(buffer, &tmp_out);
break;
case ORTE_INT:
asprintf(&tmp_out, "\t\t\tData type: ORTE_INT: no value field");
orte_gpr_base_dump_load_string(buffer, &tmp_out);
break;
case ORTE_UINT8:
asprintf(&tmp_out, "\t\t\tData type: ORTE_UINT8\tValue: %d", (int)iptr->value.ui8);
orte_gpr_base_dump_load_string(buffer, &tmp_out);
break;
case ORTE_UINT16:
asprintf(&tmp_out, "\t\t\tData type: ORTE_UINT16\tValue: %d", (int)iptr->value.ui16);
orte_gpr_base_dump_load_string(buffer, &tmp_out);
break;
case ORTE_UINT32:
asprintf(&tmp_out, "\t\t\tData type: ORTE_UINT32\tValue: %d", (int)iptr->value.ui32);
orte_gpr_base_dump_load_string(buffer, &tmp_out);
break;
#ifdef HAVE_INT64_T
case ORTE_UINT64:
asprintf(&tmp_out, "\t\t\tData type: ORTE_UINT64\tValue: %d", (int)iptr->value.ui64);
@ -294,17 +301,17 @@ void orte_gpr_base_dump_keyval_value(orte_buffer_t *buffer, orte_gpr_keyval_t *i
asprintf(&tmp_out, "\t\t\tData type: ORTE_INT8\tValue: %d", (int)iptr->value.i8);
orte_gpr_base_dump_load_string(buffer, &tmp_out);
break;
case ORTE_INT16:
asprintf(&tmp_out, "\t\t\tData type: ORTE_INT16\tValue: %d", (int)iptr->value.i16);
orte_gpr_base_dump_load_string(buffer, &tmp_out);
break;
case ORTE_INT32:
asprintf(&tmp_out, "\t\t\tData type: ORTE_INT32\tValue: %d", (int)iptr->value.i32);
orte_gpr_base_dump_load_string(buffer, &tmp_out);
break;
#ifdef HAVE_INT64_T
case ORTE_INT64:
asprintf(&tmp_out, "\t\t\tData type: ORTE_INT64\tValue: %d", (int)iptr->value.i64);
@ -317,56 +324,56 @@ void orte_gpr_base_dump_keyval_value(orte_buffer_t *buffer, orte_gpr_keyval_t *i
(unsigned long) (iptr->value.byteobject).size);
orte_gpr_base_dump_load_string(buffer, &tmp_out);
break;
case ORTE_NAME:
asprintf(&tmp_out, "\t\t\tData type: ORTE_NAME\tValue: [%lu,%lu,%lu]",
ORTE_NAME_ARGS(&(iptr->value.proc)));
orte_gpr_base_dump_load_string(buffer, &tmp_out);
break;
case ORTE_VPID:
asprintf(&tmp_out, "\t\t\tData type: ORTE_VPID\tValue: %lu",
(unsigned long) iptr->value.vpid);
orte_gpr_base_dump_load_string(buffer, &tmp_out);
break;
case ORTE_JOBID:
asprintf(&tmp_out, "\t\t\tData type: ORTE_JOBID\tValue: %lu",
(unsigned long) iptr->value.jobid);
orte_gpr_base_dump_load_string(buffer, &tmp_out);
break;
case ORTE_CELLID:
asprintf(&tmp_out, "\t\t\tData type: ORTE_CELLID\tValue: %lu",
(unsigned long) iptr->value.cellid);
orte_gpr_base_dump_load_string(buffer, &tmp_out);
break;
case ORTE_NODE_STATE:
asprintf(&tmp_out, "\t\t\tData type: ORTE_NODE_STATE\tValue: %d", (int)iptr->value.node_state);
orte_gpr_base_dump_load_string(buffer, &tmp_out);
break;
case ORTE_PROC_STATE:
asprintf(&tmp_out, "\t\t\tData type: ORTE_PROC_STATE\tValue: %d", (int)iptr->value.proc_state);
orte_gpr_base_dump_load_string(buffer, &tmp_out);
break;
case ORTE_EXIT_CODE:
asprintf(&tmp_out, "\t\t\tData type: ORTE_EXIT_CODE\tValue: %d", (int)iptr->value.exit_code);
orte_gpr_base_dump_load_string(buffer, &tmp_out);
break;
case ORTE_NULL:
asprintf(&tmp_out, "\t\t\tData type: ORTE_NULL");
orte_gpr_base_dump_load_string(buffer, &tmp_out);
break;
case ORTE_APP_CONTEXT:
asprintf(&tmp_out, "\t\t\tData type: ORTE_APP_CONTEXT");
orte_gpr_base_dump_load_string(buffer, &tmp_out);
break;
default:
asprintf(&tmp_out, "\t\t\tData type: UNKNOWN");
orte_gpr_base_dump_load_string(buffer, &tmp_out);

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

@ -4,24 +4,24 @@
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
*
* Additional copyrights may follow
*
*
* $HEADER$
*/
/** @file
/** @file
* @page gpr_api
*/
/**
/**
* \brief General Purpose Registry (GPR) API
*
* The Open MPI General Purpose Registry (GPR)
* The Open MPI General Purpose Registry (GPR)
*/
#ifndef ORTE_GPR_H_
@ -130,7 +130,7 @@ typedef int (*orte_gpr_base_module_exec_compound_cmd_fn_t)(void);
*
* @retval ORTE_SUCCESS Operation was successfully completed.
* @retval ORTE_ERROR(s) Operation failed, returning the provided error code.
*
*
* @code
* status_code = orte_gpr.cleanup_job(jobid);
* @endcode
@ -147,7 +147,7 @@ typedef int (*orte_gpr_base_module_cleanup_job_fn_t)(orte_jobid_t jobid);
*
* @retval ORTE_SUCCESS Operation was successfully completed.
* @retval ORTE_ERROR(s) Operation failed, returning the provided error code.
*
*
* @code
* status_code = orte_gpr.cleanup_process(&proc);
* @endcode
@ -162,15 +162,15 @@ typedef int (*orte_gpr_base_module_cleanup_proc_fn_t)(orte_process_name_t *proc)
* "on-the-fly", it is more efficient to initialize the segment via a separate
* command - thus allowing the registry to allocate the base storage for all
* the processes in a single malloc.
*
*
* @param name A character string indicating the name of the segment.
* @param num_slots The number of containers expected in this segment. This
* is just the starting number requested by the user - the registry will
* dynamically expand the segment as required.
*
*
* @retval ORTE_SUCCESS The operation was successfully executed.
* @retval ORTE_ERROR(s) An appropriate error code is returned.
*
*
* @code
* status_code = orte_gpr.preallocate_segment("MY_SEGMENT", num_slots);
* @endcode
@ -207,7 +207,7 @@ typedef int (*orte_gpr_base_module_delete_segment_nb_fn_t)(char *segment,
* Put a data object on the registry (BLOCKING)
* Place a data item on the registry using a blocking operation - i.e., the calling
* program will be blocked until the operation completes.
*
*
* Each value contains the addressing mode to be used. Addresses are defined by the tokens provided
* that describe the object being stored. The caller has the option of specifying how
* those tokens are to be combined in describing the object. Passing a value of
@ -225,7 +225,7 @@ typedef int (*orte_gpr_base_module_delete_segment_nb_fn_t)(char *segment,
* specified segment are checked and appropriately processed.
*
* @param cnt The number of value structures to be stored.
*
*
* @param **values A pointer to the start of a contiguous array of one or more
* pointers to orte_gpr_value_t
* objects to be stored. The registry will copy this data onto the specified segment - the
@ -240,7 +240,7 @@ typedef int (*orte_gpr_base_module_delete_segment_nb_fn_t)(char *segment,
*
* @code
* orte_gpr_value_t *value;
*
*
* status_code = orte_gpr.put(1, &value);
* @endcode
*/
@ -290,7 +290,7 @@ typedef int (*orte_gpr_base_module_put_nb_fn_t)(size_t cnt, orte_gpr_value_t **v
* @param **keys (IN) A NULL-terminated **char array of keys describing the specific
* key-value data to be returned. A value of NULL indicates that ALL key-value pairs
* described by the segment/token combination are to be returned.
*
*
* @param *cnt (OUT) A pointer to the number of objects returned by the request.
* @param ***values (OUT) A pointer to an array of orte_gpr_value_t object pointers
* containing the data
@ -299,12 +299,12 @@ typedef int (*orte_gpr_base_module_put_nb_fn_t)(size_t cnt, orte_gpr_value_t **v
*
* @retval ORTE_SUCCESS Operation was successfully completed.
* @retval ORTE_ERROR(s) Operation failed, returning the provided error code.
*
*
* @code
* opal_list_t *keyval_list;
* size_t cnt;
* orte_gpr_value_t **values;
*
*
* status_code = orte_gpr.get(addr_mode, segment, tokens, keyval_list,
* &cnt, &values);
* @endcode
@ -335,7 +335,7 @@ typedef int (*orte_gpr_base_module_get_nb_fn_t)(orte_gpr_addr_mode_t addr_mode,
* and that ONLY those tokens be present.
*
* Note: A value of NULL for the tokens will delete ALL data items from the specified
* segment.
* segment.
*
* @param addr_mode The addressing mode to be used in the search.
* @param *segment A character string indicating the name of the segment to be searched.
@ -344,13 +344,13 @@ typedef int (*orte_gpr_base_module_get_nb_fn_t)(orte_gpr_addr_mode_t addr_mode,
*
* @retval ORTE_SUCCESS Operation was successfully completed.
* @retval ORTE_ERROR(s) Operation failed, returning the provided error code.
*
*
* @code
* status_code = orte_gpr.delete_object(mode, segment, tokens);
* @endcode
*/
typedef int (*orte_gpr_base_module_delete_entries_fn_t)(orte_gpr_addr_mode_t addr_mode,
char *segment, char **tokens, char **keys);
char *segment, char **tokens, char **keys);
/*
* Delete an object from the registry (NON-BLOCKING)
@ -378,12 +378,12 @@ typedef int (*orte_gpr_base_module_delete_entries_nb_fn_t)(
*
* @retval ORTE_SUCCESS Operation was successfully completed.
* @retval ORTE_ERROR(s) Operation failed, returning the provided error code.
*
*
* @code
* int32_t cnt;
* char *index;
* char *segment;
*
*
* status_code = orte_gpr.index(segment, &cnt, &index);
* @endcode
*/
@ -396,18 +396,18 @@ typedef int (*orte_gpr_base_module_index_fn_t)(char *segment, size_t *cnt, char
*/
typedef int (*orte_gpr_base_module_index_nb_fn_t)(char *segment,
orte_gpr_notify_cb_fn_t cbfunc, void *user_tag);
/*
* Subscribe to be notified upon a specified action
* The registry includes a publish/subscribe mechanism by which callers can be notified
* upon certain actions occuring to data objects stored on the registry. This function
* allows the caller to register for such notifications. The registry allows a subscription
* to be placed upon any segment, and upon the entire registry if desired.
*
*
* Two types of subscriptions are supported:
* (a) notifications - these occur whenever the specified action occurs on the
* identified data entries in the registry.
*
*
* (b) triggers - these occur whenever a count of the number of identified data
* entries reaches the specified level. The caller can specify that the trigger
* maintain its own count - in this case, the trigger will count the number of data
@ -421,33 +421,33 @@ typedef int (*orte_gpr_base_module_index_nb_fn_t)(char *segment,
*
* Note that all addressing mode rules apply to both \em value and \em trig_value,
* including wildcards.
*
*
* @param actions (IN) The actions which are to generate a notification message and/or define
* the trigger operation. These can
* be OR'd together from the defined registry action flags.
*
*
* @param num_subs (IN) The numbr of subscription objects being provided
*
*
* @param **subscriptions (IN) A pointer to an array of subscription objects that
* contain descriptions of the data that is to be returned when a subscription fires.
* For subscribe requests that do NOT include a trigger, this is the data that
* will be monitored per the specified action. All of
* the described values will be returned in a notification message when the specified
* action occurs.
*
*
* @param num_trigs (IN) The number of trigger objects being provided
*
*
* @param **triggers (IN) A pointer to an array of orte_gpr_trigger_t objects that describe the
* conditions (as described above) which will generate a trigger message to be sent
* to the callback function. Trigger messages include all data specified in the
* subscription objects, but do NOT include the trigger counters themselves unless
* so specified with the ORTE_GPR_TRIG_INCLUDE_DATA command.
*
*
* @param *sub_number (OUT) The notify id for the resulting subscription
* is returned in the provided memory location. Callers should save this
* number for later use if (for example) it is desired to remove the
* subscription from the registry
*
*
* @retval ORTE_SUCCESS Operation was successfully completed.
* @retval ORTE_ERROR(s) Operation failed, returning the provided error code.
*
@ -455,7 +455,7 @@ typedef int (*orte_gpr_base_module_index_nb_fn_t)(char *segment,
* orte_gpr_subscription_t *subscription;
* orte_gpr_notify_id_t sub_number;
* orte_gpr_value_t trig_value;
*
*
* status_code = orte_gpr.subscribe(action, 1, &subscription, &trig_value,
* &sub_number);
* @endcode
@ -501,6 +501,18 @@ typedef int (*orte_gpr_base_module_define_trigger_fn_t)(orte_gpr_trigger_id_t *i
orte_gpr_trigger_cb_fn_t cbfunc,
void *user_tag);
typedef int (*orte_gpr_base_module_define_trigger_level_fn_t)(orte_gpr_trigger_id_t *id,
char *trig_name,
orte_gpr_trigger_action_t action,
orte_gpr_addr_mode_t addr_mode,
char *segment,
char **tokens,
size_t n,
char **keys,
size_t *levels,
orte_gpr_trigger_cb_fn_t cbfunc,
void *user_tag);
/*
* Cancel a subscription.
* Once a subscription has been entered on the registry, a caller may choose to permanently
@ -556,9 +568,23 @@ typedef int (*orte_gpr_base_module_dump_all_fn_t)(int output_id);
typedef int (*orte_gpr_base_module_dump_segment_fn_t)(char *segment, int output_id);
typedef int (*orte_gpr_base_module_dump_triggers_fn_t)(int output_id);
typedef int (*orte_gpr_base_module_dump_triggers_fn_t)(
orte_gpr_trigger_id_t tail,
int output_id);
typedef int (*orte_gpr_base_module_dump_subscriptions_fn_t)(int output_id);
typedef int (*orte_gpr_base_module_dump_subscriptions_fn_t)(
orte_gpr_subscription_id_t tail,
int output_id);
typedef int (*orte_gpr_base_module_dump_a_trigger_fn_t)(
char *name,
orte_gpr_trigger_id_t id,
int output_id);
typedef int (*orte_gpr_base_module_dump_a_subscription_fn_t)(
char *name,
orte_gpr_subscription_id_t id,
int output_id);
typedef int (*orte_gpr_base_module_dump_local_triggers_fn_t)(int output_id);
@ -591,17 +617,30 @@ typedef int (*orte_gpr_base_module_decrement_value_fn_t)(orte_gpr_value_t *value
* Because the data type of the value dictates how it must be transferred, it can be
* a burden to transfer the payload. This function centralizes that action so it only
* need be defined once.
*
*
* @param dest The address of the value union where the data is to be placed.
* @param src The address of the value union currently holding the data.
* @param type The type of the data
*
*
* @retval ORTE_SUCCESS Operation successfully completed.
* @retval ORTE_ERROR(s) Operation failed, returning the provided error code.
*/
typedef int (*orte_gpr_base_module_xfer_payload_fn_t)(orte_gpr_value_union_t *dest,
orte_gpr_value_union_t *src, orte_data_type_t type);
/* Deliver a notify message
* To support the broadcast of stage gate messages that supply all subscribed
* data in a single message, we have to provide an API that allows the xcast
* to "inject" the message back into the registry's local delivery system.
*
* @param msg A pointer to the orte_gpr_notify_message_t object to be delivered.
* Note that the calling program is responsible for releasing this object.
*
* @retval None
*/
typedef int (*orte_gpr_base_module_deliver_notify_msg_t)(orte_gpr_notify_message_t *msg);
/*
* Ver 1.0.0
*/
@ -625,6 +664,7 @@ struct orte_gpr_base_module_1_0_0_t {
/* GENERAL OPERATIONS */
orte_gpr_base_module_preallocate_segment_fn_t preallocate_segment;
orte_gpr_base_module_xfer_payload_fn_t xfer_payload;
orte_gpr_base_module_deliver_notify_msg_t deliver_notify_msg;
/* ARITHMETIC OPERATIONS */
orte_gpr_base_module_increment_value_fn_t increment_value;
orte_gpr_base_module_decrement_value_fn_t decrement_value;
@ -633,6 +673,7 @@ struct orte_gpr_base_module_1_0_0_t {
orte_gpr_base_module_subscribe_1_fn_t subscribe_1;
orte_gpr_base_module_subscribe_N_fn_t subscribe_N;
orte_gpr_base_module_define_trigger_fn_t define_trigger;
orte_gpr_base_module_define_trigger_level_fn_t define_trigger_level;
orte_gpr_base_module_unsubscribe_fn_t unsubscribe;
orte_gpr_base_module_cancel_trigger_fn_t cancel_trigger;
/* COMPOUND COMMANDS */
@ -644,6 +685,8 @@ struct orte_gpr_base_module_1_0_0_t {
orte_gpr_base_module_dump_segment_fn_t dump_segment;
orte_gpr_base_module_dump_triggers_fn_t dump_triggers;
orte_gpr_base_module_dump_subscriptions_fn_t dump_subscriptions;
orte_gpr_base_module_dump_a_trigger_fn_t dump_a_trigger;
orte_gpr_base_module_dump_a_subscription_fn_t dump_a_subscription;
orte_gpr_base_module_dump_local_triggers_fn_t dump_local_triggers;
orte_gpr_base_module_dump_local_subscriptions_fn_t dump_local_subscriptions;
orte_gpr_base_module_dump_callbacks_fn_t dump_callbacks;
@ -662,12 +705,12 @@ typedef orte_gpr_base_module_1_0_0_t orte_gpr_base_module_t;
*/
typedef orte_gpr_base_module_t* (*orte_gpr_base_component_init_fn_t)(
bool *allow_multi_user_threads,
bool *have_hidden_threads,
int *priority);
bool *allow_multi_user_threads,
bool *have_hidden_threads,
int *priority);
typedef int (*orte_gpr_base_component_finalize_fn_t)(void);
/*
* the standard component data structure
*/
@ -686,11 +729,11 @@ typedef mca_gpr_base_component_1_0_0_t mca_gpr_base_component_t;
/*
* Macro for use in modules that are of type gpr v1.0.0
*/
#define MCA_GPR_BASE_VERSION_1_0_0 \
/* gpr v1.0 is chained to MCA v1.0 */ \
MCA_BASE_VERSION_1_0_0, \
/* gpr v1.0 */ \
"gpr", 1, 0, 0
#define MCA_GPR_BASE_VERSION_1_0_0 \
/* gpr v1.0 is chained to MCA v1.0 */ \
MCA_BASE_VERSION_1_0_0, \
/* gpr v1.0 */ \
"gpr", 1, 0, 0
/*
* global module that holds function pointers

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

@ -4,24 +4,24 @@
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
*
* Additional copyrights may follow
*
*
* $HEADER$
*/
/** @file
/** @file
*/
/**
/**
* \brief General Purpose Registry (GPR) API
*
* The Open MPI General Purpose Registry (GPR)
*
* The Open MPI General Purpose Registry (GPR)
*
* This file contains the public type definitions supporting the GPR
*/
@ -120,6 +120,7 @@ typedef union { /* shared storage for the value */
size_t size;
bool tf_flag;
pid_t pid;
int intval;
uint8_t ui8;
uint16_t ui16;
uint32_t ui32;
@ -165,7 +166,7 @@ OMPI_DECLSPEC OBJ_CLASS_DECLARATION(orte_gpr_keyval_t);
* contains \em copies of the data in the registry. This prevents inadvertent
* modification of the registry, but requires the recipient to release the data's
* memory when done.
*
*
* The address mode and segment fields are included here for convenience and so that
* the structure can be re-used by the put command.
*/
@ -188,7 +189,7 @@ OMPI_DECLSPEC OBJ_CLASS_DECLARATION(orte_gpr_value_t);
*/
typedef struct {
opal_object_t super; /**< Makes this an object */
char *name; /**< Name of the associated subscripton, if provided */
char *target; /**< Name of the associated subscripton, if provided */
orte_gpr_subscription_id_t id; /**< Number of the associated subscription */
bool remove; /**< Remove this subscription from recipient's tracker */
size_t cnt; /**< Number of value objects returned, one per container */
@ -199,10 +200,17 @@ OMPI_DECLSPEC OBJ_CLASS_DECLARATION(orte_gpr_notify_data_t);
/** Return message for notify requests
*/
typedef uint8_t orte_gpr_notify_msg_type_t;
#define ORTE_GPR_NOTIFY_MSG_TYPE_T ORTE_UINT8
#define ORTE_GPR_TRIGGER_MSG (orte_gpr_notify_msg_type_t)0x01
#define ORTE_GPR_SUBSCRIPTION_MSG (orte_gpr_notify_msg_type_t)0x02
typedef struct {
opal_object_t super; /**< Make this an object */
char *name; /**< Name of the associated trigger, if provided */
orte_gpr_trigger_id_t id; /**< trigger id, if message comes from trigger (ORTE_GPR_TRIGGER_ID_MAX otherwise) */
orte_gpr_notify_msg_type_t msg_type; /**< trigger or subscription msg */
char *target; /**< Name of the associated trigger, if provided */
orte_gpr_trigger_id_t id; /**< trigger id, if message comes from trigger
(ORTE_GPR_TRIGGER_ID_MAX otherwise) */
bool remove; /**< Remove this trigger from recipient's tracker */
size_t cnt; /**< number of data objects */
orte_pointer_array_t *data; /**< Contiguous array of pointers to data objects */
@ -210,19 +218,21 @@ typedef struct {
OMPI_DECLSPEC OBJ_CLASS_DECLARATION(orte_gpr_notify_message_t);
/** Notify callback function
/** Notify callback function
* notify_msg = message containing data provided by trigger
*
*
* user_tag = whatever tag data the user provided when filing the subscription
*/
typedef void (*orte_gpr_notify_cb_fn_t)(orte_gpr_notify_data_t *notify_data, void *user_tag);
/** Trigger callback function
/** Trigger callback function
* notify_msg = message containing multiple blocks of data provided by trigger
*
*
* user_tag = whatever tag data the user provided when filing the subscription
*
* Since this only takes place locally, we CAN get a status code from the callback!
*/
typedef void (*orte_gpr_trigger_cb_fn_t)(orte_gpr_notify_message_t *msg, void *user_tag);
typedef int (*orte_gpr_trigger_cb_fn_t)(orte_gpr_notify_message_t *msg);
/** Structure for registering subscriptions
* A request to be notified when certain events occur, or when counters reach specified

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

@ -4,14 +4,14 @@
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
*
* Additional copyrights may follow
*
*
* $HEADER$
*/
@ -73,8 +73,8 @@ orte_gpr_null_delete_segment(char *segment)
static int
orte_gpr_null_delete_segment_nb(char *segment,
orte_gpr_notify_cb_fn_t cbfunc,
void *user_tag)
orte_gpr_notify_cb_fn_t cbfunc,
void *user_tag)
{
return ORTE_SUCCESS;
}
@ -87,41 +87,41 @@ orte_gpr_null_put(size_t cnt, orte_gpr_value_t ** values)
static int
orte_gpr_null_put_nb(size_t cnt, orte_gpr_value_t ** values,
orte_gpr_notify_cb_fn_t cbfunc, void *user_tag)
orte_gpr_notify_cb_fn_t cbfunc, void *user_tag)
{
return ORTE_SUCCESS;
}
static int
orte_gpr_null_get(orte_gpr_addr_mode_t addr_mode,
char *segment, char **tokens, char **keys,
size_t * cnt, orte_gpr_value_t *** values)
char *segment, char **tokens, char **keys,
size_t * cnt, orte_gpr_value_t *** values)
{
return ORTE_ERR_NOT_IMPLEMENTED;
}
static int
orte_gpr_null_get_nb(orte_gpr_addr_mode_t addr_mode,
char *segment, char **tokens, char **keys,
orte_gpr_notify_cb_fn_t cbfunc, void *user_tag)
char *segment, char **tokens, char **keys,
orte_gpr_notify_cb_fn_t cbfunc, void *user_tag)
{
return ORTE_ERR_NOT_IMPLEMENTED;
}
static int
orte_gpr_null_delete_entries(orte_gpr_addr_mode_t addr_mode,
char *segment, char **tokens,
char **keys)
char *segment, char **tokens,
char **keys)
{
return ORTE_SUCCESS;
}
static int
orte_gpr_null_delete_entries_nb(orte_gpr_addr_mode_t addr_mode,
char *segment, char **tokens,
char **keys,
orte_gpr_notify_cb_fn_t cbfunc,
void *user_tag)
char *segment, char **tokens,
char **keys,
orte_gpr_notify_cb_fn_t cbfunc,
void *user_tag)
{
return ORTE_SUCCESS;
}
@ -134,17 +134,17 @@ orte_gpr_null_index(char *segment, size_t * cnt, char ***index)
static int
orte_gpr_null_index_nb(char *segment,
orte_gpr_notify_cb_fn_t cbfunc,
void *user_tag)
orte_gpr_notify_cb_fn_t cbfunc,
void *user_tag)
{
return ORTE_SUCCESS;
}
static int
orte_gpr_null_subscribe(size_t num_subs,
orte_gpr_subscription_t ** subscriptions,
size_t num_trigs,
orte_gpr_trigger_t ** triggers)
orte_gpr_subscription_t ** subscriptions,
size_t num_trigs,
orte_gpr_trigger_t ** triggers)
{
return ORTE_SUCCESS;
}
@ -174,13 +174,13 @@ orte_gpr_null_dump_segments(char *segment, int output_id)
}
static int
orte_gpr_null_dump_triggers(int output_id)
orte_gpr_null_dump_triggers(orte_gpr_trigger_id_t start, int output_id)
{
return ORTE_SUCCESS;
}
static int
orte_gpr_null_dump_subscriptions(int output_id)
orte_gpr_null_dump_subscriptions(orte_gpr_subscription_id_t start, int output_id)
{
return ORTE_SUCCESS;
}
@ -205,14 +205,14 @@ orte_gpr_null_dump_callbacks(int output_id)
static int
orte_gpr_null_dump_notify_msg(orte_gpr_notify_message_t * msg,
int output_id)
int output_id)
{
return ORTE_SUCCESS;
}
static int
orte_gpr_null_dump_notify_data(orte_gpr_notify_data_t * data,
int output_id)
int output_id)
{
return ORTE_SUCCESS;
}
@ -237,8 +237,8 @@ orte_gpr_null_decrement_value(orte_gpr_value_t * value)
static int
orte_gpr_null_xfer_payload(orte_gpr_value_union_t * dest,
orte_gpr_value_union_t * src,
orte_data_type_t type)
orte_gpr_value_union_t * src,
orte_data_type_t type)
{
return ORTE_SUCCESS;
}
@ -260,7 +260,7 @@ static int orte_gpr_null_put_N(orte_gpr_addr_mode_t addr_mode,
{
return ORTE_SUCCESS;
}
static int orte_gpr_null_subscribe_1(orte_gpr_subscription_id_t *id,
char *trig_name,
char *sub_name,
@ -306,8 +306,41 @@ static int orte_gpr_null_define_trigger(orte_gpr_trigger_id_t *id,
return ORTE_SUCCESS;
}
static int orte_gpr_null_define_trigger_level(orte_gpr_trigger_id_t *id,
char *trig_name,
orte_gpr_trigger_action_t action,
orte_gpr_addr_mode_t addr_mode,
char *segment,
char **tokens,
size_t n,
char **keys,
size_t *levels,
orte_gpr_trigger_cb_fn_t cbfunc,
void *user_tag)
{
return ORTE_SUCCESS;
}
static int orte_gpr_null_deliver_notify_msg(orte_gpr_notify_message_t *msg)
{
return ORTE_SUCCESS;
}
static int orte_gpr_null_dump_a_trigger(
char *name,
orte_gpr_trigger_id_t id,
int output_id)
{
return ORTE_SUCCESS;
}
static int orte_gpr_null_dump_a_subscription(
char *name,
orte_gpr_subscription_id_t id,
int output_id)
{
return ORTE_SUCCESS;
}
/*
* setup the function pointers for the module
*/
@ -331,6 +364,7 @@ orte_gpr_base_module_t orte_gpr_null_module = {
/* GENERAL OPERATIONS */
orte_gpr_null_preallocate_segment,
orte_gpr_null_xfer_payload,
orte_gpr_null_deliver_notify_msg,
/* ARITHMETIC OPERATIONS */
orte_gpr_null_increment_value,
orte_gpr_null_decrement_value,
@ -339,6 +373,7 @@ orte_gpr_base_module_t orte_gpr_null_module = {
orte_gpr_null_subscribe_1,
orte_gpr_null_subscribe_N,
orte_gpr_null_define_trigger,
orte_gpr_null_define_trigger_level,
orte_gpr_null_unsubscribe,
orte_gpr_null_cancel_trigger,
/* COMPOUND COMMANDS */
@ -350,6 +385,8 @@ orte_gpr_base_module_t orte_gpr_null_module = {
orte_gpr_null_dump_segments,
orte_gpr_null_dump_triggers,
orte_gpr_null_dump_subscriptions,
orte_gpr_null_dump_a_trigger,
orte_gpr_null_dump_a_subscription,
orte_gpr_null_dump_local_triggers,
orte_gpr_null_dump_local_subscriptions,
orte_gpr_null_dump_callbacks,

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

@ -19,16 +19,17 @@
include $(top_ompi_srcdir)/config/Makefile.options
sources = \
gpr_proxy_arithmetic_ops.c \
gpr_proxy_cleanup.c \
gpr_proxy_component.c \
gpr_proxy_compound_cmd.c \
gpr_proxy_del_index.c \
gpr_proxy_cleanup.c \
gpr_proxy_deliver_notify_msg.c \
gpr_proxy_dump.c \
gpr_proxy_dump_local_trigs_subs.c \
gpr_proxy_general_operations.c \
gpr_proxy_internals.c \
gpr_proxy_put_get.c \
gpr_proxy_general_operations.c \
gpr_proxy_arithmetic_ops.c \
gpr_proxy_subscribe.c \
gpr_proxy.h

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

@ -1,17 +1,17 @@
/* -*- C -*-
*
*
* 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.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
*
* Additional copyrights may follow
*
*
* $HEADER$
*
*/
@ -55,6 +55,7 @@ int orte_gpr_proxy_finalize(void);
typedef struct {
opal_object_t super; /**< Allows this to be an object */
orte_gpr_subscription_id_t id; /**< id of this subscription */
size_t index; /**< location of this subscription in array */
char *name;
orte_gpr_notify_cb_fn_t callback; /**< Function to be called for notificaiton */
void *user_tag; /**< User-provided tag for callback function */
@ -66,6 +67,7 @@ OBJ_CLASS_DECLARATION(orte_gpr_proxy_subscriber_t);
typedef struct {
opal_object_t super; /**< Allows this to be an object */
orte_gpr_trigger_id_t id; /**< id of this trigger */
size_t index; /**< location of this trigger in array */
char *name;
orte_gpr_trigger_cb_fn_t callback; /**< Function to be called for notification */
void *user_tag; /**< User-provided tag for callback function */
@ -102,7 +104,7 @@ int orte_gpr_proxy_begin_compound_cmd(void);
int orte_gpr_proxy_stop_compound_cmd(void);
int orte_gpr_proxy_exec_compound_cmd(void);
/*
* Arithmetic operations
*/
@ -119,13 +121,13 @@ int orte_gpr_proxy_delete_segment_nb(char *segment,
orte_gpr_notify_cb_fn_t cbfunc, void *user_tag);
int orte_gpr_proxy_delete_entries(orte_gpr_addr_mode_t mode,
char *segment, char **tokens, char **keys);
char *segment, char **tokens, char **keys);
int orte_gpr_proxy_delete_entries_nb(
orte_gpr_addr_mode_t addr_mode,
char *segment, char **tokens, char **keys,
orte_gpr_notify_cb_fn_t cbfunc, void *user_tag);
int orte_gpr_proxy_index(char *segment, size_t *cnt, char ***index);
int orte_gpr_proxy_index_nb(char *segment,
@ -147,7 +149,7 @@ int orte_gpr_proxy_put(size_t cnt, orte_gpr_value_t **values);
int orte_gpr_proxy_put_nb(size_t cnt, orte_gpr_value_t **values,
orte_gpr_notify_cb_fn_t cbfunc, void *user_tag);
int orte_gpr_proxy_get(orte_gpr_addr_mode_t addr_mode,
char *segment, char **tokens, char **keys,
size_t *cnt, orte_gpr_value_t ***values);
@ -177,9 +179,17 @@ int orte_gpr_proxy_dump_all(int output_id);
int orte_gpr_proxy_dump_segments(char *segment, int output_id);
int orte_gpr_proxy_dump_triggers(int output_id);
int orte_gpr_proxy_dump_triggers(orte_gpr_trigger_id_t start, int output_id);
int orte_gpr_proxy_dump_subscriptions(int output_id);
int orte_gpr_proxy_dump_subscriptions(orte_gpr_subscription_id_t start, int output_id);
int orte_gpr_proxy_dump_a_trigger(char *name,
orte_gpr_trigger_id_t id,
int output_id);
int orte_gpr_proxy_dump_a_subscription(char *name,
orte_gpr_subscription_id_t id,
int output_id);
int orte_gpr_proxy_dump_local_triggers(int output_id);
@ -198,12 +208,14 @@ int orte_gpr_proxy_dump_value(orte_gpr_value_t *value, int output_id);
*/
int orte_gpr_proxy_preallocate_segment(char *name, size_t num_slots);
int orte_gpr_proxy_deliver_notify_msg(orte_gpr_notify_message_t *msg);
/*
* Functions that interface to the replica
*/
void orte_gpr_proxy_notify_recv(int status, orte_process_name_t* sender,
orte_buffer_t *buffer, orte_rml_tag_t tag,
void* cbdata);
orte_buffer_t *buffer, orte_rml_tag_t tag,
void* cbdata);
/*
@ -214,14 +226,14 @@ int
orte_gpr_proxy_enter_subscription(size_t cnt, orte_gpr_subscription_t **subscriptions);
int
orte_gpr_proxy_remove_subscription(orte_gpr_subscription_id_t id);
orte_gpr_proxy_remove_subscription(orte_gpr_proxy_subscriber_t *sub);
int
orte_gpr_proxy_enter_trigger(size_t cnt, orte_gpr_trigger_t **triggers);
int
orte_gpr_proxy_remove_trigger(orte_gpr_trigger_id_t id);
orte_gpr_proxy_remove_trigger(orte_gpr_proxy_trigger_t *trig);
#if defined(c_plusplus) || defined(__cplusplus)
}

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

@ -4,14 +4,14 @@
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
*
* Additional copyrights may follow
*
*
* $HEADER$
*/
/** @file:
@ -45,17 +45,17 @@
*/
mca_gpr_base_component_t mca_gpr_proxy_component = {
{
MCA_GPR_BASE_VERSION_1_0_0,
MCA_GPR_BASE_VERSION_1_0_0,
"proxy", /* MCA module name */
ORTE_MAJOR_VERSION, /* MCA module major version */
ORTE_MINOR_VERSION, /* MCA module minor version */
ORTE_RELEASE_VERSION, /* MCA module release version */
orte_gpr_proxy_open, /* module open */
orte_gpr_proxy_close /* module close */
"proxy", /* MCA module name */
ORTE_MAJOR_VERSION, /* MCA module major version */
ORTE_MINOR_VERSION, /* MCA module minor version */
ORTE_RELEASE_VERSION, /* MCA module release version */
orte_gpr_proxy_open, /* module open */
orte_gpr_proxy_close /* module close */
},
{
false /* checkpoint / restart */
false /* checkpoint / restart */
},
orte_gpr_proxy_component_init, /* module init */
orte_gpr_proxy_finalize /* module shutdown */
@ -84,6 +84,7 @@ static orte_gpr_base_module_t orte_gpr_proxy = {
/* GENERAL OPERATIONS */
orte_gpr_proxy_preallocate_segment,
orte_gpr_base_xfer_payload,
orte_gpr_proxy_deliver_notify_msg,
/* ARITHMETIC OPERATIONS */
orte_gpr_proxy_increment_value,
orte_gpr_proxy_decrement_value,
@ -92,6 +93,7 @@ static orte_gpr_base_module_t orte_gpr_proxy = {
orte_gpr_base_subscribe_1,
orte_gpr_base_subscribe_N,
orte_gpr_base_define_trigger,
orte_gpr_base_define_trigger_level,
orte_gpr_proxy_unsubscribe,
orte_gpr_proxy_cancel_trigger,
/* COMPOUND COMMANDS */
@ -103,6 +105,8 @@ static orte_gpr_base_module_t orte_gpr_proxy = {
orte_gpr_proxy_dump_segments,
orte_gpr_proxy_dump_triggers,
orte_gpr_proxy_dump_subscriptions,
orte_gpr_proxy_dump_a_trigger,
orte_gpr_proxy_dump_a_subscription,
orte_gpr_proxy_dump_local_triggers,
orte_gpr_proxy_dump_local_subscriptions,
orte_gpr_proxy_dump_callbacks,
@ -205,20 +209,20 @@ orte_gpr_proxy_component_init(bool *allow_multi_user_threads, bool *have_hidden_
{
orte_process_name_t name;
int ret;
if (orte_gpr_proxy_globals.debug) {
opal_output(0, "gpr_proxy_init called");
opal_output(0, "gpr_proxy_init called");
}
/* If we are NOT to host a replica, then we want to be selected, so do all
the setup and return the module */
if (NULL != orte_process_info.gpr_replica_uri) {
if (orte_gpr_proxy_globals.debug) {
opal_output(0, "[%lu,%lu,%lu] gpr_proxy_init: proxy selected",
if (orte_gpr_proxy_globals.debug) {
opal_output(0, "[%lu,%lu,%lu] gpr_proxy_init: proxy selected",
ORTE_NAME_ARGS(orte_process_info.my_name));
}
}
/* setup the replica location */
if(ORTE_SUCCESS != (ret = orte_rml.parse_uris(orte_process_info.gpr_replica_uri, &name, NULL))) {
ORTE_ERROR_LOG(ret);
@ -228,30 +232,30 @@ orte_gpr_proxy_component_init(bool *allow_multi_user_threads, bool *have_hidden_
ORTE_ERROR_LOG(ret);
return NULL;
}
/* Return a module (choose an arbitrary, positive priority --
it's only relevant compared to other ns components). If
we're not the seed, then we don't want to be selected, so
return NULL. */
*priority = 10;
/* We allow multi user threads but don't have any hidden threads */
*allow_multi_user_threads = true;
*have_hidden_threads = false;
/* setup thread locks and condition variable */
OBJ_CONSTRUCT(&orte_gpr_proxy_globals.mutex, opal_mutex_t);
OBJ_CONSTRUCT(&orte_gpr_proxy_globals.wait_for_compound_mutex, opal_mutex_t);
OBJ_CONSTRUCT(&orte_gpr_proxy_globals.compound_cmd_condition, opal_condition_t);
/* initialize the registry compound mode */
orte_gpr_proxy_globals.compound_cmd_mode = false;
orte_gpr_proxy_globals.compound_cmd_waiting = 0;
orte_gpr_proxy_globals.compound_cmd = NULL;
/* initialize the subscription tracker */
/* Return a module (choose an arbitrary, positive priority --
it's only relevant compared to other ns components). If
we're not the seed, then we don't want to be selected, so
return NULL. */
*priority = 10;
/* We allow multi user threads but don't have any hidden threads */
*allow_multi_user_threads = true;
*have_hidden_threads = false;
/* setup thread locks and condition variable */
OBJ_CONSTRUCT(&orte_gpr_proxy_globals.mutex, opal_mutex_t);
OBJ_CONSTRUCT(&orte_gpr_proxy_globals.wait_for_compound_mutex, opal_mutex_t);
OBJ_CONSTRUCT(&orte_gpr_proxy_globals.compound_cmd_condition, opal_condition_t);
/* initialize the registry compound mode */
orte_gpr_proxy_globals.compound_cmd_mode = false;
orte_gpr_proxy_globals.compound_cmd_waiting = 0;
orte_gpr_proxy_globals.compound_cmd = NULL;
/* initialize the subscription tracker */
if (ORTE_SUCCESS != (ret = orte_pointer_array_init(&(orte_gpr_proxy_globals.subscriptions),
orte_gpr_array_block_size,
orte_gpr_array_max_size,
@ -260,7 +264,7 @@ orte_gpr_proxy_component_init(bool *allow_multi_user_threads, bool *have_hidden_
return NULL;
}
orte_gpr_proxy_globals.num_subs = 0;
/* initialize the trigger counter */
if (ORTE_SUCCESS != (ret = orte_pointer_array_init(&(orte_gpr_proxy_globals.triggers),
orte_gpr_array_block_size,
@ -270,7 +274,7 @@ orte_gpr_proxy_component_init(bool *allow_multi_user_threads, bool *have_hidden_
return NULL;
}
orte_gpr_proxy_globals.num_trigs = 0;
initialized = true;
return &orte_gpr_proxy;
} else {
@ -298,12 +302,12 @@ int orte_gpr_proxy_finalize(void)
{
if (orte_gpr_proxy_globals.debug) {
opal_output(0, "[%lu,%lu,%lu] gpr_proxy_finalize called",
opal_output(0, "[%lu,%lu,%lu] gpr_proxy_finalize called",
ORTE_NAME_ARGS(orte_process_info.my_name));
}
if (initialized) {
initialized = false;
initialized = false;
}
/* All done */
@ -311,36 +315,28 @@ int orte_gpr_proxy_finalize(void)
return ORTE_SUCCESS;
}
/*
/*
* handle notify messages from replicas
*/
void orte_gpr_proxy_notify_recv(int status, orte_process_name_t* sender,
orte_buffer_t *buffer, orte_rml_tag_t tag,
void* cbdata)
orte_buffer_t *buffer, orte_rml_tag_t tag,
void* cbdata)
{
orte_gpr_cmd_flag_t command;
orte_gpr_notify_message_t *msg;
orte_gpr_notify_data_t **data;
orte_gpr_proxy_subscriber_t *sub;
orte_gpr_proxy_trigger_t *trig;
size_t i, n;
size_t n;
int rc;
if (orte_gpr_proxy_globals.debug) {
opal_output(0, "[%lu,%lu,%lu] gpr_proxy_notify_recv: received trigger message",
ORTE_NAME_ARGS(orte_process_info.my_name));
}
n = 1;
if (ORTE_SUCCESS != (rc = orte_dps.unpack(buffer, &command, &n, ORTE_GPR_CMD))) {
ORTE_ERROR_LOG(rc);
goto RETURN_ERROR;
}
if (ORTE_GPR_NOTIFY_CMD != command) {
if (ORTE_GPR_NOTIFY_CMD != command) {
ORTE_ERROR_LOG(ORTE_ERR_COMM_FAILURE);
goto RETURN_ERROR;
goto RETURN_ERROR;
}
msg = OBJ_NEW(orte_gpr_notify_message_t);
@ -348,7 +344,7 @@ void orte_gpr_proxy_notify_recv(int status, orte_process_name_t* sender,
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
goto RETURN_ERROR;
}
n = 1;
if (ORTE_SUCCESS != (rc = orte_dps.unpack(buffer, &msg, &n, ORTE_GPR_NOTIFY_MSG))) {
ORTE_ERROR_LOG(rc);
@ -356,61 +352,16 @@ void orte_gpr_proxy_notify_recv(int status, orte_process_name_t* sender,
goto RETURN_ERROR;
}
/* if the message trigger id is valid (i.e., it is set to
* something other than ORTE_GPR_TRIGGER_ID_MAX), then this
* is an aggregated message intended for a single receiver.
* In that case, look up the associated TRIGGER id and pass
* the entire message to that receiver.
*/
if (ORTE_GPR_TRIGGER_ID_MAX > msg->id) {
trig = (orte_gpr_proxy_globals.triggers)->addr[msg->id];
if (NULL == trig) {
ORTE_ERROR_LOG(ORTE_ERR_GPR_DATA_CORRUPT);
} else {
trig->callback(msg, sub->user_tag);
}
if (msg->remove) {
if (ORTE_SUCCESS != (rc = orte_gpr_proxy_remove_trigger(msg->id))) {
ORTE_ERROR_LOG(rc);
}
}
OBJ_RELEASE(msg);
goto RETURN_ERROR;
}
/* if the message trigger id was NOT valid, then we split the
* message into its component datagrams and send each of them
* separately to their rescpective subscriber.
*/
if (msg->cnt > 0) {
data = (orte_gpr_notify_data_t**)(msg->data)->addr;
for (i=0; i < msg->cnt; i++) {
/* for speed purposes, we take advantage here of
* our knowledge on how this pointer array was
* constructed - we know that it is contiguous
* and that there are no NULL gaps in it.
*/
/* process request */
if (data[i]->id > orte_gpr_proxy_globals.num_subs) {
ORTE_ERROR_LOG(ORTE_ERR_GPR_DATA_CORRUPT);
continue;
}
sub = (orte_gpr_proxy_globals.subscriptions)->addr[data[i]->id];
if (NULL == sub) {
ORTE_ERROR_LOG(ORTE_ERR_GPR_DATA_CORRUPT);
} else {
sub->callback(data[i], sub->user_tag);
}
if (data[i]->remove) {
if (ORTE_SUCCESS != (rc = orte_gpr_proxy_remove_subscription(data[i]->id))) {
ORTE_ERROR_LOG(rc);
}
}
}
/* release data */
/* process the message */
if (ORTE_SUCCESS != (rc = orte_gpr_proxy_deliver_notify_msg(msg))) {
ORTE_ERROR_LOG(rc);
OBJ_RELEASE(msg);
}
goto RETURN_ERROR;
}
/* release data */
OBJ_RELEASE(msg);
RETURN_ERROR:

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

@ -4,14 +4,14 @@
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
*
* Additional copyrights may follow
*
*
* $HEADER$
*/
/** @file:
@ -44,80 +44,107 @@ int orte_gpr_proxy_deliver_notify_msg(orte_gpr_notify_message_t *msg)
{
orte_gpr_notify_data_t **data;
orte_gpr_proxy_subscriber_t **subs, *sub;
orte_gpr_proxy_trigger_t *trig;
size_t i, j, k;
orte_gpr_proxy_trigger_t *trig, **trigs;
size_t i, j, k, n;
bool processed;
int rc;
/* if the message trigger id is valid (i.e., it is set to
* something other than ORTE_GPR_TRIGGER_ID_MAX), then this
* is an aggregated message intended for a single receiver.
* In that case, look up the associated TRIGGER id and pass
* the entire message to that receiver.
/* we first have to check if the message is a trigger message - if so,
* then the message is intended to be
* sent as a single block to that trigger's callback function.
*/
if (ORTE_GPR_TRIGGER_ID_MAX > msg->id) {
if (ORTE_GPR_TRIGGER_MSG == msg->msg_type) {
trig = (orte_gpr_proxy_globals.triggers)->addr[msg->id];
if (NULL == trig) {
ORTE_ERROR_LOG(ORTE_ERR_GPR_DATA_CORRUPT);
opal_output(0, "Trigger id: %lu", (unsigned long)msg->id);
orte_gpr.dump_local_triggers(0);
return ORTE_ERR_GPR_DATA_CORRUPT;
} else {
trig->callback(msg);
}
if (msg->remove) {
if (ORTE_SUCCESS != (rc = orte_gpr_proxy_remove_trigger(msg->id))) {
ORTE_ERROR_LOG(rc);
return rc;
}
/* remove the specified trigger from the local tracker */
trigs = (orte_gpr_proxy_trigger_t**)(orte_gpr_proxy_globals.triggers)->addr;
for (i=0, j=0; j < orte_gpr_proxy_globals.num_trigs &&
i < (orte_gpr_proxy_globals.triggers)->size; i++) {
if (NULL != trigs[i]){
j++;
if (msg->id == trigs[i]->id) {
if (ORTE_SUCCESS != (rc = orte_gpr_proxy_remove_trigger(trigs[i]))) {
ORTE_ERROR_LOG(rc);
}
OPAL_THREAD_UNLOCK(&orte_gpr_proxy_globals.mutex);
return rc;
}
}
}
/* must not have been found - report error */
ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND);
return ORTE_ERR_NOT_FOUND;
}
return ORTE_SUCCESS;
}
/* if the message trigger id was NOT valid, then we split the
* message into its component datagrams and send each of them
* separately to their respective subscriber.
/* get here if this wasn't a trigger message. Only other allowed message type
* is a subscription message - if that isn't the case, then we have corrupt
* data, so flag it and return
*/
if (ORTE_GPR_SUBSCRIPTION_MSG != msg->msg_type) {
ORTE_ERROR_LOG(ORTE_ERR_GPR_DATA_CORRUPT);
return ORTE_ERR_GPR_DATA_CORRUPT;
}
/* get here if we have a subscription message - i.e., the message should
* be broken into its component parts and delivered separately
* to the indicated subscribers
*/
data = (orte_gpr_notify_data_t**)(msg->data)->addr;
orte_gpr.dump_local_subscriptions(0);
for (i=0; i < msg->cnt; i++) {
opal_output(0, "[%lu,%lu,%lu] Sub data id %lu", ORTE_NAME_ARGS(orte_process_info.my_name), (unsigned long)data[i]->id);
opal_output(0, "\tSub name %s", data[i]->target);
/* for each datagram in the message, we need to lookup
* the associated subscription (could be specified by name or id) to find the correct
* callback function. Name specifications are given precedence over id.
*/
subs = (orte_gpr_proxy_subscriber_t**)
(orte_gpr_proxy_globals.subscriptions)->addr;
processed = false;
for (j=0, k=0; !processed &&
k < orte_gpr_proxy_globals.num_subs &&
j < (orte_gpr_proxy_globals.subscriptions)->size; j++) {
if (NULL != subs[j]) {
k++;
if ((NULL != subs[j]->name &&
NULL != data[i]->target &&
0 == strcmp(data[i]->target, subs[j]->name)) ||
(data[i]->id == subs[j]->id)) {
sub = subs[j];
processed = true;
for (i=0, n=0; n < msg->cnt &&
i < (msg->data)->size; i++) {
if (NULL != data[i]) {
n++;
if (ORTE_GPR_SUBSCRIPTION_ID_MAX != data[i]->id || NULL != data[i]->target) {
/* for each datagram in the message, we need to lookup
* the associated subscription (could be specified by name or id) to find the correct
* callback function. Name specifications are given precedence over id.
*/
subs = (orte_gpr_proxy_subscriber_t**)
(orte_gpr_proxy_globals.subscriptions)->addr;
processed = false;
for (j=0, k=0; !processed &&
k < orte_gpr_proxy_globals.num_subs &&
j < (orte_gpr_proxy_globals.subscriptions)->size; j++) {
if (NULL != subs[j]) {
k++;
if (NULL != data[i]->target) {
/* if target name provided, must use it */
if (NULL != subs[j]->name &&
0 == strcmp(data[i]->target, subs[j]->name)) {
sub = subs[j];
processed = true;
}
} else if (data[i]->id == subs[j]->id) {
/* otherwise, see if id's match */
sub = subs[j];
processed = true;
}
}
}
}
}
/* get here and not processed => not found, abort */
if (!processed) {
ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND);
return ORTE_ERR_NOT_FOUND;
}
OPAL_THREAD_UNLOCK(&orte_gpr_proxy_globals.mutex);
sub->callback(data[i], sub->user_tag);
OPAL_THREAD_LOCK(&orte_gpr_proxy_globals.mutex);
/* get here and not processed => not found, abort */
if (!processed) {
ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND);
return ORTE_ERR_NOT_FOUND;
}
OPAL_THREAD_UNLOCK(&orte_gpr_proxy_globals.mutex);
sub->callback(data[i], sub->user_tag);
OPAL_THREAD_LOCK(&orte_gpr_proxy_globals.mutex);
if (data[i]->remove) {
if (ORTE_SUCCESS != (rc = orte_gpr_proxy_remove_subscription(sub))) {
ORTE_ERROR_LOG(rc);
return rc;
if (data[i]->remove) {
if (ORTE_SUCCESS != (rc = orte_gpr_proxy_remove_subscription(sub))) {
ORTE_ERROR_LOG(rc);
return rc;
}
}
}
}
}

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

@ -167,7 +167,7 @@ int orte_gpr_proxy_dump_segments(char *segment, int output_id)
return rc;
}
int orte_gpr_proxy_dump_triggers(int output_id)
int orte_gpr_proxy_dump_triggers(orte_gpr_trigger_id_t start, int output_id)
{
orte_gpr_cmd_flag_t command;
orte_buffer_t *cmd;
@ -176,7 +176,7 @@ int orte_gpr_proxy_dump_triggers(int output_id)
size_t n;
if (orte_gpr_proxy_globals.compound_cmd_mode) {
return orte_gpr_base_pack_dump_triggers(orte_gpr_proxy_globals.compound_cmd);
return orte_gpr_base_pack_dump_triggers(orte_gpr_proxy_globals.compound_cmd, start);
}
cmd = OBJ_NEW(orte_buffer_t);
@ -185,7 +185,7 @@ int orte_gpr_proxy_dump_triggers(int output_id)
return ORTE_ERR_OUT_OF_RESOURCE;
}
if (ORTE_SUCCESS != (rc = orte_gpr_base_pack_dump_triggers(cmd))) {
if (ORTE_SUCCESS != (rc = orte_gpr_base_pack_dump_triggers(cmd, start))) {
ORTE_ERROR_LOG(rc);
OBJ_RELEASE(cmd);
return rc;
@ -228,7 +228,7 @@ int orte_gpr_proxy_dump_triggers(int output_id)
return rc;
}
int orte_gpr_proxy_dump_subscriptions(int output_id)
int orte_gpr_proxy_dump_subscriptions(orte_gpr_subscription_id_t start, int output_id)
{
orte_gpr_cmd_flag_t command;
orte_buffer_t *cmd;
@ -237,7 +237,7 @@ int orte_gpr_proxy_dump_subscriptions(int output_id)
size_t n;
if (orte_gpr_proxy_globals.compound_cmd_mode) {
return orte_gpr_base_pack_dump_subscriptions(orte_gpr_proxy_globals.compound_cmd);
return orte_gpr_base_pack_dump_subscriptions(orte_gpr_proxy_globals.compound_cmd, start);
}
cmd = OBJ_NEW(orte_buffer_t);
@ -246,7 +246,7 @@ int orte_gpr_proxy_dump_subscriptions(int output_id)
return ORTE_ERR_OUT_OF_RESOURCE;
}
if (ORTE_SUCCESS != (rc = orte_gpr_base_pack_dump_subscriptions(cmd))) {
if (ORTE_SUCCESS != (rc = orte_gpr_base_pack_dump_subscriptions(cmd, start))) {
ORTE_ERROR_LOG(rc);
OBJ_RELEASE(cmd);
return rc;
@ -289,6 +289,134 @@ int orte_gpr_proxy_dump_subscriptions(int output_id)
return rc;
}
int orte_gpr_proxy_dump_a_trigger(char *name,
orte_gpr_trigger_id_t id,
int output_id)
{
orte_gpr_cmd_flag_t command;
orte_buffer_t *cmd;
orte_buffer_t *answer;
int rc;
size_t n;
if (orte_gpr_proxy_globals.compound_cmd_mode) {
return orte_gpr_base_pack_dump_a_trigger(orte_gpr_proxy_globals.compound_cmd, name, id);
}
cmd = OBJ_NEW(orte_buffer_t);
if (NULL == cmd) { /* got a problem */
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
if (ORTE_SUCCESS != (rc = orte_gpr_base_pack_dump_a_trigger(cmd, name, id))) {
ORTE_ERROR_LOG(rc);
OBJ_RELEASE(cmd);
return rc;
}
if (0 > orte_rml.send_buffer(orte_process_info.gpr_replica, cmd, ORTE_RML_TAG_GPR, 0)) {
ORTE_ERROR_LOG(ORTE_ERR_COMM_FAILURE);
return ORTE_ERR_COMM_FAILURE;
}
answer = OBJ_NEW(orte_buffer_t);
if (NULL == answer) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
if (0 > orte_rml.recv_buffer(orte_process_info.gpr_replica, answer, ORTE_RML_TAG_GPR)) {
ORTE_ERROR_LOG(ORTE_ERR_COMM_FAILURE);
return ORTE_ERR_COMM_FAILURE;
}
n = 1;
if (ORTE_SUCCESS != (rc = orte_dps.unpack(answer, &command, &n, ORTE_GPR_CMD))) {
ORTE_ERROR_LOG(rc);
OBJ_RELEASE(answer);
return rc;
}
if (ORTE_GPR_DUMP_TRIGGERS_CMD != command) {
ORTE_ERROR_LOG(ORTE_ERR_COMM_FAILURE);
OBJ_RELEASE(answer);
return ORTE_ERR_COMM_FAILURE;
}
if (ORTE_SUCCESS != (rc = orte_gpr_base_print_dump(answer, output_id))) {
ORTE_ERROR_LOG(rc);
}
OBJ_RELEASE(answer);
return rc;
}
int orte_gpr_proxy_dump_a_subscription(char *name,
orte_gpr_subscription_id_t id,
int output_id)
{
orte_gpr_cmd_flag_t command;
orte_buffer_t *cmd;
orte_buffer_t *answer;
int rc;
size_t n;
if (orte_gpr_proxy_globals.compound_cmd_mode) {
return orte_gpr_base_pack_dump_a_subscription(orte_gpr_proxy_globals.compound_cmd, name, id);
}
cmd = OBJ_NEW(orte_buffer_t);
if (NULL == cmd) { /* got a problem */
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
if (ORTE_SUCCESS != (rc = orte_gpr_base_pack_dump_a_subscription(cmd, name, id))) {
ORTE_ERROR_LOG(rc);
OBJ_RELEASE(cmd);
return rc;
}
if (0 > orte_rml.send_buffer(orte_process_info.gpr_replica, cmd, ORTE_RML_TAG_GPR, 0)) {
ORTE_ERROR_LOG(ORTE_ERR_COMM_FAILURE);
return ORTE_ERR_COMM_FAILURE;
}
answer = OBJ_NEW(orte_buffer_t);
if (NULL == answer) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
if (0 > orte_rml.recv_buffer(orte_process_info.gpr_replica, answer, ORTE_RML_TAG_GPR)) {
ORTE_ERROR_LOG(ORTE_ERR_COMM_FAILURE);
return ORTE_ERR_COMM_FAILURE;
}
n = 1;
if (ORTE_SUCCESS != (rc = orte_dps.unpack(answer, &command, &n, ORTE_GPR_CMD))) {
ORTE_ERROR_LOG(rc);
OBJ_RELEASE(answer);
return rc;
}
if (ORTE_GPR_DUMP_TRIGGERS_CMD != command) {
ORTE_ERROR_LOG(ORTE_ERR_COMM_FAILURE);
OBJ_RELEASE(answer);
return ORTE_ERR_COMM_FAILURE;
}
if (ORTE_SUCCESS != (rc = orte_gpr_base_print_dump(answer, output_id))) {
ORTE_ERROR_LOG(rc);
}
OBJ_RELEASE(answer);
return rc;
}
int orte_gpr_proxy_dump_callbacks(int output_id)
{
orte_gpr_cmd_flag_t command;

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

@ -3,14 +3,14 @@
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
*
* Additional copyrights may follow
*
*
* $HEADER$
*/
/** @file:
@ -35,8 +35,8 @@ int
orte_gpr_proxy_enter_subscription(size_t cnt, orte_gpr_subscription_t **subscriptions)
{
orte_gpr_proxy_subscriber_t *sub;
size_t i, id;
size_t i;
for (i=0; i < cnt; i++) {
sub = OBJ_NEW(orte_gpr_proxy_subscriber_t);
if (NULL == sub) {
@ -48,7 +48,7 @@ orte_gpr_proxy_enter_subscription(size_t cnt, orte_gpr_subscription_t **subscrip
}
sub->callback = subscriptions[i]->cbfunc;
sub->user_tag = subscriptions[i]->user_tag;
if (0 > orte_pointer_array_add(&id, orte_gpr_proxy_globals.subscriptions, sub)) {
if (0 > orte_pointer_array_add(&sub->index, orte_gpr_proxy_globals.subscriptions, sub)) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
@ -56,7 +56,7 @@ orte_gpr_proxy_enter_subscription(size_t cnt, orte_gpr_subscription_t **subscrip
subscriptions[i]->id = sub->id;
(orte_gpr_proxy_globals.num_subs)++;
}
return ORTE_SUCCESS;
}
@ -64,10 +64,45 @@ orte_gpr_proxy_enter_subscription(size_t cnt, orte_gpr_subscription_t **subscrip
int
orte_gpr_proxy_enter_trigger(size_t cnt, orte_gpr_trigger_t **trigs)
{
orte_gpr_proxy_trigger_t *trig;
size_t i, id;
orte_gpr_proxy_trigger_t *trig, **tptr;
size_t i, j, k;
for (i=0; i < cnt; i++) {
/* If the provided trigger has a name, see if it already is on
* the local trigger list. If so, then check to see if we
* already defined a return point for it and/or if this trigger
* doesn't - in either of those two cases, we ignore the
* trigger and just use the existing entry
*/
if (NULL != trigs[i]->name) {
tptr = (orte_gpr_proxy_trigger_t**)(orte_gpr_proxy_globals.triggers)->addr;
for (j=0, k=0; k < orte_gpr_proxy_globals.num_trigs &&
j < (orte_gpr_proxy_globals.triggers)->size; j++) {
if (NULL != tptr[j]) {
k++;
if (0 == strcmp(tptr[j]->name, trigs[i]->name)) {
/* same name - trigger is already on list */
if (NULL != tptr[j]->callback || NULL == trigs[i]->cbfunc) {
/* ignore these cases */
trig = tptr[j];
goto MOVEON;
}
/* reach here if either the prior trigger didn't provide
* a callback, and the new one provides one. In this
* case, we update the existing trigger callback and then
* move on
*/
tptr[j]->callback = trigs[i]->cbfunc;
trig = tptr[j];
goto MOVEON;
}
}
}
}
/* either the trigger doesn't have a name, OR it did, but it isn't
* already on the list - add it to the list now
*/
trig = OBJ_NEW(orte_gpr_proxy_trigger_t);
if (NULL == trig) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
@ -89,38 +124,51 @@ orte_gpr_proxy_enter_trigger(size_t cnt, orte_gpr_trigger_t **trigs)
}
trig->callback = trigs[i]->cbfunc;
trig->user_tag = trigs[i]->user_tag;
if (0 > orte_pointer_array_add(&id, orte_gpr_proxy_globals.triggers, trig)) {
if (0 > orte_pointer_array_add(&trig->index, orte_gpr_proxy_globals.triggers, trig)) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
trig->id = orte_gpr_proxy_globals.num_trigs;
trigs[i]->id = trig->id;
(orte_gpr_proxy_globals.num_trigs)++;
MOVEON:
trigs[i]->id = trig->id;
}
return ORTE_SUCCESS;
}
int
orte_gpr_proxy_remove_subscription(orte_gpr_subscription_id_t id)
orte_gpr_proxy_remove_subscription(orte_gpr_proxy_subscriber_t *sub)
{
if (NULL != (orte_gpr_proxy_globals.subscriptions)->addr[id]) {
OBJ_RELEASE((orte_gpr_proxy_globals.subscriptions)->addr[id]);
orte_pointer_array_set_item(orte_gpr_proxy_globals.subscriptions, (size_t)id, NULL);
size_t index;
if (NULL == sub) {
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
return ORTE_ERR_BAD_PARAM;
}
index = sub->index;
OBJ_RELEASE(sub);
orte_pointer_array_set_item(orte_gpr_proxy_globals.subscriptions, index, NULL);
return ORTE_SUCCESS;
}
int
orte_gpr_proxy_remove_trigger(orte_gpr_trigger_id_t id)
orte_gpr_proxy_remove_trigger(orte_gpr_proxy_trigger_t *trig)
{
if (NULL != (orte_gpr_proxy_globals.triggers)->addr[id]) {
OBJ_RELEASE((orte_gpr_proxy_globals.triggers)->addr[id]);
orte_pointer_array_set_item(orte_gpr_proxy_globals.triggers, (size_t)id, NULL);
size_t index;
if (NULL == trig) {
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
return ORTE_ERR_BAD_PARAM;
}
index = trig->index;
OBJ_RELEASE(trig);
orte_pointer_array_set_item(orte_gpr_proxy_globals.triggers, index, NULL);
return ORTE_SUCCESS;
}

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

@ -3,14 +3,14 @@
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
*
* Additional copyrights may follow
*
*
* $HEADER$
*/
/** @file:
@ -45,13 +45,14 @@ orte_gpr_proxy_subscribe(size_t num_subs,
{
orte_buffer_t *cmd;
orte_buffer_t *answer;
orte_gpr_proxy_subscriber_t **subs;
int rc = ORTE_SUCCESS, ret;
size_t i;
/* need to protect against errors */
if (NULL == subscriptions && NULL == trigs) { /* need at least one */
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
return ORTE_ERR_BAD_PARAM;
return ORTE_ERR_BAD_PARAM;
}
OPAL_THREAD_LOCK(&orte_gpr_proxy_globals.mutex);
@ -83,15 +84,15 @@ orte_gpr_proxy_subscribe(size_t num_subs,
* compound cmd buffer and return
*/
if (orte_gpr_proxy_globals.compound_cmd_mode) {
if (ORTE_SUCCESS != (rc = orte_gpr_base_pack_subscribe(orte_gpr_proxy_globals.compound_cmd,
num_subs, subscriptions,
if (ORTE_SUCCESS != (rc = orte_gpr_base_pack_subscribe(orte_gpr_proxy_globals.compound_cmd,
num_subs, subscriptions,
num_trigs, trigs))) {
ORTE_ERROR_LOG(rc);
goto ERROR;
}
/* done */
OPAL_THREAD_UNLOCK(&orte_gpr_proxy_globals.mutex);
OPAL_THREAD_UNLOCK(&orte_gpr_proxy_globals.mutex);
return ORTE_SUCCESS;
}
@ -102,13 +103,13 @@ orte_gpr_proxy_subscribe(size_t num_subs,
rc = ORTE_ERR_OUT_OF_RESOURCE;
goto ERROR;
}
/* pack the command and send it */
if (ORTE_SUCCESS != (rc = orte_gpr_base_pack_subscribe(cmd,
num_subs, subscriptions,
num_trigs, trigs))) {
ORTE_ERROR_LOG(rc);
OBJ_RELEASE(cmd);
OBJ_RELEASE(cmd);
goto ERROR;
}
@ -128,7 +129,7 @@ orte_gpr_proxy_subscribe(size_t num_subs,
rc = ORTE_ERR_OUT_OF_RESOURCE;
goto ERROR;
}
if (0 > orte_rml.recv_buffer(orte_process_info.gpr_replica, answer, ORTE_RML_TAG_GPR)) {
ORTE_ERROR_LOG(ORTE_ERR_COMM_FAILURE);
OBJ_RELEASE(answer);
@ -152,7 +153,7 @@ orte_gpr_proxy_subscribe(size_t num_subs,
OBJ_RELEASE(answer);
OPAL_THREAD_UNLOCK(&orte_gpr_proxy_globals.mutex);
return ORTE_SUCCESS;
/* if an error was encountered during processing this request, we need to
* remove the subscriptions from the subscription tracking system. do this
* and then exit.
@ -162,14 +163,16 @@ orte_gpr_proxy_subscribe(size_t num_subs,
* numbers are NOT re-used.
*/
ERROR:
subs = (orte_gpr_proxy_subscriber_t**)(orte_gpr_proxy_globals.subscriptions)->addr;
for (i=0; i < num_subs; i++) {
if (ORTE_SUCCESS != (rc = orte_gpr_proxy_remove_subscription(subscriptions[i]->id))) {
/* find the subscription on the local tracker */
if (ORTE_SUCCESS != (rc = orte_gpr_proxy_remove_subscription(subs[subscriptions[i]->id]))) {
ORTE_ERROR_LOG(rc);
OPAL_THREAD_UNLOCK(&orte_gpr_proxy_globals.mutex);
return rc;
}
}
OPAL_THREAD_UNLOCK(&orte_gpr_proxy_globals.mutex);
return rc;
}
@ -179,17 +182,33 @@ int orte_gpr_proxy_unsubscribe(orte_gpr_subscription_id_t sub_number)
{
orte_buffer_t *cmd;
orte_buffer_t *answer;
orte_gpr_proxy_subscriber_t **subs;
size_t i, j;
int rc, ret;
OPAL_THREAD_LOCK(&orte_gpr_proxy_globals.mutex);
/* remove the specified subscription from the local tracker */
if (ORTE_SUCCESS != (rc = orte_gpr_proxy_remove_subscription(sub_number))) {
ORTE_ERROR_LOG(rc);
OPAL_THREAD_UNLOCK(&orte_gpr_proxy_globals.mutex);
return rc;
subs = (orte_gpr_proxy_subscriber_t**)(orte_gpr_proxy_globals.subscriptions)->addr;
for (i=0, j=0; j < orte_gpr_proxy_globals.num_subs &&
i < (orte_gpr_proxy_globals.subscriptions)->size; i++) {
if (NULL != subs[i]){
j++;
if (sub_number == subs[i]->id) {
if (ORTE_SUCCESS != (rc = orte_gpr_proxy_remove_subscription(subs[i]))) {
ORTE_ERROR_LOG(rc);
OPAL_THREAD_UNLOCK(&orte_gpr_proxy_globals.mutex);
return rc;
}
goto PROCESS;
}
}
}
/* must not have been found - report error */
ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND);
return ORTE_ERR_NOT_FOUND;
PROCESS:
/* if in compound cmd mode, then just pack the command into
* that buffer and return
*/
@ -198,7 +217,7 @@ int orte_gpr_proxy_unsubscribe(orte_gpr_subscription_id_t sub_number)
sub_number))) {
ORTE_ERROR_LOG(rc);
}
OPAL_THREAD_UNLOCK(&orte_gpr_proxy_globals.mutex);
return rc;
}
@ -212,7 +231,7 @@ int orte_gpr_proxy_unsubscribe(orte_gpr_subscription_id_t sub_number)
OPAL_THREAD_UNLOCK(&orte_gpr_proxy_globals.mutex);
return ORTE_ERR_OUT_OF_RESOURCE;
}
/* pack and transmit the command */
if (ORTE_SUCCESS != (rc = orte_gpr_base_pack_unsubscribe(cmd, sub_number))) {
ORTE_ERROR_LOG(rc);
@ -225,10 +244,10 @@ int orte_gpr_proxy_unsubscribe(orte_gpr_subscription_id_t sub_number)
ORTE_ERROR_LOG(ORTE_ERR_COMM_FAILURE);
OBJ_RELEASE(cmd);
OPAL_THREAD_UNLOCK(&orte_gpr_proxy_globals.mutex);
return ORTE_ERR_COMM_FAILURE;
return ORTE_ERR_COMM_FAILURE;
}
OBJ_RELEASE(cmd);
/* init a buffer to receive the replica's reply */
answer = OBJ_NEW(orte_buffer_t);
if (NULL == answer) {
@ -236,10 +255,10 @@ int orte_gpr_proxy_unsubscribe(orte_gpr_subscription_id_t sub_number)
OPAL_THREAD_UNLOCK(&orte_gpr_proxy_globals.mutex);
return ORTE_ERR_OUT_OF_RESOURCE;
}
if (0 > orte_rml.recv_buffer(orte_process_info.gpr_replica, answer, ORTE_RML_TAG_GPR)) {
ORTE_ERROR_LOG(ORTE_ERR_COMM_FAILURE);
OBJ_RELEASE(answer);
OBJ_RELEASE(answer);
OPAL_THREAD_UNLOCK(&orte_gpr_proxy_globals.mutex);
return ORTE_ERR_COMM_FAILURE;
}
@ -252,14 +271,14 @@ int orte_gpr_proxy_unsubscribe(orte_gpr_subscription_id_t sub_number)
*/
if (ORTE_SUCCESS != (rc = orte_gpr_base_unpack_unsubscribe(answer, &ret))) {
ORTE_ERROR_LOG(rc);
OBJ_RELEASE(answer);
OBJ_RELEASE(answer);
OPAL_THREAD_UNLOCK(&orte_gpr_proxy_globals.mutex);
return rc;
}
OBJ_RELEASE(answer);
OPAL_THREAD_UNLOCK(&orte_gpr_proxy_globals.mutex);
return ret;
return ret;
}
@ -267,17 +286,33 @@ int orte_gpr_proxy_cancel_trigger(orte_gpr_trigger_id_t trig)
{
orte_buffer_t *cmd;
orte_buffer_t *answer;
orte_gpr_proxy_trigger_t **trigs;
size_t i, j;
int rc, ret;
OPAL_THREAD_LOCK(&orte_gpr_proxy_globals.mutex);
/* remove the specified trigger from the local tracker */
if (ORTE_SUCCESS != (rc = orte_gpr_proxy_remove_trigger(trig))) {
ORTE_ERROR_LOG(rc);
OPAL_THREAD_UNLOCK(&orte_gpr_proxy_globals.mutex);
return rc;
trigs = (orte_gpr_proxy_trigger_t**)(orte_gpr_proxy_globals.triggers)->addr;
for (i=0, j=0; j < orte_gpr_proxy_globals.num_trigs &&
i < (orte_gpr_proxy_globals.triggers)->size; i++) {
if (NULL != trigs[i]){
j++;
if (trig == trigs[i]->id) {
if (ORTE_SUCCESS != (rc = orte_gpr_proxy_remove_trigger(trigs[i]))) {
ORTE_ERROR_LOG(rc);
OPAL_THREAD_UNLOCK(&orte_gpr_proxy_globals.mutex);
return rc;
}
goto PROCESS;
}
}
}
/* must not have been found - report error */
ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND);
return ORTE_ERR_NOT_FOUND;
PROCESS:
/* if the compound cmd mode is on, pack the command into that buffer
* and return
*/
@ -286,7 +321,7 @@ int orte_gpr_proxy_cancel_trigger(orte_gpr_trigger_id_t trig)
orte_gpr_proxy_globals.compound_cmd, trig))) {
ORTE_ERROR_LOG(rc);
}
OPAL_THREAD_UNLOCK(&orte_gpr_proxy_globals.mutex);
return rc;
}
@ -300,7 +335,7 @@ int orte_gpr_proxy_cancel_trigger(orte_gpr_trigger_id_t trig)
OPAL_THREAD_UNLOCK(&orte_gpr_proxy_globals.mutex);
return ORTE_ERR_OUT_OF_RESOURCE;
}
/* pack the trigger number and transmit the command */
if (ORTE_SUCCESS != (rc = orte_gpr_base_pack_cancel_trigger(cmd, trig))) {
ORTE_ERROR_LOG(rc);
@ -316,7 +351,7 @@ int orte_gpr_proxy_cancel_trigger(orte_gpr_trigger_id_t trig)
return ORTE_ERR_COMM_FAILURE;
}
OBJ_RELEASE(cmd);
/* init a buffer to receive the replica's response */
answer = OBJ_NEW(orte_buffer_t);
if (NULL == answer) {
@ -324,7 +359,7 @@ int orte_gpr_proxy_cancel_trigger(orte_gpr_trigger_id_t trig)
OPAL_THREAD_UNLOCK(&orte_gpr_proxy_globals.mutex);
return ORTE_ERR_OUT_OF_RESOURCE;
}
if (0 > orte_rml.recv_buffer(orte_process_info.gpr_replica, answer, ORTE_RML_TAG_GPR)) {
ORTE_ERROR_LOG(ORTE_ERR_COMM_FAILURE);
OBJ_RELEASE(answer);

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

@ -18,13 +18,14 @@ include $(top_ompi_srcdir)/config/Makefile.options
noinst_LTLIBRARIES = libmca_gpr_replica_api.la
libmca_gpr_replica_api_la_SOURCES = \
gpr_replica_api.h \
gpr_replica_segment_ops_api.c \
gpr_replica_cleanup_api.c \
gpr_replica_compound_cmd_api.c \
gpr_replica_del_index_api.c \
gpr_replica_dump_api.c \
gpr_replica_dump_local_trigs_subs_api.c \
gpr_replica_arithmetic_ops_api.c \
gpr_replica_put_get_api.c \
gpr_replica_subscribe_api.c
gpr_replica_api.h \
gpr_replica_segment_ops_api.c \
gpr_replica_cleanup_api.c \
gpr_replica_compound_cmd_api.c \
gpr_replica_del_index_api.c \
gpr_replica_deliver_notify_msg_api.c \
gpr_replica_dump_api.c \
gpr_replica_dump_local_trigs_subs_api.c \
gpr_replica_arithmetic_ops_api.c \
gpr_replica_put_get_api.c \
gpr_replica_subscribe_api.c

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

@ -129,9 +129,19 @@ int orte_gpr_replica_dump_all(int output_id);
int orte_gpr_replica_dump_segments(char *segment, int output_id);
int orte_gpr_replica_dump_triggers(int output_id);
int orte_gpr_replica_dump_triggers(orte_gpr_trigger_id_t start, int output_id);
int orte_gpr_replica_dump_subscriptions(int output_id);
int orte_gpr_replica_dump_subscriptions(orte_gpr_subscription_id_t start, int output_id);
int orte_gpr_replica_dump_a_trigger(
char *name,
orte_gpr_trigger_id_t id,
int output_id);
int orte_gpr_replica_dump_a_subscription(
char *name,
orte_gpr_subscription_id_t id,
int output_id);
int orte_gpr_replica_dump_local_triggers(int output_id);
@ -150,6 +160,8 @@ int orte_gpr_replica_dump_value(orte_gpr_value_t *value, int output_id);
*/
int orte_gpr_replica_preallocate_segment(char *name, size_t num_slots);
int orte_gpr_replica_deliver_notify_msg(orte_gpr_notify_message_t *msg);
#if defined(c_plusplus) || defined(__cplusplus)
}
#endif

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

@ -4,14 +4,14 @@
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
*
* Additional copyrights may follow
*
*
* $HEADER$
*/
/** @file:
@ -35,16 +35,15 @@ int orte_gpr_replica_deliver_notify_msg(orte_gpr_notify_message_t *msg)
orte_gpr_notify_data_t **data;
orte_gpr_replica_local_trigger_t **local_trigs;
orte_gpr_replica_local_subscriber_t **local_subs, *sub;
size_t i, j, k;
size_t i, j, k, n;
int rc;
bool processed;
/* we first have to check the trigger id in the message. If that
* field is set to a valid value (i.e., one other than
* ORTE_GPR_TRIGGER_ID_MAX), then the message is intended to be
/* we first have to check if the message is a trigger message - if so,
* then the message is intended to be
* sent as a single block to that trigger's callback function.
*/
if (ORTE_GPR_TRIGGER_ID_MAX > msg->id) {
if (ORTE_GPR_TRIGGER_MSG == msg->msg_type) {
/* use the local trigger callback */
local_trigs = (orte_gpr_replica_local_trigger_t**)
(orte_gpr_replica_globals.local_triggers)->addr;
@ -68,54 +67,73 @@ int orte_gpr_replica_deliver_notify_msg(orte_gpr_notify_message_t *msg)
}
return ORTE_SUCCESS;
}
/* get here if the trigger id indicated that this was NOT
* intended for a trigger callback - i.e., the message should
/* get here if this wasn't a trigger message. Only other allowed message type
* is a subscription message - if that isn't the case, then we have corrupt
* data, so flag it and return
*/
if (ORTE_GPR_SUBSCRIPTION_MSG != msg->msg_type) {
ORTE_ERROR_LOG(ORTE_ERR_GPR_DATA_CORRUPT);
return ORTE_ERR_GPR_DATA_CORRUPT;
}
/* get here if we have a subscription message - i.e., the message should
* be broken into its component parts and delivered separately
* to the indicated subscribers
*/
data = (orte_gpr_notify_data_t**)(msg->data)->addr;
for (i=0; i < msg->cnt; i++) {
/* for each datagram in the message, we need to lookup
* the associated subscription (could be specified by name or id) to find the correct
* callback function. Name specifications are given precedence over id.
*/
local_subs = (orte_gpr_replica_local_subscriber_t**)
(orte_gpr_replica_globals.local_subscriptions)->addr;
processed = false;
for (j=0, k=0; !processed &&
k < orte_gpr_replica_globals.num_local_subs &&
j < (orte_gpr_replica_globals.local_subscriptions)->size; j++) {
if (NULL != local_subs[j]) {
k++;
if ((NULL != local_subs[j]->name &&
NULL != data[i]->target &&
0 == strcmp(data[i]->target, local_subs[j]->name)) ||
(data[i]->id == local_subs[j]->id)) {
sub = local_subs[j];
processed = true;
for (i=0, n=0; n < msg->cnt &&
i < (msg->data)->size; i++) {
if (NULL != data[i]) {
n++;
if (ORTE_GPR_SUBSCRIPTION_ID_MAX != data[i]->id || NULL != data[i]->target) {
/* for each datagram in the message, we need to lookup
* the associated subscription (could be specified by name or id) to find the correct
* callback function. Name specifications are given precedence over id.
*/
local_subs = (orte_gpr_replica_local_subscriber_t**)
(orte_gpr_replica_globals.local_subscriptions)->addr;
processed = false;
for (j=0, k=0; !processed &&
k < orte_gpr_replica_globals.num_local_subs &&
j < (orte_gpr_replica_globals.local_subscriptions)->size; j++) {
if (NULL != local_subs[j]) {
k++;
if (NULL != data[i]->target) {
/* if target name provided, must use it */
if (NULL != local_subs[j]->name &&
0 == strcmp(data[i]->target, local_subs[j]->name)) {
sub = local_subs[j];
processed = true;
}
} else if (data[i]->id == local_subs[j]->id) {
/* otherwise, see if id's match */
sub = local_subs[j];
processed = true;
}
}
}
/* get here and not processed => not found, abort */
if (!processed) {
ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND);
return ORTE_ERR_NOT_FOUND;
}
OPAL_THREAD_UNLOCK(&orte_gpr_replica_globals.mutex);
sub->callback(data[i], sub->user_tag);
OPAL_THREAD_LOCK(&orte_gpr_replica_globals.mutex);
if (data[i]->remove) {
if (ORTE_SUCCESS != (rc = orte_gpr_replica_remove_local_subscription(sub))) {
ORTE_ERROR_LOG(rc);
return rc;
}
}
}
}
/* get here and not processed => not found, abort */
if (!processed) {
ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND);
return ORTE_ERR_NOT_FOUND;
}
OPAL_THREAD_UNLOCK(&orte_gpr_replica_globals.mutex);
sub->callback(data[i], sub->user_tag);
OPAL_THREAD_LOCK(&orte_gpr_replica_globals.mutex);
if (data[i]->remove) {
if (ORTE_SUCCESS != (rc = orte_gpr_replica_remove_local_subscription(sub))) {
ORTE_ERROR_LOG(rc);
return rc;
}
}
}
/* the calling program will release the message object */
return ORTE_SUCCESS;
}

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

@ -98,7 +98,7 @@ int orte_gpr_replica_dump_segments(char *segment, int output_id)
return rc;
}
int orte_gpr_replica_dump_triggers(int output_id)
int orte_gpr_replica_dump_triggers(orte_gpr_trigger_id_t start, int output_id)
{
orte_buffer_t *buffer;
int rc;
@ -116,7 +116,7 @@ int orte_gpr_replica_dump_triggers(int output_id)
return ORTE_ERR_OUT_OF_RESOURCE;
}
if (ORTE_SUCCESS != (rc = orte_gpr_replica_dump_triggers_fn(buffer))) {
if (ORTE_SUCCESS != (rc = orte_gpr_replica_dump_triggers_fn(buffer, start))) {
ORTE_ERROR_LOG(rc);
}
@ -130,7 +130,7 @@ int orte_gpr_replica_dump_triggers(int output_id)
return rc;
}
int orte_gpr_replica_dump_subscriptions(int output_id)
int orte_gpr_replica_dump_subscriptions(orte_gpr_subscription_id_t start, int output_id)
{
orte_buffer_t *buffer;
int rc;
@ -143,7 +143,7 @@ int orte_gpr_replica_dump_subscriptions(int output_id)
return ORTE_ERR_OUT_OF_RESOURCE;
}
if (ORTE_SUCCESS != (rc = orte_gpr_replica_dump_subscriptions_fn(buffer))) {
if (ORTE_SUCCESS != (rc = orte_gpr_replica_dump_subscriptions_fn(buffer, start))) {
ORTE_ERROR_LOG(rc);
}
@ -157,6 +157,133 @@ int orte_gpr_replica_dump_subscriptions(int output_id)
return rc;
}
int orte_gpr_replica_dump_a_trigger(
char *name,
orte_gpr_trigger_id_t id,
int output_id)
{
orte_buffer_t buffer;
orte_gpr_replica_trigger_t **trigs;
size_t i, j;
int rc;
OPAL_THREAD_LOCK(&orte_gpr_replica_globals.mutex);
OBJ_CONSTRUCT(&buffer, orte_buffer_t);
if (NULL == name) { /* dump the trigger corresponding to the provided id */
trigs = (orte_gpr_replica_trigger_t**)(orte_gpr_replica.triggers)->addr;
for (i=0, j=0; j < orte_gpr_replica.num_trigs &&
i < (orte_gpr_replica.triggers)->size; i++) {
if (NULL != trigs[i]) {
j++;
if (id == trigs[i]->index) {
if (ORTE_SUCCESS != (rc = orte_gpr_replica_dump_trigger(&buffer, trigs[i]))) {
ORTE_ERROR_LOG(rc);
}
goto PROCESS;
}
}
}
ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND);
OBJ_DESTRUCT(&buffer);
OPAL_THREAD_UNLOCK(&orte_gpr_replica_globals.mutex);
return ORTE_ERR_NOT_FOUND;
} else { /* dump the named trigger */
trigs = (orte_gpr_replica_trigger_t**)(orte_gpr_replica.triggers)->addr;
for (i=0, j=0; j < orte_gpr_replica.num_trigs &&
i < (orte_gpr_replica.triggers)->size; i++) {
if (NULL != trigs[i]) {
j++;
if (0 == strcmp(name, trigs[i]->name)) {
if (ORTE_SUCCESS != (rc = orte_gpr_replica_dump_trigger(&buffer, trigs[i]))) {
ORTE_ERROR_LOG(rc);
}
goto PROCESS;
}
}
}
ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND);
OBJ_DESTRUCT(&buffer);
OPAL_THREAD_UNLOCK(&orte_gpr_replica_globals.mutex);
return ORTE_ERR_NOT_FOUND;
}
PROCESS:
if (ORTE_SUCCESS == rc) {
orte_gpr_base_print_dump(&buffer, output_id);
}
OBJ_DESTRUCT(&buffer);
OPAL_THREAD_UNLOCK(&orte_gpr_replica_globals.mutex);
return rc;
}
int orte_gpr_replica_dump_a_subscription(char *name,
orte_gpr_subscription_id_t id,
int output_id)
{
orte_buffer_t buffer;
orte_gpr_replica_subscription_t **subs;
size_t i, j;
int rc;
OPAL_THREAD_LOCK(&orte_gpr_replica_globals.mutex);
OBJ_CONSTRUCT(&buffer, orte_buffer_t);
if (NULL == name) { /* dump the subscription corresponding to the provided id */
subs = (orte_gpr_replica_subscription_t**)(orte_gpr_replica.subscriptions)->addr;
for (i=0, j=0; j < orte_gpr_replica.num_subs &&
i < (orte_gpr_replica.subscriptions)->size; i++) {
if (NULL != subs[i]) {
j++;
if (id == subs[i]->index) {
if (ORTE_SUCCESS != (rc = orte_gpr_replica_dump_subscription(&buffer, subs[i]))) {
ORTE_ERROR_LOG(rc);
}
goto PROCESS;
}
}
}
ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND);
OBJ_DESTRUCT(&buffer);
OPAL_THREAD_UNLOCK(&orte_gpr_replica_globals.mutex);
return ORTE_ERR_NOT_FOUND;
} else { /* dump the named subscription */
subs = (orte_gpr_replica_subscription_t**)(orte_gpr_replica.subscriptions)->addr;
for (i=0, j=0; j < orte_gpr_replica.num_subs &&
i < (orte_gpr_replica.subscriptions)->size; i++) {
if (NULL != subs[i]) {
j++;
if (0 == strcmp(name, subs[i]->name)) {
if (ORTE_SUCCESS != (rc = orte_gpr_replica_dump_subscription(&buffer, subs[i]))) {
ORTE_ERROR_LOG(rc);
}
goto PROCESS;
}
}
}
ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND);
OBJ_DESTRUCT(&buffer);
OPAL_THREAD_UNLOCK(&orte_gpr_replica_globals.mutex);
return ORTE_ERR_NOT_FOUND;
}
PROCESS:
if (ORTE_SUCCESS == rc) {
orte_gpr_base_print_dump(&buffer, output_id);
}
OBJ_DESTRUCT(&buffer);
OPAL_THREAD_UNLOCK(&orte_gpr_replica_globals.mutex);
return rc;
}
int orte_gpr_replica_dump_callbacks(int output_id)
{
orte_buffer_t *buffer;

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

@ -53,6 +53,11 @@ int orte_gpr_replica_dump_local_triggers(int output_id)
} else {
opal_output(output_id, "\ttrigger name: %s", trigs[j]->name);
}
if (NULL == trigs[j]->callback) {
opal_output(output_id, "\tNULL callback");
} else {
opal_output(output_id, "\tCallback %0x", trigs[j]->callback);
}
}
}
return ORTE_SUCCESS;
@ -78,7 +83,11 @@ int orte_gpr_replica_dump_local_subscriptions(int output_id)
} else {
opal_output(output_id, "\tsubscription name: %s", subs[j]->name);
}
}
if (NULL == subs[j]->callback) {
opal_output(output_id, "\tNULL callback");
} else {
opal_output(output_id, "\tCallback %0x", subs[j]->callback);
} }
}
return ORTE_SUCCESS;
}

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

@ -3,14 +3,14 @@
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
*
* Additional copyrights may follow
*
*
* $HEADER$
*/
/** @file:
@ -25,10 +25,10 @@
#include "orte_config.h"
#include "dps/dps.h"
#include "orte/dps/dps.h"
#include "mca/ns/ns.h"
#include "mca/errmgr/errmgr.h"
#include "orte/mca/ns/ns.h"
#include "orte/mca/errmgr/errmgr.h"
#include "gpr_replica_api.h"
@ -43,7 +43,7 @@ orte_gpr_replica_subscribe(size_t num_subs,
/* protect against errors */
if (NULL == subscriptions && NULL == trigs) { /* need at least one */
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
return ORTE_ERR_BAD_PARAM;
return ORTE_ERR_BAD_PARAM;
}
OPAL_THREAD_LOCK(&orte_gpr_replica_globals.mutex);
@ -90,7 +90,7 @@ orte_gpr_replica_subscribe(size_t num_subs,
}
rc = orte_gpr_replica_process_callbacks();
OPAL_THREAD_UNLOCK(&orte_gpr_replica_globals.mutex);
return rc;
@ -99,11 +99,31 @@ orte_gpr_replica_subscribe(size_t num_subs,
int orte_gpr_replica_unsubscribe(orte_gpr_subscription_id_t sub_number)
{
orte_gpr_replica_local_subscriber_t **subs;
size_t i, j;
int rc;
OPAL_THREAD_LOCK(&orte_gpr_replica_globals.mutex);
rc = orte_gpr_replica_remove_subscription(NULL, sub_number);
if (ORTE_SUCCESS != (rc = orte_gpr_replica_remove_subscription(NULL, sub_number))) {
ORTE_ERROR_LOG(rc);
}
if (ORTE_SUCCESS == rc) {
/* find and remove it from the local subscription tracking system */
subs = (orte_gpr_replica_local_subscriber_t**)(orte_gpr_replica_globals.local_subscriptions)->addr;
for (i=0, j=0; j < orte_gpr_replica_globals.num_local_subs &&
i < (orte_gpr_replica_globals.local_subscriptions)->size; i++) {
if (NULL != subs[i]) {
j++;
if (sub_number == subs[i]->id) {
if (ORTE_SUCCESS != (rc = orte_gpr_replica_remove_local_subscription(subs[i]))) {
ORTE_ERROR_LOG(rc);
}
}
}
}
}
OPAL_THREAD_UNLOCK(&orte_gpr_replica_globals.mutex);
@ -113,12 +133,30 @@ int orte_gpr_replica_unsubscribe(orte_gpr_subscription_id_t sub_number)
int orte_gpr_replica_cancel_trigger(orte_gpr_trigger_id_t trig)
{
orte_gpr_replica_local_trigger_t **trigs;
size_t i, j;
int rc;
OPAL_THREAD_LOCK(&orte_gpr_replica_globals.mutex);
rc = orte_gpr_replica_remove_trigger(NULL, trig);
if (ORTE_SUCCESS == rc) {
/* find and remove it from the local trigger tracking system */
trigs = (orte_gpr_replica_local_trigger_t**)(orte_gpr_replica_globals.local_triggers)->addr;
for (i=0, j=0; j < orte_gpr_replica_globals.num_local_trigs &&
i < (orte_gpr_replica_globals.local_triggers)->size; i++) {
if (NULL != trigs[i]) {
j++;
if (trig == trigs[i]->id) {
if (ORTE_SUCCESS != (rc = orte_gpr_replica_remove_local_trigger(trigs[i]))) {
ORTE_ERROR_LOG(rc);
}
}
}
}
}
OPAL_THREAD_UNLOCK(&orte_gpr_replica_globals.mutex);
return rc;

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

@ -218,7 +218,7 @@ int orte_gpr_replica_process_command_buffer(orte_buffer_t *input_buffer,
opal_output(0, "\tdump triggers cmd");
}
if (ORTE_SUCCESS != (ret = orte_gpr_replica_recv_dump_triggers_cmd(answer))) {
if (ORTE_SUCCESS != (ret = orte_gpr_replica_recv_dump_triggers_cmd(input_buffer, answer))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
@ -232,7 +232,7 @@ int orte_gpr_replica_process_command_buffer(orte_buffer_t *input_buffer,
opal_output(0, "\tdump subscriptions cmd");
}
if (ORTE_SUCCESS != (ret = orte_gpr_replica_recv_dump_subscriptions_cmd(answer))) {
if (ORTE_SUCCESS != (ret = orte_gpr_replica_recv_dump_subscriptions_cmd(input_buffer, answer))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
@ -240,6 +240,32 @@ int orte_gpr_replica_process_command_buffer(orte_buffer_t *input_buffer,
case ORTE_GPR_DUMP_A_TRIGGER_CMD: /***** DUMP *****/
if (orte_gpr_replica_globals.debug) {
opal_output(0, "\tdump a trigger cmd");
}
if (ORTE_SUCCESS != (ret = orte_gpr_replica_recv_dump_a_trigger_cmd(input_buffer, answer))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
break;
case ORTE_GPR_DUMP_A_SUBSCRIPTION_CMD: /***** DUMP *****/
if (orte_gpr_replica_globals.debug) {
opal_output(0, "\tdump a subscription cmd");
}
if (ORTE_SUCCESS != (ret = orte_gpr_replica_recv_dump_a_subscription_cmd(input_buffer, answer))) {
ORTE_ERROR_LOG(ret);
goto RETURN_ERROR;
}
break;
case ORTE_GPR_DUMP_CALLBACKS_CMD: /***** DUMP *****/
if (orte_gpr_replica_globals.debug) {

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

@ -111,9 +111,17 @@ int orte_gpr_replica_recv_dump_all_cmd(orte_buffer_t *answer);
int orte_gpr_replica_recv_dump_segments_cmd(orte_buffer_t *input_buffer, orte_buffer_t *answer);
int orte_gpr_replica_recv_dump_triggers_cmd(orte_buffer_t *answer);
int orte_gpr_replica_recv_dump_triggers_cmd(orte_buffer_t *input_buffer,
orte_buffer_t *answer);
int orte_gpr_replica_recv_dump_subscriptions_cmd(orte_buffer_t *answer);
int orte_gpr_replica_recv_dump_subscriptions_cmd(orte_buffer_t *input_buffer,
orte_buffer_t *answer);
int orte_gpr_replica_recv_dump_a_trigger_cmd(orte_buffer_t *input_buffer,
orte_buffer_t *answer);
int orte_gpr_replica_recv_dump_a_subscription_cmd(orte_buffer_t *input_buffer,
orte_buffer_t *answer);
int orte_gpr_replica_recv_dump_callbacks_cmd(orte_buffer_t *answer);

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

@ -74,9 +74,12 @@ int orte_gpr_replica_recv_dump_segments_cmd(orte_buffer_t *input_buffer, orte_bu
return rc;
}
int orte_gpr_replica_recv_dump_triggers_cmd(orte_buffer_t *answer)
int orte_gpr_replica_recv_dump_triggers_cmd(orte_buffer_t *input_buffer,
orte_buffer_t *answer)
{
orte_gpr_cmd_flag_t command=ORTE_GPR_DUMP_TRIGGERS_CMD;
orte_gpr_trigger_id_t start;
size_t n;
int rc;
if (ORTE_SUCCESS != (rc = orte_dps.pack(answer, &command, 1, ORTE_GPR_CMD))) {
@ -84,7 +87,13 @@ int orte_gpr_replica_recv_dump_triggers_cmd(orte_buffer_t *answer)
return rc;
}
rc = orte_gpr_replica_dump_triggers_fn(answer);
n=1;
if (ORTE_SUCCESS != (rc = orte_dps.unpack(input_buffer, &start, &n, ORTE_GPR_TRIGGER_ID))) {
ORTE_ERROR_LOG(rc);
return rc;
}
rc = orte_gpr_replica_dump_triggers_fn(answer, start);
if (ORTE_SUCCESS != rc) {
ORTE_ERROR_LOG(rc);
@ -92,9 +101,12 @@ int orte_gpr_replica_recv_dump_triggers_cmd(orte_buffer_t *answer)
return rc;
}
int orte_gpr_replica_recv_dump_subscriptions_cmd(orte_buffer_t *answer)
int orte_gpr_replica_recv_dump_subscriptions_cmd(orte_buffer_t *input_buffer,
orte_buffer_t *answer)
{
orte_gpr_cmd_flag_t command=ORTE_GPR_DUMP_SUBSCRIPTIONS_CMD;
orte_gpr_subscription_id_t start;
size_t n;
int rc;
if (ORTE_SUCCESS != (rc = orte_dps.pack(answer, &command, 1, ORTE_GPR_CMD))) {
@ -102,7 +114,13 @@ int orte_gpr_replica_recv_dump_subscriptions_cmd(orte_buffer_t *answer)
return rc;
}
rc = orte_gpr_replica_dump_subscriptions_fn(answer);
n=1;
if (ORTE_SUCCESS != (rc = orte_dps.unpack(input_buffer, &start, &n, ORTE_GPR_SUBSCRIPTION_ID))) {
ORTE_ERROR_LOG(rc);
return rc;
}
rc = orte_gpr_replica_dump_subscriptions_fn(answer, start);
if (ORTE_SUCCESS != rc) {
ORTE_ERROR_LOG(rc);
@ -110,6 +128,135 @@ int orte_gpr_replica_recv_dump_subscriptions_cmd(orte_buffer_t *answer)
return rc;
}
int orte_gpr_replica_recv_dump_a_trigger_cmd(orte_buffer_t *input_buffer,
orte_buffer_t *answer)
{
orte_gpr_cmd_flag_t command=ORTE_GPR_DUMP_A_TRIGGER_CMD;
char *name;
orte_gpr_trigger_id_t id;
orte_gpr_replica_trigger_t **trigs;
size_t n, i, j;
int rc;
if (ORTE_SUCCESS != (rc = orte_dps.pack(answer, &command, 1, ORTE_GPR_CMD))) {
ORTE_ERROR_LOG(rc);
return rc;
}
n=1;
if (ORTE_SUCCESS != (rc = orte_dps.unpack(input_buffer, &name, &n, ORTE_STRING))) {
ORTE_ERROR_LOG(rc);
return rc;
}
n=1;
if (ORTE_SUCCESS != (rc = orte_dps.unpack(input_buffer, &id, &n, ORTE_GPR_TRIGGER_ID))) {
ORTE_ERROR_LOG(rc);
return rc;
}
if (NULL == name) { /* dump the trigger corresponding to the provided id */
trigs = (orte_gpr_replica_trigger_t**)(orte_gpr_replica.triggers)->addr;
for (i=0, j=0; j < orte_gpr_replica.num_trigs &&
i < (orte_gpr_replica.triggers)->size; i++) {
if (NULL != trigs[i]) {
j++;
if (id == trigs[i]->index) {
if (ORTE_SUCCESS != (rc = orte_gpr_replica_dump_trigger(answer, trigs[i]))) {
ORTE_ERROR_LOG(rc);
}
return rc;
}
}
}
ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND);
return ORTE_ERR_NOT_FOUND;
} else { /* dump the named trigger */
trigs = (orte_gpr_replica_trigger_t**)(orte_gpr_replica.triggers)->addr;
for (i=0, j=0; j < orte_gpr_replica.num_trigs &&
i < (orte_gpr_replica.triggers)->size; i++) {
if (NULL != trigs[i]) {
j++;
if (0 == strcmp(name, trigs[i]->name)) {
if (ORTE_SUCCESS != (rc = orte_gpr_replica_dump_trigger(answer, trigs[i]))) {
ORTE_ERROR_LOG(rc);
}
return rc;
}
}
}
ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND);
}
return rc;
}
int orte_gpr_replica_recv_dump_a_subscription_cmd(orte_buffer_t *input_buffer,
orte_buffer_t *answer)
{
orte_gpr_cmd_flag_t command=ORTE_GPR_DUMP_A_SUBSCRIPTION_CMD;
orte_gpr_replica_subscription_t **subs;
orte_gpr_subscription_id_t id;
size_t n, i, j;
char *name;
int rc;
if (ORTE_SUCCESS != (rc = orte_dps.pack(answer, &command, 1, ORTE_GPR_CMD))) {
ORTE_ERROR_LOG(rc);
return rc;
}
n=1;
if (ORTE_SUCCESS != (rc = orte_dps.unpack(input_buffer, &name, &n, ORTE_STRING))) {
ORTE_ERROR_LOG(rc);
return rc;
}
n=1;
if (ORTE_SUCCESS != (rc = orte_dps.unpack(input_buffer, &id, &n, ORTE_GPR_SUBSCRIPTION_ID))) {
ORTE_ERROR_LOG(rc);
return rc;
}
if (NULL == name) { /* dump the subscription corresponding to the provided id */
subs = (orte_gpr_replica_subscription_t**)(orte_gpr_replica.subscriptions)->addr;
for (i=0, j=0; j < orte_gpr_replica.num_subs &&
i < (orte_gpr_replica.subscriptions)->size; i++) {
if (NULL != subs[i]) {
j++;
if (id == subs[i]->index) {
if (ORTE_SUCCESS != (rc = orte_gpr_replica_dump_subscription(answer, subs[i]))) {
ORTE_ERROR_LOG(rc);
}
return rc;
}
}
}
ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND);
return ORTE_ERR_NOT_FOUND;
} else { /* dump the named subscription */
subs = (orte_gpr_replica_subscription_t**)(orte_gpr_replica.subscriptions)->addr;
for (i=0, j=0; j < orte_gpr_replica.num_subs &&
i < (orte_gpr_replica.subscriptions)->size; i++) {
if (NULL != subs[i]) {
j++;
if (0 == strcmp(name, subs[i]->name)) {
if (ORTE_SUCCESS != (rc = orte_gpr_replica_dump_subscription(answer, subs[i]))) {
ORTE_ERROR_LOG(rc);
}
free(name);
return rc;
}
}
}
ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND);
}
return rc;
}
int orte_gpr_replica_recv_dump_callbacks_cmd(orte_buffer_t *answer)
{
orte_gpr_cmd_flag_t command=ORTE_GPR_DUMP_CALLBACKS_CMD;

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

@ -3,14 +3,14 @@
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
*
* Additional copyrights may follow
*
*
* $HEADER$
*/
/** @file:
@ -43,35 +43,30 @@ static void orte_gpr_replica_dump_load_string(orte_buffer_t *buffer, char **tmp)
void orte_gpr_replica_dump_itagval_value(orte_buffer_t *buffer,
orte_gpr_replica_itagval_t *iptr);
static void orte_gpr_replica_dump_trigger(orte_buffer_t *buffer, size_t cnt,
orte_gpr_replica_trigger_t *trig);
static void orte_gpr_replica_dump_subscription(orte_buffer_t *buffer,
orte_gpr_replica_subscription_t *sub);
int orte_gpr_replica_dump_all_fn(orte_buffer_t *buffer)
{
char tmp_out[80], *tmp;
int rc;
tmp = tmp_out;
sprintf(tmp_out, "\n\n\nDUMP OF GENERAL PURPOSE REGISTRY");
orte_gpr_replica_dump_load_string(buffer, &tmp);
if (ORTE_SUCCESS != (rc = orte_gpr_replica_dump_triggers_fn(buffer))) {
if (ORTE_SUCCESS != (rc = orte_gpr_replica_dump_triggers_fn(buffer, 0))) {
return rc;
}
if (ORTE_SUCCESS != (rc = orte_gpr_replica_dump_subscriptions_fn(buffer))) {
if (ORTE_SUCCESS != (rc = orte_gpr_replica_dump_subscriptions_fn(buffer, 0))) {
return rc;
}
if (ORTE_SUCCESS != (rc = orte_gpr_replica_dump_callbacks_fn(buffer))) {
return rc;
}
rc = orte_gpr_replica_dump_segments_fn(buffer, NULL);
return rc;
}
@ -96,7 +91,7 @@ int orte_gpr_replica_dump_segments_fn(orte_buffer_t *buffer, char *segment)
}
return ORTE_SUCCESS;
}
/* otherwise, dump just the one specified */
if (ORTE_SUCCESS != (rc = orte_gpr_replica_find_seg(&segptr, false, segment))) {
ORTE_ERROR_LOG(rc);
@ -108,9 +103,9 @@ int orte_gpr_replica_dump_segments_fn(orte_buffer_t *buffer, char *segment)
}
return ORTE_SUCCESS;
}
int orte_gpr_replica_dump_a_segment_fn(orte_buffer_t *buffer, orte_gpr_replica_segment_t *seg)
{
{
orte_gpr_replica_container_t **cptr;
orte_gpr_replica_itag_t *itaglist;
orte_gpr_replica_itagval_t **iptr;
@ -124,29 +119,29 @@ int orte_gpr_replica_dump_segments_fn(orte_buffer_t *buffer, char *segment)
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
sprintf(tmp_out, "\nDUMP OF GPR SEGMENT %s", seg->name);
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
num_objects = (seg->containers)->size - (seg->containers)->number_free;
sprintf(tmp_out, "\tNumber of containers: %lu\n",
sprintf(tmp_out, "\tNumber of containers: %lu\n",
(unsigned long) num_objects);
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
/* loop through all containers and print their info and contents */
cptr = (orte_gpr_replica_container_t**)(seg->containers)->addr;
for (j=0, n=0; n < seg->num_containers &&
j < (seg->containers)->size; j++) {
if (NULL != cptr[j]) {
n++;
sprintf(tmp_out, "\n\tInfo for container %lu"
sprintf(tmp_out, "\n\tInfo for container %lu"
"\tNumber of keyvals: %lu"
"\n\tTokens:\n",
(unsigned long) j,
(unsigned long) j,
((unsigned long) (cptr[j]->itagvals)->size - (cptr[j]->itagvals)->number_free));
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
/* reverse lookup tokens and print them */
itaglist = cptr[j]->itags;
for (k=0; k < cptr[j]->num_itags; k++) {
@ -154,20 +149,20 @@ int orte_gpr_replica_dump_segments_fn(orte_buffer_t *buffer, char *segment)
&token, seg, itaglist[k])) {
sprintf(tmp_out, "\t\titag num %lu"
": No entry found for itag %lu",
(unsigned long) k,
(unsigned long) k,
(unsigned long) itaglist[k]);
} else {
sprintf(tmp_out, "\t\titag num %lu: itag %lu\tToken: %s",
(unsigned long) k,
(unsigned long) k,
(unsigned long) itaglist[k], token);
free(token);
}
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
}
sprintf(tmp_out, "\n\tKeyval info:");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
/* loop through all itagvals and print their info */
iptr = (orte_gpr_replica_itagval_t**)(cptr[j]->itagvals)->addr;
for (k=0, p=0; p < cptr[j]->num_itagvals &&
@ -177,11 +172,11 @@ int orte_gpr_replica_dump_segments_fn(orte_buffer_t *buffer, char *segment)
if (ORTE_SUCCESS != orte_gpr_replica_dict_reverse_lookup(
&token, seg, iptr[k]->itag)) {
sprintf(tmp_out, "\n\t\titag num %lu: No entry found for itag %lu",
(unsigned long) k,
(unsigned long) k,
(unsigned long) iptr[k]->itag);
} else {
sprintf(tmp_out, "\n\t\tEntry %lu: itag %lu\tKey: %s",
(unsigned long) k,
(unsigned long) k,
(unsigned long) iptr[k]->itag, token);
free(token);
}
@ -191,7 +186,7 @@ int orte_gpr_replica_dump_segments_fn(orte_buffer_t *buffer, char *segment)
}
}
}
free(tmp_out);
return ORTE_SUCCESS;
}
@ -204,13 +199,13 @@ int orte_gpr_replica_dump_callbacks_fn(orte_buffer_t *buffer)
orte_gpr_replica_itag_t *itaglist;
char *tmp_out, *token;
size_t i, j, k;
tmp_out = (char*)malloc(1000);
if (NULL == tmp_out) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
sprintf(tmp_out, "\nDUMP OF GPR REGISTERED CALLBACKS\n");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
@ -218,16 +213,16 @@ int orte_gpr_replica_dump_callbacks_fn(orte_buffer_t *buffer)
sprintf(tmp_out, "--- None registered at this time ---");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
} else {
sprintf(tmp_out, "--- %lu callback(s) registered at this time",
sprintf(tmp_out, "--- %lu callback(s) registered at this time",
(unsigned long) k);
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
i=0;
for (cb = (orte_gpr_replica_callbacks_t*)opal_list_get_first(&(orte_gpr_replica.callbacks));
cb != (orte_gpr_replica_callbacks_t*)opal_list_get_end(&(orte_gpr_replica.callbacks));
cb = (orte_gpr_replica_callbacks_t*)opal_list_get_next(cb)) {
if (NULL == cb) {
sprintf(tmp_out, "\n\t--- BAD CALLBACK POINTER %lu ---",
sprintf(tmp_out, "\n\t--- BAD CALLBACK POINTER %lu ---",
(unsigned long) i);
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
return ORTE_SUCCESS;
@ -237,7 +232,7 @@ int orte_gpr_replica_dump_callbacks_fn(orte_buffer_t *buffer)
if (NULL == cb->requestor) {
sprintf(tmp_out, "Local requestor");
} else {
sprintf(tmp_out, "Requestor: [%lu,%lu,%lu]",
sprintf(tmp_out, "Requestor: [%lu,%lu,%lu]",
ORTE_NAME_ARGS(cb->requestor));
}
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
@ -245,14 +240,14 @@ int orte_gpr_replica_dump_callbacks_fn(orte_buffer_t *buffer)
i++;
}
}
sprintf(tmp_out, "\n");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
if (0 < orte_gpr_replica_globals.num_acted_upon) {
sprintf(tmp_out, "\nDUMP OF GPR ACTION RECORDS\n");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
action = (orte_gpr_replica_action_taken_t**)orte_gpr_replica_globals.acted_upon->addr;
for (i=0, j=0; j < orte_gpr_replica_globals.num_acted_upon &&
i < (orte_gpr_replica_globals.acted_upon)->size; i++) {
@ -268,7 +263,7 @@ int orte_gpr_replica_dump_callbacks_fn(orte_buffer_t *buffer)
if (NULL != action[i]->cptr) {
sprintf(tmp_out, "\tContainer Tokens:");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
/* reverse lookup tokens and print them */
itaglist = action[i]->cptr->itags;
for (k=0; k < action[i]->cptr->num_itags; k++) {
@ -276,11 +271,11 @@ int orte_gpr_replica_dump_callbacks_fn(orte_buffer_t *buffer)
&token, action[i]->seg, itaglist[k])) {
sprintf(tmp_out, "\t\titag num %lu"
": No entry found for itag %lu",
(unsigned long) k,
(unsigned long) k,
(unsigned long) itaglist[k]);
} else {
sprintf(tmp_out, "\t\titag num %lu: itag %lu\tToken: %s",
(unsigned long) k,
(unsigned long) k,
(unsigned long) itaglist[k], token);
free(token);
}
@ -298,7 +293,7 @@ int orte_gpr_replica_dump_callbacks_fn(orte_buffer_t *buffer)
if (ORTE_GPR_REPLICA_ENTRY_DELETED & action[i]->action) {
sprintf(tmp_out, "\n\tKeyval DELETED:");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
}
}
if (ORTE_GPR_REPLICA_ENTRY_CHANGED & action[i]->action) {
sprintf(tmp_out, "\n\tKeyval CHANGED");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
@ -311,7 +306,7 @@ int orte_gpr_replica_dump_callbacks_fn(orte_buffer_t *buffer)
sprintf(tmp_out, "\t\tKeyval CHANGED FROM:");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
}
if (ORTE_SUCCESS != orte_gpr_replica_dict_reverse_lookup(
&token, action[i]->seg, action[i]->iptr->itag)) {
sprintf(tmp_out, "\t\tNo entry found for itag %lu",
@ -333,18 +328,20 @@ int orte_gpr_replica_dump_callbacks_fn(orte_buffer_t *buffer)
sprintf(tmp_out, "\nNO GPR ACTION RECORDS STORED\n");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
}
free(tmp_out);
return ORTE_SUCCESS;
}
int orte_gpr_replica_dump_triggers_fn(orte_buffer_t *buffer)
int orte_gpr_replica_dump_triggers_fn(orte_buffer_t *buffer,
orte_gpr_trigger_id_t start)
{
orte_gpr_replica_trigger_t **trig;
char tmp_out[100], *tmp;
size_t j, k;
size_t j, k, m;
int rc;
tmp = tmp_out;
sprintf(tmp_out, "\nDUMP OF GPR TRIGGERS\n");
orte_gpr_replica_dump_load_string(buffer, &tmp);
@ -352,34 +349,45 @@ int orte_gpr_replica_dump_triggers_fn(orte_buffer_t *buffer)
trig = (orte_gpr_replica_trigger_t**)((orte_gpr_replica.triggers)->addr);
sprintf(tmp_out, "Number of triggers: %lu\n", (unsigned long) orte_gpr_replica.num_trigs);
orte_gpr_replica_dump_load_string(buffer, &tmp);
/* dump the trigger info for the registry */
if (0 == start) { /* dump the whole thing */
m = 0;
} else {
m = orte_gpr_replica.num_trigs - start;
}
for (j=0, k=0; k < orte_gpr_replica.num_trigs &&
j < (orte_gpr_replica.triggers)->size; j++) {
if (NULL != trig[j]) {
orte_gpr_replica_dump_trigger(buffer, k, trig[j]);
if (k >= m) {
if (ORTE_SUCCESS != (rc = orte_gpr_replica_dump_trigger(buffer, trig[j]))) {
ORTE_ERROR_LOG(rc);
return rc;
}
}
k++;
}
}
return ORTE_SUCCESS;
}
static void orte_gpr_replica_dump_trigger(orte_buffer_t *buffer, size_t cnt,
orte_gpr_replica_trigger_t *trig)
}
int orte_gpr_replica_dump_trigger(orte_buffer_t *buffer,
orte_gpr_replica_trigger_t *trig)
{
char *tmp_out, *token;
size_t i, j;
orte_gpr_replica_counter_t **cntr;
orte_gpr_replica_subscription_t **subs;
orte_gpr_replica_trigger_requestor_t **attached;
tmp_out = (char*)malloc(1000);
if (NULL == tmp_out) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return;
return ORTE_ERR_OUT_OF_RESOURCE;
}
sprintf(tmp_out, "\nData for trigger %lu", (unsigned long) trig->index);
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
@ -429,7 +437,7 @@ static void orte_gpr_replica_dump_trigger(orte_buffer_t *buffer, size_t cnt,
}
}
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
if (ORTE_GPR_TRIG_ONE_SHOT & trig->action) {
sprintf(tmp_out, "\tORTE_GPR_TRIG_ONE_SHOT");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
@ -456,7 +464,7 @@ static void orte_gpr_replica_dump_trigger(orte_buffer_t *buffer, size_t cnt,
if (0 < trig->num_counters) {
if (ORTE_GPR_TRIG_AT_LEVEL & trig->action) {
sprintf(tmp_out, "\tTrigger monitoring %lu counters for level",
sprintf(tmp_out, "\tTrigger monitoring %lu counters for level",
(unsigned long) trig->num_counters);
} else {
sprintf(tmp_out, "\tTrigger monitoring %lu counters for compare",
@ -470,7 +478,7 @@ static void orte_gpr_replica_dump_trigger(orte_buffer_t *buffer, size_t cnt,
ORTE_SUCCESS == orte_gpr_replica_dict_reverse_lookup(&token, cntr[i]->seg,
(cntr[i]->iptr)->itag)) {
j++;
sprintf(tmp_out, "\t\tCounter: %lu\tSegment: %s\tName: %s",
sprintf(tmp_out, "\t\tCounter: %lu\tSegment: %s\tName: %s",
(unsigned long) i, (cntr[i]->seg)->name, token);
free(token);
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
@ -485,7 +493,7 @@ static void orte_gpr_replica_dump_trigger(orte_buffer_t *buffer, size_t cnt,
}
}
}
if (0 < trig->num_subscriptions) {
sprintf(tmp_out, "\tTrigger has %lu subscriptions attached to it",
(unsigned long) trig->num_subscriptions);
@ -499,65 +507,78 @@ static void orte_gpr_replica_dump_trigger(orte_buffer_t *buffer, size_t cnt,
}
}
}
free(tmp_out);
return;
return ORTE_SUCCESS;
}
int orte_gpr_replica_dump_subscriptions_fn(orte_buffer_t *buffer)
int orte_gpr_replica_dump_subscriptions_fn(orte_buffer_t *buffer,
orte_gpr_subscription_id_t start)
{
char *tmp_out, *tmp;
size_t i, m;
size_t i, m, n;
orte_gpr_replica_subscription_t **subs;
int rc;
tmp_out = (char*)malloc(1000);
if (NULL == tmp_out) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
tmp = tmp_out;
sprintf(tmp_out, "\nDUMP OF GPR SUBSCRIPTIONS\n");
orte_gpr_replica_dump_load_string(buffer, &tmp);
subs = (orte_gpr_replica_subscription_t**)((orte_gpr_replica.subscriptions)->addr);
sprintf(tmp_out, "Number of subscriptions: %lu\n", (unsigned long) orte_gpr_replica.num_subs);
orte_gpr_replica_dump_load_string(buffer, &tmp);
/* dump the subscription info for the registry */
if (0 == start) { /* dump the whole thing */
n = 0;
} else {
n = orte_gpr_replica.num_subs - start;
}
for (i=0, m=0; m < orte_gpr_replica.num_subs &&
i < (orte_gpr_replica.subscriptions)->size; i++) {
if (NULL != subs[i]) {
if (m >= n) {
if (ORTE_SUCCESS != (rc = orte_gpr_replica_dump_subscription(buffer, subs[i]))) {
ORTE_ERROR_LOG(rc);
return rc;
}
}
m++;
orte_gpr_replica_dump_subscription(buffer, subs[i]);
}
}
free(tmp_out);
return ORTE_SUCCESS;
}
static void orte_gpr_replica_dump_subscription(orte_buffer_t *buffer,
orte_gpr_replica_subscription_t *sub)
int orte_gpr_replica_dump_subscription(orte_buffer_t *buffer,
orte_gpr_replica_subscription_t *sub)
{
char *tmp_out, *token, *tmp;
size_t j, k, n, p;
orte_gpr_replica_requestor_t **reqs;
orte_gpr_replica_ivalue_t **ivals;
tmp_out = (char*)malloc(1000);
if (NULL == tmp_out) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return;
return ORTE_ERR_OUT_OF_RESOURCE;
}
tmp = tmp_out;
if (NULL == sub->name) {
sprintf(tmp, "\nSubscription %lu: UNNAMED",
(unsigned long) sub->index);
sprintf(tmp, "\nSubscription %lu: UNNAMED idtag %lu",
(unsigned long) sub->index, (unsigned long) sub->idtag);
} else {
sprintf(tmp, "\nSubscription %lu name %s",
sprintf(tmp, "\nSubscription %lu: name %s idtag %lu",
(unsigned long) sub->index,
sub->name);
sub->name, (unsigned long) sub->idtag);
}
orte_gpr_replica_dump_load_string(buffer, &tmp);
@ -567,14 +588,14 @@ static void orte_gpr_replica_dump_subscription(orte_buffer_t *buffer,
sprintf(tmp_out, "\tSubscription INACTIVE");
}
orte_gpr_replica_dump_load_string(buffer, &tmp);
if (sub->cleanup) {
sprintf(tmp_out, "\tSubscription scheduled for cleanup");
} else {
sprintf(tmp_out, "\tSubscription NOT scheduled for cleanup");
}
orte_gpr_replica_dump_load_string(buffer, &tmp);
/* output recipient info */
sprintf(tmp_out, "\tList of requestors for this subscription:");
orte_gpr_replica_dump_load_string(buffer, &tmp);
@ -588,13 +609,13 @@ static void orte_gpr_replica_dump_subscription(orte_buffer_t *buffer,
(unsigned long) reqs[j]->idtag);
} else {
sprintf(tmp_out, "\t\tRequestor: [%lu,%lu,%lu] @ subscription id %lu",
ORTE_NAME_ARGS(reqs[j]->requestor),
ORTE_NAME_ARGS(reqs[j]->requestor),
(unsigned long) reqs[j]->idtag);
}
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
}
}
sprintf(tmp_out, "\tActions:");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
if (ORTE_GPR_NOTIFY_VALUE_CHG & sub->action) {
@ -638,29 +659,29 @@ static void orte_gpr_replica_dump_subscription(orte_buffer_t *buffer,
p++;
sprintf(tmp_out, "\t\tData on segment %s", (ivals[n]->seg)->name);
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
k = (int)orte_value_array_get_size(&(ivals[n]->tokentags));
if (0 == k) {
sprintf(tmp_out, "\t\tNULL token (wildcard)");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
} else {
sprintf(tmp_out, "\t\tNumber of tokens: %lu",
sprintf(tmp_out, "\t\tNumber of tokens: %lu",
(unsigned long) k);
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
for (j=0; j < k; j++) {
if (ORTE_SUCCESS == orte_gpr_replica_dict_reverse_lookup(&token, ivals[n]->seg,
ORTE_VALUE_ARRAY_GET_ITEM(&(ivals[n]->tokentags), orte_gpr_replica_itag_t, j))) {
sprintf(tmp_out, "\t\t\tToken: %s", token);
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
free(token);
}
}
}
}
sprintf(tmp_out, "\t\tToken addressing mode:\n");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
if (ORTE_GPR_TOKENS_NOT & ivals[n]->addr_mode) {
sprintf(tmp_out, "\t\t\tORTE_GPR_TOKENS_NOT\n");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
@ -681,7 +702,7 @@ static void orte_gpr_replica_dump_subscription(orte_buffer_t *buffer,
sprintf(tmp_out, "\t\t\tORTE_GPR_TOKENS_XOR\n");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
}
k = (int)orte_value_array_get_size(&(ivals[n]->keytags));
if (0 == k) {
sprintf(tmp_out, "\t\tNULL key (wildcard)");
@ -689,7 +710,7 @@ static void orte_gpr_replica_dump_subscription(orte_buffer_t *buffer,
} else {
sprintf(tmp_out, "\t\tNumber of keys: %lu", (unsigned long) k);
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
for (j=0; j < k; j++) {
if (ORTE_SUCCESS == orte_gpr_replica_dict_reverse_lookup(&token, ivals[n]->seg,
ORTE_VALUE_ARRAY_GET_ITEM(&(ivals[n]->keytags), orte_gpr_replica_itag_t, j))) {
@ -699,10 +720,10 @@ static void orte_gpr_replica_dump_subscription(orte_buffer_t *buffer,
}
}
}
sprintf(tmp_out, "\t\tKey addressing mode:\n");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
if (ORTE_GPR_KEYS_NOT & ivals[n]->addr_mode) {
sprintf(tmp_out, "\t\t\tORTE_GPR_KEYS_NOT\n");
orte_gpr_replica_dump_load_string(buffer, &tmp_out);
@ -727,7 +748,7 @@ static void orte_gpr_replica_dump_subscription(orte_buffer_t *buffer,
} /* for n */
free(tmp_out);
return;
return ORTE_SUCCESS;
}
@ -735,48 +756,47 @@ void orte_gpr_replica_dump_itagval_value(orte_buffer_t *buffer,
orte_gpr_replica_itagval_t *iptr)
{
char tmp[132], *tmp2;
tmp2 = tmp;
switch(iptr->type) {
case ORTE_BYTE:
sprintf(tmp, "\t\tData type: ORTE_BYTE");
break;
case ORTE_BOOL:
sprintf(tmp, "\t\tData type: ORTE_BOOL\tValue: %s", iptr->value.tf_flag ? "TRUE" : "FALSE");
break;
case ORTE_STRING:
sprintf(tmp, "\t\tData type: ORTE_STRING\tValue: %s", iptr->value.strptr);
break;
case ORTE_SIZE:
sprintf(tmp, "\t\tData type: ORTE_SIZE\tValue: %lu",
(unsigned long) iptr->value.size);
break;
case ORTE_PID:
sprintf(tmp, "\t\tData type: ORTE_PID\tValue: " ORTE_PID_T_PRINTF,
iptr->value.pid);
sprintf(tmp, "\t\tData type: ORTE_PID\tValue: %lu", (unsigned long)iptr->value.pid);
break;
case ORTE_INT:
sprintf(tmp, "\t\tData type: ORTE_INT\tValue: %d", (int)iptr->value.i32);
break;
case ORTE_UINT8:
sprintf(tmp, "\t\tData type: ORTE_UINT8\tValue: %d", (int)iptr->value.ui8);
break;
case ORTE_UINT16:
sprintf(tmp, "\t\tData type: ORTE_UINT16\tValue: %d", (int)iptr->value.ui16);
break;
case ORTE_UINT32:
sprintf(tmp, "\t\tData type: ORTE_UINT32\tValue: %d", (int)iptr->value.ui32);
break;
#ifdef HAVE_INT64_T
case ORTE_UINT64:
sprintf(tmp, "\t\tData type: ORTE_UINT64\tValue: %d", (int)iptr->value.ui64);
@ -786,15 +806,15 @@ void orte_gpr_replica_dump_itagval_value(orte_buffer_t *buffer,
case ORTE_INT8:
sprintf(tmp, "\t\tData type: ORTE_INT8\tValue: %d", (int)iptr->value.i8);
break;
case ORTE_INT16:
sprintf(tmp, "\t\tData type: ORTE_INT16\tValue: %d", (int)iptr->value.i16);
break;
case ORTE_INT32:
sprintf(tmp, "\t\tData type: ORTE_INT32\tValue: %d", (int)iptr->value.i32);
break;
#ifdef HAVE_INT64_T
case ORTE_INT64:
sprintf(tmp, "\t\tData type: ORTE_INT64\tValue: %d", (int)iptr->value.i64);
@ -805,56 +825,56 @@ void orte_gpr_replica_dump_itagval_value(orte_buffer_t *buffer,
sprintf(tmp, "\t\tData type: ORTE_BYTE_OBJECT\tSize: %lu",
(unsigned long) (iptr->value.byteobject).size);
break;
case ORTE_NAME:
sprintf(tmp, "\t\tData type: ORTE_NAME\tValue: [%lu,%lu,%lu]",
ORTE_NAME_ARGS(&(iptr->value.proc)));
break;
case ORTE_VPID:
sprintf(tmp, "\t\tData type: ORTE_VPID\tValue: %lu",
(unsigned long) iptr->value.vpid);
break;
case ORTE_JOBID:
sprintf(tmp, "\t\tData type: ORTE_JOBID\tValue: %lu",
(unsigned long) iptr->value.jobid);
break;
case ORTE_CELLID:
sprintf(tmp, "\t\tData type: ORTE_CELLID\tValue: %lu",
(unsigned long) iptr->value.cellid);
break;
case ORTE_NODE_STATE:
sprintf(tmp, "\t\tData type: ORTE_NODE_STATE\tValue: %d", (int)iptr->value.node_state);
break;
case ORTE_PROC_STATE:
sprintf(tmp, "\t\tData type: ORTE_PROC_STATE\tValue: %d", (int)iptr->value.proc_state);
break;
case ORTE_JOB_STATE:
sprintf(tmp, "\t\tData type: ORTE_JOB_STATE\tValue: %d", (int)iptr->value.job_state);
break;
case ORTE_EXIT_CODE:
sprintf(tmp, "\t\tData type: ORTE_EXIT_CODE\tValue: %d", (int)iptr->value.exit_code);
break;
case ORTE_NULL:
sprintf(tmp, "\t\tData type: ORTE_NULL");
break;
case ORTE_APP_CONTEXT:
sprintf(tmp, "\t\tData type: ORTE_APP_CONTEXT");
break;
default:
sprintf(tmp, "\t\tData type: UNKNOWN");
break;
}
if (NULL == buffer) {
opal_output(0, "%s", tmp);
} else {

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

@ -3,14 +3,14 @@
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
*
* Additional copyrights may follow
*
*
* $HEADER$
*/
/** @file:
@ -36,7 +36,7 @@ extern "C" {
* The "fn" layer of the registry API functions - not accessible from outside
* the replica
*/
/*
* Arithemetic operations
*/
@ -65,7 +65,7 @@ int orte_gpr_replica_delete_entries_nb_fn(
orte_gpr_replica_segment_t *seg,
orte_gpr_replica_itag_t *token_itags, size_t num_tokens,
orte_gpr_replica_itag_t *key_tags, size_t num_keys);
int orte_gpr_replica_index_fn(orte_gpr_replica_segment_t *seg,
size_t *cnt, char ***index);
@ -94,7 +94,7 @@ int orte_gpr_replica_put_nb_fn(orte_gpr_addr_mode_t addr_mode,
orte_gpr_replica_itag_t *token_itags, size_t num_tokens,
size_t cnt, orte_gpr_keyval_t **keyvals,
orte_gpr_notify_cb_fn_t cbfunc, void *user_tag);
int orte_gpr_replica_get_fn(orte_gpr_addr_mode_t addr_mode,
orte_gpr_replica_segment_t *seg,
orte_gpr_replica_itag_t *tokentags, size_t num_tokens,
@ -126,11 +126,19 @@ int orte_gpr_replica_dump_segments_fn(orte_buffer_t *buffer, char *segment);
int orte_gpr_replica_dump_a_segment_fn(orte_buffer_t *buffer, orte_gpr_replica_segment_t *seg);
int orte_gpr_replica_dump_triggers_fn(orte_buffer_t *buffer);
int orte_gpr_replica_dump_triggers_fn(orte_buffer_t *buffer,
orte_gpr_trigger_id_t start);
int orte_gpr_replica_dump_subscriptions_fn(orte_buffer_t *buffer);
int orte_gpr_replica_dump_subscriptions_fn(orte_buffer_t *buffer,
orte_gpr_subscription_id_t start);
int orte_gpr_replica_dump_callbacks_fn(orte_buffer_t *buffer);
int orte_gpr_replica_dump_trigger(orte_buffer_t *buffer,
orte_gpr_replica_trigger_t *trig);
int orte_gpr_replica_dump_subscription(orte_buffer_t *buffer,
orte_gpr_replica_subscription_t *sub);
int orte_gpr_replica_dump_callbacks_fn(orte_buffer_t *buffer);
/*
* ********* INTERNAL UTILITY FUNCTIONS **********
@ -183,12 +191,12 @@ int orte_gpr_replica_delete_itagval(orte_gpr_replica_segment_t *seg,
/*
* DICTIONARY OPERATIONS
*/
bool orte_gpr_replica_check_itag_list(orte_gpr_replica_addr_mode_t mode,
size_t num_itags_search,
orte_gpr_replica_itag_t *itags,
size_t num_itags_entry,
orte_gpr_replica_itag_t *entry_itags);
size_t num_itags_search,
orte_gpr_replica_itag_t *itags,
size_t num_itags_entry,
orte_gpr_replica_itag_t *entry_itags);
int orte_gpr_replica_copy_itag_list(orte_gpr_replica_itag_t **dest,
orte_gpr_replica_itag_t *src, size_t num_itags);
@ -203,9 +211,9 @@ int orte_gpr_replica_enter_local_subscription(size_t cnt, orte_gpr_subscription_
int orte_gpr_replica_enter_local_trigger(size_t cnt, orte_gpr_trigger_t **trigs);
int orte_gpr_replica_remove_local_subscription(orte_gpr_subscription_id_t id);
int orte_gpr_replica_remove_local_subscription(orte_gpr_replica_local_subscriber_t *sub);
int orte_gpr_proxy_remove_local_trigger(orte_gpr_trigger_id_t id);
int orte_gpr_replica_remove_local_trigger(orte_gpr_replica_local_trigger_t *trig);
int orte_gpr_replica_record_action(orte_gpr_replica_segment_t *seg,
orte_gpr_replica_container_t *cptr,
@ -247,18 +255,20 @@ int
orte_gpr_replica_remove_trigger(orte_process_name_t *requestor,
orte_gpr_trigger_id_t id);
int orte_gpr_replica_register_callback(orte_gpr_replica_trigger_t *trig,
orte_gpr_replica_subscription_t *sub,
int orte_gpr_replica_register_callback(orte_gpr_replica_subscription_t *sub,
orte_gpr_value_t *value);
int orte_gpr_replica_define_callback(orte_gpr_replica_callbacks_t **cbptr,
int orte_gpr_replica_register_trigger_callback(orte_gpr_replica_trigger_t *trig);
int orte_gpr_replica_define_callback(orte_gpr_notify_msg_type_t msg_type,
orte_gpr_replica_callbacks_t **cbptr,
orte_process_name_t *recipient);
int orte_gpr_replica_process_callbacks(void);
int orte_gpr_replica_purge_subscriptions(orte_process_name_t *proc);
int orte_gpr_replica_store_value_in_msg(orte_gpr_subscription_id_t id,
int orte_gpr_replica_store_value_in_msg(orte_gpr_replica_requestor_t *req,
orte_gpr_notify_message_t *msg,
size_t cnt,
orte_gpr_value_t **values);

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

@ -3,14 +3,14 @@
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
*
* Additional copyrights may follow
*
*
* $HEADER$
*/
/** @file:
@ -40,8 +40,8 @@ int
orte_gpr_replica_enter_local_subscription(size_t cnt, orte_gpr_subscription_t **subscriptions)
{
orte_gpr_replica_local_subscriber_t *sub;
size_t i, id;
size_t i;
for (i=0; i < cnt; i++) {
sub = OBJ_NEW(orte_gpr_replica_local_subscriber_t);
if (NULL == sub) {
@ -53,7 +53,7 @@ orte_gpr_replica_enter_local_subscription(size_t cnt, orte_gpr_subscription_t **
}
sub->callback = subscriptions[i]->cbfunc;
sub->user_tag = subscriptions[i]->user_tag;
if (0 > orte_pointer_array_add(&id, orte_gpr_replica_globals.local_subscriptions, sub)) {
if (0 > orte_pointer_array_add(&sub->index, orte_gpr_replica_globals.local_subscriptions, sub)) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
@ -61,7 +61,7 @@ orte_gpr_replica_enter_local_subscription(size_t cnt, orte_gpr_subscription_t **
subscriptions[i]->id = sub->id;
(orte_gpr_replica_globals.num_local_subs)++;
}
return ORTE_SUCCESS;
}
@ -69,10 +69,45 @@ orte_gpr_replica_enter_local_subscription(size_t cnt, orte_gpr_subscription_t **
int
orte_gpr_replica_enter_local_trigger(size_t cnt, orte_gpr_trigger_t **trigs)
{
orte_gpr_replica_local_trigger_t *trig;
size_t i, id;
orte_gpr_replica_local_trigger_t *trig, **tptr;
size_t i, j, k;
for (i=0; i < cnt; i++) {
/* If the provided trigger has a name, see if it already is on
* the local trigger list. If so, then check to see if we
* already defined a return point for it and/or if this trigger
* doesn't - in either of those two cases, we ignore the
* trigger and just use the existing entry
*/
if (NULL != trigs[i]->name) {
tptr = (orte_gpr_replica_local_trigger_t**)(orte_gpr_replica_globals.local_triggers)->addr;
for (j=0, k=0; k < orte_gpr_replica_globals.num_local_trigs &&
j < (orte_gpr_replica_globals.local_triggers)->size; j++) {
if (NULL != tptr[j]) {
k++;
if (0 == strcmp(tptr[j]->name, trigs[i]->name)) {
/* same name - trigger is already on list */
if (NULL != tptr[j]->callback || NULL == trigs[i]->cbfunc) {
/* ignore these cases */
trig = tptr[j];
goto MOVEON;
}
/* reach here if either the prior trigger didn't provide
* a callback, and the new one provides one. In this
* case, we update the existing trigger callback and then
* move on
*/
tptr[j]->callback = trigs[i]->cbfunc;
trig = tptr[j];
goto MOVEON;
}
}
}
}
/* either the trigger doesn't have a name, OR it did, but it isn't
* already on the list - add it to the list now
*/
trig = OBJ_NEW(orte_gpr_replica_local_trigger_t);
if (NULL == trig) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
@ -94,35 +129,49 @@ orte_gpr_replica_enter_local_trigger(size_t cnt, orte_gpr_trigger_t **trigs)
}
trig->callback = trigs[i]->cbfunc;
trig->user_tag = trigs[i]->user_tag;
if (0 > orte_pointer_array_add(&id, orte_gpr_replica_globals.local_triggers, trig)) {
if (0 > orte_pointer_array_add(&trig->index, orte_gpr_replica_globals.local_triggers, trig)) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
trig->id = orte_gpr_replica_globals.num_local_trigs;
trigs[i]->id = trig->id;
(orte_gpr_replica_globals.num_local_trigs)++;
MOVEON:
trigs[i]->id = trig->id;
}
return ORTE_SUCCESS;
}
int orte_gpr_replica_remove_local_subscription(orte_gpr_subscription_id_t id)
int orte_gpr_replica_remove_local_subscription(orte_gpr_replica_local_subscriber_t *sub)
{
if (NULL != (orte_gpr_replica_globals.local_subscriptions)->addr[id]) {
OBJ_RELEASE((orte_gpr_replica_globals.local_subscriptions)->addr[id]);
orte_pointer_array_set_item(orte_gpr_replica_globals.local_subscriptions, (size_t)id, NULL);
size_t index;
if (NULL == sub) {
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
return ORTE_ERR_BAD_PARAM;
}
index = sub->index;
OBJ_RELEASE(sub);
orte_pointer_array_set_item(orte_gpr_replica_globals.local_subscriptions, index, NULL);
return ORTE_SUCCESS;
}
int orte_gpr_proxy_remove_local_trigger(orte_gpr_trigger_id_t id)
int orte_gpr_replica_remove_local_trigger(orte_gpr_replica_local_trigger_t *trig)
{
if (NULL != (orte_gpr_replica_globals.local_triggers)->addr[id]) {
OBJ_RELEASE((orte_gpr_replica_globals.local_triggers)->addr[id]);
orte_pointer_array_set_item(orte_gpr_replica_globals.local_triggers, (size_t)id, NULL);
size_t index;
if (NULL == trig) {
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
return ORTE_ERR_BAD_PARAM;
}
index = trig->index;
OBJ_RELEASE(trig);
orte_pointer_array_set_item(orte_gpr_replica_globals.local_triggers, index, NULL);
return ORTE_SUCCESS;
}

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

@ -4,14 +4,14 @@
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
*
* Additional copyrights may follow
*
*
* $HEADER$
*/
/** @file:
@ -39,17 +39,21 @@
#include "mca/gpr/replica/communications/gpr_replica_comm.h"
#include "gpr_replica_fn.h"
static int orte_gpr_replica_get_callback_data(orte_gpr_value_t ***values, size_t *num_vals,
orte_gpr_replica_subscription_t *sub);
static int orte_gpr_replica_store_value_in_trigger_msg(orte_gpr_replica_subscription_t *sub,
orte_gpr_notify_message_t *msg,
size_t cnt,
orte_gpr_value_t **values);
int orte_gpr_replica_process_callbacks(void)
{
orte_gpr_replica_callbacks_t *cb;
orte_gpr_notify_data_t **data;
orte_gpr_replica_trigger_t **trigs;
orte_gpr_replica_local_trigger_t **local_trigs;
orte_gpr_replica_subscription_t **subs;
orte_gpr_replica_local_subscriber_t **local_subs;
orte_gpr_replica_requestor_t **reqs;
size_t i, j, k, m;
bool processed;
int rc;
/* check and set flag indicating callbacks being processed */
@ -57,82 +61,25 @@ int orte_gpr_replica_process_callbacks(void)
return ORTE_SUCCESS;
}
orte_gpr_replica.processing_callbacks = true;
while (NULL != (cb = (orte_gpr_replica_callbacks_t*)opal_list_remove_last(&orte_gpr_replica.callbacks))) {
/* each callback corresponds to a specific requestor
* The message in the callback consists of at least one (and can
* be more) "datagrams" intended for that requestor, each of which
* is slated to be returned to a specific function on the requestor.
*/
if (NULL == cb->requestor) { /* local callback */
/* each callback corresponds to a specific requestor
* The message in the callback consists of at least one (and can
* be more) "datagrams" intended for that requestor, each of which
* is slated to be returned to a specific
* function on the requestor.
*
* Since this requestor is "local", we simply execute
/* Since this requestor is "local", we simply execute
* the callbacks ourself.
*/
/* we first have to check the trigger id in the message. If that
* field is set to a valid value (i.e., one other than
* ORTE_GPR_TRIGGER_ID_MAX), then the message is intended to be
* sent as a single block to that trigger's callback function.
*/
if (ORTE_GPR_TRIGGER_ID_MAX > (cb->message)->id) {
/* use the local trigger callback */
local_trigs = (orte_gpr_replica_local_trigger_t**)
(orte_gpr_replica_globals.local_triggers)->addr;
for (i=0, j=0; j < orte_gpr_replica_globals.num_local_trigs &&
i < (orte_gpr_replica_globals.local_triggers)->size; i++) {
if (NULL != local_trigs[i]) {
j++;
if ((cb->message)->id == local_trigs[i]->id) {
OPAL_THREAD_UNLOCK(&orte_gpr_replica_globals.mutex);
local_trigs[i]->callback(cb->message, local_trigs[i]->user_tag);
OPAL_THREAD_LOCK(&orte_gpr_replica_globals.mutex);
goto CLEANUP;
}
}
}
/* get here if the trigger could not be found */
ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND);
goto CLEANUP;
if (ORTE_SUCCESS != (rc = orte_gpr_replica_deliver_notify_msg(cb->message))) {
ORTE_ERROR_LOG(rc);
}
/* get here if the trigger id indicated that this was NOT
* intended for a trigger callback - i.e., the message should
* be broken into its component parts and delivered separately
* to the indicated subscribers
*/
data = (orte_gpr_notify_data_t**)((cb->message)->data)->addr;
for (i=0; i < (cb->message)->cnt; i++) {
/* for each datagram in the message, we need to lookup
* the associated subscription id to find the correct
* callback function.
*/
local_subs = (orte_gpr_replica_local_subscriber_t**)
(orte_gpr_replica_globals.local_subscriptions)->addr;
processed = false;
for (j=0, k=0; !processed &&
k < orte_gpr_replica_globals.num_local_subs &&
j < (orte_gpr_replica_globals.local_subscriptions)->size; j++) {
if (NULL != local_subs[j]) {
k++;
if (data[i]->id == local_subs[j]->id) {
OPAL_THREAD_UNLOCK(&orte_gpr_replica_globals.mutex);
local_subs[j]->callback(data[i], local_subs[j]->user_tag);
OPAL_THREAD_LOCK(&orte_gpr_replica_globals.mutex);
processed = true;
}
}
}
/* get here and not processed => not found */
if (!processed) {
ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND);
}
}
} else { /* remote request - send messages back */
orte_gpr_replica_remote_notify(cb->requestor, cb->message);
}
CLEANUP:
OBJ_RELEASE(cb);
}
@ -154,7 +101,7 @@ CLEANUP:
}
}
orte_gpr_replica.num_trigs -= m;
/* cleanup any subscriptions that are supposed to be
* removed based on a trigger having fired - set processing to false
* on all others
@ -186,99 +133,36 @@ CLEANUP:
/* all callbacks processed - indicate list is open */
orte_gpr_replica.processing_callbacks = false;
return ORTE_SUCCESS;
}
int orte_gpr_replica_register_callback(orte_gpr_replica_trigger_t *trig,
orte_gpr_replica_subscription_t *sub,
int orte_gpr_replica_register_callback(orte_gpr_replica_subscription_t *sub,
orte_gpr_value_t *value)
{
orte_gpr_replica_callbacks_t *cb;
orte_gpr_replica_requestor_t **reqs;
size_t interim, cnt, num_tokens, num_keys;
orte_gpr_value_t **vals, **values;
orte_gpr_replica_ivalue_t **ivals;
size_t i, j, k;
orte_gpr_value_t **values;
size_t cnt;
size_t i, j;
bool cleanup_reqd;
int rc;
/* The data to be returned will be the same for all requestors
* on this subscription. First, let's get the data (if it hasn't
* already been provided) so we have it ready to be added to
* the callback
*/
/* check to see if value provided - if so, we'll just use it */
if (NULL != value) {
if (NULL != value) { /* no need to get data - already provided */
values = &value;
cnt = 1;
cleanup_reqd = false;
} else {
/* value not provided - get the data off the registry. since a
* subscription can have multiple data sources specified, we
* have to loop through those sources, constructing an aggregated
* array of data values that we can work with in composing the
* final message
*/
ivals = (orte_gpr_replica_ivalue_t**)(sub->values)->addr;
cnt = 0;
values = NULL;
for (i=0, j=0; j < sub->num_values &&
i < (sub->values)->size; i++) {
if (NULL != ivals[i]) {
j++;
num_tokens = orte_value_array_get_size(&(ivals[i]->tokentags));
num_keys = orte_value_array_get_size(&(ivals[i]->keytags));
/* get the data for this description off the registry */
if (ORTE_SUCCESS != (rc = orte_gpr_replica_get_fn(ivals[i]->addr_mode,
ivals[i]->seg,
ORTE_VALUE_ARRAY_GET_BASE(&(ivals[i]->tokentags), orte_gpr_replica_itag_t),
num_tokens,
ORTE_VALUE_ARRAY_GET_BASE(&(ivals[i]->keytags), orte_gpr_replica_itag_t),
num_keys,
&interim, &vals))) {
ORTE_ERROR_LOG(rc);
return rc;
}
/* if we don't get any data back, just continue - don't
* try to add it to the values since that would cause a
* zero-byte malloc
*/
if (0 == interim) {
continue;
}
/* add these results to those we have already obtained */
if (0 == cnt) { /* first time through */
values = (orte_gpr_value_t**)malloc(interim *
sizeof(orte_gpr_value_t*));
if (NULL == values) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
} else {
/* reallocate values array */
values = (orte_gpr_value_t**)realloc(values,
(cnt+interim)*sizeof(orte_gpr_value_t*));
if (NULL == values) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
}
/* add data to end of array */
for (k=0; k < interim; k++) {
values[k+cnt] = vals[k];
}
/* release the array of pointers - the pointers themselves
* will remain "alive" in the values array to be released
* later
*/
free(vals);
/* update the count */
cnt += interim;
}
if (ORTE_SUCCESS != (rc = orte_gpr_replica_get_callback_data(&values, &cnt, sub))) {
ORTE_ERROR_LOG(rc);
return rc;
}
cleanup_reqd = true;
}
@ -292,81 +176,45 @@ int orte_gpr_replica_register_callback(orte_gpr_replica_trigger_t *trig,
* the remote process which callback function to use when it receives
* a message from us.
* Each subscription can have multiple "requestors" attached to it,
* each "requestor" consisting of the process name and
* each "requestor" consisting of the process name and
* subscription id (for remote processes), and callback info (for local
* processes).
* For each requestor, we need to check to see if a callback has
* already been scheduled to that destination - if so, we piggyback
* another datagram onto it to minimize communication costs.
*/
/* first, we need to determine if the data in this message
* is to be sent back through the trigger callback function
* or not. if it is, then we set the callback's message
* to point at the correct trigger id for that requestor
* so the message goes to the correct place, and we go ahead
* and store the data in the message
/* this data is intended to be sent to the individual
* subscribers themselves. Cycle through the subscription's
* requestors, define callbacks to them appropriately,
* and set the id to indicate that it does NOT go
* to a trigger
*/
if (NULL != trig && NULL != trig->master) {
/* define the callback */
if (ORTE_SUCCESS != (rc = orte_gpr_replica_define_callback(&cb, (trig->master)->requestor))) {
ORTE_ERROR_LOG(rc);
goto CLEANUP;
}
/* transfer the trigger name, if available */
if (NULL != trig->name) {
(cb->message)->name = strdup(trig->name);
}
/* set the callback id to point to the trigger callback function */
(cb->message)->id = (trig->master)->idtag;
/* cycle through all the subscription's requestors and place
* the data on the message so that the trigger master can distribute
* it as required
*/
reqs = (orte_gpr_replica_requestor_t**)(sub->requestors)->addr;
for (i=0, j=0; j < sub->num_requestors &&
i < (sub->requestors)->size; i++) {
if (NULL != reqs[i]) {
j++;
if (ORTE_SUCCESS != (rc = orte_gpr_replica_store_value_in_msg(reqs[i]->idtag,
cb->message, cnt, values))) {
ORTE_ERROR_LOG(rc);
goto CLEANUP;
}
reqs = (orte_gpr_replica_requestor_t**)(sub->requestors)->addr;
for (i=0, j=0; j < sub->num_requestors &&
i < (sub->requestors)->size; i++) {
if (NULL != reqs[i]) {
j++;
/* define the callback */
if (ORTE_SUCCESS != (rc = orte_gpr_replica_define_callback(ORTE_GPR_SUBSCRIPTION_MSG,
&cb, reqs[i]->requestor))) {
ORTE_ERROR_LOG(rc);
goto CLEANUP;
}
/* set the callback id to indicate not a trigger callback */
(cb->message)->id = ORTE_GPR_TRIGGER_ID_MAX;
/* okay, now we have a message going to the requestor. We need to
* store the values in the notify_data structure corresponding to this
* subscription id, combining data where the id's match
*/
if (ORTE_SUCCESS != (rc = orte_gpr_replica_store_value_in_msg(reqs[i],
cb->message, cnt, values))) {
ORTE_ERROR_LOG(rc);
goto CLEANUP;
}
}
} else {
/* this data is intended to be sent to the individual
* subscribers themselves. Cycle through the subscription's
* requestors, define callbacks to them appropriately,
* and set the id to indicate that it does NOT go
* to a trigger
*/
reqs = (orte_gpr_replica_requestor_t**)(sub->requestors)->addr;
for (i=0, j=0; j < sub->num_requestors &&
i < (sub->requestors)->size; i++) {
if (NULL != reqs[i]) {
j++;
/* define the callback */
if (ORTE_SUCCESS != (rc = orte_gpr_replica_define_callback(&cb, reqs[i]->requestor))) {
ORTE_ERROR_LOG(rc);
goto CLEANUP;
}
/* set the callback id to indicate not a trigger callback */
(cb->message)->id = ORTE_GPR_TRIGGER_ID_MAX;
/* okay, now we have a message going to the requestor. We need to
* store the values in the notify_data structure corresponding to this
* subscription id, combining data where the id's match
*/
if (ORTE_SUCCESS != (rc = orte_gpr_replica_store_value_in_msg(reqs[i]->idtag,
cb->message, cnt, values))) {
ORTE_ERROR_LOG(rc);
goto CLEANUP;
}
}
} /* for i */
} /* if else */
} /* for i */
CLEANUP:
/* release the values here - the value objects have been "retained" in
* the store_value function, so this just ensures that they will be
@ -378,27 +226,163 @@ CLEANUP:
* only a single value is passed in, so there is no array to free
*/
if (cleanup_reqd && NULL != values) free(values);
return rc;
}
int orte_gpr_replica_define_callback(orte_gpr_replica_callbacks_t **cbptr,
int orte_gpr_replica_register_trigger_callback(orte_gpr_replica_trigger_t *trig)
{
orte_gpr_replica_callbacks_t *cb;
orte_gpr_replica_counter_t **cntr;
orte_gpr_replica_subscription_t **subs;
orte_gpr_value_t **values, *value;
size_t i, j, k, cnt;
int rc;
/* set the callback's message
* to point at the correct trigger id for that requestor
* so the message goes to the correct place, and go ahead
* and store the data in the message
*/
/* define the callback */
if (ORTE_SUCCESS != (rc = orte_gpr_replica_define_callback(ORTE_GPR_TRIGGER_MSG,
&cb, (trig->master)->requestor))) {
ORTE_ERROR_LOG(rc);
return rc;
}
/* transfer the trigger name, if available */
if (NULL != trig->name) {
(cb->message)->target = strdup(trig->name);
}
/* set the callback id to point to the trigger callback function */
(cb->message)->id = (trig->master)->idtag;
/* if the trigger counters are to be included, do so */
if (ORTE_GPR_TRIG_INCLUDE_TRIG_CNTRS & trig->action) {
cntr = (orte_gpr_replica_counter_t**)((trig->counters)->addr);
for (i=0, j=0; j < trig->num_counters &&
i < (trig->counters)->size; i++) {
if (NULL != cntr[i]) {
j++;
value = OBJ_NEW(orte_gpr_value_t);
if (NULL == value) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
value->segment = strdup(cntr[i]->seg->name);
value->cnt = 1;
value->keyvals = (orte_gpr_keyval_t**)malloc(sizeof(orte_gpr_keyval_t*));
if (NULL == value->keyvals) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
value->keyvals[0] = OBJ_NEW(orte_gpr_keyval_t);
if (NULL == value->keyvals[0]) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
if (ORTE_SUCCESS != (rc = orte_gpr_replica_dict_reverse_lookup(
&(value->keyvals[0]->key), cntr[i]->seg,
cntr[i]->iptr->itag))) {
ORTE_ERROR_LOG(rc);
OBJ_RELEASE(value);
return rc;
}
value->keyvals[0]->type = cntr[i]->iptr->type;
if (ORTE_SUCCESS != (rc = orte_gpr_base_xfer_payload(
&(value->keyvals[0]->value),
&(cntr[i]->iptr->value), cntr[i]->iptr->type))) {
ORTE_ERROR_LOG(rc);
OBJ_RELEASE(value);
return rc;
}
/*
* store the data in the message
*/
if (ORTE_SUCCESS != (rc = orte_gpr_replica_store_value_in_trigger_msg(NULL,
cb->message, 1, &value))) {
ORTE_ERROR_LOG(rc);
return rc;
}
/* release the storage */
OBJ_RELEASE(value);
}
}
}
/* cycle through all the trigger's subscriptions and place
* that data on the message
*/
subs = (orte_gpr_replica_subscription_t**)(trig->subscriptions)->addr;
for (i=0, j=0; j < trig->num_subscriptions &&
i < (trig->subscriptions)->size; i++) {
if (NULL != subs[i]) {
j++;
if (NULL != subs[i]->name) {
/* if it's a named subscription, we will deliver it via the
* trigger callback function. The data to be returned will
* be the same for all requestors.
*/
if (ORTE_SUCCESS != (rc = orte_gpr_replica_get_callback_data(&values, &cnt, subs[i]))) {
ORTE_ERROR_LOG(rc);
return rc;
}
/*
* store the data in the message
*/
if (ORTE_SUCCESS != (rc = orte_gpr_replica_store_value_in_trigger_msg(subs[i],
cb->message, cnt, values))) {
ORTE_ERROR_LOG(rc);
return rc;
}
/* release the storage */
for (k=0; k < cnt; k++) OBJ_RELEASE(values[k]);
if (NULL != values) free(values);
} else {
/* in the case of a non-named subscription, we know that someone
* has attached a subscription to this trigger, and that the
* requestor needs the data to be returned directly to them. This
* occurs in the case of orterun, which attaches subscriptions to
* the standard triggers so it can monitor the progress of a job
* it has launched. To facilitate this, we register a separate
* callback for this subscription
*/
if (ORTE_SUCCESS != (rc = orte_gpr_replica_register_callback(subs[i], NULL))) {
ORTE_ERROR_LOG(rc);
return rc;
}
}
}
}
return ORTE_SUCCESS;
}
int orte_gpr_replica_define_callback(orte_gpr_notify_msg_type_t msg_type,
orte_gpr_replica_callbacks_t **cbptr,
orte_process_name_t *recipient)
{
orte_gpr_replica_callbacks_t *cb;
int rc;
/* see if a callback has already been registered for this recipient */
for (cb = (orte_gpr_replica_callbacks_t*)opal_list_get_first(&(orte_gpr_replica.callbacks));
cb != (orte_gpr_replica_callbacks_t*)opal_list_get_end(&(orte_gpr_replica.callbacks));
cb = (orte_gpr_replica_callbacks_t*)opal_list_get_next(cb)) {
if ((NULL == recipient && NULL == cb->requestor) ||
((NULL != recipient && NULL != cb->requestor) &&
/* must check to see if both the recipient is the same AND that the
* message type being sent is identical (i.e., that messages going back
* to trigger callbacks do NOT get mixed with messages going back to
* subscription callbacks). This is critical as the deliver_notify_msg
* functions handle these message types in different ways
*/
if (((NULL == recipient && NULL == cb->requestor) &&
(msg_type == cb->message->msg_type)) ||
(((NULL != recipient && NULL != cb->requestor) &&
(0 == orte_ns.compare(ORTE_NS_CMP_ALL,
recipient,
cb->requestor)))) {
cb->requestor))) &&
(msg_type == cb->message->msg_type))) {
/* okay, a callback has been registered to send data to this
* recipient - return this location
*/
@ -406,7 +390,7 @@ int orte_gpr_replica_define_callback(orte_gpr_replica_callbacks_t **cbptr,
return ORTE_SUCCESS;
}
}
/* this is going to somebody new - create a new callback
* for this recipient
*/
@ -415,15 +399,16 @@ int orte_gpr_replica_define_callback(orte_gpr_replica_callbacks_t **cbptr,
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
opal_list_append(&orte_gpr_replica.callbacks, &cb->item);
/* construct the message */
cb->message = OBJ_NEW(orte_gpr_notify_message_t);
if (NULL == cb->message) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
cb->message->msg_type = msg_type;
if (NULL == recipient) {
cb->requestor = NULL;
@ -433,22 +418,22 @@ int orte_gpr_replica_define_callback(orte_gpr_replica_callbacks_t **cbptr,
return rc;
}
}
/* return the pointer to the new callback */
*cbptr = cb;
return ORTE_SUCCESS;
}
int orte_gpr_replica_store_value_in_msg(orte_gpr_subscription_id_t id,
int orte_gpr_replica_store_value_in_msg(orte_gpr_replica_requestor_t *req,
orte_gpr_notify_message_t *msg,
size_t cnt,
orte_gpr_value_t **values)
{
size_t i, j, k, index;
orte_gpr_notify_data_t **data, *dptr;
/* check to see if this data is going to the same place as
* any prior data on the message. if so, then we add the values
* to that existing data structure. if not, then we realloc to
@ -459,7 +444,7 @@ int orte_gpr_replica_store_value_in_msg(orte_gpr_subscription_id_t id,
i < (msg->data)->size; i++) {
if (NULL != data[i]) {
k++;
if (data[i]->id == id) { /* going to the same place */
if (data[i]->id == req->idtag) { /* going to the same place */
for (j=0; j < cnt; j++) {
if (0 > orte_pointer_array_add(&index, data[i]->values, values[j])) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
@ -489,7 +474,7 @@ int orte_gpr_replica_store_value_in_msg(orte_gpr_subscription_id_t id,
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
dptr->id = id;
dptr->id = req->idtag;
if (0 > orte_pointer_array_add(&index, msg->data, dptr)) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
@ -514,3 +499,159 @@ int orte_gpr_replica_store_value_in_msg(orte_gpr_subscription_id_t id,
return ORTE_SUCCESS;
}
static int orte_gpr_replica_store_value_in_trigger_msg(orte_gpr_replica_subscription_t *sub,
orte_gpr_notify_message_t *msg,
size_t cnt,
orte_gpr_value_t **values)
{
size_t i, j, k, index;
orte_gpr_notify_data_t **data, *dptr;
/* check to see if this data is going to the same place as
* any prior data on the message. if so, then we add the values
* to that existing data structure. if not, then we realloc to
* establish a new data structure and store the data there
*/
data = (orte_gpr_notify_data_t**)(msg->data)->addr;
for (i=0, k=0; k < msg->cnt &&
i < (msg->data)->size; i++) {
if (NULL != data[i]) {
k++;
if ((NULL == data[i]->target && NULL == sub) ||
(NULL != data[i]->target &&
0 == strcmp(data[i]->target, sub->name))) { /* going to the same place */
for (j=0; j < cnt; j++) {
if (0 > orte_pointer_array_add(&index, data[i]->values, values[j])) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
/* must "retain" the value object to ensure that it is
* there for this datagram. Since we are only storing
* pointers to the object (and not actually copying it),
* datagrams may wind up sharing the object. Hence, when
* a datagram is released, it will release the object. Without
* the retain, the next datagram that shares that object
* will see trash
*/
OBJ_RETAIN(values[j]);
}
data[i]->cnt += cnt;
return ORTE_SUCCESS;
}
}
}
/* no prior matching data found, so add another data location to
* the message and store the values there
*/
dptr = OBJ_NEW(orte_gpr_notify_data_t);
if (NULL == dptr) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
if (NULL != sub) {
dptr->target = strdup(sub->name);
}
if (0 > orte_pointer_array_add(&index, msg->data, dptr)) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
(msg->cnt)++;
for (j=0; j < cnt; j++) {
if (0 > orte_pointer_array_add(&index, dptr->values, values[j])) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
/* must "retain" the value object to ensure that it is
* there for this datagram. Since we are only storing
* pointers to the object (and not actually copying it),
* datagrams may wind up sharing the object. Hence, when
* a datagram is released, it will release the object. Without
* the retain, the next datagram that shares that object
* will see trash
*/
OBJ_RETAIN(values[j]);
}
dptr->cnt = cnt;
return ORTE_SUCCESS;
}
static int orte_gpr_replica_get_callback_data(orte_gpr_value_t ***ret_values, size_t *cnt,
orte_gpr_replica_subscription_t *sub)
{
orte_gpr_value_t **vals, **values;
orte_gpr_replica_ivalue_t **ivals;
size_t i, j, k, num_tokens, num_keys, interim, count;
int rc;
/* setup default error returns */
*ret_values = NULL;
*cnt = 0;
/* get the data off the registry. since a
* subscription can have multiple data sources specified, we
* have to loop through those sources, constructing an aggregated
* array of data values that we can work with in composing the
* final message
*/
ivals = (orte_gpr_replica_ivalue_t**)(sub->values)->addr;
count = 0;
values = NULL;
for (i=0, j=0; j < sub->num_values &&
i < (sub->values)->size; i++) {
if (NULL != ivals[i]) {
j++;
num_tokens = orte_value_array_get_size(&(ivals[i]->tokentags));
num_keys = orte_value_array_get_size(&(ivals[i]->keytags));
/* get the data for this description off the registry */
if (ORTE_SUCCESS != (rc = orte_gpr_replica_get_fn(ivals[i]->addr_mode,
ivals[i]->seg,
ORTE_VALUE_ARRAY_GET_BASE(&(ivals[i]->tokentags), orte_gpr_replica_itag_t),
num_tokens,
ORTE_VALUE_ARRAY_GET_BASE(&(ivals[i]->keytags), orte_gpr_replica_itag_t),
num_keys,
&interim, &vals))) {
ORTE_ERROR_LOG(rc);
return rc;
}
/* if we don't get any data back, just continue - don't
* try to add it to the values since that would cause a
* zero-byte malloc
*/
if (0 == interim) {
continue;
}
/* add these results to those we have already obtained */
if (0 == count) { /* first time through */
values = (orte_gpr_value_t**)malloc(interim *
sizeof(orte_gpr_value_t*));
if (NULL == values) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
} else {
/* reallocate values array */
values = (orte_gpr_value_t**)realloc(values,
(count+interim)*sizeof(orte_gpr_value_t*));
if (NULL == values) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
}
/* add data to end of array */
for (k=0; k < interim; k++) {
values[k+count] = vals[k];
}
/* release the array of pointers - the pointers themselves
* will remain "alive" in the values array to be released
* later
*/
free(vals);
/* update the count */
count += interim;
}
}
*ret_values = values;
*cnt = count;
return ORTE_SUCCESS;
}

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

@ -3,14 +3,14 @@
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
*
* Additional copyrights may follow
*
*
* $HEADER$
*/
/** @file:
@ -48,7 +48,7 @@ orte_gpr_replica_register_subscription(orte_gpr_replica_subscription_t **subptr,
orte_gpr_replica_addr_mode_t tok_mode, key_mode;
orte_gpr_replica_itag_t itag, *tokentags=NULL;
orte_gpr_replica_ivalue_t *ival;
/* if this is a named subscription, see if that name has
* already been entered on the replica. If it has, then we
* simply attach this recipient to that subscription -
@ -73,11 +73,11 @@ orte_gpr_replica_register_subscription(orte_gpr_replica_subscription_t **subptr,
}
}
}
/* Either this is NOT a named subscription, or it is named
* but that name is NOT on the current list of subscriptions.
* Either way, we add this subscription to the replica's list.
*
*
* NOTE that you CANNOT add yourself as a recipient to a non-named
* subscription - even if all the subscription specifications are
* identical. This is done in the interest of speed as checking
@ -86,11 +86,19 @@ orte_gpr_replica_register_subscription(orte_gpr_replica_subscription_t **subptr,
* Un-named subscriptions are, therefore, assumed to be specialty
* subscriptions that do not merit such consideration.
*/
/* see if another subscription is available on the system */
if (ORTE_GPR_SUBSCRIPTION_ID_MAX-1 < orte_gpr_replica.num_subs) { /* none left! */
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
sub = OBJ_NEW(orte_gpr_replica_subscription_t);
if (NULL == sub) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
sub->idtag = orte_gpr_replica.num_subs;
if (NULL != subscription->name) {
sub->name = strdup(subscription->name);
@ -101,19 +109,22 @@ orte_gpr_replica_register_subscription(orte_gpr_replica_subscription_t **subptr,
} else {
sub->active = true;
}
/* store all the data specifications for this subscription */
for (i=0; i < subscription->cnt; i++) {
ival = OBJ_NEW(orte_gpr_replica_ivalue_t);
if (NULL == ival) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_RELEASE(sub);
return ORTE_ERR_OUT_OF_RESOURCE;
}
/* find and store the segment */
if (ORTE_SUCCESS != (rc = orte_gpr_replica_find_seg(&(ival->seg), true,
subscription->values[i]->segment))) {
ORTE_ERROR_LOG(rc);
OBJ_RELEASE(sub);
OBJ_RELEASE(ival);
return rc;
}
tok_mode = 0x004f & subscription->values[i]->addr_mode;
@ -125,18 +136,22 @@ orte_gpr_replica_register_subscription(orte_gpr_replica_subscription_t **subptr,
key_mode = ORTE_GPR_REPLICA_OR;
}
ival->addr_mode = ((orte_gpr_addr_mode_t)(key_mode) << 8) | (orte_gpr_addr_mode_t)tok_mode;
if (NULL != subscription->values[i]->tokens &&
0 < subscription->values[i]->num_tokens) {
num_tokens = subscription->values[i]->num_tokens; /* indicates non-NULL terminated list */
if (ORTE_SUCCESS != (rc = orte_gpr_replica_get_itag_list(&tokentags, ival->seg,
subscription->values[i]->tokens, &num_tokens))) {
ORTE_ERROR_LOG(rc);
OBJ_RELEASE(sub);
OBJ_RELEASE(ival);
return rc;
}
if (ORTE_SUCCESS != (rc = orte_value_array_set_size(&(ival->tokentags), (size_t)num_tokens))) {
ORTE_ERROR_LOG(rc);
OBJ_RELEASE(sub);
OBJ_RELEASE(ival);
return rc;
}
for (j=0; j < num_tokens; j++) {
@ -146,12 +161,14 @@ orte_gpr_replica_register_subscription(orte_gpr_replica_subscription_t **subptr,
free(tokentags);
tokentags = NULL;
}
if (NULL != subscription->values[i]->keyvals &&
0 < subscription->values[i]->cnt) {
num_keys = subscription->values[i]->cnt;
if (ORTE_SUCCESS != (rc = orte_value_array_set_size(&(ival->keytags), num_keys))) {
ORTE_ERROR_LOG(rc);
OBJ_RELEASE(sub);
OBJ_RELEASE(ival);
return rc;
}
for (j=0; j < num_keys; j++) {
@ -159,6 +176,8 @@ orte_gpr_replica_register_subscription(orte_gpr_replica_subscription_t **subptr,
ival->seg,
subscription->values[i]->keyvals[j]->key))) {
ORTE_ERROR_LOG(rc);
OBJ_RELEASE(sub);
OBJ_RELEASE(ival);
return rc;
}
ORTE_VALUE_ARRAY_SET_ITEM(&(ival->keytags), orte_gpr_replica_itag_t,
@ -168,6 +187,8 @@ orte_gpr_replica_register_subscription(orte_gpr_replica_subscription_t **subptr,
/* add the object to the subscription's value pointer array */
if (0 > (rc = orte_pointer_array_add(&(ival->index), sub->values, ival))) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_RELEASE(sub);
OBJ_RELEASE(ival);
return ORTE_ERR_OUT_OF_RESOURCE;
}
(sub->num_values)++;
@ -175,10 +196,11 @@ orte_gpr_replica_register_subscription(orte_gpr_replica_subscription_t **subptr,
/* add the object to the replica's subscriptions pointer array */
if (0 > (rc = orte_pointer_array_add(&(sub->index), orte_gpr_replica.subscriptions, sub))) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_RELEASE(sub);
return ORTE_ERR_OUT_OF_RESOURCE;
}
(orte_gpr_replica.num_subs)++;
ADDREQ:
/* add this requestor to the subscription */
req = OBJ_NEW(orte_gpr_replica_requestor_t);
@ -196,13 +218,13 @@ ADDREQ:
} else {
req->requestor = NULL;
}
if (0 > (rc = orte_pointer_array_add(&(req->index), sub->requestors, req))) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
(sub->num_requestors)++;
/* store the requestor's subscription id so they can ask
* us to cancel their subscription at a later time,
* if they choose to do so, and so that we can tell
@ -213,7 +235,7 @@ ADDREQ:
/* record where the subscription went */
*subptr = sub;
return ORTE_SUCCESS;
}
@ -236,7 +258,7 @@ orte_gpr_replica_register_trigger(orte_gpr_replica_trigger_t **trigptr,
/* set a default response value */
*trigptr = NULL;
/* if this is a named trigger, see if that name has
* already been entered on the replica. If it has, then we
* can simply return the pointer to the existing trigger.
@ -259,11 +281,11 @@ orte_gpr_replica_register_trigger(orte_gpr_replica_trigger_t **trigptr,
}
}
}
/* Either this is NOT a named trigger, or it is named
* but that name is NOT on the current list of triggers.
* Either way, we add this trigger to the replica's list.
*
*
* NOTE that you CANNOT add a subscription to a pre-entered non-named
* trigger - even if all the trigger specifications are
* identical. This is done in the interest of speed as checking
@ -273,11 +295,18 @@ orte_gpr_replica_register_trigger(orte_gpr_replica_trigger_t **trigptr,
* triggers that do not merit such consideration.
*/
/* see if another trigger is available */
if (ORTE_GPR_TRIGGER_ID_MAX-1 < orte_gpr_replica.num_trigs) { /* none left! */
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
trig = OBJ_NEW(orte_gpr_replica_trigger_t);
if (NULL == trig) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
trig->idtag = orte_gpr_replica.num_trigs;
/* if a name for this trigger has been provided, copy it over */
if (NULL != trigger->name) {
@ -285,14 +314,14 @@ orte_gpr_replica_register_trigger(orte_gpr_replica_trigger_t **trigptr,
}
/* copy the action field */
trig->action = trigger->action;
/* put this trigger on the replica's list */
if (0 > (rc = orte_pointer_array_add(&(trig->index), orte_gpr_replica.triggers, trig))) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
(orte_gpr_replica.num_trigs)++;
/* locate and setup the trigger's counters */
for (i=0; i < trigger->cnt; i++) {
/* get this counter's addressing modes */
@ -304,7 +333,7 @@ orte_gpr_replica_register_trigger(orte_gpr_replica_trigger_t **trigptr,
if (0x00 == key_mode) { /* default key address mode to OR */
key_mode = ORTE_GPR_REPLICA_OR;
}
/* locate this counter's segment - this is where the counter will be */
if (ORTE_SUCCESS != (rc = orte_gpr_replica_find_seg(&seg, true,
trigger->values[i]->segment))) {
@ -312,7 +341,7 @@ orte_gpr_replica_register_trigger(orte_gpr_replica_trigger_t **trigptr,
OPAL_THREAD_UNLOCK(&orte_gpr_replica_globals.mutex);
return rc;
}
/* convert the counter's tokens to an itaglist */
if (NULL != (trigger->values[i])->tokens &&
0 < (trigger->values[i])->num_tokens) {
@ -323,21 +352,22 @@ orte_gpr_replica_register_trigger(orte_gpr_replica_trigger_t **trigptr,
goto CLEANUP;
}
}
/* find the specified container(s) */
if (ORTE_SUCCESS != (rc = orte_gpr_replica_find_containers(seg, tok_mode,
tokentags, num_tokens))) {
ORTE_ERROR_LOG(rc);
goto CLEANUP;
}
if (0 == orte_gpr_replica_globals.num_srch_cptr) { /* no existing container found - create one using all the tokens */
if (0 == orte_gpr_replica_globals.num_srch_cptr) {
/* no existing container found - create one using all the tokens */
if (ORTE_SUCCESS != (rc = orte_gpr_replica_create_container(&cptr2, seg,
num_tokens, tokentags))) {
ORTE_ERROR_LOG(rc);
goto CLEANUP;
}
/* ok, store all of this counter's values in the new container, adding a pointer to each
* one in the trigger's counter array
*/
@ -392,7 +422,8 @@ orte_gpr_replica_register_trigger(orte_gpr_replica_trigger_t **trigptr,
0 < orte_gpr_replica_globals.num_srch_ival) {
/* this key already exists - make sure it's unique
*/
if (1 < orte_gpr_replica_globals.num_srch_ival || found) { /* not unique - error out */
if (1 < orte_gpr_replica_globals.num_srch_ival || found) {
/* not unique - error out */
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
rc = ORTE_ERR_BAD_PARAM;
goto CLEANUP;
@ -456,40 +487,51 @@ ADDREQ:
return ORTE_ERR_OUT_OF_RESOURCE;
}
(trig->num_attached)++;
/* store the requestor's trigger id so they can ask
* us to cancel their subscription at a later time,
* if they choose to do so.
*/
req->idtag = trigger->id;
/* see if the ROUTE_DATA_TO_ME flag is set. This indicates
* that the requestor wants all data sent to them and
* is assuming all responsibility for properly routing
* the data
*/
if (ORTE_GPR_TRIG_ROUTE_DATA_THRU_ME & trig->action) {
if (NULL != trig->master) {
if (NULL == trig->master) {
/* someone already requested this responsibility.
* this is an error - report it
* if I'm a singleton, this is NOT an error - the
* initial "launch" has recorded the stage gate
* triggers using the [-1,-1,-1] name, so we need to
* overwrite that with my name so I get the notifications.
*/
ORTE_ERROR_LOG(ORTE_ERR_NOT_AVAILABLE);
#if 0
if (orte_process_info.singleton || orte_process_info.seed) {
opal_output(0, "Trigger master being redefined");
trig->master = req;
} else {
/* if i'm not a singleton, then this is an error - report it */
ORTE_ERROR_LOG(ORTE_ERR_NOT_AVAILABLE);
}
} else {
#endif
trig->master = req;
}
}
/* report the location of this trigger */
*trigptr = trig;
/* record that we had success */
rc = ORTE_SUCCESS;
CLEANUP:
if (NULL != tokentags) {
free(tokentags);
}
return rc;
}
@ -508,7 +550,7 @@ orte_gpr_replica_remove_subscription(orte_process_name_t *requestor,
orte_gpr_replica_trigger_t **trigs;
size_t i, j, k, m;
bool found;
/* find this subscription on the list */
subs = (orte_gpr_replica_subscription_t**)(orte_gpr_replica.subscriptions)->addr;
for (i=0, j=0; j < orte_gpr_replica.num_subs &&
@ -560,7 +602,7 @@ PROCESS:
orte_pointer_array_set_item(orte_gpr_replica.subscriptions, sub->index, NULL);
(orte_gpr_replica.num_subs)--;
}
/* check for this subscription throughout the list of triggers
* and remove it wherever found
*/
@ -593,7 +635,7 @@ PROCESS:
}
/* done with sub, so now can release it if we need to do so */
if (0 == sub->num_requestors) OBJ_RELEASE(sub);
/* ALL DONE! */
return ORTE_SUCCESS;
}
@ -612,7 +654,7 @@ orte_gpr_replica_remove_trigger(orte_process_name_t *requestor,
orte_gpr_replica_trigger_requestor_t **reqs, *req;
orte_gpr_replica_trigger_t **trigs, *trig;
size_t i, j, k, m;
/* find this trigger on the list */
trigs = (orte_gpr_replica_trigger_t**)(orte_gpr_replica.triggers)->addr;
for (i=0, j=0; j < orte_gpr_replica.num_trigs &&
@ -681,10 +723,10 @@ PROCESS:
}
}
}
/* done processing trigger - can release it now, if we need to do so */
if (0 == trig->num_attached) OBJ_RELEASE(trig);
/* ALL DONE! */
return ORTE_SUCCESS;
}
@ -698,35 +740,35 @@ int orte_gpr_replica_record_action(orte_gpr_replica_segment_t *seg,
orte_gpr_replica_action_taken_t *new_action;
size_t index;
int rc;
new_action = OBJ_NEW(orte_gpr_replica_action_taken_t);
if (NULL == new_action) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
new_action->action = action;
/* store pointers to the affected itagval */
new_action->seg = seg;
new_action->cptr = cptr;
new_action->iptr = iptr;
/* "retain" ALL of the respective objects so they can't disappear until
* after we process the actions
*/
OBJ_RETAIN(seg);
OBJ_RETAIN(cptr);
OBJ_RETAIN(iptr);
/* add the new action record to the array */
if (0 > (rc = orte_pointer_array_add(&index, orte_gpr_replica_globals.acted_upon, new_action))) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
/* increment the number acted upon */
(orte_gpr_replica_globals.num_acted_upon)++;
return ORTE_SUCCESS;
}
@ -738,7 +780,7 @@ int orte_gpr_replica_update_storage_locations(orte_gpr_replica_itagval_t *new_ip
orte_gpr_replica_itagval_t **old_iptrs;
size_t i, j, k, m, n, p;
bool replaced;
trig = (orte_gpr_replica_trigger_t**)((orte_gpr_replica.triggers)->addr);
for (i=0, m=0; m < orte_gpr_replica.num_trigs &&
i < (orte_gpr_replica.triggers)->size; i++) {
@ -804,7 +846,7 @@ int orte_gpr_replica_check_events(void)
} /* if notify */
}
}
/* check for triggers that might have fired.
* NOTE: MUST DO THIS *AFTER* THE NOTIFY CHECK. If the trigger was
* set to start notifies after firing, then checking notifies
@ -823,7 +865,7 @@ int orte_gpr_replica_check_events(void)
}
} /* if trig not NULL */
}
/* clean up the action record. The recorded actions from a given
* call into the registry are only needed through the "check_events"
* function call.
@ -837,7 +879,7 @@ int orte_gpr_replica_check_events(void)
}
}
orte_gpr_replica_globals.num_acted_upon = 0;
return ORTE_SUCCESS;
}
@ -854,7 +896,7 @@ int orte_gpr_replica_check_trig(orte_gpr_replica_trigger_t *trig)
size_t i, j;
int cmp;
int rc;
if (ORTE_GPR_TRIG_CMP_LEVELS & trig->action) { /* compare the levels of the counters */
cntr = (orte_gpr_replica_counter_t**)((trig->counters)->addr);
first = true;
@ -883,7 +925,7 @@ int orte_gpr_replica_check_trig(orte_gpr_replica_trigger_t *trig)
goto FIRED;
}
return ORTE_SUCCESS;
} else if (ORTE_GPR_TRIG_AT_LEVEL & trig->action) { /* see if counters are at a level */
cntr = (orte_gpr_replica_counter_t**)((trig->counters)->addr);
fire = true;
@ -907,50 +949,83 @@ int orte_gpr_replica_check_trig(orte_gpr_replica_trigger_t *trig)
}
return ORTE_SUCCESS;
}
return ORTE_SUCCESS; /* neither cmp nor at level set */
FIRED:
/* for each subscription associated with this trigger, we need to
* register a callback to the requestor that returns the specified
* data
/* if this trigger wants everything routed through a "master", then we register
* this as a trigger_callback.
*/
subs = (orte_gpr_replica_subscription_t**)(trig->subscriptions)->addr;
for (i=0, j=0; j < trig->num_subscriptions &&
i < (trig->subscriptions)->size; i++) {
if (NULL != subs[i]) {
j++;
if (ORTE_SUCCESS != (rc = orte_gpr_replica_register_callback(trig, subs[i], NULL))) {
ORTE_ERROR_LOG(rc);
return rc;
if (NULL != trig->master) {
if (ORTE_SUCCESS != (rc = orte_gpr_replica_register_trigger_callback(trig))) {
ORTE_ERROR_LOG(rc);
return rc;
}
/* for each subscription assocated with this trigger, check to see if
* the subscription needs any special treatment
*/
subs = (orte_gpr_replica_subscription_t**)(trig->subscriptions)->addr;
for (i=0, j=0; j < trig->num_subscriptions &&
i < (trig->subscriptions)->size; i++) {
if (NULL != subs[i]) {
j++;
/* if ORTE_GPR_NOTIFY_STARTS_AFTER_TRIG set, set the subscription
* "active" to indicate that trigger fired
*/
if (ORTE_GPR_NOTIFY_STARTS_AFTER_TRIG & subs[i]->action) {
subs[i]->active = true;
}
/* if ORTE_GPR_NOTIFY_DELETE_AFTER_TRIG set, then set the flag
* so it can be cleaned up later
*/
if (ORTE_GPR_NOTIFY_DELETE_AFTER_TRIG & subs[i]->action) {
subs[i]->cleanup = true;
}
}
/* if ORTE_GPR_NOTIFY_STARTS_AFTER_TRIG set, set the subscription
* "active" to indicate that trigger fired
*/
if (ORTE_GPR_NOTIFY_STARTS_AFTER_TRIG & subs[i]->action) {
subs[i]->active = true;
}
/* if ORTE_GPR_NOTIFY_DELETE_AFTER_TRIG set, then set the flag
* so it can be cleaned up later
*/
if (ORTE_GPR_NOTIFY_DELETE_AFTER_TRIG & subs[i]->action) {
subs[i]->cleanup = true;
}
} else {
/* for each subscription associated with this trigger, we need to
* register a callback to the requestor that returns the specified
* data
*/
subs = (orte_gpr_replica_subscription_t**)(trig->subscriptions)->addr;
for (i=0, j=0; j < trig->num_subscriptions &&
i < (trig->subscriptions)->size; i++) {
if (NULL != subs[i]) {
j++;
if (ORTE_SUCCESS != (rc = orte_gpr_replica_register_callback(subs[i], NULL))) {
ORTE_ERROR_LOG(rc);
return rc;
}
/* if ORTE_GPR_NOTIFY_STARTS_AFTER_TRIG set, set the subscription
* "active" to indicate that trigger fired
*/
if (ORTE_GPR_NOTIFY_STARTS_AFTER_TRIG & subs[i]->action) {
subs[i]->active = true;
}
/* if ORTE_GPR_NOTIFY_DELETE_AFTER_TRIG set, then set the flag
* so it can be cleaned up later
*/
if (ORTE_GPR_NOTIFY_DELETE_AFTER_TRIG & subs[i]->action) {
subs[i]->cleanup = true;
}
}
}
}
/* set the processing flag so we don't go into infinite loop if
* any callback functions modify the registry
*/
trig->processing = true;
/* if this trigger was a one-shot, set flag to indicate it has fired
* so it can be cleaned up later
*/
if (ORTE_GPR_TRIG_ONE_SHOT & trig->action) {
trig->one_shot_fired = true;
}
return ORTE_SUCCESS;
}
@ -965,7 +1040,7 @@ int orte_gpr_replica_check_subscription(orte_gpr_replica_subscription_t *sub)
orte_gpr_value_t *value;
orte_gpr_addr_mode_t addr_mode;
int rc=ORTE_SUCCESS;
/* When entering this function, we know that the specified
* subscription is active since that was tested above. What we now need
* to determine is whether or not any of the data
@ -982,21 +1057,21 @@ int orte_gpr_replica_check_subscription(orte_gpr_replica_subscription_t *sub)
if (
(((sub->action & ORTE_GPR_NOTIFY_ADD_ENTRY) &&
(ptr[i]->action & ORTE_GPR_REPLICA_ENTRY_ADDED)) ||
((sub->action & ORTE_GPR_NOTIFY_DEL_ENTRY) &&
(ptr[i]->action & ORTE_GPR_REPLICA_ENTRY_DELETED)) ||
((sub->action & ORTE_GPR_NOTIFY_VALUE_CHG) &&
(ptr[i]->action & ORTE_GPR_REPLICA_ENTRY_CHG_TO)) ||
((sub->action & ORTE_GPR_NOTIFY_VALUE_CHG) &&
(ptr[i]->action & ORTE_GPR_REPLICA_ENTRY_CHG_FRM)) ||
((sub->action & ORTE_GPR_NOTIFY_VALUE_CHG) &&
(ptr[i]->action & ORTE_GPR_REPLICA_ENTRY_CHANGED)))
&& orte_gpr_replica_check_notify_matches(&addr_mode, sub, ptr[i])) {
/* if the notify matched one of the subscription values,
* then the address mode will have
* been stored for us. we now need to send back
@ -1025,7 +1100,7 @@ int orte_gpr_replica_check_subscription(orte_gpr_replica_subscription_t *sub)
OBJ_RELEASE(value);
return ORTE_ERR_OUT_OF_RESOURCE;
}
value->segment = strdup(ptr[i]->seg->name);
value->num_tokens = ptr[i]->cptr->num_itags;
value->tokens = (char **)malloc(value->num_tokens * sizeof(char*));
@ -1057,7 +1132,7 @@ int orte_gpr_replica_check_subscription(orte_gpr_replica_subscription_t *sub)
goto CLEANUP;
}
if (ORTE_SUCCESS != (rc =
orte_gpr_replica_register_callback(NULL, sub, value))) {
orte_gpr_replica_register_callback(sub, value))) {
ORTE_ERROR_LOG(rc);
goto CLEANUP;
}
@ -1068,7 +1143,7 @@ int orte_gpr_replica_check_subscription(orte_gpr_replica_subscription_t *sub)
}
}
}
CLEANUP:
return rc;
}
@ -1081,7 +1156,7 @@ bool orte_gpr_replica_check_notify_matches(orte_gpr_addr_mode_t *addr_mode,
orte_gpr_replica_addr_mode_t tokmod;
size_t i, j;
orte_gpr_replica_ivalue_t **ivals;
/* we need to run through all of this subscription's defined
* values to see if any of them match the acted upon one.
*/
@ -1094,7 +1169,7 @@ bool orte_gpr_replica_check_notify_matches(orte_gpr_addr_mode_t *addr_mode,
if (ivals[i]->seg != ptr->seg) { /* don't match - return false */
continue;
}
/* next, check to see if the containers match */
tokmod = 0x004f & ivals[i]->addr_mode;
if (!orte_gpr_replica_check_itag_list(tokmod,
@ -1117,7 +1192,7 @@ bool orte_gpr_replica_check_notify_matches(orte_gpr_addr_mode_t *addr_mode,
}
}
}
/* if we get here, then the acted upon value was
* nowhere on the subscription's defined values */
return false;
@ -1130,7 +1205,7 @@ int orte_gpr_replica_purge_subscriptions(orte_process_name_t *proc)
orte_gpr_replica_trigger_t **trig;
size_t i;
int rc;
/* locate any notification events that have proc as the requestor
* and remove them
*/

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

@ -1,21 +1,21 @@
/* -*- C -*-
*
*
* 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.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
*
* Additional copyrights may follow
*
*
* $HEADER$
*
*/
/** @file
/** @file
*/
#ifndef ORTE_GPR_REPLICA_H
@ -77,6 +77,7 @@ typedef uint8_t orte_gpr_replica_action_t;
typedef struct {
opal_object_t super; /**< Allows this to be an object */
orte_gpr_subscription_id_t id; /**< id of this subscription */
size_t index; /**< location of this subscription in array */
char *name;
orte_gpr_notify_cb_fn_t callback; /**< Function to be called for notificaiton */
void *user_tag; /**< User-provided tag for callback function */
@ -92,6 +93,7 @@ OBJ_CLASS_DECLARATION(orte_gpr_replica_local_subscriber_t);
typedef struct {
opal_object_t super; /**< Allows this to be an object */
orte_gpr_trigger_id_t id; /**< id of this trigger */
size_t index; /**< location of this trigger in array */
char *name;
orte_gpr_trigger_cb_fn_t callback; /**< Function to be called for notification */
void *user_tag; /**< User-provided tag for callback function */
@ -136,21 +138,21 @@ typedef struct orte_gpr_replica_dict_t orte_gpr_replica_dict_t;
/*
* Registry "head"
* The registry "head" contains:
*
*
* (2) the next available itag for the segment dictionary.
*
*
* (3) a managed array of pointers to segment objects.
*
* (4) a managed array of pointers to triggers acting on the entire registry
*
*
*/
struct orte_gpr_replica_t {
orte_pointer_array_t *segments; /**< Managed array of pointers to segment objects */
size_t num_segs;
orte_pointer_array_t *triggers; /**< Managed array of pointers to triggers */
size_t num_trigs;
orte_gpr_trigger_id_t num_trigs;
orte_pointer_array_t *subscriptions; /**< Managed array of pointers to subscriptions */
size_t num_subs;
orte_gpr_subscription_id_t num_subs;
bool processing_callbacks;
opal_list_t callbacks; /**< List of callbacks to be processed */
};
@ -183,18 +185,18 @@ OBJ_CLASS_DECLARATION(orte_gpr_replica_segment_t);
/** The core registry structure.
* Each segment of the registry contains an array of registry containers, each composed
* of:
*
* (1) An object structure that allows the structure to be treated with the OBJ
*
* (1) An object structure that allows the structure to be treated with the OBJ
* memory management system
*
*
* (2) An array of itags that define the container - these are 1:1 correspondents with
* the character string tokens provided by caller
*
*
* (3) An array of indices into the trigger notifier array - each index points to
* a notifier whose trigger refers to this container.
*
*
* (4) An array of pointers to keyval objects that actually hold the data.
*
*
* At this time, no security is provided on an object-level basis. Thus, all requests for an
* object are automatically granted. This may be changed at some future time by adding an
* "authorization" linked list of ID's and their access rights to this structure.
@ -260,17 +262,18 @@ typedef struct {
orte_process_name_t *requestor;
/* idtag associated with this subscription */
orte_gpr_subscription_id_t idtag;
/* for a local subscription, where this block of data goes */
orte_gpr_notify_cb_fn_t callback; /**< Function to be called for notification */
void *user_tag; /**< User-provided tag for callback function */
} orte_gpr_replica_requestor_t;
OBJ_CLASS_DECLARATION(orte_gpr_replica_requestor_t);
typedef struct {
opal_object_t super; /**< Makes this an object */
/* index of this entry in subscription array - corresponds to local idtag */
opal_object_t super; /**< Makes this an object */
/* index of this entry in subscription array */
size_t index;
/* idtag for the subscription - may be different than index since
* the data type can be different than size_t
*/
orte_gpr_subscription_id_t idtag;
/* name of this subscription, if provided */
char *name;
/* boolean indicating if this subscription is active or not */
@ -323,8 +326,10 @@ struct orte_gpr_replica_trigger_t {
opal_object_t super; /**< Make this an object */
/* name of this trigger, if provided */
char *name;
/* index of this trigger in the triggers array - corresponds to local idtag */
/* index of this trigger in the triggers array */
size_t index;
/* trigger id on the local system */
orte_gpr_trigger_id_t idtag;
/* array of requestors that have "attached" themselves to this trigger */
size_t num_attached;
orte_pointer_array_t *attached;
@ -398,7 +403,7 @@ OBJ_CLASS_DECLARATION(orte_gpr_replica_callbacks_t);
* of the entry. The GPR requires that each entry be replicated in at least
* two locations. This structure is used to create a linked list of
* replicas for the entry.
*
*
* THIS IS NOT IMPLEMENTED YET
*/
struct orte_gpr_replica_list_t {
@ -415,7 +420,7 @@ OBJ_CLASS_DECLARATION(orte_gpr_replica_list_t);
* is no longer valid, a time tag indicating the time of the last known modification
* of the entry within the global registry, and the replica holding the last known
* up-to-date version of the entry.
*
*
* THIS IS NOT IMPLEMENTED YET
*/
struct orte_gpr_replica_write_invalidate_t {

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

@ -1,21 +1,21 @@
/* -*- C -*-
*
*
* 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.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
*
* Additional copyrights may follow
*
*
* $HEADER$
*
*/
/** @file
/** @file
*/
#ifndef ORTE_GPR_REPLICA_CLASS_INSTANCES_H_
@ -37,6 +37,8 @@
static void orte_gpr_replica_local_subscriber_constructor(orte_gpr_replica_local_subscriber_t *ptr)
{
ptr->name = NULL;
ptr->callback = NULL;
ptr->user_tag = NULL;
}
static void orte_gpr_replica_local_subscriber_destructor(orte_gpr_replica_local_subscriber_t *ptr)
@ -55,6 +57,8 @@ OBJ_CLASS_INSTANCE(
static void orte_gpr_replica_local_trigger_constructor(orte_gpr_replica_local_trigger_t *ptr)
{
ptr->name = NULL;
ptr->callback = NULL;
ptr->user_tag = NULL;
}
static void orte_gpr_replica_local_trigger_destructor(orte_gpr_replica_local_trigger_t *ptr)
@ -76,7 +80,7 @@ static void orte_gpr_replica_segment_construct(orte_gpr_replica_segment_t* seg)
{
seg->name = NULL;
seg->itag = ORTE_GPR_REPLICA_ITAG_MAX;
seg->num_dict_entries = 0;
orte_pointer_array_init(&(seg->dict), orte_gpr_array_block_size,
orte_gpr_array_max_size,
@ -95,7 +99,7 @@ static void orte_gpr_replica_segment_destructor(orte_gpr_replica_segment_t* seg)
size_t i, k;
orte_gpr_replica_dict_t **dptr;
orte_gpr_replica_container_t **cptr;
if (NULL != seg->name) {
free(seg->name);
}
@ -114,7 +118,7 @@ static void orte_gpr_replica_segment_destructor(orte_gpr_replica_segment_t* seg)
}
OBJ_RELEASE(seg->dict);
}
if (NULL != seg->containers) {
cptr = (orte_gpr_replica_container_t**)((seg->containers)->addr);
for (i=0, k=0; k < seg->num_containers &&
@ -148,7 +152,7 @@ static void orte_gpr_replica_container_construct(orte_gpr_replica_container_t* r
orte_gpr_array_max_size,
orte_gpr_array_block_size);
reg->num_itagvals = 0;
OBJ_CONSTRUCT(&(reg->itaglist), orte_value_array_t);
orte_value_array_init(&(reg->itaglist), sizeof(orte_gpr_replica_itag_t));
@ -227,7 +231,7 @@ static void orte_gpr_replica_ivalue_construct(orte_gpr_replica_ivalue_t* ptr)
ptr->index = 0;
ptr->seg = NULL;
ptr->addr_mode = 0;
OBJ_CONSTRUCT(&(ptr->tokentags), orte_value_array_t);
orte_value_array_init(&(ptr->tokentags), sizeof(orte_gpr_replica_itag_t));
@ -303,12 +307,13 @@ OBJ_CLASS_INSTANCE(
static void orte_gpr_replica_subscription_construct(orte_gpr_replica_subscription_t* sub)
{
sub->index = 0;
sub->idtag = ORTE_GPR_SUBSCRIPTION_ID_MAX;
sub->name = NULL;
sub->active = false;
sub->processing = false;
sub->cleanup = false;
sub->action = ORTE_GPR_REPLICA_NO_ACTION;
sub->num_values = 0;
orte_pointer_array_init(&(sub->values), orte_gpr_array_block_size,
orte_gpr_array_max_size,
@ -326,7 +331,7 @@ static void orte_gpr_replica_subscription_destructor(orte_gpr_replica_subscripti
orte_gpr_replica_requestor_t **ptr;
orte_gpr_replica_ivalue_t **ivals;
size_t i, k;
if (NULL != sub->name) free(sub->name);
if (NULL != sub->requestors) {
@ -367,6 +372,7 @@ OBJ_CLASS_INSTANCE(
static void orte_gpr_replica_trigger_requestor_construct(orte_gpr_replica_trigger_requestor_t* ptr)
{
ptr->index = 0;
ptr->idtag = ORTE_GPR_TRIGGER_ID_MAX;
ptr->requestor = NULL;
ptr->idtag = 0;
}
@ -391,6 +397,7 @@ static void orte_gpr_replica_trigger_construct(orte_gpr_replica_trigger_t* trig)
{
trig->name = NULL;
trig->index = 0;
trig->idtag = ORTE_GPR_TRIGGER_ID_MAX;
trig->num_attached = 0;
orte_pointer_array_init(&(trig->attached), orte_gpr_array_block_size,
@ -398,11 +405,11 @@ static void orte_gpr_replica_trigger_construct(orte_gpr_replica_trigger_t* trig)
orte_gpr_array_block_size);
trig->master = NULL;;
trig->action = ORTE_GPR_REPLICA_NO_ACTION;
trig->one_shot_fired = false;
trig->processing = false;
trig->num_counters = 0;
orte_pointer_array_init(&(trig->counters), orte_gpr_array_block_size,
orte_gpr_array_max_size,
@ -421,7 +428,7 @@ static void orte_gpr_replica_trigger_destructor(orte_gpr_replica_trigger_t* trig
size_t i, cnt;
orte_gpr_replica_counter_t **cntrs;
orte_gpr_replica_trigger_requestor_t **att;
if (NULL != trig->name) {
free(trig->name);
}
@ -515,11 +522,11 @@ static void orte_gpr_replica_callbacks_construct(orte_gpr_replica_callbacks_t* c
static void orte_gpr_replica_callbacks_destructor(orte_gpr_replica_callbacks_t* cb)
{
if (NULL != cb->message) OBJ_RELEASE(cb->message);
if (NULL != cb->requestor) {
free(cb->requestor);
}
}
/* define instance of opal_class_t */

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

@ -4,14 +4,14 @@
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
*
* Additional copyrights may follow
*
*
* $HEADER$
*/
/** @file:
@ -43,17 +43,17 @@
*/
OMPI_COMP_EXPORT mca_gpr_base_component_t mca_gpr_replica_component = {
{
MCA_GPR_BASE_VERSION_1_0_0,
MCA_GPR_BASE_VERSION_1_0_0,
"replica", /* MCA module name */
ORTE_MAJOR_VERSION, /* MCA module major version */
ORTE_MINOR_VERSION, /* MCA module minor version */
ORTE_RELEASE_VERSION, /* MCA module release version */
orte_gpr_replica_open, /* module open */
orte_gpr_replica_close /* module close */
"replica", /* MCA module name */
ORTE_MAJOR_VERSION, /* MCA module major version */
ORTE_MINOR_VERSION, /* MCA module minor version */
ORTE_RELEASE_VERSION, /* MCA module release version */
orte_gpr_replica_open, /* module open */
orte_gpr_replica_close /* module close */
},
{
false /* checkpoint / restart */
false /* checkpoint / restart */
},
orte_gpr_replica_init, /* module init */
orte_gpr_replica_finalize /* module shutdown */
@ -82,6 +82,7 @@ static orte_gpr_base_module_t orte_gpr_replica_module = {
/* GENERAL OPERATIONS */
orte_gpr_replica_preallocate_segment,
orte_gpr_base_xfer_payload,
orte_gpr_replica_deliver_notify_msg,
/* ARITHMETIC OPERATIONS */
orte_gpr_replica_increment_value,
orte_gpr_replica_decrement_value,
@ -90,6 +91,7 @@ static orte_gpr_base_module_t orte_gpr_replica_module = {
orte_gpr_base_subscribe_1,
orte_gpr_base_subscribe_N,
orte_gpr_base_define_trigger,
orte_gpr_base_define_trigger_level,
orte_gpr_replica_unsubscribe,
orte_gpr_replica_cancel_trigger,
/* COMPOUND COMMANDS */
@ -101,6 +103,8 @@ static orte_gpr_base_module_t orte_gpr_replica_module = {
orte_gpr_replica_dump_segments,
orte_gpr_replica_dump_triggers,
orte_gpr_replica_dump_subscriptions,
orte_gpr_replica_dump_a_trigger,
orte_gpr_replica_dump_a_subscription,
orte_gpr_replica_dump_local_triggers,
orte_gpr_replica_dump_local_subscriptions,
orte_gpr_replica_dump_callbacks,
@ -139,7 +143,7 @@ int orte_gpr_replica_open(void)
} else {
orte_gpr_replica_globals.debug = false;
}
id = mca_base_param_register_int("gpr", "replica", "isolate", NULL, 0);
mca_base_param_lookup_int(id, &tmp);
if (tmp) {
@ -162,28 +166,28 @@ int orte_gpr_replica_close(void)
orte_gpr_base_module_t *orte_gpr_replica_init(bool *allow_multi_user_threads, bool *have_hidden_threads, int *priority)
{
int rc;
/* If we are to host a replica, then we want to be selected, so do all the
setup and return the module */
if (NULL == orte_process_info.gpr_replica_uri) {
/* Return a module (choose an arbitrary, positive priority --
it's only relevant compared to other ns components). If
we're not the seed, then we don't want to be selected, so
return NULL. */
*priority = 50;
/* We allow multi user threads but don't have any hidden threads */
*allow_multi_user_threads = true;
*have_hidden_threads = false;
/* setup the thread locks and condition variables */
OBJ_CONSTRUCT(&orte_gpr_replica_globals.mutex, opal_mutex_t);
/* Return a module (choose an arbitrary, positive priority --
it's only relevant compared to other ns components). If
we're not the seed, then we don't want to be selected, so
return NULL. */
/* initialize the registry head */
*priority = 50;
/* We allow multi user threads but don't have any hidden threads */
*allow_multi_user_threads = true;
*have_hidden_threads = false;
/* setup the thread locks and condition variables */
OBJ_CONSTRUCT(&orte_gpr_replica_globals.mutex, opal_mutex_t);
/* initialize the registry head */
if (ORTE_SUCCESS != (rc = orte_pointer_array_init(&(orte_gpr_replica.segments),
orte_gpr_array_block_size,
orte_gpr_array_max_size,
@ -192,7 +196,7 @@ orte_gpr_base_module_t *orte_gpr_replica_init(bool *allow_multi_user_threads, bo
return NULL;
}
orte_gpr_replica.num_segs = 0;
if (ORTE_SUCCESS != (rc = orte_pointer_array_init(&(orte_gpr_replica.triggers),
orte_gpr_array_block_size,
orte_gpr_array_max_size,
@ -201,7 +205,7 @@ orte_gpr_base_module_t *orte_gpr_replica_init(bool *allow_multi_user_threads, bo
return NULL;
}
orte_gpr_replica.num_trigs = 0;
if (ORTE_SUCCESS != (rc = orte_pointer_array_init(&(orte_gpr_replica.subscriptions),
orte_gpr_array_block_size,
orte_gpr_array_max_size,
@ -210,11 +214,11 @@ orte_gpr_base_module_t *orte_gpr_replica_init(bool *allow_multi_user_threads, bo
return NULL;
}
orte_gpr_replica.num_subs = 0;
/* initialize the callback list head */
OBJ_CONSTRUCT(&orte_gpr_replica.callbacks, opal_list_t);
/* initialize the callback list head */
OBJ_CONSTRUCT(&orte_gpr_replica.callbacks, opal_list_t);
orte_gpr_replica.processing_callbacks = false;
/* initialize the local subscription and trigger trackers */
if (ORTE_SUCCESS != (rc = orte_pointer_array_init(
&(orte_gpr_replica_globals.local_subscriptions),
@ -235,7 +239,7 @@ orte_gpr_base_module_t *orte_gpr_replica_init(bool *allow_multi_user_threads, bo
return NULL;
}
orte_gpr_replica_globals.num_local_trigs = 0;
/* initialize the search arrays for temporarily storing search results */
if (ORTE_SUCCESS != (rc = orte_pointer_array_init(&(orte_gpr_replica_globals.sub_ptrs),
100, orte_gpr_array_max_size, 100))) {
@ -249,7 +253,7 @@ orte_gpr_base_module_t *orte_gpr_replica_init(bool *allow_multi_user_threads, bo
return NULL;
}
orte_gpr_replica_globals.num_srch_cptr = 0;
if (ORTE_SUCCESS != (rc = orte_pointer_array_init(&(orte_gpr_replica_globals.overwritten),
20, orte_gpr_array_max_size, 20))) {
ORTE_ERROR_LOG(rc);
@ -270,29 +274,29 @@ orte_gpr_base_module_t *orte_gpr_replica_init(bool *allow_multi_user_threads, bo
return NULL;
}
orte_gpr_replica_globals.num_acted_upon = 0;
if (ORTE_SUCCESS != (rc = orte_bitmap_init(&(orte_gpr_replica_globals.srch_itag), 64))) {
ORTE_ERROR_LOG(rc);
return NULL;
}
if (orte_gpr_replica_globals.debug) {
opal_output(0, "nb receive setup");
}
/* Return the module */
/* Return the module */
initialized = true;
return &orte_gpr_replica_module;
} else {
return NULL;
return NULL;
}
}
int orte_gpr_replica_module_init(void)
{
/* issue the non-blocking receive */
/* issue the non-blocking receive */
if (!orte_gpr_replica_globals.isolate) {
int rc = orte_rml.recv_buffer_nb(ORTE_RML_NAME_ANY, ORTE_RML_TAG_GPR, 0, orte_gpr_replica_recv, NULL);
if(rc < 0) {
@ -302,7 +306,7 @@ int orte_gpr_replica_module_init(void)
}
return ORTE_SUCCESS;
}
/*
* finalize routine
@ -313,9 +317,9 @@ int orte_gpr_replica_finalize(void)
orte_gpr_replica_segment_t** seg;
orte_gpr_replica_trigger_t** trig;
orte_gpr_replica_callbacks_t* cb;
if (orte_gpr_replica_globals.debug) {
opal_output(0, "finalizing gpr replica");
opal_output(0, "finalizing gpr replica");
}
seg = (orte_gpr_replica_segment_t**)(orte_gpr_replica.segments)->addr;
@ -327,7 +331,7 @@ int orte_gpr_replica_finalize(void)
}
}
OBJ_RELEASE(orte_gpr_replica.segments);
trig = (orte_gpr_replica_trigger_t**)(orte_gpr_replica.triggers)->addr;
for (i=0, j=0; j < orte_gpr_replica.num_trigs &&
i < (orte_gpr_replica.triggers)->size; i++) {
@ -337,7 +341,7 @@ int orte_gpr_replica_finalize(void)
}
}
OBJ_RELEASE(orte_gpr_replica.triggers);
while (NULL != (cb = (orte_gpr_replica_callbacks_t*)opal_list_remove_first(&orte_gpr_replica.callbacks))) {
OBJ_RELEASE(cb);
}
@ -345,15 +349,15 @@ int orte_gpr_replica_finalize(void)
/* clean up the globals */
if (NULL != orte_gpr_replica_globals.srch_cptr) {
OBJ_RELEASE(orte_gpr_replica_globals.srch_cptr);
}
if (NULL != orte_gpr_replica_globals.overwritten) {
OBJ_RELEASE(orte_gpr_replica_globals.overwritten);
}
if (NULL != orte_gpr_replica_globals.srch_ival) {
OBJ_RELEASE(orte_gpr_replica_globals.srch_ival);
}
@ -366,7 +370,7 @@ int orte_gpr_replica_finalize(void)
if (orte_gpr_replica_globals.isolate) {
return ORTE_SUCCESS;
}
orte_rml.recv_cancel(ORTE_RML_NAME_ANY, ORTE_RML_TAG_GPR);
orte_rml.recv_cancel(ORTE_RML_NAME_ANY, ORTE_RML_TAG_GPR);
return ORTE_SUCCESS;
}

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

@ -3,14 +3,14 @@
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
*
* Additional copyrights may follow
*
*
* $HEADER$
*/
/** @file:
@ -43,7 +43,7 @@ int orte_ns_replica_create_cellid(orte_cellid_t *cellid, char *site, char *resou
orte_ns_replica_cell_tracker_t *new_cell;
int rc;
size_t index;
OPAL_THREAD_LOCK(&orte_ns_replica.mutex);
*cellid = ORTE_CELLID_MAX;
@ -76,9 +76,9 @@ int orte_ns_replica_create_cellid(orte_cellid_t *cellid, char *site, char *resou
new_cell->cell = orte_ns_replica.num_cells;
*cellid = new_cell->cell;
(orte_ns_replica.num_cells)++;
OPAL_THREAD_UNLOCK(&orte_ns_replica.mutex);
return ORTE_SUCCESS;
OPAL_THREAD_UNLOCK(&orte_ns_replica.mutex);
return ORTE_SUCCESS;
}
int orte_ns_replica_get_cell_info(orte_cellid_t cellid,
@ -86,7 +86,7 @@ int orte_ns_replica_get_cell_info(orte_cellid_t cellid,
{
size_t i, j;
orte_ns_replica_cell_tracker_t **cell;
OPAL_THREAD_LOCK(&orte_ns_replica.mutex);
cell = (orte_ns_replica_cell_tracker_t**)(orte_ns_replica.cells)->addr;
@ -106,7 +106,7 @@ int orte_ns_replica_get_cell_info(orte_cellid_t cellid,
OPAL_THREAD_UNLOCK(&orte_ns_replica.mutex);
return ORTE_ERR_NOT_FOUND;
}
/*
* JOBID functions
@ -116,7 +116,7 @@ int orte_ns_replica_create_jobid(orte_jobid_t *jobid)
orte_ns_replica_jobid_tracker_t *ptr;
int rc;
size_t index;
OPAL_THREAD_LOCK(&orte_ns_replica.mutex);
*jobid = ORTE_JOBID_MAX;
@ -129,7 +129,7 @@ int orte_ns_replica_create_jobid(orte_jobid_t *jobid)
OPAL_THREAD_UNLOCK(&orte_ns_replica.mutex);
return ORTE_ERR_OUT_OF_RESOURCE;
}
ptr = OBJ_NEW(orte_ns_replica_jobid_tracker_t);
if (NULL == ptr) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
@ -143,11 +143,11 @@ int orte_ns_replica_create_jobid(orte_jobid_t *jobid)
OPAL_THREAD_UNLOCK(&orte_ns_replica.mutex);
return rc;
}
ptr->jobid = orte_ns_replica.num_jobids;
*jobid = ptr->jobid;
(orte_ns_replica.num_jobids)++;
OPAL_THREAD_UNLOCK(&orte_ns_replica.mutex);
return ORTE_SUCCESS;
}
@ -178,7 +178,7 @@ int orte_ns_replica_reserve_range(orte_jobid_t job, orte_vpid_t range,
ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND);
OPAL_THREAD_UNLOCK(&orte_ns_replica.mutex);
return ORTE_ERR_NOT_FOUND;
PROCESS:
if ((ORTE_VPID_MAX-range-(ptr[j]->next_vpid)) > 0) {
*start = ptr[j]->next_vpid;
@ -186,21 +186,21 @@ PROCESS:
OPAL_THREAD_UNLOCK(&orte_ns_replica.mutex);
return ORTE_SUCCESS;
}
/* get here if the range isn't available */
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OPAL_THREAD_UNLOCK(&orte_ns_replica.mutex);
return ORTE_ERR_OUT_OF_RESOURCE;
}
int orte_ns_replica_get_job_peers(orte_process_name_t **procs,
int orte_ns_replica_get_job_peers(orte_process_name_t **procs,
size_t *num_procs, orte_jobid_t job)
{
orte_ns_replica_jobid_tracker_t **ptr;
orte_process_name_t *nptr;
size_t j;
orte_jobid_t k;
OPAL_THREAD_LOCK(&orte_ns_replica.mutex);
/* find the jobid */
@ -235,9 +235,10 @@ PROCESS:
nptr->cellid = 0;
nptr->jobid = job;
nptr->vpid = (orte_vpid_t)k;
nptr++;
}
*num_procs = (size_t)ptr[j]->next_vpid;
OPAL_THREAD_UNLOCK(&orte_ns_replica.mutex);
return ORTE_SUCCESS;
}
@ -250,19 +251,19 @@ int orte_ns_replica_dump_cells(int output_id)
{
orte_buffer_t buffer;
int rc;
OBJ_CONSTRUCT(&buffer, orte_buffer_t);
if (ORTE_SUCCESS != (rc = orte_ns_replica_dump_cells_fn(&buffer))) {
ORTE_ERROR_LOG(rc);
return rc;
}
if (ORTE_SUCCESS != (rc = orte_ns_base_print_dump(&buffer, output_id))) {
ORTE_ERROR_LOG(rc);
OBJ_DESTRUCT(&buffer);
return rc;
}
OBJ_DESTRUCT(&buffer);
return ORTE_SUCCESS;
}
@ -315,20 +316,20 @@ int orte_ns_replica_dump_jobs(int output_id)
{
orte_buffer_t buffer;
int rc;
OBJ_CONSTRUCT(&buffer, orte_buffer_t);
if (ORTE_SUCCESS != (rc = orte_ns_replica_dump_jobs_fn(&buffer))) {
ORTE_ERROR_LOG(rc);
return rc;
}
if (ORTE_SUCCESS != (rc = orte_ns_base_print_dump(&buffer, output_id))) {
ORTE_ERROR_LOG(rc);
OBJ_DESTRUCT(&buffer);
return rc;
}
OBJ_DESTRUCT(&buffer);
return ORTE_SUCCESS;
}
@ -375,19 +376,19 @@ int orte_ns_replica_dump_tags(int output_id)
{
orte_buffer_t buffer;
int rc;
OBJ_CONSTRUCT(&buffer, orte_buffer_t);
if (ORTE_SUCCESS != (rc = orte_ns_replica_dump_tags_fn(&buffer))) {
ORTE_ERROR_LOG(rc);
return rc;
}
if (ORTE_SUCCESS != (rc = orte_ns_base_print_dump(&buffer, output_id))) {
ORTE_ERROR_LOG(rc);
OBJ_DESTRUCT(&buffer);
return rc;
}
OBJ_DESTRUCT(&buffer);
return ORTE_SUCCESS;
}
@ -434,19 +435,19 @@ int orte_ns_replica_dump_datatypes(int output_id)
{
orte_buffer_t buffer;
int rc;
OBJ_CONSTRUCT(&buffer, orte_buffer_t);
if (ORTE_SUCCESS != (rc = orte_ns_replica_dump_datatypes_fn(&buffer))) {
ORTE_ERROR_LOG(rc);
return rc;
}
if (ORTE_SUCCESS != (rc = orte_ns_base_print_dump(&buffer, output_id))) {
ORTE_ERROR_LOG(rc);
OBJ_DESTRUCT(&buffer);
return rc;
}
OBJ_DESTRUCT(&buffer);
return ORTE_SUCCESS;
}
@ -497,7 +498,7 @@ int orte_ns_replica_assign_rml_tag(orte_rml_tag_t *tag,
orte_ns_replica_tagitem_t *tagitem, **tags;
size_t i, j;
int rc;
OPAL_THREAD_LOCK(&orte_ns_replica.mutex);
if (NULL != name) {
@ -516,10 +517,10 @@ int orte_ns_replica_assign_rml_tag(orte_rml_tag_t *tag,
}
}
}
/* not in list or not provided, so allocate next tag */
*tag = ORTE_RML_TAG_MAX;
/* check if tag is available - need to do this since the tag type
* is probably not going to be a size_t, so we cannot just rely
* on the pointer_array's size limits to protect us. NOTE: need to
@ -531,7 +532,7 @@ int orte_ns_replica_assign_rml_tag(orte_rml_tag_t *tag,
OPAL_THREAD_UNLOCK(&orte_ns_replica.mutex);
return ORTE_ERR_OUT_OF_RESOURCE;
}
tagitem = OBJ_NEW(orte_ns_replica_tagitem_t);
if (NULL == tagitem) { /* out of memory */
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
@ -557,7 +558,7 @@ int orte_ns_replica_assign_rml_tag(orte_rml_tag_t *tag,
return ORTE_SUCCESS;
}
/*
* DATA TYPE SERVER functions
*/
@ -567,12 +568,12 @@ int orte_ns_replica_define_data_type(const char *name,
orte_ns_replica_dti_t **dti, *dtip;
size_t i, j;
int rc;
if (NULL == name || 0 < *type) {
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
return ORTE_ERR_BAD_PARAM;
}
OPAL_THREAD_LOCK(&orte_ns_replica.mutex);
dti = (orte_ns_replica_dti_t**)orte_ns_replica.dts->addr;
@ -588,10 +589,10 @@ int orte_ns_replica_define_data_type(const char *name,
}
}
}
/* not in list or not provided, so allocate next id */
*type = ORTE_DPS_ID_MAX;
/* check if id is available - need to do this since the data type
* is probably not going to be a size_t, so we cannot just rely
* on the pointer_array's size limits to protect us.
@ -617,7 +618,7 @@ int orte_ns_replica_define_data_type(const char *name,
}
dtip->id = orte_ns_replica.num_dts;
(orte_ns_replica.num_dts)++;
*type = dtip->id;
OPAL_THREAD_UNLOCK(&orte_ns_replica.mutex);
return ORTE_SUCCESS;
@ -633,7 +634,7 @@ int orte_ns_replica_create_my_name(void)
orte_jobid_t jobid;
orte_vpid_t vpid;
int rc;
if (ORTE_SUCCESS != (rc = orte_ns.create_jobid(&jobid))) {
ORTE_ERROR_LOG(rc);
return rc;
@ -647,6 +648,6 @@ int orte_ns_replica_create_my_name(void)
ORTE_ERROR_LOG(rc);
return rc;
}
return ORTE_SUCCESS;
}

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

@ -26,6 +26,7 @@
#include "dps/dps_types.h"
#include "mca/mca.h"
#include "mca/ns/ns_types.h"
#include "mca/gpr/gpr_types.h"
#include "mca/oob/oob_types.h"
#ifdef HAVE_SYS_UIO_H
@ -406,7 +407,7 @@ OMPI_DECLSPEC int mca_oob_xcast(
orte_process_name_t* peers,
size_t num_peers,
orte_buffer_t* buffer,
mca_oob_callback_packed_fn_t cbfunc);
orte_gpr_trigger_cb_fn_t cbfunc);
#if defined(c_plusplus) || defined(__cplusplus)
}

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

@ -20,6 +20,7 @@
#include "include/constants.h"
#include "opal/util/output.h"
#include "util/proc_info.h"
#include "orte/dps/dps.h"
#include "mca/oob/oob.h"
#include "mca/oob/base/base.h"
#include "mca/ns/ns.h"
@ -46,7 +47,7 @@ int mca_oob_xcast(
orte_process_name_t* peers,
size_t num_peers,
orte_buffer_t* buffer,
mca_oob_callback_packed_fn_t cbfunc)
orte_gpr_trigger_cb_fn_t cbfunc)
{
size_t i;
int rc;
@ -74,14 +75,29 @@ int mca_oob_xcast(
}
} else {
orte_buffer_t rbuf;
orte_gpr_notify_message_t *msg;
OBJ_CONSTRUCT(&rbuf, orte_buffer_t);
rc = mca_oob_recv_packed(MCA_OOB_NAME_ANY, &rbuf, tag);
if(rc < 0) {
OBJ_DESTRUCT(&rbuf);
return rc;
}
if(cbfunc != NULL)
cbfunc(rc, root, &rbuf, tag, NULL);
if (cbfunc != NULL) {
msg = OBJ_NEW(orte_gpr_notify_message_t);
if (NULL == msg) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
i=1;
if (ORTE_SUCCESS != (rc = orte_dps.unpack(&rbuf, &msg, &i, ORTE_GPR_NOTIFY_MSG))) {
ORTE_ERROR_LOG(rc);
OBJ_RELEASE(msg);
return rc;
}
cbfunc(msg);
OBJ_RELEASE(msg);
}
OBJ_DESTRUCT(&rbuf);
}
return ORTE_SUCCESS;

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

@ -194,7 +194,7 @@ typedef int (*mca_oob_base_module_xcast_fn_t)(orte_process_name_t* root,
orte_process_name_t* peers,
size_t num_peers,
orte_buffer_t* buffer,
mca_oob_callback_packed_fn_t cbfunc);
orte_gpr_trigger_cb_fn_t cbfunc);
/**
* OOB Module

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

@ -1,16 +1,16 @@
/*
/*
* 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.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
*
* Additional copyrights may follow
*
*
* $HEADER$
*/
@ -45,37 +45,37 @@
things like EAGAIN, EINPROGRESS, etc. It has been verified that this will \
not conflict with other error codes that are returned by these functions \
under UNIX/Linux environments */
/*
* Data structure for accepting connections.
*/
struct mca_oob_tcp_event_t {
opal_list_item_t item;
opal_event_t event;
};
typedef struct mca_oob_tcp_event_t mca_oob_tcp_event_t;
static void mca_oob_tcp_event_construct(mca_oob_tcp_event_t* event)
{
OPAL_THREAD_LOCK(&mca_oob_tcp_component.tcp_lock);
opal_list_append(&mca_oob_tcp_component.tcp_events, &event->item);
OPAL_THREAD_UNLOCK(&mca_oob_tcp_component.tcp_lock);
}
static void mca_oob_tcp_event_destruct(mca_oob_tcp_event_t* event)
{
OPAL_THREAD_LOCK(&mca_oob_tcp_component.tcp_lock);
opal_list_remove_item(&mca_oob_tcp_component.tcp_events, &event->item);
OPAL_THREAD_UNLOCK(&mca_oob_tcp_component.tcp_lock);
}
OBJ_CLASS_INSTANCE(
mca_oob_tcp_event_t,
opal_list_item_t,
mca_oob_tcp_event_construct,
mca_oob_tcp_event_destruct);
/*
* Local utility functions
*/
@ -117,7 +117,7 @@ mca_oob_tcp_component_t mca_oob_tcp_component = {
{
false /* checkpoint / restart */
},
mca_oob_tcp_component_init
mca_oob_tcp_component_init
}
};
@ -174,7 +174,7 @@ int mca_oob_tcp_component_open(void)
return OMPI_ERROR;
}
#endif
OBJ_CONSTRUCT(&mca_oob_tcp_component.tcp_subscriptions, opal_list_t);
OBJ_CONSTRUCT(&mca_oob_tcp_component.tcp_peer_list, opal_list_t);
OBJ_CONSTRUCT(&mca_oob_tcp_component.tcp_peers, opal_hash_table_t);
@ -216,7 +216,7 @@ int mca_oob_tcp_component_close(void)
#ifdef WIN32
WSACleanup();
#endif
/* cleanup resources */
OBJ_DESTRUCT(&mca_oob_tcp_component.tcp_peer_list);
OBJ_DESTRUCT(&mca_oob_tcp_component.tcp_peers);
@ -247,7 +247,7 @@ static void mca_oob_tcp_accept(void)
struct sockaddr_in addr;
mca_oob_tcp_event_t* event;
int sd;
sd = accept(mca_oob_tcp_component.tcp_listen_sd, (struct sockaddr*)&addr, &addrlen);
if(sd < 0) {
IMPORTANT_WINDOWS_COMMENT();
@ -265,7 +265,7 @@ static void mca_oob_tcp_accept(void)
inet_ntoa(addr.sin_addr),
addr.sin_port);
}
/* wait for receipt of peers process identifier to complete this connection */
event = OBJ_NEW(mca_oob_tcp_event_t);
opal_event_set(&event->event, sd, OPAL_EV_READ, mca_oob_tcp_recv_handler, event);
@ -276,7 +276,7 @@ static void mca_oob_tcp_accept(void)
/*
* Create a listen socket and bind to all interfaces
*/
static int mca_oob_tcp_create_listen(void)
{
int flags;
@ -306,13 +306,13 @@ static int mca_oob_tcp_create_listen(void)
return OMPI_ERROR;
}
mca_oob_tcp_component.tcp_listen_port = inaddr.sin_port;
/* setup listen backlog to maximum allowed by kernel */
if(listen(mca_oob_tcp_component.tcp_listen_sd, SOMAXCONN) < 0) {
opal_output(0, "mca_oob_tcp_component_init: listen() failed with errno=%d", ompi_socket_errno);
return OMPI_ERROR;
}
/* set socket up to be non-blocking, otherwise accept could block */
if((flags = fcntl(mca_oob_tcp_component.tcp_listen_sd, F_GETFL, 0)) < 0) {
opal_output(0, "mca_oob_tcp_component_init: fcntl(F_GETFL) failed with errno=%d", ompi_socket_errno);
@ -324,7 +324,7 @@ static int mca_oob_tcp_create_listen(void)
return OMPI_ERROR;
}
}
/* register listen port */
opal_event_set(
&mca_oob_tcp_component.tcp_recv_event,
@ -380,18 +380,18 @@ static void mca_oob_tcp_recv_connect(int sd, mca_oob_tcp_hdr_t* hdr)
/* now set socket up to be non-blocking */
if((flags = fcntl(sd, F_GETFL, 0)) < 0) {
opal_output(0, "[%lu,%lu,%lu] mca_oob_tcp_recv_handler: fcntl(F_GETFL) failed with errno=%d",
opal_output(0, "[%lu,%lu,%lu] mca_oob_tcp_recv_handler: fcntl(F_GETFL) failed with errno=%d",
ORTE_NAME_ARGS(orte_process_info.my_name), ompi_socket_errno);
} else {
flags |= O_NONBLOCK;
if(fcntl(sd, F_SETFL, flags) < 0) {
opal_output(0, "[%lu,%lu,%lu] mca_oob_tcp_recv_handler: fcntl(F_SETFL) failed with errno=%d",
opal_output(0, "[%lu,%lu,%lu] mca_oob_tcp_recv_handler: fcntl(F_SETFL) failed with errno=%d",
ORTE_NAME_ARGS(orte_process_info.my_name), ompi_socket_errno);
}
}
/* check for wildcard name - if this is true - we allocate a name from the name server
* and return to the peer
/* check for wildcard name - if this is true - we allocate a name from the name server
* and return to the peer
*/
cmpval = orte_ns.compare(ORTE_NS_CMP_ALL, &hdr->msg_src, MCA_OOB_NAME_ANY);
if (cmpval == 0) {
@ -458,7 +458,7 @@ static void mca_oob_tcp_recv_handler(int sd, short flags, void* user)
return;
}
if(ompi_socket_errno != EINTR) {
opal_output(0, "[%lu,%lu,%lu] mca_oob_tcp_recv_handler: recv() failed with errno=%d\n",
opal_output(0, "[%lu,%lu,%lu] mca_oob_tcp_recv_handler: recv() failed with errno=%d\n",
ORTE_NAME_ARGS(orte_process_info.my_name), ompi_socket_errno);
close(sd);
return;
@ -475,7 +475,7 @@ static void mca_oob_tcp_recv_handler(int sd, short flags, void* user)
mca_oob_tcp_recv_connect(sd, &hdr);
break;
default:
opal_output(0, "[%lu,%lu,%lu] mca_oob_tcp_recv_handler: invalid message type: %d\n",
opal_output(0, "[%lu,%lu,%lu] mca_oob_tcp_recv_handler: invalid message type: %d\n",
ORTE_NAME_ARGS(orte_process_info.my_name), hdr.msg_type);
close(sd);
break;
@ -556,16 +556,16 @@ void mca_oob_tcp_registry_callback(
k++;
value = values[i];
for(j = 0; j < value->cnt; j++) {
/* check to make sure this is the requested key */
keyval = value->keyvals[j];
if(strcmp(keyval->key,"oob-tcp") != 0)
continue;
/* transfer ownership of registry object to buffer and unpack */
OBJ_CONSTRUCT(&buffer, orte_buffer_t);
if(orte_dps.load(&buffer,
keyval->value.byteobject.bytes,
if(orte_dps.load(&buffer,
keyval->value.byteobject.bytes,
keyval->value.byteobject.size) != ORTE_SUCCESS) {
/* TSW - throw ERROR */
continue;
@ -580,13 +580,13 @@ void mca_oob_tcp_registry_callback(
ORTE_NAME_ARGS(orte_process_info.my_name));
continue;
}
if(mca_oob_tcp_component.tcp_debug > 1) {
opal_output(0, "[%lu,%lu,%lu] mca_oob_tcp_registry_callback: received peer [%lu,%lu,%lu]\n",
ORTE_NAME_ARGS(orte_process_info.my_name),
ORTE_NAME_ARGS(&(addr->addr_name)));
}
/* check for existing cache entry */
existing = (mca_oob_tcp_addr_t *)orte_hash_table_get_proc(
&mca_oob_tcp_component.tcp_peer_names, &addr->addr_name);
@ -595,7 +595,7 @@ void mca_oob_tcp_registry_callback(
OBJ_RELEASE(addr);
continue;
}
/* insert into cache and notify peer */
orte_hash_table_set_proc(&mca_oob_tcp_component.tcp_peer_names, &addr->addr_name, addr);
peer = (mca_oob_tcp_peer_t *)orte_hash_table_get_proc(
@ -616,14 +616,15 @@ int mca_oob_tcp_resolve(mca_oob_tcp_peer_t* peer)
{
mca_oob_tcp_addr_t* addr;
mca_oob_tcp_subscription_t* subscription;
orte_gpr_trigger_t trig, *trigs;
orte_gpr_subscription_t sub, *subs;
char *segment, *sub_name, *trig_name;
char *key="oob-tcp";
orte_gpr_subscription_id_t sub_id;
opal_list_item_t* item;
int rc;
/* if the address is already cached - simply return it */
OPAL_THREAD_LOCK(&mca_oob_tcp_component.tcp_lock);
addr = (mca_oob_tcp_addr_t *)orte_hash_table_get_proc(&mca_oob_tcp_component.tcp_peer_names,
addr = (mca_oob_tcp_addr_t *)orte_hash_table_get_proc(&mca_oob_tcp_component.tcp_peer_names,
&peer->peer_name);
if(NULL != addr) {
OPAL_THREAD_UNLOCK(&mca_oob_tcp_component.tcp_lock);
@ -641,112 +642,56 @@ int mca_oob_tcp_resolve(mca_oob_tcp_peer_t* peer)
return OMPI_SUCCESS;
}
}
OBJ_CONSTRUCT(&sub, orte_gpr_subscription_t);
/* indicate that this is a standard subscription. This indicates that the
* subscription will be common to all processes. Thus, the resulting data
* can be consolidated into a process-independent message and broadcast
* to all processes
*/
if (ORTE_SUCCESS != (rc = orte_schema.get_std_subscription_name(&(sub.name),
if (ORTE_SUCCESS != (rc = orte_schema.get_std_subscription_name(&sub_name,
OMPI_OOB_SUBSCRIPTION, peer->peer_name.jobid))) {
ORTE_ERROR_LOG(rc);
return rc;
}
/* send data when trigger fires, continue to monitor. The default
* action for any subscription that includes a trigger condition is
* to send the specified data when the trigger fires. This set of flags
* indicates that - AFTER the trigger fires - the subscription should
* continue to send data any time an entry is added or changed.
*/
sub.action = ORTE_GPR_NOTIFY_ADD_ENTRY |
ORTE_GPR_NOTIFY_VALUE_CHG |
ORTE_GPR_NOTIFY_STARTS_AFTER_TRIG;
/* setup the value structures that describe the data to
* be monitored and returned by this subscription
*/
sub.cnt = 1;
sub.values = (orte_gpr_value_t**)malloc(sizeof(orte_gpr_value_t*));
if (NULL == sub.values) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
sub.values[0] = OBJ_NEW(orte_gpr_value_t);
if (NULL == sub.values[0]) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
sub.cnt = 1;
/* define the segment */
if (ORTE_SUCCESS != (rc = orte_schema.get_job_segment_name(
&(sub.values[0]->segment),
peer->peer_name.jobid))) {
ORTE_ERROR_LOG(rc);
OBJ_DESTRUCT(&sub);
return rc;
}
sub.values[0]->addr_mode = ORTE_GPR_KEYS_OR | ORTE_GPR_TOKENS_OR;
/* look at all containers on this segment */
sub.values[0]->tokens = NULL;
sub.values[0]->num_tokens = 0;
/* look for any keyval with "modex" key */
sub.values[0]->cnt = 1;
sub.values[0]->keyvals = (orte_gpr_keyval_t**)malloc(sizeof(orte_gpr_keyval_t*));
if (NULL == sub.values[0]->keyvals) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_DESTRUCT(&sub);
return ORTE_ERR_OUT_OF_RESOURCE;
}
sub.values[0]->keyvals[0] = OBJ_NEW(orte_gpr_keyval_t);
if (NULL == sub.values[0]->keyvals[0]) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_DESTRUCT(&sub);
return ORTE_ERR_OUT_OF_RESOURCE;
}
sub.values[0]->keyvals[0]->key = strdup("oob-tcp");
if (NULL == sub.values[0]->keyvals[0]->key) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_DESTRUCT(&sub);
return ORTE_ERR_OUT_OF_RESOURCE;
}
/* define the callback function */
sub.cbfunc = mca_oob_tcp_registry_callback;
sub.user_tag = NULL;
/* setup the trigger value */
OBJ_CONSTRUCT(&trig, orte_gpr_trigger_t);
if (ORTE_SUCCESS != (rc = orte_schema.get_std_trigger_name(&(trig.name),
/* attach to the stage-1 standard trigger */
if (ORTE_SUCCESS != (rc = orte_schema.get_std_trigger_name(&trig_name,
ORTE_STG1_TRIGGER, peer->peer_name.jobid))) {
ORTE_ERROR_LOG(rc);
free(sub_name);
return rc;
}
/* this is an ORTE-standard trigger that is defined by the ORTE resource manager
* when the job was launched - therefore, we don't need to provide any additional
* info
*/
trigs = &trig;
subs = &sub;
subscription = OBJ_NEW(mca_oob_tcp_subscription_t);
subscription->jobid = peer->peer_name.jobid;
rc = orte_gpr.subscribe(1, &subs, 1, &trigs);
if(rc != OMPI_SUCCESS) {
/* define the segment */
if (ORTE_SUCCESS != (rc = orte_schema.get_job_segment_name(&segment,
peer->peer_name.jobid))) {
ORTE_ERROR_LOG(rc);
OBJ_DESTRUCT(&sub);
OBJ_DESTRUCT(&trig);
free(sub_name);
free(trig_name);
return rc;
}
/* the id of each subscription is stored by the system in the corresponding
* subscription object we passed into orte_gpr.subscribe. We record it
if (ORTE_SUCCESS != (rc = orte_gpr.subscribe_1(&sub_id, trig_name, sub_name,
ORTE_GPR_NOTIFY_ADD_ENTRY |
ORTE_GPR_NOTIFY_VALUE_CHG |
ORTE_GPR_NOTIFY_STARTS_AFTER_TRIG,
ORTE_GPR_KEYS_OR | ORTE_GPR_TOKENS_OR,
segment,
NULL, /* look at all containers on this segment */
key,
mca_oob_tcp_registry_callback, NULL))) {
ORTE_ERROR_LOG(rc);
free(sub_name);
free(trig_name);
free(segment);
return rc;
}
subscription = OBJ_NEW(mca_oob_tcp_subscription_t);
subscription->jobid = peer->peer_name.jobid;
/* the id of each subscription is recorded
* here so we can (if desired) cancel that subscription later
*/
subscription->subid = sub.id;
subscription->subid = sub_id;
/* done with these, so release any memory */
OBJ_DESTRUCT(&sub);
OBJ_DESTRUCT(&trig);
free(trig_name);
free(sub_name);
free(segment);
opal_list_append(&mca_oob_tcp_component.tcp_subscriptions, &subscription->item);
OPAL_THREAD_UNLOCK(&mca_oob_tcp_component.tcp_lock);
@ -761,13 +706,16 @@ int mca_oob_tcp_init(void)
{
orte_jobid_t jobid;
orte_buffer_t *buffer;
orte_gpr_trigger_t trig, *trigs;
orte_gpr_value_t *value;
orte_gpr_subscription_id_t sub_id;
char *sub_name, *segment, *trig_name, **tokens;
char *keys[] = {"oob-tcp", ORTE_PROC_RML_IP_ADDRESS_KEY};
orte_data_type_t types[2];
orte_gpr_value_union_t values[2];
mca_oob_tcp_subscription_t *subscription;
orte_gpr_subscription_t sub, *subs;
int rc;
opal_list_item_t* item;
char *tmp, *tmp2, *tmp3;
size_t num_tokens;
/* random delay to stagger connections back to seed */
#if defined(WIN32)
@ -777,7 +725,7 @@ int mca_oob_tcp_init(void)
#endif
/* get my jobid */
if (ORTE_SUCCESS != (rc = orte_ns.get_jobid(&jobid,
if (ORTE_SUCCESS != (rc = orte_ns.get_jobid(&jobid,
orte_process_info.my_name))) {
ORTE_ERROR_LOG(rc);
return rc;
@ -803,212 +751,119 @@ int mca_oob_tcp_init(void)
OPAL_THREAD_UNLOCK(&mca_oob_tcp_component.tcp_lock);
if(mca_oob_tcp_component.tcp_debug > 2) {
opal_output(0, "[%lu,%lu,%lu] mca_oob_tcp_init: calling orte_gpr.subscribe\n",
opal_output(0, "[%lu,%lu,%lu] mca_oob_tcp_init: calling orte_gpr.subscribe\n",
ORTE_NAME_ARGS(orte_process_info.my_name));
}
/* setup the subscription description value */
OBJ_CONSTRUCT(&sub, orte_gpr_subscription_t);
/* indicate that this is a standard subscription. This indicates that the
* subscription will be common to all processes. Thus, the resulting data
* can be consolidated into a process-independent message and broadcast
* to all processes
*/
if (ORTE_SUCCESS != (rc = orte_schema.get_std_subscription_name(&(sub.name),
if (ORTE_SUCCESS != (rc = orte_schema.get_std_subscription_name(&sub_name,
OMPI_OOB_SUBSCRIPTION, jobid))) {
ORTE_ERROR_LOG(rc);
return rc;
}
/* send data when trigger fires, continue to monitor. The default
* action for any subscription that includes a trigger condition is
* to send the specified data when the trigger fires. This set of flags
* indicates that - AFTER the trigger fires - the subscription should
* continue to send data any time an entry is added or changed.
*/
sub.action = ORTE_GPR_NOTIFY_ADD_ENTRY |
ORTE_GPR_NOTIFY_VALUE_CHG |
ORTE_GPR_NOTIFY_STARTS_AFTER_TRIG;
/* setup the value structures that describe the data to
* be monitored and returned by this subscription
*/
sub.cnt = 1;
sub.values = (orte_gpr_value_t**)malloc(sizeof(orte_gpr_value_t*));
if (NULL == sub.values) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
sub.values[0] = OBJ_NEW(orte_gpr_value_t);
if (NULL == sub.values[0]) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
/* attach to the stage-1 standard trigger */
if (ORTE_SUCCESS != (rc = orte_schema.get_std_trigger_name(&trig_name,
ORTE_STG1_TRIGGER, jobid))) {
ORTE_ERROR_LOG(rc);
free(sub_name);
return rc;
}
/* define the segment */
if (ORTE_SUCCESS != (rc = orte_schema.get_job_segment_name(
&(sub.values[0]->segment),
jobid))) {
ORTE_ERROR_LOG(rc);
OBJ_DESTRUCT(&sub);
return rc;
}
sub.values[0]->addr_mode = ORTE_GPR_KEYS_OR | ORTE_GPR_TOKENS_OR;
/* look at all containers on this segment */
sub.values[0]->tokens = NULL;
sub.values[0]->num_tokens = 0;
/* look for any keyval with "modex" key */
sub.values[0]->cnt = 1;
sub.values[0]->keyvals = (orte_gpr_keyval_t**)malloc(sizeof(orte_gpr_keyval_t*));
if (NULL == sub.values[0]->keyvals) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_DESTRUCT(&sub);
return ORTE_ERR_OUT_OF_RESOURCE;
}
sub.values[0]->keyvals[0] = OBJ_NEW(orte_gpr_keyval_t);
if (NULL == sub.values[0]->keyvals[0]) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_DESTRUCT(&sub);
return ORTE_ERR_OUT_OF_RESOURCE;
}
sub.values[0]->keyvals[0]->key = strdup("oob-tcp");
if (NULL == sub.values[0]->keyvals[0]->key) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_DESTRUCT(&sub);
return ORTE_ERR_OUT_OF_RESOURCE;
}
/* define the callback function */
sub.cbfunc = mca_oob_tcp_registry_callback;
sub.user_tag = NULL;
/* setup the trigger value */
OBJ_CONSTRUCT(&trig, orte_gpr_trigger_t);
if (ORTE_SUCCESS != (rc = orte_schema.get_std_trigger_name(&(trig.name),
ORTE_STG1_TRIGGER, jobid))) {
if (ORTE_SUCCESS != (rc = orte_schema.get_job_segment_name(&segment, jobid))) {
ORTE_ERROR_LOG(rc);
free(sub_name);
free(trig_name);
return rc;
}
/* this is an ORTE-standard trigger that is defined by the ORTE resource manager
* when the job was launched - therefore, we don't need to provide any additional
* info
*/
trigs = &trig;
subs = &sub;
subscription = OBJ_NEW(mca_oob_tcp_subscription_t);
subscription->jobid = jobid;
rc = orte_gpr.subscribe(1, &subs, 1, &trigs);
if(rc != OMPI_SUCCESS) {
if (ORTE_SUCCESS != (rc = orte_gpr.subscribe_1(&sub_id, trig_name, sub_name,
ORTE_GPR_NOTIFY_ADD_ENTRY |
ORTE_GPR_NOTIFY_VALUE_CHG |
ORTE_GPR_NOTIFY_STARTS_AFTER_TRIG,
ORTE_GPR_KEYS_OR | ORTE_GPR_TOKENS_OR,
segment,
NULL, /* look at all containers on this segment */
keys[0],
mca_oob_tcp_registry_callback, NULL))) {
ORTE_ERROR_LOG(rc);
OBJ_DESTRUCT(&sub);
OBJ_DESTRUCT(&trig);
free(sub_name);
free(trig_name);
free(segment);
return rc;
}
/* the id of each subscription is stored by the system in the corresponding
* subscription object we passed into orte_gpr.subscribe. We record it
/* the id of each subscription is recorded
* here so we can (if desired) cancel that subscription later
*/
subscription->subid = sub.id;
subscription->subid = sub_id;
/* done with these, so release any memory */
OBJ_DESTRUCT(&sub);
OBJ_DESTRUCT(&trig);
free(trig_name);
free(sub_name);
/* now setup to put our contact info on registry */
buffer = OBJ_NEW(orte_buffer_t);
if(buffer == NULL) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return OMPI_ERR_OUT_OF_RESOURCE;
return ORTE_ERR_OUT_OF_RESOURCE;
}
rc = mca_oob_tcp_addr_pack(buffer);
if(rc != OMPI_SUCCESS) {
if (ORTE_SUCCESS != (rc = mca_oob_tcp_addr_pack(buffer))) {
ORTE_ERROR_LOG(rc);
OBJ_RELEASE(buffer);
return rc;
}
/* put our contact info in registry */
value = OBJ_NEW(orte_gpr_value_t);
if (NULL == value) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
value->addr_mode = ORTE_GPR_OVERWRITE | ORTE_GPR_TOKENS_XAND;
if (ORTE_SUCCESS != (rc = orte_schema.get_job_segment_name(&(value->segment), jobid))) {
ORTE_ERROR_LOG(rc);
return rc;
}
value->cnt = 2;
value->keyvals = (orte_gpr_keyval_t**)malloc(value->cnt * sizeof(orte_gpr_keyval_t*));
if(NULL == value->keyvals) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
value->keyvals[0] = OBJ_NEW(orte_gpr_keyval_t);
if (NULL == value->keyvals[0]) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
value->keyvals[1] = OBJ_NEW(orte_gpr_keyval_t);
if (NULL == value->keyvals[1]) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
if (ORTE_SUCCESS != (rc = orte_schema.get_proc_tokens(&(value->tokens),
&(value->num_tokens), orte_process_info.my_name))) {
/* extract payload for storage */
types[0] = ORTE_BYTE_OBJECT;
if (ORTE_SUCCESS != (rc = orte_dps.unload(buffer, (void**)&(values[0].byteobject.bytes),
&(values[0].byteobject.size)))) {
ORTE_ERROR_LOG(rc);
OBJ_RELEASE(value);
return rc;
}
(value->keyvals[0])->type = ORTE_BYTE_OBJECT;
(value->keyvals[0])->key = strdup("oob-tcp");
rc = orte_dps.unload(buffer, (void**)&(value->keyvals[0])->value.byteobject.bytes,
&(value->keyvals[0])->value.byteobject.size);
if(rc != ORTE_SUCCESS) {
ORTE_ERROR_LOG(rc);
OBJ_RELEASE(value);
free(segment);
OBJ_RELEASE(buffer);
return rc;
}
OBJ_RELEASE(buffer);
(value->keyvals[1])->type = ORTE_STRING;
(value->keyvals[1])->key = strdup(ORTE_PROC_RML_IP_ADDRESS_KEY);
/* setup the IP address for storage */
tmp = mca_oob.oob_get_addr();
tmp2 = strrchr(tmp, '/') + 1;
tmp3 = strrchr(tmp, ':');
if(NULL == tmp2 || NULL == tmp3) {
opal_output(0, "[%lu,%lu,%lu] mca_oob_tcp_init: invalid address \'%s\' "
"returned for selected oob interfaces.\n",
"returned for selected oob interfaces.\n",
ORTE_NAME_ARGS(orte_process_info.my_name), tmp);
ORTE_ERROR_LOG(ORTE_ERROR);
free(segment);
free(tmp);
free(values[0].byteobject.bytes);
return ORTE_ERROR;
}
*tmp3 = '\0';
(value->keyvals[1])->value.strptr = strdup(tmp2);
types[1] = ORTE_STRING;
values[1].strptr = strdup(tmp2);
free(tmp);
if(mca_oob_tcp_component.tcp_debug > 2) {
opal_output(0, "[%lu,%lu,%lu] mca_oob_tcp_init: calling orte_gpr.put(%s)\n",
ORTE_NAME_ARGS(orte_process_info.my_name),
value->segment);
}
rc = orte_gpr.put(1, &value);
if(rc != OMPI_SUCCESS) {
/* get the process tokens */
if (ORTE_SUCCESS != (rc = orte_schema.get_proc_tokens(&tokens, &num_tokens,
orte_process_info.my_name))) {
ORTE_ERROR_LOG(rc);
OBJ_RELEASE(value);
OBJ_RELEASE(buffer);
free(segment);
free(values[0].byteobject.bytes);
free(values[1].strptr);
return rc;
}
OBJ_RELEASE(buffer);
OBJ_RELEASE(value);
if(rc != ORTE_SUCCESS) {
/* put our contact info in registry */
if (ORTE_SUCCESS != (rc = orte_gpr.put_N(ORTE_GPR_OVERWRITE | ORTE_GPR_TOKENS_XAND,
segment, tokens, 2, keys, types, values))) {
ORTE_ERROR_LOG(rc);
return rc;
}
return OMPI_SUCCESS;
free(segment);
free(values[0].byteobject.bytes);
free(values[1].strptr);
return rc;
}
/*
@ -1022,7 +877,7 @@ int mca_oob_tcp_fini(void)
/* close listen socket */
if (mca_oob_tcp_component.tcp_listen_sd >= 0) {
opal_event_del(&mca_oob_tcp_component.tcp_recv_event);
opal_event_del(&mca_oob_tcp_component.tcp_recv_event);
close(mca_oob_tcp_component.tcp_listen_sd);
mca_oob_tcp_component.tcp_listen_sd = -1;
}

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

@ -3,14 +3,14 @@
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
*
* Additional copyrights may follow
*
*
* $HEADER$
*/
/** @file:
@ -62,11 +62,11 @@ OMPI_DECLSPEC int orte_rmgr_base_put_app_context(
size_t num_context);
OMPI_DECLSPEC int orte_rmgr_base_get_job_slots(
orte_jobid_t jobid,
orte_jobid_t jobid,
size_t* num_slots);
OMPI_DECLSPEC int orte_rmgr_base_set_job_slots(
orte_jobid_t jobid,
orte_jobid_t jobid,
size_t num_slots);
@ -103,8 +103,8 @@ OMPI_DECLSPEC int orte_rmgr_base_cmd_dispatch(
* Base functions that are common to all implementations - can be overridden
*/
int orte_rmgr_base_create_not_available(
orte_app_context_t** app_context,
size_t num_context,
orte_app_context_t** app_context,
size_t num_context,
orte_jobid_t* jobid);
int orte_rmgr_base_query_not_available(void);
int orte_rmgr_base_allocate_not_available(orte_jobid_t);
@ -115,15 +115,13 @@ int orte_rmgr_base_terminate_job_not_available(orte_jobid_t);
int orte_rmgr_base_terminate_proc_not_available(const orte_process_name_t*);
int orte_rmgr_base_proc_stage_gate_init(orte_jobid_t job);
int orte_rmgr_base_proc_stage_gate_subscribe(orte_jobid_t job, orte_gpr_notify_cb_fn_t, void*);
void orte_rmgr_base_proc_stage_gate_mgr(
orte_gpr_notify_data_t *data,
void *user_tag);
void orte_rmgr_base_proc_stage_gate_mgr_abort(
orte_gpr_notify_data_t *data,
void *user_tag);
int orte_rmgr_base_proc_stage_gate_mgr(
orte_gpr_notify_message_t *msg);
int orte_rmgr_base_proc_stage_gate_mgr_abort(
orte_gpr_notify_message_t *msg);
int orte_rmgr_base_spawn_not_available(
orte_app_context_t** app_context,
size_t num_context,
orte_app_context_t** app_context,
size_t num_context,
orte_jobid_t* jobid,
orte_rmgr_cb_fn_t cbfn);
int orte_rmgr_base_finalize_not_available(void);

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

@ -3,14 +3,14 @@
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
*
* Additional copyrights may follow
*
*
* $HEADER$
*/
/** @file:
@ -30,6 +30,7 @@
#include "orte/dps/dps.h"
#include "orte/mca/gpr/gpr.h"
#include "orte/mca/ns/ns.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/mca/rml/rml.h"
#include "orte/mca/soh/soh.h"
@ -41,9 +42,7 @@ int orte_rmgr_base_proc_stage_gate_init(orte_jobid_t job)
{
size_t i, num_counters=6, num_named_trigs=5;
int rc;
orte_gpr_value_t *values, value, trigvalue, *trigvals;
orte_gpr_trigger_t trig, *trigs;
orte_gpr_subscription_t sub, *subs;
orte_gpr_value_t *values, value;
char* keys[] = {
/* changes to this ordering need to be reflected in code below */
ORTE_PROC_NUM_AT_STG1,
@ -61,6 +60,9 @@ int orte_rmgr_base_proc_stage_gate_init(orte_jobid_t job)
ORTE_NUM_FINALIZED_TRIGGER,
ORTE_NUM_TERMINATED_TRIGGER
};
char *segment, *trig_name, *tokens[2], *trig_keys[2];
orte_gpr_trigger_id_t id;
size_t trig_level;
/* setup the counters */
OBJ_CONSTRUCT(&value, orte_gpr_value_t);
@ -97,7 +99,7 @@ int orte_rmgr_base_proc_stage_gate_init(orte_jobid_t job)
value.keyvals[i]->value.size = 0;
}
values = &value;
/* put the counters on the registry */
if (ORTE_SUCCESS != (rc = orte_gpr.put(1, &values))) {
ORTE_ERROR_LOG(rc);
@ -105,517 +107,205 @@ int orte_rmgr_base_proc_stage_gate_init(orte_jobid_t job)
return rc;
}
OBJ_DESTRUCT(&value);
/* for the stage gate triggers, we want the counter values returned to us AND
* information on VPID_START so we can generate the list of peers
* to receive the xcast messages for barrier release.
/*** DEFINE STAGE GATE STANDARD TRIGGERS ***/
/* The standard triggers will return the trigger counters so that we
* can get required information for notifying processes. Other
* subscriptions will then attach to them.
*/
/*** SUBSCRIPTIONS ***/
/* the subscription object is used to define the values we want
* returned to us. we'll enter the precise data
* keys when we are ready to register the subscription - for now,
* do all the basic stuff
*/
OBJ_CONSTRUCT(&sub, orte_gpr_subscription_t);
/* we do not name the subscription - see explanation below. also, we do
* not assign the subscription id here - it is assigned for us when the
* registry "registers" the subscription and is returned in the
* subscription object at that time
*/
/*
* set the action to delete the subscription after the trigger fires. this
* subscription is solely for the purpose of returning stagegate information
* to the resource manager - we don't need it after that happens
*/
sub.action = ORTE_GPR_NOTIFY_DELETE_AFTER_TRIG;
/*
* setup the value object to define the data to be returned to us
*/
OBJ_CONSTRUCT(&value, orte_gpr_value_t);
values = &value;
sub.values = &values;
sub.cnt = 1;
/* set the address mode to identify a specific container (in this case,
* the ORTE_JOB_GLOBALS container) and any keys within it
*/
value.addr_mode = ORTE_GPR_TOKENS_XAND | ORTE_GPR_KEYS_OR;
if (ORTE_SUCCESS != (rc = orte_schema.get_job_segment_name(&(value.segment), job))) {
if (ORTE_SUCCESS != (rc = orte_schema.get_job_segment_name(&segment, job))) {
ORTE_ERROR_LOG(rc);
OBJ_DESTRUCT(&value);
sub.values = NULL;
OBJ_DESTRUCT(&sub);
return rc;
}
/* define the tokens for the container */
value.tokens = (char**)malloc(sizeof(char*));
if (NULL == value.tokens) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_DESTRUCT(&value);
sub.values = NULL;
OBJ_DESTRUCT(&sub);
return ORTE_ERR_OUT_OF_RESOURCE;
}
value.tokens[0] = strdup(ORTE_JOB_GLOBALS); /* the counters are in the job's globals container */
value.num_tokens = 1;
/* define the keys to be returned */
value.cnt = 3;
value.keyvals = (orte_gpr_keyval_t**)malloc(value.cnt * sizeof(orte_gpr_keyval_t*));
if (NULL == value.keyvals) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_DESTRUCT(&value);
sub.values = NULL;
OBJ_DESTRUCT(&sub);
return ORTE_ERR_OUT_OF_RESOURCE;
}
for (i=0; i < value.cnt; i++) {
value.keyvals[i] = OBJ_NEW(orte_gpr_keyval_t);
if (NULL == value.keyvals[i]) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_DESTRUCT(&value);
sub.values = NULL;
OBJ_DESTRUCT(&sub);
return ORTE_ERR_OUT_OF_RESOURCE;
}
}
/* the 0th entry will be defined below */
value.keyvals[1]->key = strdup(ORTE_JOB_SLOTS_KEY);
value.keyvals[2]->key = strdup(ORTE_JOB_VPID_START_KEY);
/* we don't need to define the type and value for the keyvals - the subscribe
* function ignores those fields
*/
sub.cbfunc = orte_rmgr_base_proc_stage_gate_mgr;
sub.user_tag = NULL;
/*** TRIGGERS ***/
/* setup the trigger information - initialize the common elements */
OBJ_CONSTRUCT(&trig, orte_gpr_trigger_t);
/* we WILL name the trig - see explanation below. we do
* NOT assign the trigger id here - it is assigned for us when the
* registry "registers" the trigger and is returned in the
* trigger object at that time
*/
/*
* set the action to compare all specified counter levels. this will
* "fire" the trigger when all counters are equal
*/
trig.action = ORTE_GPR_TRIG_ALL_CMP;
/*
* setup the value object to define the data to be returned to us
*/
OBJ_CONSTRUCT(&trigvalue, orte_gpr_value_t);
trigvals = &trigvalue;
trig.values = &trigvals;
trig.cnt = 1;
/* set the address mode to identify a specific container (in this case,
* the ORTE_JOB_GLOBALS container) and any keys within it
*/
trigvalue.addr_mode = ORTE_GPR_TOKENS_XAND | ORTE_GPR_KEYS_OR;
if (ORTE_SUCCESS != (rc = orte_schema.get_job_segment_name(&(trigvalue.segment), job))) {
ORTE_ERROR_LOG(rc);
goto CLEANUP;
}
/* define the tokens for the container */
trigvalue.tokens = (char**)malloc(sizeof(char*));
if (NULL == trigvalue.tokens) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
rc = ORTE_ERR_OUT_OF_RESOURCE;
goto CLEANUP;
}
trigvalue.tokens[0] = strdup(ORTE_JOB_GLOBALS); /* the counters are in the job's globals container */
trigvalue.num_tokens = 1;
/* define the keys that identify the counters */
trigvalue.cnt = 2;
trigvalue.keyvals = (orte_gpr_keyval_t**)malloc(trigvalue.cnt * sizeof(orte_gpr_keyval_t*));
if (NULL == trigvalue.keyvals) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
rc = ORTE_ERR_OUT_OF_RESOURCE;
goto CLEANUP;
}
trigvalue.keyvals[0] = OBJ_NEW(orte_gpr_keyval_t);
if (NULL == trigvalue.keyvals[0]) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
rc = ORTE_ERR_OUT_OF_RESOURCE;
goto CLEANUP;
}
trigvalue.keyvals[1] = OBJ_NEW(orte_gpr_keyval_t);
if (NULL == trigvalue.keyvals[1]) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
rc = ORTE_ERR_OUT_OF_RESOURCE;
goto CLEANUP;
}
tokens[0] = strdup(ORTE_JOB_GLOBALS);
tokens[1] = NULL;
/* setup the triggers for the three main stage gates - these all compare
* their value to that in ORTE_JOB_SLOTS_KEY
*/
trigvalue.keyvals[0]->key = strdup(ORTE_JOB_SLOTS_KEY);
if (NULL == trigvalue.keyvals[0]->key) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
rc = ORTE_ERR_OUT_OF_RESOURCE;
goto CLEANUP;
}
/* we don't need to define the type and value for the keyvals - the subscribe
* function ignores those fields
*/
/* do the three stage gate subscriptions, plus the named triggers
* that compare their values to the JOB_SLOTS_KEY
*/
trig_keys[0] = strdup(ORTE_JOB_SLOTS_KEY);
for (i=0; i < num_named_trigs; i++) {
/*
* NOTE: we do NOT name the subscriptions here as these are not
* standard subscriptions that multiple processes should attach
* themselves to - the subscriptions only have meaning to the
* resource manager
*/
value.keyvals[0]->key = strdup(keys[i]);
if (NULL == value.keyvals[0]->key) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
rc = ORTE_ERR_OUT_OF_RESOURCE;
goto CLEANUP;
}
/*
* NOTE: we DO name the triggers as these will be standard triggers
* that multiple processes will want to attach themselves to - for
* example, a process may well want to receive some information when
* it reaches STAGE_GATE_1, and so will "attach" itself to that
* trigger as defined by us here
*/
if (ORTE_SUCCESS != (rc = orte_schema.get_std_trigger_name(&(trig.name),
trig_keys[1] = strdup(keys[i]);
if (ORTE_SUCCESS != (rc = orte_schema.get_std_trigger_name(&trig_name,
trig_names[i], job))) {
ORTE_ERROR_LOG(rc);
goto CLEANUP;
free(trig_keys[0]);
free(trig_keys[1]);
return rc;
}
trigvalue.keyvals[1]->key = strdup(keys[i]);
if (NULL == trigvalue.keyvals[1]->key) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
rc = ORTE_ERR_OUT_OF_RESOURCE;
goto CLEANUP;
if (ORTE_SUCCESS != (rc = orte_gpr.define_trigger(&id, trig_name,
ORTE_GPR_TRIG_INCLUDE_TRIG_CNTRS | ORTE_GPR_TRIG_ONE_SHOT |
ORTE_GPR_TRIG_ROUTE_DATA_THRU_ME | ORTE_GPR_TRIG_CMP_LEVELS,
ORTE_GPR_TOKENS_XAND | ORTE_GPR_KEYS_OR,
segment, tokens, 2, trig_keys,
orte_rmgr_base_proc_stage_gate_mgr, NULL))) {
ORTE_ERROR_LOG(rc);
free(trig_name);
free(trig_keys[0]);
free(trig_keys[1]);
return rc;
}
subs = &sub;
trigs = &trig;
rc = orte_gpr.subscribe(
1, &subs,
1, &trigs);
if (ORTE_SUCCESS != rc) {
ORTE_ERROR_LOG(rc);
goto CLEANUP;
}
free(value.keyvals[0]->key);
value.keyvals[0]->key = NULL;
free(trig.name);
free(trigvalue.keyvals[1]->key);
trigvalue.keyvals[1]->key = NULL;
free(trig_name);
free(trig_keys[1]);
}
/* Next, setup the trigger that watches the NUM_ABORTED counter to see if
* any process abnormally terminates - if so, then call the
* stage_gate_mgr_abort function
* so it can in turn order the job to be aborted
free(trig_keys[0]);
/* Now define the abort trigger. Again, only the trigger counter needs
* to be returned, so we don't need to setup a subscription to get
* other information
*/
sub.cbfunc = orte_rmgr_base_proc_stage_gate_mgr_abort;
value.keyvals[0]->key = strdup(ORTE_PROC_NUM_ABORTED);
if (NULL == value.keyvals[0]->key) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
rc = ORTE_ERR_OUT_OF_RESOURCE;
goto CLEANUP;
}
/* set the trigger name */
if (ORTE_SUCCESS != (rc = orte_schema.get_std_trigger_name(&(trig.name),
trig_keys[0] = strdup(ORTE_PROC_NUM_ABORTED);
if (ORTE_SUCCESS != (rc = orte_schema.get_std_trigger_name(&trig_name,
ORTE_NUM_ABORTED_TRIGGER, job))) {
ORTE_ERROR_LOG(rc);
goto CLEANUP;
return rc;
}
/* set the trigger action to fire at a specified level */
trig.action = ORTE_GPR_TRIG_ALL_AT;
/* cleanup the trigger keyvals that are no longer needed - we will
* rebuild them as required
*/
OBJ_RELEASE(trigvalue.keyvals[0]);
OBJ_RELEASE(trigvalue.keyvals[1]);
free(trigvalue.keyvals);
/* we only need one trigger keyval here as we are not comparing
* trigger levels - we are just asking to be notified when
* a specific counter changes value to "1"
*/
trigvalue.cnt = 1;
trigvalue.keyvals = (orte_gpr_keyval_t**)malloc(sizeof(orte_gpr_keyval_t**));
if (NULL == trigvalue.keyvals) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
rc = ORTE_ERR_OUT_OF_RESOURCE;
goto CLEANUP;
}
trigvalue.keyvals[0] = OBJ_NEW(orte_gpr_keyval_t);
if (NULL == trigvalue.keyvals[0]) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
rc = ORTE_ERR_OUT_OF_RESOURCE;
goto CLEANUP;
}
trigvalue.keyvals[0]->key = strdup(ORTE_PROC_NUM_ABORTED);
if (NULL == trigvalue.keyvals[0]->key) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
rc = ORTE_ERR_OUT_OF_RESOURCE;
goto CLEANUP;
}
/* trigger on the first process that aborts */
trigvalue.keyvals[0]->type = ORTE_SIZE;
trigvalue.keyvals[0]->value.size = 1;
subs = &sub;
trigs = &trig;
rc = orte_gpr.subscribe(
1, &subs,
1, &trigs);
if (ORTE_SUCCESS != rc) {
trig_level = 1;
if (ORTE_SUCCESS != (rc = orte_gpr.define_trigger_level(&id, trig_name,
ORTE_GPR_TRIG_INCLUDE_TRIG_CNTRS | ORTE_GPR_TRIG_ONE_SHOT |
ORTE_GPR_TRIG_AT_LEVEL,
ORTE_GPR_TOKENS_XAND | ORTE_GPR_KEYS_OR,
segment, tokens, 1, trig_keys, &trig_level,
orte_rmgr_base_proc_stage_gate_mgr_abort, NULL))) {
ORTE_ERROR_LOG(rc);
goto CLEANUP;
free(trig_name);
free(trig_keys[0]);
return rc;
}
free(trig_name);
free(trig_keys[0]);
/* set the job state to "launched" */
if (ORTE_SUCCESS != (rc = orte_soh.set_job_soh(job, ORTE_JOB_STATE_LAUNCHED))) {
ORTE_ERROR_LOG(rc);
}
CLEANUP:
OBJ_DESTRUCT(&trigvalue);
trig.values = NULL;
OBJ_DESTRUCT(&trig);
OBJ_DESTRUCT(&value);
sub.values = NULL;
OBJ_DESTRUCT(&sub);
return rc;
}
void orte_rmgr_base_proc_stage_gate_mgr(orte_gpr_notify_data_t *data,
void *user_tag)
int orte_rmgr_base_proc_stage_gate_mgr(orte_gpr_notify_message_t *msg)
{
orte_gpr_value_t **values;
orte_gpr_keyval_t **kvals;
orte_buffer_t buffer;
orte_process_name_t *recipients=NULL;
size_t i, j, m, n=0;
orte_vpid_t k=0;
size_t n=0;
int rc;
bool found_slots=false, found_start=false;
bool found_stg1=false, found_stg2=false;
bool found_stg3=false, found_finalized=false;
orte_buffer_t msg;
orte_jobid_t job;
char **tokens=NULL;
size_t num_tokens;
values = (orte_gpr_value_t**)(data->values)->addr;
/* get the jobid from the segment name
* we setup the stage gate triggers to return at least one value
* to us. we use that value to extract the jobid for the returned
* data
/* check to see if this came from terminate. If so, we ignore it because
* that stage gate does NOT set an xcast barrier - processes simply
* record their state and continue processing
*/
if (orte_schema.check_std_trigger_name(msg->target, ORTE_NUM_TERMINATED_TRIGGER)) {
return ORTE_SUCCESS;
}
/* All stage gate triggers are named, so we can extract the jobid
* directly from the trigger name
*/
if (ORTE_SUCCESS != (rc = orte_schema.extract_jobid_from_std_trigger_name(&job, msg->target))) {
ORTE_ERROR_LOG(rc);
return rc;
}
/* need the list of peers for this job so we can send them the xcast.
* obtain this list from the name service's get_job_peers function
*/
if (ORTE_SUCCESS != (rc =
orte_schema.extract_jobid_from_segment_name(&job,
values[0]->segment))) {
if (ORTE_SUCCESS != (rc = orte_ns.get_job_peers(&recipients, &n, job))) {
ORTE_ERROR_LOG(rc);
return;
return rc;
}
if (ORTE_SUCCESS != (rc = orte_schema.get_job_tokens(&tokens, &num_tokens, job))) {
ORTE_ERROR_LOG(rc);
return;
}
/* check to see if this came from one of the stage gates as opposed
* to either terminate or finalize - if the latter, we set the job
* state as appropriate and then return - no message needs to be
* sent to the processes themselves
*/
kvals = values[0]->keyvals;
for (i=0; i < values[0]->cnt; i++) {
if (0 == strcmp(kvals[i]->key, ORTE_PROC_NUM_TERMINATED)) {
if (ORTE_SUCCESS != (rc = orte_soh.set_job_soh(job, ORTE_JOB_STATE_TERMINATED))) {
ORTE_ERROR_LOG(rc);
}
goto CLEANUP;
}
}
/* value returned will contain the counter, which contains the number of
* procs in this job. We need to know which counter is included as this
* tells us the job state we have reached.
*/
for (i=0, m=0; m < data->cnt &&
i < (data->values)->size &&
(!found_slots || !found_start ||
(!found_stg1 && !found_stg2 && !found_stg3 && !found_finalized)); i++) {
if (NULL != values[i]) {
m++;
kvals = values[i]->keyvals;
/* check to see if ORTE_JOB_GLOBALS is the token */
if (NULL != values[i]->tokens &&
0 == strcmp(ORTE_JOB_GLOBALS, values[i]->tokens[0])) {
/* find the ORTE_JOB_SLOTS_KEY and the ORTE_JOB_VPID_START_KEY keyval */
for (j=0; j < values[i]->cnt &&
(!found_slots || !found_start ||
(!found_stg1 && !found_stg2 && !found_stg3 && !found_finalized)); j++) {
if (NULL != kvals[j] && !found_slots &&
0 == strcmp(ORTE_JOB_SLOTS_KEY, kvals[j]->key)) {
n = kvals[j]->value.size;
found_slots = true;
}
if (NULL != kvals[j] && !found_start &&
0 == strcmp(ORTE_JOB_VPID_START_KEY, kvals[j]->key)) {
k = kvals[j]->value.vpid;
found_start = true;
}
if (NULL != kvals[j] &&
0 == strcmp(ORTE_PROC_NUM_AT_STG1, kvals[j]->key)) {
found_stg1 = true;
} else if (NULL != kvals[j] &&
0 == strcmp(ORTE_PROC_NUM_AT_STG2, kvals[j]->key)) {
found_stg2 = true;
} else if (NULL != kvals[j] &&
0 == strcmp(ORTE_PROC_NUM_AT_STG3, kvals[j]->key)) {
found_stg3 = true;
} else if (NULL != kvals[j] &&
0 == strcmp(ORTE_PROC_NUM_FINALIZED, kvals[j]->key)) {
found_finalized = true;
}
}
}
}
}
if (!found_slots) {
ORTE_ERROR_LOG(ORTE_ERR_GPR_DATA_CORRUPT);
goto CLEANUP;
}
if (!found_start) {
ORTE_ERROR_LOG(ORTE_ERR_GPR_DATA_CORRUPT);
goto CLEANUP;
}
/* set the job state to the appropriate level */
if (found_stg1) {
if (orte_schema.check_std_trigger_name(msg->target, ORTE_STG1_TRIGGER)) {
if (ORTE_SUCCESS != (rc = orte_soh.set_job_soh(job, ORTE_JOB_STATE_AT_STG1))) {
ORTE_ERROR_LOG(rc);
goto CLEANUP;
}
} else if (found_stg2) {
} else if (orte_schema.check_std_trigger_name(msg->target, ORTE_STG2_TRIGGER)) {
if (ORTE_SUCCESS != (rc = orte_soh.set_job_soh(job, ORTE_JOB_STATE_AT_STG2))) {
ORTE_ERROR_LOG(rc);
goto CLEANUP;
}
} else if (found_stg3) {
} else if (orte_schema.check_std_trigger_name(msg->target, ORTE_STG3_TRIGGER)) {
if (ORTE_SUCCESS != (rc = orte_soh.set_job_soh(job, ORTE_JOB_STATE_AT_STG3))) {
ORTE_ERROR_LOG(rc);
goto CLEANUP;
}
} else if (found_finalized) {
} else if (orte_schema.check_std_trigger_name(msg->target, ORTE_NUM_FINALIZED_TRIGGER)) {
if (ORTE_SUCCESS != (rc = orte_soh.set_job_soh(job, ORTE_JOB_STATE_FINALIZED))) {
ORTE_ERROR_LOG(rc);
goto CLEANUP;
}
}
/* now can generate the list of recipients */
recipients = (orte_process_name_t*)malloc(n * sizeof(orte_process_name_t));
for (i=0; i < n; i++) {
recipients[i].cellid = 0;
recipients[i].jobid = job;
recipients[i].vpid = (orte_vpid_t)(k + i);
}
/* for the purposes of the stage gate manager, we don't actually have
* to determine anything from the message. All we have to do is respond
* by sending an xcast to all processes. However, the buffer has to include
* at least one piece of data for the RML to function, so pack something
* meaningless.
/* set the message type to SUBSCRIPTION. When we give this to the processes, we want
* them to break the message down and deliver it to the various subsystems.
*/
OBJ_CONSTRUCT(&msg, orte_buffer_t);
if (ORTE_SUCCESS != (rc = orte_dps.pack(&msg, &job, 1, ORTE_JOBID))) {
ORTE_ERROR_LOG(rc);
OBJ_DESTRUCT(&msg);
goto CLEANUP;
}
if (ORTE_SUCCESS != (rc = orte_rml.xcast(orte_process_info.my_name, recipients,
n, &msg, NULL))) {
ORTE_ERROR_LOG(rc);
OBJ_DESTRUCT(&msg);
goto CLEANUP;
}
OBJ_DESTRUCT(&msg);
msg->msg_type = ORTE_GPR_SUBSCRIPTION_MSG;
msg->id = ORTE_GPR_TRIGGER_ID_MAX;
/* need to pack the msg for sending */
OBJ_CONSTRUCT(&buffer, orte_buffer_t);
if (ORTE_SUCCESS != (rc = orte_dps.pack(&buffer, &msg, 1, ORTE_GPR_NOTIFY_MSG))) {
ORTE_ERROR_LOG(rc);
OBJ_DESTRUCT(&buffer);
goto CLEANUP;
}
/* send the message */
if (ORTE_SUCCESS != (rc = orte_rml.xcast(orte_process_info.my_name, recipients,
n, &buffer, NULL, NULL))) {
ORTE_ERROR_LOG(rc);
}
OBJ_DESTRUCT(&buffer);
CLEANUP:
for (j=0; j < num_tokens; j++) {
free(tokens[j]);
tokens[j] = NULL;
}
if (NULL != tokens) free(tokens);
if (NULL != recipients) free(recipients);
return;
return rc;
}
void orte_rmgr_base_proc_stage_gate_mgr_abort(orte_gpr_notify_data_t *data,
void *user_tag)
int orte_rmgr_base_proc_stage_gate_mgr_abort(orte_gpr_notify_message_t *msg)
{
orte_gpr_value_t **values;
orte_jobid_t job;
int rc;
/* get the jobid from the segment name
* we setup the stage gate triggers to return at least one value
* to us. we use that value to extract the jobid for the returned
* data
*/
values = (orte_gpr_value_t**)(data->values)->addr;
if (ORTE_SUCCESS != (rc =
orte_schema.extract_jobid_from_segment_name(&job,
values[0]->segment))) {
ORTE_ERROR_LOG(rc);
return;
}
/* All stage gate triggers are named, so we can extract the jobid
* directly from the trigger name
*/
if (ORTE_SUCCESS != (rc = orte_schema.extract_jobid_from_std_trigger_name(&job, msg->target))) {
ORTE_ERROR_LOG(rc);
return rc;
}
/* set the job status to "aborted" */
if (ORTE_SUCCESS != (rc = orte_soh.set_job_soh(job, ORTE_JOB_STATE_ABORTED))) {
ORTE_ERROR_LOG(rc);
}
orte_errmgr.incomplete_start(job);
return ORTE_SUCCESS;
}
/*
* Routine that subscribes to events on all counters.
* Routine that tools such as orterun can use to subscribe
* to events on all counters.
*/
int orte_rmgr_base_proc_stage_gate_subscribe(orte_jobid_t job, orte_gpr_notify_cb_fn_t cbfunc, void* cbdata)
{
size_t i;
int rc;
orte_gpr_value_t value, *values;
orte_gpr_trigger_t trig, *trigs;
orte_gpr_subscription_t sub, *subs;
char *segment, *trig_name, *tokens[2];
orte_gpr_subscription_id_t id;
char* keys[] = {
/* changes to this ordering need to be reflected in code below */
ORTE_PROC_NUM_AT_STG1,
ORTE_PROC_NUM_AT_STG2,
ORTE_PROC_NUM_AT_STG3,
ORTE_PROC_NUM_FINALIZED,
ORTE_PROC_NUM_TERMINATED
ORTE_PROC_NUM_TERMINATED,
ORTE_PROC_NUM_ABORTED
};
char* trig_names[] = {
/* changes to this ordering need to be reflected in code below
@ -625,160 +315,45 @@ int orte_rmgr_base_proc_stage_gate_subscribe(orte_jobid_t job, orte_gpr_notify_c
ORTE_STG2_TRIGGER,
ORTE_STG3_TRIGGER,
ORTE_NUM_FINALIZED_TRIGGER,
ORTE_NUM_TERMINATED_TRIGGER
ORTE_NUM_TERMINATED_TRIGGER,
ORTE_NUM_ABORTED_TRIGGER
};
size_t num_counters = sizeof(keys)/sizeof(keys[0]);
/*** SUBSCRIPTIONS ***/
/* the subscription object is used to define the values we want
* returned to us. we'll enter the precise data
* keys when we are ready to register the subscription - for now,
* do all the basic stuff
*/
OBJ_CONSTRUCT(&sub, orte_gpr_subscription_t);
/* we do not name the subscription - see explanation below. also, we do
* not assign the subscription id here - it is assigned for us when the
* registry "registers" the subscription and is returned in the
* subscription object at that time
*/
/*
* set the action to delete the subscription after the trigger fires. this
* subscription is solely for the purpose of returning stagegate information
* to the resource manager - we don't need it after that happens
*/
sub.action = ORTE_GPR_NOTIFY_DELETE_AFTER_TRIG;
/*
* setup the value object to define the data to be returned to us
*/
OBJ_CONSTRUCT(&value, orte_gpr_value_t);
values = &value;
sub.values = &values;
sub.cnt = 1;
/* set the address mode to identify a specific container (in this case,
* the ORTE_JOB_GLOBALS container) and any keys within it
*/
value.addr_mode = ORTE_GPR_TOKENS_XAND | ORTE_GPR_KEYS_OR;
if (ORTE_SUCCESS != (rc = orte_schema.get_job_segment_name(&(value.segment), job))) {
/* identify the segment for this job */
if (ORTE_SUCCESS != (rc = orte_schema.get_job_segment_name(&segment, job))) {
ORTE_ERROR_LOG(rc);
OBJ_DESTRUCT(&value);
sub.values = NULL;
OBJ_DESTRUCT(&sub);
return rc;
}
/* define the tokens for the container */
value.tokens = (char**)malloc(sizeof(char*));
if (NULL == value.tokens) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_DESTRUCT(&value);
sub.values = NULL;
OBJ_DESTRUCT(&sub);
return ORTE_ERR_OUT_OF_RESOURCE;
}
value.tokens[0] = strdup(ORTE_JOB_GLOBALS); /* the counters are in the job's globals container */
value.num_tokens = 1;
/* the keys describing the data to be returned will be defined later
* for now, we simply allocate the space
*/
value.keyvals = (orte_gpr_keyval_t**)malloc(sizeof(orte_gpr_keyval_t*));
if (NULL == value.keyvals) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_DESTRUCT(&value);
sub.values = NULL;
OBJ_DESTRUCT(&sub);
return ORTE_ERR_OUT_OF_RESOURCE;
}
value.keyvals[0] = OBJ_NEW(orte_gpr_keyval_t);
if (NULL == value.keyvals[0]) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_DESTRUCT(&value);
sub.values = NULL;
OBJ_DESTRUCT(&sub);
return ORTE_ERR_OUT_OF_RESOURCE;
}
value.cnt = 1;
/* define the callback and associated data tag */
sub.cbfunc = cbfunc;
sub.user_tag = cbdata;
/*** TRIGGERS ***/
/* setup the trigger information - initialize the common elements */
OBJ_CONSTRUCT(&trig, orte_gpr_trigger_t);
/* since the named triggers have already been defined, we don't need
* to replicate that here! all we need to do is refer to the
* proper trigger name - we'll do that below
*/
trig.action = ORTE_GPR_TRIG_ALL_CMP;
/* do the trigger subscriptions */
/* setup the tokens */
tokens[0]=ORTE_JOB_GLOBALS;
tokens[1]=NULL;
for (i=0; i < num_counters; i++) {
/* insert the subscription key identifying the data to
* be returned from this trigger
*/
value.keyvals[0]->key = strdup(keys[i]);
if (NULL == value.keyvals[0]->key) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
rc = ORTE_ERR_OUT_OF_RESOURCE;
goto CLEANUP;
}
/* get the standard trigger name to which we are "attaching" */
if (ORTE_SUCCESS != (rc = orte_schema.get_std_trigger_name(&(trig.name),
trig_names[i], job))) {
/* attach ourselves to the appropriate standard trigger */
if (ORTE_SUCCESS !=
(rc = orte_schema.get_std_trigger_name(&trig_name, trig_names[i], job))) {
ORTE_ERROR_LOG(rc);
goto CLEANUP;
free(segment);
return rc;
}
subs = &sub;
trigs = &trig;
rc = orte_gpr.subscribe(
1, &subs,
1, &trigs);
if(ORTE_SUCCESS != rc) {
ORTE_ERROR_LOG(rc);
goto CLEANUP;
}
free(value.keyvals[0]->key);
value.keyvals[0]->key = NULL;
free(trig.name);
trig.name = NULL;
}
/* Now do the abort trigger.
* setup the subscription to return the number aborted\
*/
value.keyvals[0]->key = strdup(ORTE_PROC_NUM_ABORTED);
if (NULL == value.keyvals[0]->key) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
rc = ORTE_ERR_OUT_OF_RESOURCE;
goto CLEANUP;
}
/* set the trigger action */
trig.action = ORTE_GPR_TRIG_ALL_AT;
/* get the standard "abort" trigger name */
if (ORTE_SUCCESS != (rc = orte_schema.get_std_trigger_name(&(trig.name),
ORTE_NUM_ABORTED_TRIGGER, job))) {
ORTE_ERROR_LOG(rc);
goto CLEANUP;
if (ORTE_SUCCESS != (rc = orte_gpr.subscribe_1(&id, trig_name, NULL,
ORTE_GPR_NOTIFY_DELETE_AFTER_TRIG,
ORTE_GPR_TOKENS_OR | ORTE_GPR_KEYS_OR,
segment, tokens, keys[i],
cbfunc, cbdata))) {
ORTE_ERROR_LOG(rc);
free(segment);
free(trig_name);
return rc;
}
free(trig_name);
}
free(segment);
subs = &sub;
trigs = &trig;
rc = orte_gpr.subscribe(
1, &subs,
1, &trigs);
if (ORTE_SUCCESS != rc) {
ORTE_ERROR_LOG(rc);
}
CLEANUP:
OBJ_DESTRUCT(&trig);
OBJ_DESTRUCT(&value);
sub.values = NULL;
OBJ_DESTRUCT(&sub);
return rc;
return ORTE_SUCCESS;
}

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

@ -3,20 +3,20 @@
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
*
* Additional copyrights may follow
*
*
* $HEADER$
*/
/** @file:
*
* The Open RTE Resource Manager (RMGR) Subsystem
*
*
* The resource manager (RMGR) subsystem serves as the central
* switchyard for all resource management activities, including
* resource discovery, resource allocation, process mapping, and
@ -51,28 +51,28 @@
* @endcode
*/
typedef int (*orte_rmgr_base_module_query_fn_t)(void);
/**
* Create a job. Allocated a jobid and initializes the job segment.
*
*
* @param app_context Array of application context values.
* @param num_context Number of entries in the app_context array.
* @param jobid Returns id allocated to the job.
*
* @code
* orte_jobid_t jobid;
*
*
* return_value = orte_rmgr.create(app_context,num_context,&jobid);
* @endcode
*/
typedef int (*orte_rmgr_base_module_create_fn_t)(
orte_app_context_t** app_context,
size_t num_context,
orte_app_context_t** app_context,
size_t num_context,
orte_jobid_t *jobid);
/**
* Allocate resources to a job.
*
*
* @code
* return_value = orte_rmgr.allocate(orte_jobid_t jobid)
* @endcode
@ -107,7 +107,7 @@ typedef int (*orte_rmgr_base_module_map_fn_t)(orte_jobid_t job);
typedef int (*orte_rmgr_base_module_launch_fn_t)(orte_jobid_t job);
/**
* Terminate an entire job.
* Terminate an entire job.
*
* @code
* return_value = orte_rmgr.terminate_job(orte_jobid_t jobid);
@ -116,7 +116,7 @@ typedef int (*orte_rmgr_base_module_launch_fn_t)(orte_jobid_t job);
typedef int (*orte_rmgr_base_module_terminate_job_fn_t)(orte_jobid_t job);
/**
* Terminate a specific process.
* Terminate a specific process.
*
* @code
* return_value = orte_rmgr.terminate_proc(const orte_process_name_t* proc_name);
@ -130,7 +130,7 @@ typedef int (*orte_rmgr_base_module_terminate_proc_fn_t)(const orte_process_name
typedef void (*orte_rmgr_cb_fn_t)(orte_jobid_t jobid, orte_proc_state_t state);
/**
* Shortcut to spawn an applications. Perform all steps required to
* Shortcut to spawn an applications. Perform all steps required to
* launch the specified application.
*
* (1) Create the application context - create a jobid
@ -146,8 +146,8 @@ typedef void (*orte_rmgr_cb_fn_t)(orte_jobid_t jobid, orte_proc_state_t state);
* @endcode
*/
typedef int (*orte_rmgr_base_module_spawn_fn_t)(
orte_app_context_t** app_context,
size_t num_context,
orte_app_context_t** app_context,
size_t num_context,
orte_jobid_t *jobid,
orte_rmgr_cb_fn_t cbfn);
@ -169,7 +169,7 @@ typedef int (*orte_rmgr_base_module_proc_stage_gate_init_fn_t)(orte_jobid_t job)
* usually, broadcasting a message to all processes in the job that allows them
* to proceed.
*/
typedef void (*orte_rmgr_base_module_proc_stage_gate_mgr_fn_t)(orte_gpr_notify_data_t *data, void *user_tag);
typedef int (*orte_rmgr_base_module_proc_stage_gate_mgr_fn_t)(orte_gpr_notify_message_t *msg);
/**
* Cleanup resources held by rmgr.
@ -205,7 +205,7 @@ typedef orte_rmgr_base_module_1_0_0_t orte_rmgr_base_module_t;
typedef orte_rmgr_base_module_t* (*orte_rmgr_base_component_init_fn_t)(
int *priority);
/*
* the standard component data structure
*/

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

@ -338,7 +338,8 @@ typedef int (*orte_rml_module_xcast_fn_t)(
orte_process_name_t* peers,
size_t num_peers,
orte_buffer_t* buffer,
orte_rml_buffer_callback_fn_t cbfunc);
orte_gpr_trigger_cb_fn_t cbfunc,
void *user_tag);
/*
* Initialization/Cleanup